diff --git a/.idea/sonarlint/issuestore/index.pb b/.idea/sonarlint/issuestore/index.pb index a3c1272d..448db4b2 100644 --- a/.idea/sonarlint/issuestore/index.pb +++ b/.idea/sonarlint/issuestore/index.pb @@ -11,8 +11,6 @@ c 3src/components/dashboard/ProgressBar/ProgressBar.js,6\7\67d295badc748915bf1a6efeea38b9c58f514818 \ ,src/components/dashboard/Ratings/styles.scss,4\d\4de8d3bfe1c9d5b916a3562a19e3ab2a3f10325f -V -&src/components/services/UserService.js,4\3\43b64a74751ee9053b0052baa95dab17ca3aba2b B src/index-dev.scss,2\1\2141da40a2e04f68f12e4fcdcc340d14a126d224 B @@ -23,4 +21,10 @@ g 7src/components/dashboard/CountryPicker/CountryPicker.js,9\e\9e64c56a3d55d4c4bff840610045dad14026a967 : -AUTHORS.md,a\2\a2b261d0119ad783ac285fbc4f699e96fc0b7e2f \ No newline at end of file +AUTHORS.md,a\2\a2b261d0119ad783ac285fbc4f699e96fc0b7e2f +O +charts/country-risk/values.yaml,d\f\dfd8927926db4939f1420a87cf1eb4c3af6a3b0b +B +docs/User-Guide.md,b\f\bf6845072684d0fabe6f6c75b14ea44b6ec136b7 +K +docs/Arc42-Documentation.md,7\8\78886f8c4fd104c8647d1e81bfe3a52495e3ddee \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a1112a7..0530b3ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,16 +5,18 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [1.2.0] - tbr +## [1.2.0] - 2023-10-11 ### Added - Role-based column visibility in tables. 'Supplier' and 'Customer' columns are now hidden or shown based on user roles. - Asynchronous fetching of roles to ensure they are available before rendering the table. - Added new vars on the backend charts to pass auth url as dynamic - Added ability for user to export PDF file in world map dialog view with different information (Ranges, Ratings, Year, Gate) +- Added Eclipse Room to ReadMe documentation ### Fixed - Issue where roles could be undefined, causing an error when calling the includes method. +- Fixed logic for role validation when client token is not found ### Changed - Changed client id for country risk app registered on portal diff --git a/README.md b/README.md index 964a7a71..92cb6c98 100644 --- a/README.md +++ b/README.md @@ -33,6 +33,8 @@ Source: For more information and documentation, please refer to [documentation](https://github.com/eclipse-tractusx/vas-country-risk-frontend/tree/main/docs). +For topics and information discussion, please refer to [Eclipse Country Risk Room](https://chat.eclipse.org/#/room/#tools.tractusx-country-risk:matrix.eclipse.org) + ## Demo environments There are two demo environments provided by Catena-X: diff --git a/charts/country-risk/Chart.yaml b/charts/country-risk/Chart.yaml index 5724f05f..2514cf59 100644 --- a/charts/country-risk/Chart.yaml +++ b/charts/country-risk/Chart.yaml @@ -20,7 +20,7 @@ apiVersion: v2 name: country-risk type: application -version: 1.0.0 +version: 1.1.0 description: A Helm chart for deploying the Country Risk service home: https://github.com/eclipse-tractusx/vas-country-risk-frontend sources: @@ -37,6 +37,6 @@ dependencies: repository: https://helm.runix.net version: 1.x.x - name: country-risk-backend - version: 3.0.0 + version: 3.0.1 - name: country-risk-frontend - version: 3.0.0 + version: 3.0.1 diff --git a/charts/country-risk/charts/country-risk-backend/Chart.yaml b/charts/country-risk/charts/country-risk-backend/Chart.yaml index 03edffe4..814fd561 100644 --- a/charts/country-risk/charts/country-risk-backend/Chart.yaml +++ b/charts/country-risk/charts/country-risk-backend/Chart.yaml @@ -36,13 +36,13 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 3.0.0 +version: 3.0.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.1.1" +appVersion: "1.2.0" dependencies: - name: postgresql diff --git a/charts/country-risk/charts/country-risk-frontend/Chart.yaml b/charts/country-risk/charts/country-risk-frontend/Chart.yaml index f8a1d66e..78b99676 100644 --- a/charts/country-risk/charts/country-risk-frontend/Chart.yaml +++ b/charts/country-risk/charts/country-risk-frontend/Chart.yaml @@ -34,10 +34,10 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 3.0.0 +version: 3.0.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. # It is recommended to use it with quotes. -appVersion: "1.1.2" +appVersion: "1.2.0" diff --git a/public/index.html b/public/index.html index da7047d5..602727b2 100644 --- a/public/index.html +++ b/public/index.html @@ -4,10 +4,13 @@ React App diff --git a/scripts/inject-dynamic-env.sh b/scripts/inject-dynamic-env.sh index d9b84db1..a975f172 100644 --- a/scripts/inject-dynamic-env.sh +++ b/scripts/inject-dynamic-env.sh @@ -21,11 +21,13 @@ custom_env_vars_REACT_APP_AUTH_URL='REACT_APP_AUTH_URL:"'$REACT_APP_AUTH_URL'"' custom_env_vars_REACT_APP_COUNTRY_RISK_API='REACT_APP_COUNTRY_RISK_API:"'$REACT_APP_COUNTRY_RISK_API'"' custom_env_vars_REACT_APP_PORTAL_FRONTEND='REACT_APP_PORTAL_FRONTEND:"'$REACT_APP_PORTAL_FRONTEND'"' custom_env_vars_REACT_APP_PORTAL_BACKEND='REACT_APP_PORTAL_BACKEND:"'$REACT_APP_PORTAL_BACKEND'"' +custom_env_vars_REACT_APP_COUNTRY_RISK_CLIENT='REACT_APP_COUNTRY_RISK_CLIENT:"'$REACT_APP_COUNTRY_RISK_CLIENT'"' REACT_APP_AUTH_URL_anchor='REACT_APP_AUTH_URL:"http://localhost:8080/auth"' REACT_APP_COUNTRY_RISK_API_anchor='REACT_APP_COUNTRY_RISK_API:"http://localhost:8080"' REACT_APP_PORTAL_FRONTEND_anchor='REACT_APP_PORTAL_FRONTEND:"http://localhost:8080"' REACT_APP_PORTAL_BACKEND_anchor='REACT_APP_PORTAL_BACKEND:"http://localhost:8080"' +REACT_APP_COUNTRY_RISK_CLIENT_anchor='REACT_APP_COUNTRY_RISK_CLIENT:"country_risk_client"' index_html_reference=`cat /usr/share/nginx/html/index.html.reference` @@ -33,6 +35,7 @@ index_html=$(sed -r 's%'$REACT_APP_AUTH_URL_anchor'%'$custom_env_vars_REACT_APP_ index_html=$(sed -r 's%'$REACT_APP_COUNTRY_RISK_API_anchor'%'$custom_env_vars_REACT_APP_COUNTRY_RISK_API'%g' <<< "$index_html") index_html=$(sed -r 's%'$REACT_APP_PORTAL_FRONTEND_anchor'%'$custom_env_vars_REACT_APP_PORTAL_FRONTEND'%g' <<< "$index_html") index_html=$(sed -r 's%'$REACT_APP_PORTAL_BACKEND_anchor'%'$custom_env_vars_REACT_APP_PORTAL_BACKEND'%g' <<< "$index_html") +index_html=$(sed -r 's%'$REACT_APP_COUNTRY_RISK_CLIENT_anchor'%'$custom_env_vars_REACT_APP_COUNTRY_RISK_CLIENT'%g' <<< "$index_html") echo "$index_html" echo "$index_html" > /usr/share/nginx/html/index.html \ No newline at end of file diff --git a/src/components/dashboard/DashBoardTable/tableColumns.js b/src/components/dashboard/DashBoardTable/tableColumns.js index 7e396dc9..cb153131 100644 --- a/src/components/dashboard/DashBoardTable/tableColumns.js +++ b/src/components/dashboard/DashBoardTable/tableColumns.js @@ -24,12 +24,11 @@ import { capitalize } from "@mui/material"; import CheckCircleIcon from "@mui/icons-material/CheckCircle"; import CancelIcon from "@mui/icons-material/Cancel"; export const columns = (ranges, onDetailClick, roles) => { - const hiddenColumns = ["street", "houseNumber", "zipCode"]; const hasReadCustomersRole = - roles && Array.isArray(roles) ? roles.includes("read_customers") : false; + roles && Array.isArray(roles) ? roles.includes("Customer") : false; const hasReadSuppliersRole = - roles && Array.isArray(roles) ? roles.includes("read_suppliers") : false; + roles && Array.isArray(roles) ? roles.includes("Supplier") : false; return [ { diff --git a/src/components/services/EnvironmentService.js b/src/components/services/EnvironmentService.js index 95621536..8c102971 100644 --- a/src/components/services/EnvironmentService.js +++ b/src/components/services/EnvironmentService.js @@ -23,6 +23,9 @@ const REACT_APP_COUNTRY_RISK_API = window.ENV?.REACT_APP_COUNTRY_RISK_API?.valueOf(); const LOCAL_SERVICES_BACKEND = window.ENV?.REACT_APP_PORTAL_BACKEND?.valueOf(); const LOCAL_SERVICES_CENTRALIDP = window.ENV?.REACT_APP_AUTH_URL?.valueOf(); +const LOCAL_COUNTRY_RISK_CLIENT_ID = + window.ENV?.REACT_APP_COUNTRY_RISK_CLIENT?.valueOf(); + export const getHostname = () => window.location.hostname; export const isLocal = () => getHostname() === "localhost"; @@ -50,12 +53,14 @@ export const getLogoutLink = () => { return LOCAL_SERVICES_FRONTEND + "/logout"; }; +export const getCountryRiskAppId = () => { + return LOCAL_COUNTRY_RISK_CLIENT_ID; +}; + export const getClientId = () => "Cl2-CX-Portal"; export const getCountryRiskClientId = () => "Cl16-CX-CRisk"; -export const getCountryRiskAppId = () => "app374"; - export const getBpdmId = () => "Cl7-CX-BPDM"; export const getClientIdSemantic = () => "Cl3-CX-Semantic"; diff --git a/src/components/services/UserService.js b/src/components/services/UserService.js index 87078539..6be3a8ba 100644 --- a/src/components/services/UserService.js +++ b/src/components/services/UserService.js @@ -106,11 +106,24 @@ const getTenant = () => KC.tokenParsed?.tenant; // TODO: add a more sustainable logic for role management with multiple clients // not sustainable because client roles need to be unique across all clients const getRoles = () => { - const rolesCountryRisk = - KC.tokenParsed?.resource_access[keycloakConfigCountryRisk.clientId] - ?.roles || []; - const rolesBpdm = - KC.tokenParsed?.resource_access[keycloakConfigBpdm.clientId]?.roles || []; + // Initialize empty arrays for roles + let rolesCountryRisk = []; + let rolesBpdm = []; + + // Safely extract roles from the token + const resourceAccess = KC.tokenParsed?.resource_access || {}; + + // Check if roles exist for CountryRisk client and assign them + if (resourceAccess.hasOwnProperty(keycloakConfigCountryRisk.clientId)) { + rolesCountryRisk = resourceAccess[keycloakConfigCountryRisk.clientId].roles; + } + + // Check if roles exist for Bpdm client and assign them + if (resourceAccess.hasOwnProperty(keycloakConfigBpdm.clientId)) { + rolesBpdm = resourceAccess[keycloakConfigBpdm.clientId].roles; + } + + // Concatenate and return roles return rolesCountryRisk.concat(rolesBpdm); };