Skip to content

Commit

Permalink
Merge pull request #33 from catenax-ng/main
Browse files Browse the repository at this point in the history
Release new version for country risk frontend
  • Loading branch information
almadigabor authored Oct 11, 2023
2 parents 4260508 + 260f423 commit d6fa4ee
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 25 deletions.
10 changes: 7 additions & 3 deletions .idea/sonarlint/issuestore/index.pb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions charts/country-risk/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
4 changes: 2 additions & 2 deletions charts/country-risk/charts/country-risk-backend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions charts/country-risk/charts/country-risk-frontend/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
11 changes: 7 additions & 4 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script>
window.ENV = {REACT_APP_COUNTRY_RISK_API:"http://localhost:8080",
REACT_APP_AUTH_URL:"http://localhost:8080/auth",
REACT_APP_PORTAL_FRONTEND:"http://localhost:8080",
REACT_APP_PORTAL_BACKEND:"http://localhost:8080"};
window.ENV = {
REACT_APP_COUNTRY_RISK_API: "http://localhost:8080",
REACT_APP_AUTH_URL: "http://localhost:8080/auth",
REACT_APP_PORTAL_FRONTEND: "http://localhost:8080",
REACT_APP_PORTAL_BACKEND: "http://localhost:8080",
REACT_APP_COUNTRY_RISK_CLIENT: "country_risk_client",
};
</script>
<title>React App</title>
</head>
Expand Down
3 changes: 3 additions & 0 deletions scripts/inject-dynamic-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,21 @@ 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`

index_html=$(sed -r 's%'$REACT_APP_AUTH_URL_anchor'%'$custom_env_vars_REACT_APP_AUTH_URL'%g' <<< "$index_html_reference")
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
5 changes: 2 additions & 3 deletions src/components/dashboard/DashBoardTable/tableColumns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 [
{
Expand Down
9 changes: 7 additions & 2 deletions src/components/services/EnvironmentService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
23 changes: 18 additions & 5 deletions src/components/services/UserService.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

Expand Down

0 comments on commit d6fa4ee

Please sign in to comment.