diff --git a/.eslintrc.json b/.eslintrc.json index c46843efd..5af5fd7ee 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -80,6 +80,7 @@ "react/display-name": 0, "react/jsx-key": 0, "react/no-children-prop": 0, + "react/no-deprecated": 0, "react/no-unescaped-entities": 0, "spaced-comment": 0 } diff --git a/CHANGELOG.md b/CHANGELOG.md index 07734de65..2e9ce4b43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## 1.6.0-RC6 + +### Change + +- Service Account creation - added multiLangugae support when fetching the role description from BE + +### Technical Support + +- Sonar findings fixed (Code smells and bugs) +- Dependabot findings fixed (Upgrading dependencies to the latest versions) + +### Bugfix + +- Application card favorite button click (separation from the rest of the card where the click results into opening the app card) +- Admin Credential Board - views/filter function fixed +- Service Release Form - fixed erase of entered data on deleting uploaded image +- Service Detail - header UI fix of rendering issues + ## 1.6.0-RC5 ### Change diff --git a/DEPENDENCIES b/DEPENDENCIES index efdaf9c95..1a83b2051 100644 --- a/DEPENDENCIES +++ b/DEPENDENCIES @@ -244,7 +244,7 @@ npm/npmjs/-/eslint-config-prettier/8.8.0, MIT, approved, #7543 npm/npmjs/-/eslint-config-react-app/7.0.1, MIT, approved, clearlydefined npm/npmjs/-/eslint-config-standard-with-typescript/35.0.0, MIT, approved, #9133 npm/npmjs/-/eslint-config-standard/17.0.0, MIT, approved, clearlydefined -npm/npmjs/-/eslint-import-resolver-node/0.3.7, MIT, approved, clearlydefined +npm/npmjs/-/eslint-import-resolver-node/0.3.7, MIT, approved, #9923 npm/npmjs/-/eslint-module-utils/2.8.0, MIT, approved, #8209 npm/npmjs/-/eslint-plugin-es/4.1.0, MIT, approved, #5026 npm/npmjs/-/eslint-plugin-flowtype/8.0.3, BSD-3-Clause, approved, #2958 @@ -257,7 +257,7 @@ npm/npmjs/-/eslint-plugin-react-hooks/4.6.0, MIT, approved, clearlydefined npm/npmjs/-/eslint-plugin-react/7.32.2, MIT, approved, #7035 npm/npmjs/-/eslint-plugin-testing-library/5.11.0, MIT, approved, clearlydefined npm/npmjs/-/eslint-scope/5.1.1, BSD-2-Clause, approved, clearlydefined -npm/npmjs/-/eslint-scope/7.2.0, BSD-2-Clause, approved, clearlydefined +npm/npmjs/-/eslint-scope/7.2.0, BSD-2-Clause, approved, #9916 npm/npmjs/-/eslint-utils/2.1.0, MIT, approved, #2498 npm/npmjs/-/eslint-utils/3.0.0, MIT, approved, #2431 npm/npmjs/-/eslint-visitor-keys/1.3.0, Apache-2.0, approved, #2501 @@ -576,7 +576,6 @@ npm/npmjs/-/normalize-path/3.0.0, MIT, approved, clearlydefined npm/npmjs/-/normalize-range/0.1.2, MIT, approved, clearlydefined npm/npmjs/-/normalize-url/6.1.0, MIT, approved, clearlydefined npm/npmjs/-/npm-run-path/4.0.1, MIT, approved, clearlydefined -npm/npmjs/-/nth-check/1.0.2, BSD-2-Clause, approved, CQ22629 npm/npmjs/-/nth-check/2.1.1, BSD-2-Clause, approved, clearlydefined npm/npmjs/-/nwsapi/2.2.5, MIT, approved, #7909 npm/npmjs/-/object-assign/4.1.1, MIT, approved, clearlydefined @@ -1115,7 +1114,7 @@ npm/npmjs/@babel/plugin-transform-unicode-property-regex/7.22.5, MIT AND (BSD-2- npm/npmjs/@babel/plugin-transform-unicode-regex/7.22.5, MIT, approved, #8929 npm/npmjs/@babel/plugin-transform-unicode-sets-regex/7.22.5, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8755 npm/npmjs/@babel/preset-env/7.22.5, MIT AND (BSD-2-Clause AND ISC AND MIT) AND BSD-2-Clause AND BSD-3-Clause, approved, #8748 -npm/npmjs/@babel/preset-modules/0.1.5, MIT, approved, clearlydefined +npm/npmjs/@babel/preset-modules/0.1.5, MIT, approved, #9932 npm/npmjs/@babel/preset-react/7.22.5, MIT, approved, #8987 npm/npmjs/@babel/preset-typescript/7.22.5, MIT, approved, #9074 npm/npmjs/@babel/regjsgen/0.8.0, MIT, approved, #7149 @@ -1124,7 +1123,7 @@ npm/npmjs/@babel/template/7.22.5, MIT, approved, #9017 npm/npmjs/@babel/traverse/7.22.5, MIT, approved, #8954 npm/npmjs/@babel/types/7.22.5, MIT, approved, #8967 npm/npmjs/@bcoe/v8-coverage/0.2.3, ISC AND MIT, approved, clearlydefined -npm/npmjs/@catena-x/portal-shared-components/2.0.14, Apache-2.0 AND (BSD-3-Clause AND MIT), approved, #9187 +npm/npmjs/@catena-x/portal-shared-components/2.0.18, Apache-2.0 AND (BSD-3-Clause AND MIT), approved, #9187 npm/npmjs/@csstools/normalize.css/12.0.0, CC0-1.0, approved, clearlydefined npm/npmjs/@csstools/postcss-cascade-layers/1.1.1, CC0-1.0, approved, clearlydefined npm/npmjs/@csstools/postcss-color-function/1.1.1, CC0-1.0 AND (MIT AND W3C-20150513) AND W3C-20150513 AND MIT, approved, #3022 @@ -1194,7 +1193,7 @@ npm/npmjs/@jridgewell/set-array/1.1.2, MIT, approved, clearlydefined npm/npmjs/@jridgewell/source-map/0.3.3, MIT, approved, #9304 npm/npmjs/@jridgewell/sourcemap-codec/1.4.14, MIT, approved, clearlydefined npm/npmjs/@jridgewell/sourcemap-codec/1.4.15, MIT, approved, clearlydefined -npm/npmjs/@jridgewell/trace-mapping/0.3.18, MIT, approved, clearlydefined +npm/npmjs/@jridgewell/trace-mapping/0.3.18, MIT, approved, #9904 npm/npmjs/@leichtgewicht/ip-codec/2.0.4, MIT, approved, clearlydefined npm/npmjs/@mui/base/5.0.0-beta.4, MIT, approved, #2992 npm/npmjs/@mui/core-downloads-tracker/5.13.4, MIT, approved, #8983 diff --git a/package.json b/package.json index 4536a9923..cb3da5bcc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@catena-x/portal-frontend", - "version": "v1.6.0-RC5", + "version": "v1.6.0-RC6", "description": "Catena-X Portal Frontend", "author": "Catena-X Contributors", "license": "Apache-2.0", @@ -26,7 +26,7 @@ ] }, "dependencies": { - "@catena-x/portal-shared-components": "^2.0.14", + "@catena-x/portal-shared-components": "^2.0.18", "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", "@hookform/error-message": "^2.0.1", @@ -87,13 +87,16 @@ "react-scripts": "5.0.1", "typescript": "5.0.4" }, + "resolutions": { + "**/nth-check": "^2.1.1" + }, "scripts": { "prepare": "husky install", "build:sources": "zip -r portal-frontend.zip src package.json yarn.lock -x '*.stories.*' -x '*.test.*' -x '*.css' -x '*.scss' -x '*.svg' -x '*.jpg' -x '*.png' -x '*.webp' -x '*.ttf'", "pretty": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,sass,scss,xml,md}\"", "lint": "yarn run eslint \"./src/**/*.{ts,tsx}\"", "start": "PORT=3001 BROWSER=none GENERATE_SOURCEMAP=false react-scripts start", - "build": "react-scripts build", + "build": "GENERATE_SOURCEMAP=false react-scripts build", "test": "react-scripts test", "test:ci": "CI=true react-scripts test", "build:docker": "if [ -d \"./build\" ]; then yarn build:docker:prebuilt; else yarn build:docker:full; fi", diff --git a/src/assets/locales/de/main.json b/src/assets/locales/de/main.json index 203a030d7..9df7a8455 100644 --- a/src/assets/locales/de/main.json +++ b/src/assets/locales/de/main.json @@ -977,10 +977,10 @@ }, "appPage": { "headerTitle": "App Details", - "headerDescription": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .", - "longDescriptionEN": "Long Description - EN", - "longDescriptionDE": "Long Description - DE", - "images": "Images", + "headerDescription": "Füllen Sie die Seite mit den App-Details aus. Auf dem Marktplatz werden die folgenden zusätzlichen Informationen für Kunden öffentlich verfügbar sein, um einen erweiterten Überblick über die von Ihrer Anwendung unterstützten Funktionen sowie notwendige Details zu Sicherheit, Architektur usw. zu erhalten.", + "longDescriptionEN": "Detailierte Beschreibung - EN", + "longDescriptionDE": "Detailierte Beschreibung - DE", + "images": "Bilder", "note": "Note:", "maxThreeImages": "Max.3 Images", "uploadDataPrerequisits": "Upload “Data Prerequisits”", @@ -1008,16 +1008,16 @@ }, "technicalIntegration": { "headerTitle": "Technical Integration", - "headerDescription": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .", + "headerDescription": "Integrieren Sie Ihre App mit dem catena-x-Datenraum. Für die Integration müssen Sie die von der Anwendung unterstützten Rollen sowie das erforderliche technische Benutzerprofil hochladen, das zum Ausführen Ihrer Anwendung im Netzwerk erforderlich ist. Bitte beachten Sie: In diesem Schritt legen Sie nur den Rahmen der Authentifizierung fest – es werden keine Benutzer erstellt. Wenn Sie Unterstützung benötigen, können Sie gerne die Schaltfläche „Hilfe“ oder die beigefügte Vorlage verwenden.", "step1Header": "1. User Role Upload", - "step1HeaderDescription": "[copy] Lorem ipsum sapientem ne neque dolor erat,eros solet invidunt duo Quisque aliquid leo. Pretium patrioque sociis eu nihil Cum enim ad, ipsum alii vidisse justo id. Option porttitor diam voluptua. Cu Eam augue dolor dolores quis,", + "step1HeaderDescription": "Laden Sie Ihre Anwendungsrollen hoch, die Benutzeridentitäten zugewiesen werden können, um auf die Anwendung zugreifen zu können.", "clientID": "Client ID", "URL": "URL", "pleaseEnterValidURL": "Please enter a valid URL", "URLPlaceholder": "http://www.loremipsum.de", "clientCreated": "Client created", "step2Header": "2. Technical User Setup", - "step2HeaderDescription": "[copy] Lorem ipsum sapientem ne neque dolor erat,eros solet invidunt duo Quisque aliquid leo. Pretium patrioque sociis eu nihil Cum enim ad, ipsum alii vidisse justo id. Option porttitor diam voluptua. Cu Eam augue dolor dolores quis,", + "step2HeaderDescription": "Richten Sie das technische Profil eines technischen Benutzer-/Dienstkontos mit den erforderlichen Berechtigungen ein, um die Anwendung im Datenraum ausführen zu können.", "uploadRolesDescription": "Upload all app roles by using the available upload template (csv) file added attached", "rolesPreview": "Preview of Roles uploaded", "uploadAppRolesButton": "Upload App Roles", diff --git a/src/assets/locales/en/main.json b/src/assets/locales/en/main.json index 1d1a383d2..119dbca1e 100644 --- a/src/assets/locales/en/main.json +++ b/src/assets/locales/en/main.json @@ -939,7 +939,7 @@ }, "appPage": { "headerTitle": "App Details", - "headerDescription": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .", + "headerDescription": "Fill out your app details page. On the marketplace the following added information will be public available for customers to get a extended view of your application supported functions as well as necessary details regarding security, architecture, etc.", "longDescriptionEN": "Long Description (en)", "longDescriptionDE": "Long Description (de)", "images": "Images", @@ -950,8 +950,8 @@ "uploadAppContract": "Upload “App Contract”", "providerDetails": "Provider Details", "providerHomePage": "Provider Homepage", - "providerContactEmail": "Customer Contact E-Mail", - "providerPhoneContact": "Provider Phone Contact", + "providerContactEmail": "Contact (E-Mail)", + "providerPhoneContact": "Contac (Phone Number)", "providerPhoneContactPlaceholder": "Following formats are supported: +xx (xxx) xxxxxxxxxx; +xx xxxxxxxxxx and +xxxxxxxxxxxx", "pleaseEnterValidHomePageURL": "Please enter a valid url - eg: https://catena-x.net", "pleaseEnterValidEmail": "Please enter a valid Customer Contact E-Mail", @@ -970,16 +970,16 @@ }, "technicalIntegration": { "headerTitle": "Technical Integration", - "headerDescription": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .", + "headerDescription": "Integrate your app with the catena-x dataspace. For the integration you need to upload the application supported roles as well as the necessary technical user profile which is needed to run your application inside the network. Please note: in this step you are only setting the frame of the authentication - no users are going to get created. If you need any support feel free to use the 'Help' button or the attached template.", "step1Header": "1. User Role Upload", - "step1HeaderDescription": "[copy] Lorem ipsum sapientem ne neque dolor erat,eros solet invidunt duo Quisque aliquid leo. Pretium patrioque sociis eu nihil Cum enim ad, ipsum alii vidisse justo id. Option porttitor diam voluptua. Cu Eam augue dolor dolores quis,", + "step1HeaderDescription": "Upload your application roles which can get assigned to user identities to be able to access the application.", "clientID": "Client ID", "URL": "URL", "pleaseEnterValidURL": "Please enter a valid URL", "URLPlaceholder": "http://www.loremipsum.de", "clientCreated": "Client created", "step2Header": "2. Technical User Setup", - "step2HeaderDescription": "[copy] Lorem ipsum sapientem ne neque dolor erat,eros solet invidunt duo Quisque aliquid leo. Pretium patrioque sociis eu nihil Cum enim ad, ipsum alii vidisse justo id. Option porttitor diam voluptua. Cu Eam augue dolor dolores quis,", + "step2HeaderDescription": "Setup the technical profile of a technical user/service account of needed permissions to be able to run the application inside the dataspace.", "uploadRolesDescription": "Upload all app roles by using the available upload template (csv) file added attached", "rolesPreview": "Preview of Roles uploaded", "uploadAppRolesButton": "Upload App Roles", diff --git a/src/assets/locales/en/servicerelease.json b/src/assets/locales/en/servicerelease.json index 2e8ca2897..88045857a 100644 --- a/src/assets/locales/en/servicerelease.json +++ b/src/assets/locales/en/servicerelease.json @@ -52,13 +52,13 @@ }, "technicalIntegration": { "headerTitle": "Technical Integration", - "headerDescription": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .", - "technicalUserSetupMandatory": "Please select atleast one technical user setup", + "headerDescription": "Setup the technical profile of a technical user/service account of needed permissions to be able to run the application inside the dataspace. Select minimum one permission, the selected permission(s) will be stored as service technical user profile and used to create technical users for subscription activations.", + "technicalUserSetupMandatory": "Please select at least one technical user permission for the service tech user profile", "technicalUserProfileError": "Error while updating technical user profiles" }, "step4": { "headerTitle": "Validate & Publish", - "headerDescription": "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard .Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard ", + "headerDescription": "Below you can find a summary of all your service registration inputs as well as the look of the marketplace service card and detail page. Please check your entered data carefully before sending the service for release. We will validate your service registration shortly after the service submission.", "appDetails": "Service Details", "documents": "Documents", "providerInformation": "Provider Information", @@ -104,7 +104,7 @@ "overview": "My services overview" }, "defaultValues": { - "conformityDocumentsDescription": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", + "conformityDocumentsDescription": "To publish your service on the marketplace, a number of Catena-X specific agreements need to get signed by you. Please have a look at the mentioned agreements and agree to them via the checklist approval.", "documentsDescription": "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat." }, "serviceoverview": { diff --git a/src/components/pages/AdminBoardDetail/BoardContentDetails.tsx b/src/components/pages/AdminBoardDetail/BoardContentDetails.tsx index 37bcd246c..526e922f8 100644 --- a/src/components/pages/AdminBoardDetail/BoardContentDetails.tsx +++ b/src/components/pages/AdminBoardDetail/BoardContentDetails.tsx @@ -18,7 +18,6 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -import { useEffect, useState } from 'react' import { useNavigate } from 'react-router-dom' import { useTranslation } from 'react-i18next' import { @@ -39,20 +38,6 @@ import BoardTechnicalUserSetup from './components/BoardTechnicalUserSetup' export default function BoardContentDetails({ item }: { item: AppDetails }) { const { t } = useTranslation() const navigate = useNavigate() - const [images, setImages] = useState() - - useEffect(() => { - if (item) { - const newPromies = CommonService.fetchLeadPictures(item.images, item.id) - Promise.all(newPromies) - .then((result) => { - setImages(result.flat()) - }) - .catch((err) => { - console.log(err) - }) - } - }, [item]) return ( item && ( @@ -79,7 +64,13 @@ export default function BoardContentDetails({ item }: { item: AppDetails }) { ))} - {images && } +
diff --git a/src/components/pages/AdminCredential/AdminCredentialElements.tsx b/src/components/pages/AdminCredential/AdminCredentialElements.tsx index 533dd2d0c..111646f91 100644 --- a/src/components/pages/AdminCredential/AdminCredentialElements.tsx +++ b/src/components/pages/AdminCredential/AdminCredentialElements.tsx @@ -57,7 +57,6 @@ export default function AdminCredentialElements() { const [refresh, setRefresh] = useState(0) const [group, setGroup] = useState(FilterType.ALL) const [searchExpr, setSearchExpr] = useState('') - const [filterStatus, setFilterStatus] = useState() const [filterValueAPI, setFilterValueAPI] = useState('') const [fetchHookArgs, setFetchHookArgs] = useState({}) @@ -69,23 +68,21 @@ export default function AdminCredentialElements() { const viewValue = e.currentTarget.value if (viewValue === FilterType.OPEN) setFilterValueAPI(SubscriptionStatus.PENDING) - if (viewValue === FilterType.CONFIRMED) + else if (viewValue === FilterType.CONFIRMED) setFilterValueAPI(SubscriptionStatus.ACTIVE) - if (viewValue === FilterType.DECLINED) + else if (viewValue === FilterType.DECLINED) setFilterValueAPI(SubscriptionStatus.INACTIVE) - setFilterStatus(viewValue) + else setFilterValueAPI('') setGroup(viewValue) setRefresh(Date.now()) } useEffect(() => { - if (onValidate(searchExpr)) { - setFetchHookArgs({ - filterType: filterValueAPI, - expr: searchExpr, - }) - } - }, [filterStatus, searchExpr]) + setFetchHookArgs({ + filterType: filterValueAPI, + expr: searchExpr, + }) + }, [filterValueAPI, searchExpr]) const onValidate = (expr: string) => { const validateExpr = /^[ A-Za-z0-9]{1,1000}$/.test(expr) diff --git a/src/components/pages/AppDetail/AppDetailContentDetails.tsx b/src/components/pages/AppDetail/AppDetailContentDetails.tsx index 0c83fad02..940874643 100644 --- a/src/components/pages/AppDetail/AppDetailContentDetails.tsx +++ b/src/components/pages/AppDetail/AppDetailContentDetails.tsx @@ -18,7 +18,7 @@ * SPDX-License-Identifier: Apache-2.0 ********************************************************************************/ -import { useEffect, useState } from 'react' +import { useState } from 'react' import { Typography, Navigation, @@ -47,7 +47,6 @@ export default function AppDetailContentDetails({ }) { const navigate = useNavigate() const { t } = useTranslation() - const [images, setImages] = useState() const [selectedItem, setSelectedItem] = useState('#description') const navigationItems = [ @@ -73,19 +72,6 @@ export default function AppDetailContentDetails({ }, ] - useEffect(() => { - if (item) { - const newPromies = CommonService.fetchLeadPictures(item.images, item.id) - Promise.all(newPromies) - .then((result) => { - setImages(result.flat()) - }) - .catch((err) => { - console.log(err) - }) - } - }, [item]) - return ( item && ( <> @@ -122,11 +108,15 @@ export default function AppDetailContentDetails({
- {images && ( - - )} +
diff --git a/src/components/pages/AppMarketplace/components/AppListSection/index.tsx b/src/components/pages/AppMarketplace/components/AppListSection/index.tsx index 1b5823e39..e21724bd6 100644 --- a/src/components/pages/AppMarketplace/components/AppListSection/index.tsx +++ b/src/components/pages/AppMarketplace/components/AppListSection/index.tsx @@ -77,7 +77,8 @@ export default function AppListSection() { const checkIsFavorite = (appId: string) => favoriteItems.includes(appId) - const addOrRemoveFavorite = (appId: string) => { + const addOrRemoveFavorite = (event: React.MouseEvent, appId: string) => { + event?.stopPropagation() dispatch(checkIsFavorite(appId) ? removeItem(appId) : addItem(appId)) } @@ -141,7 +142,8 @@ export default function AppListSection() { items={cardsData.map((card) => ({ ...card, onButtonClick: () => navigate(`/appdetail/${card.id}`), - onSecondaryButtonClick: () => addOrRemoveFavorite(card.id!), + onSecondaryButtonClick: (e: React.MouseEvent) => + addOrRemoveFavorite(e, card.id!), addButtonClicked: checkIsFavorite(card.id!), }))} groupKey={group} diff --git a/src/components/pages/ServiceMarketplaceDetail/components/MarketplaceHeader/MarketplaceHeader.scss b/src/components/pages/ServiceMarketplaceDetail/components/MarketplaceHeader/MarketplaceHeader.scss index 9a067239c..2ab3de0cb 100644 --- a/src/components/pages/ServiceMarketplaceDetail/components/MarketplaceHeader/MarketplaceHeader.scss +++ b/src/components/pages/ServiceMarketplaceDetail/components/MarketplaceHeader/MarketplaceHeader.scss @@ -22,12 +22,15 @@ height: 288px; display: flex; flex-wrap: wrap; - .lead-image > img { - border-radius: 16px; - width: '288px'; - height: '288px'; + .lead-image { + img { + border-radius: 16px; + width: '288px'; + height: '288px'; + } } .marketplace-app-content { + width: 50%; padding: 0px 0px 0px 56px; } } diff --git a/src/components/shared/basic/ReleaseProcess/OfferCard/index.tsx b/src/components/shared/basic/ReleaseProcess/OfferCard/index.tsx index 910804b9e..da000d5bd 100644 --- a/src/components/shared/basic/ReleaseProcess/OfferCard/index.tsx +++ b/src/components/shared/basic/ReleaseProcess/OfferCard/index.tsx @@ -136,7 +136,7 @@ export default function OfferCard() { alt: fetchServiceStatus?.leadPictureUri || '', }, } - }, [fetchServiceStatus, imageData]) + }, [fetchServiceStatus]) const { handleSubmit, @@ -234,16 +234,19 @@ export default function OfferCard() { apiBody: CreateServiceStep1Item, buttonLabel: string ) => { - const uploadImageValue = getValues().uploadImage - .leadPictureUri as unknown as DropzoneFile + const uploadImageValue = + getValues().uploadImage && + (getValues().uploadImage.leadPictureUri as unknown as DropzoneFile) await saveService({ id: serviceId, body: apiBody, }) .unwrap() .then(() => { - !uploadImageValue.id && - handleUploadDocument(serviceId, uploadImageValue) + if (uploadImageValue) { + !uploadImageValue.id && + handleUploadDocument(serviceId, uploadImageValue) + } dispatch(setServiceId(serviceId)) buttonLabel === ButtonLabelTypes.SAVE_AND_PROCEED && dispatch(serviceReleaseStepIncrement()) @@ -261,8 +264,9 @@ export default function OfferCard() { apiBody: CreateServiceStep1Item, buttonLabel: string ) => { - const uploadImageValue = getValues().uploadImage - .leadPictureUri as unknown as DropzoneFile + const uploadImageValue = + getValues().uploadImage && + (getValues().uploadImage.leadPictureUri as unknown as DropzoneFile) await createService({ id: '', body: apiBody, @@ -270,7 +274,10 @@ export default function OfferCard() { .unwrap() .then((result) => { if (isString(result)) { - !uploadImageValue.id && handleUploadDocument(result, uploadImageValue) + if (uploadImageValue) { + !uploadImageValue.id && + handleUploadDocument(result, uploadImageValue) + } dispatch(setServiceId(result)) buttonLabel === ButtonLabelTypes.SAVE_AND_PROCEED && dispatch(serviceReleaseStepIncrement()) @@ -293,10 +300,11 @@ export default function OfferCard() { const apiBody = { serviceTypeIds: data.serviceTypeIds, title: data.title, - leadPictureUri: - data.uploadImage.leadPictureUri !== null && - Object.keys(data.uploadImage.leadPictureUri).length > 0 && - Object.values(data.uploadImage.leadPictureUri)[0], + leadPictureUri: data.uploadImage?.leadPictureUri + ? data.uploadImage.leadPictureUri !== null && + Object.keys(data.uploadImage.leadPictureUri).length > 0 && + Object.values(data.uploadImage.leadPictureUri)[0] + : '', descriptions: [ { languageCode: 'de', diff --git a/src/components/shared/basic/ReleaseProcess/components/CommonValidateAndPublish.tsx b/src/components/shared/basic/ReleaseProcess/components/CommonValidateAndPublish.tsx index 4b8bd5199..538fe57b0 100644 --- a/src/components/shared/basic/ReleaseProcess/components/CommonValidateAndPublish.tsx +++ b/src/components/shared/basic/ReleaseProcess/components/CommonValidateAndPublish.tsx @@ -183,17 +183,12 @@ export default function CommonValidateAndPublish({ statusData?.documents?.APP_IMAGE && statusData?.documents?.APP_IMAGE[0].documentId ) { - const newPromies = CommonService.fetchLeadPictures( - statusData?.documents?.APP_IMAGE, - id + setMultipleImages( + CommonService.imagesAndAppidToImageType( + statusData?.documents?.APP_IMAGE, + id + ) ) - Promise.all(newPromies) - .then((result) => { - setMultipleImages(result.flat()) - }) - .catch((err) => { - console.log(err) - }) } setDefaultValues(values) reset(values) diff --git a/src/features/admin/serviceApiSlice.ts b/src/features/admin/serviceApiSlice.ts index 86fcc7421..0df0df3f8 100644 --- a/src/features/admin/serviceApiSlice.ts +++ b/src/features/admin/serviceApiSlice.ts @@ -19,9 +19,10 @@ ********************************************************************************/ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react' +import { apiBaseQuery } from 'utils/rtkUtil' +import i18next from 'i18next' import { PAGE_SIZE } from 'types/Constants' import { PaginFetchArgs, PaginResult } from '@catena-x/portal-shared-components' -import { apiBaseQuery } from 'utils/rtkUtil' export enum ServiceAccountType { SECRET = 'SECRET', @@ -90,7 +91,8 @@ export const apiSlice = createApi({ `/api/administration/serviceaccount/owncompany/serviceaccounts/${id}`, }), fetchServiceAccountRoles: builder.query({ - query: () => '/api/administration/serviceaccount/user/roles', + query: () => + `/api/administration/serviceaccount/user/roles?languageShortName=${i18next.language}`, }), }), }) diff --git a/src/services/CommonService.ts b/src/services/CommonService.ts index f518c4670..45f85e71d 100644 --- a/src/services/CommonService.ts +++ b/src/services/CommonService.ts @@ -20,8 +20,9 @@ import { getApiBase, getAssetBase } from './EnvironmentService' import i18next from 'i18next' -import UserService from './UserService' import { AppMarketplaceApp } from 'features/apps/apiSlice' +import { ImageType } from '@catena-x/portal-shared-components' +import { fetchImageWithToken } from './ImageService' const getName = (app: AppMarketplaceApp) => app.name ?? '' const getDescription = (app: AppMarketplaceApp) => @@ -48,48 +49,17 @@ const appToCard = (app: AppMarketplaceApp) => ({ }, }) -const fetchLeadPictures = (images: string[], appId: string) => { - const promises = images?.map((image: any) => { - return [ - new Promise((resolve, reject) => { - let url = '' - if (!image.documentId) { - url = `${getApiBase()}/api/apps/${appId}/appDocuments/${isValidPictureId( - image - )}` - } else { - url = `${getApiBase()}/api/apps/${appId}/appDocuments/${isValidPictureId( - image.documentId - )}` - } - - return fetch(url, { - method: 'GET', - headers: { - authorization: `Bearer ${UserService.getToken()}`, - }, - }) - .then((response) => response.blob()) - .then( - async (blob) => - await new Promise((callback) => { - let reader = new FileReader() - reader.onload = function () { - resolve({ - url: this.result, - text: '', - }) - } - reader.readAsDataURL(blob) - }) - ) - }), - ] - }) - - const newPromies = promises.map((promise) => Promise.all(promise)) - return newPromies -} +const imagesAndAppidToImageType = ( + images: string[], + appId: string +): ImageType[] => + images?.map((image: any) => ({ + url: `${getApiBase()}/api/apps/${appId}/appDocuments/${isValidPictureId( + image.documentId ?? image + )}`, + text: 'Catena-X', + loader: fetchImageWithToken, + })) const isValidPictureId = (id: string) => { return id === '00000000-0000-0000-0000-000000000000' @@ -153,7 +123,7 @@ const CommonService = { getCompanyRoles, getUseCases, getDataSpace, - fetchLeadPictures, + imagesAndAppidToImageType, getRoleDescription, getCompanyRoleUpdateData, } diff --git a/yarn.lock b/yarn.lock index 954c4d4fd..b342bac9a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1175,10 +1175,10 @@ resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39" integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw== -"@catena-x/portal-shared-components@^2.0.14": - version "2.0.14" - resolved "https://registry.yarnpkg.com/@catena-x/portal-shared-components/-/portal-shared-components-2.0.14.tgz#4892f23afedd03984e77a0e79312ceb1aed8fd8c" - integrity sha512-hjN1qx/N6I0P5UKzW5fTzgXGzjxJjfGJcBoltxq1FoB2jcN8ud4HlKPvVjYKNeRpEsA0WfQf9swFt6k3n4ldRg== +"@catena-x/portal-shared-components@^2.0.18": + version "2.0.18" + resolved "https://registry.yarnpkg.com/@catena-x/portal-shared-components/-/portal-shared-components-2.0.18.tgz#02088046a5efef84370ef88b463a5139a9bf26d6" + integrity sha512-gFG0pPmzjOD06nY2nas/hC/PnbHcZ+oomzodUjARZqAGxkS5yqdBnWpIA/xGSjqOcnNJWeBz8q2ivsqPyaqVBQ== dependencies: "@mui/base" "^5.0.0-beta.3" "@mui/system" "^5.13.2" @@ -3424,7 +3424,7 @@ bonjour-service@^1.0.11: fast-deep-equal "^3.1.3" multicast-dns "^7.2.5" -boolbase@^1.0.0, boolbase@~1.0.0: +boolbase@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" integrity sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww== @@ -7237,14 +7237,7 @@ npm-run-path@^4.0.1: dependencies: path-key "^3.0.0" -nth-check@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-1.0.2.tgz#b2bd295c37e3dd58a3bf0700376663ba4d9cf05c" - integrity sha512-WeBOdju8SnzPN5vTUJYxYUxLeXpCaVP5i5e0LF8fg7WORF2Wd7wFX/pk0tYZk7s8T+J7VLy0Da6J1+wCT0AtHg== - dependencies: - boolbase "~1.0.0" - -nth-check@^2.0.1: +nth-check@^1.0.2, nth-check@^2.0.1, nth-check@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.1.1.tgz#c9eab428effce36cd6b92c924bdb000ef1f1ed1d" integrity sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==