Skip to content

Commit

Permalink
fix(idp config): fix user csv file upload results (#452)
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhigarg-bmw authored Jan 31, 2024
1 parent f7f178d commit 2a71133
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 17 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
- Delete certificate screen
- Company Roles
- Fetch the standard library data from standards.json and implement Table component to display it in the company roles section.
- Fix Idp users CSV results empty after upload

## 1.8.0-RC2

Expand Down
2 changes: 1 addition & 1 deletion src/assets/locales/de/idp.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"error": "Something went wrong. IdP got not disabled."
},
"users": {
"title": "Link existing users to new IdP",
"title": "Update/Migrate User Accounts",
"subtitle": "Make sure users can continue working",
"short": "Link IdP Users",
"desc1": "When you create your own Identity Provider, you can migrate/connect your existing Catena-X users with the users listed in your own IdP. This is facilitated by the Keycloak IdP.<br />All user data and settings are retained and assigned to the correct user. <br /><br />To do this, select the file format and download a list of your Catena-X users. <br />Add the corresponding unique user ID from your own IdP to each Catena-X user.<br/> Upload the updated file back to Catena-X.<br />This will link the existing Catena-X user accounts to the corresponding user account from your own IdP.<br /> <br /> Your users can now log in to the CX-Portal with their company credentials.",
Expand Down
2 changes: 1 addition & 1 deletion src/assets/locales/en/idp.json
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
"error": "Something went wrong. IdP got not disabled."
},
"users": {
"title": "Link existing users to new IdP",
"title": "Update/Migrate User Accounts",
"subtitle": "Make sure users can continue working",
"short": "Link IdP Users",
"desc1": "When you create your own Identity Provider, you can migrate/connect your existing Catena-X users with the users listed in your own IdP. This is facilitated by the Keycloak IdP.<br />All user data and settings are retained and assigned to the correct user. <br /><br />To do this, select the file format and download a list of your Catena-X users. <br />Add the corresponding unique user ID from your own IdP to each Catena-X user.<br/> Upload the updated file back to Catena-X.<br />This will link the existing Catena-X user accounts to the corresponding user account from your own IdP.<br /> <br /> Your users can now log in to the CX-Portal with their company credentials.",
Expand Down
33 changes: 18 additions & 15 deletions src/components/overlays/AddusersIDP/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const AddusersIDPResponse = ({
const [tableErrorData, setTableErrorData] = useState<TableType>()

useEffect(() => {
if (userResponse) {
if (userResponse?.error && !tableErrorData?.body.length) {
const errorMsgs = userResponse.errors.map((error: ErrorResponse) => [
`${csvData[error.line - 1].firstName} ${
csvData[error.line - 1].lastName
Expand Down Expand Up @@ -321,28 +321,31 @@ export const AddusersIDP = ({ id }: { id: string }) => {
)

const csvcols2json = useCallback(
(cols: Array<string>): UserIdentityProviders => ({
companyUserId: cols[0],
firstName: cols[1],
lastName: cols[2],
email: cols[3],
identityProviders: [
{
identityProviderId: cols[4] ?? '',
userId: cols[5] ?? '',
userName: cols[6] ?? '',
},
],
}),
(cols: Array<string>): UserIdentityProviders => {
return {
companyUserId: cols[0],
firstName: cols[1],
lastName: cols[2],
email: cols[3],
identityProviders: [
{
identityProviderId: cols[4] ?? '',
userId: cols[5] ?? '',
userName: cols[6]?.replace(/['"]+/g, '') ?? '',
},
],
}
},
[]
)

const csv2json = useCallback(
(users: string) =>
users
.trim()
.split('\n')
.split(/\\r\\n|\\n|\n/)
.slice(1)
.filter((row) => row.length > 1)
.map((row) => csvcols2json(row.split(',').map((col) => col.trim()))),
[csvcols2json]
)
Expand Down

0 comments on commit 2a71133

Please sign in to comment.