Skip to content

Commit

Permalink
Handle roles with applications that do no exist is Manage
Browse files Browse the repository at this point in the history
  • Loading branch information
oharsta committed Jan 9, 2024
1 parent acee905 commit d54ee1c
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 9 deletions.
3 changes: 2 additions & 1 deletion client/src/locale/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ const en = {
},
unknownRoles: {
title: "Roles linked to applications unknown in Manage",
searchPlaceHolder: "Search..."
searchPlaceHolder: "Search...",
noRoles: "Yeah, no unknown manage applications"
}
}

Expand Down
3 changes: 2 additions & 1 deletion client/src/locale/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,8 @@ const nl = {
},
unknownRoles: {
title: "Rollen gekoppeld aan applicaties die verwijderd zijn in Manage",
searchPlaceHolder: "Zoek..."
searchPlaceHolder: "Zoek...",
noRoles: "Yeah, no unknown manage applications"
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/src/pages/RoleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const RoleForm = () => {
} else {
breadcrumbPath.push({path: `/roles/${res[0].id}`, value: name});

res[0].applicationMaps.forEach(m => m.landingPage = res[0].applicationUsages.find(appUsage => appUsage.application.manageId === m.id).landingPage);
res[0].applicationMaps.forEach(m => m.landingPage = (res[0].applicationUsages.find(appUsage => appUsage.application.manageId === m.id) || {}).landingPage);
setApplications(providersToOptions(res[0].applicationMaps));
}
breadcrumbPath.push({value: I18n.t(`roles.${newRole ? "new" : "edit"}`, {name: name})});
Expand Down
5 changes: 3 additions & 2 deletions client/src/tabs/Applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {AUTHORITIES, isUserAllowed} from "../utils/UserRole";
import {useAppStore} from "../stores/AppStore";
import {useNavigate} from "react-router-dom";
import {providerInfo} from "../utils/Manage";
import {ReactComponent as AlertLogo} from "@surfnet/sds/icons/functional-icons/alert-circle.svg";

/*
* Show all roles with the manage information and a link to role detail for super admin
Expand Down Expand Up @@ -60,7 +61,7 @@ const Applications = () => {
const provider = allProviders.find(provider => provider.id === manageId) || providerInfo(null);
const organisation = provider["OrganizationName:en"];
const organisationValue = isEmpty(organisation) ? "" : ` (${organisation})`;
return `${provider["name:en"]}${organisationValue}`;
return provider.unknownInManage ? <span className="unknown-in-manage">{I18n.t("roles.unknownInManage")}</span> : `${provider["name:en"]}${organisationValue}`;
}

const providerLogoById = (manageMaps, allProviders) => {
Expand All @@ -69,7 +70,7 @@ const Applications = () => {
}
const manageId = manageMaps[0].id
const provider = allProviders.find(provider => provider.id === manageId) || providerInfo(null);
return provider.logo;
return provider.unknownInManage ? <div className="unknown-in-manage"><AlertLogo/></div> : provider.logo;
}

const provisioningsByProviderId = (manageMaps, allProvisionings) => {
Expand Down
9 changes: 9 additions & 0 deletions client/src/tabs/Applications.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ div.mod-applications {
}
}
}

.unknown-in-manage {
color: var(--sds--color--red--500);
font-weight: 600;

svg {
margin-left: 15px;
}
}
}
}
}
2 changes: 1 addition & 1 deletion client/src/tabs/RolesUnknownInManage.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export const RolesUnknownInManage = () => {
defaultSort="name"
columns={columns}
searchAttributes={["name", "description", "applicationName"]}
customNoEntities={I18n.t(`system.noRoles`)}
customNoEntities={I18n.t("unknownRoles.noRoles")}
loading={false}
inputFocus={true}
hideTitle={false}
Expand Down
7 changes: 4 additions & 3 deletions client/src/utils/Manage.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export const singleProviderToOption = provider => {
type: manageType,
manageType: manageType,
manageId: manageId,
url: provider.url,
landingPage: provider.landingPage
url: provider.url || provider.landingPage,
landingPage: provider.landingPage || provider.url
};
}

Expand Down Expand Up @@ -69,7 +69,8 @@ export const providerInfo = provider => {
return {
"OrganizationName:en": "",
provisioning_type: "",
"name:en": "Unknown in Manage"
"name:en": "Unknown in Manage",
unknownInManage: true
}
}
return provider;
Expand Down

0 comments on commit d54ee1c

Please sign in to comment.