From fba33fea32af7f4600cd389d9ce6a29e9c0439d9 Mon Sep 17 00:00:00 2001 From: Christopher Berge Hove Date: Mon, 16 Dec 2024 12:26:08 +0100 Subject: [PATCH] fix: Show error when application is deleted form app service --- .../src/components/AgStyle.tsx | 9 ++++ .../components/OnboardedApps/AppsTable.tsx | 8 ++++ .../components/PortalApps/PortalAppTable.tsx | 44 ++++++++++++++++--- .../src/query/apps-mutations.ts | 8 ++-- .../src/query/apps-queries.ts | 2 +- .../portal-administration/src/types/index.ts | 1 + 6 files changed, 63 insertions(+), 9 deletions(-) diff --git a/client/apps/portal-administration/src/components/AgStyle.tsx b/client/apps/portal-administration/src/components/AgStyle.tsx index 44a743455..9bdbe38c7 100644 --- a/client/apps/portal-administration/src/components/AgStyle.tsx +++ b/client/apps/portal-administration/src/components/AgStyle.tsx @@ -14,6 +14,10 @@ export const AgStyles = { padding: 0.5rem; overflow: hidden; `, + TextCellWrapperLeft: styled.div` + display: flex; + overflow: hidden; + `, Chip: styled(Chip)` margin-top: 0.25rem; `, @@ -59,5 +63,10 @@ export const AgStyles = { } height: 100%; position: relative; + + .notActive { + font-weight: bold; + background-color: ${tokens.colors.ui.background__danger.hex} !important; + } `, }; diff --git a/client/apps/portal-administration/src/components/OnboardedApps/AppsTable.tsx b/client/apps/portal-administration/src/components/OnboardedApps/AppsTable.tsx index cf74e7a30..d7237f2f2 100644 --- a/client/apps/portal-administration/src/components/OnboardedApps/AppsTable.tsx +++ b/client/apps/portal-administration/src/components/OnboardedApps/AppsTable.tsx @@ -13,6 +13,8 @@ import { OnboardedAppsActionBar } from './OnboardedAppsActionBar'; import { useResizeObserver } from '../../hooks/use-resise-observer'; import { Message } from '../Message'; +const FAIL_MESSAGE = 'Application Error!'; + export const AppsTable = ({ onboardedApps }: { onboardedApps: PortalApp[] | undefined }) => { const [selectedApps, setSelectedApps] = useState([]); const { mutateAsync: deleteAppByAppKey } = useDeleteOnboardedApp(); @@ -35,6 +37,9 @@ export const AppsTable = ({ onboardedApps }: { onboardedApps: PortalApp[] | unde sortable: true, resizable: true, }} + rowClassRules={{ + notActive: (params) => !Boolean(params.data?.displayName || params.data?.description), + }} autoSizeStrategy={{ type: 'fitGridWidth', defaultMinWidth: 80, @@ -61,6 +66,9 @@ export const AppsTable = ({ onboardedApps }: { onboardedApps: PortalApp[] | unde field: 'displayName', headerName: 'Display Name', filter: true, + valueFormatter: (params) => { + return params.value ? params.value : FAIL_MESSAGE; + }, }, { field: 'appKey', diff --git a/client/apps/portal-administration/src/components/PortalApps/PortalAppTable.tsx b/client/apps/portal-administration/src/components/PortalApps/PortalAppTable.tsx index 088904a27..71b419b16 100644 --- a/client/apps/portal-administration/src/components/PortalApps/PortalAppTable.tsx +++ b/client/apps/portal-administration/src/components/PortalApps/PortalAppTable.tsx @@ -8,6 +8,8 @@ import { ActionBar } from './ActionBar'; import { AgStyles } from '../AgStyle'; import { Message } from '../Message'; +const FAIL_MESSAGE = 'Application Error!'; + export const PortalAppTable = ({ portalApps, canEdit }: { portalApps: PortalApplication[]; canEdit?: boolean }) => { const ref = useRef(null); const [_, height] = useResizeObserver(ref); @@ -28,6 +30,9 @@ export const PortalAppTable = ({ portalApps, canEdit }: { portalApps: PortalAppl sortable: true, resizable: true, }} + rowClassRules={{ + notActive: (params) => !Boolean(params.data?.appManifest), + }} ensureDomOrder onGridReady={(event) => { const api = event.api; @@ -57,19 +62,19 @@ export const PortalAppTable = ({ portalApps, canEdit }: { portalApps: PortalAppl isActive?: boolean; isContextual?: boolean; appKey: string; - appManifest: { name: string }; + appManifest?: { name: string }; }> ) => { return ( {params.data?.isContextual ? ( ) : ( )} @@ -102,9 +107,20 @@ export const PortalAppTable = ({ portalApps, canEdit }: { portalApps: PortalAppl filterOptions: ['contains', 'startsWith', 'endsWith'], defaultOption: 'startsWith', }, + cellRenderer: ( + params: CustomCellRendererProps<{ + appManifest?: { displayName: string }; + }> + ) => { + return ( + + {params.data?.appManifest ? params.data?.appManifest.displayName : FAIL_MESSAGE} + + ); + }, }, { - field: 'appManifest.appKey', + field: 'appKey', maxWidth: 350, headerName: 'Application key', filterParams: { @@ -120,16 +136,34 @@ export const PortalAppTable = ({ portalApps, canEdit }: { portalApps: PortalAppl filterOptions: ['contains', 'startsWith', 'endsWith'], defaultOption: 'startsWith', }, + cellRenderer: ( + params: CustomCellRendererProps<{ + appManifest?: { category: { displayName: string } }; + }> + ) => { + return ( + + {params.data?.appManifest + ? params.data?.appManifest.category.displayName + : FAIL_MESSAGE} + + ); + }, }, { - field: 'appManifest.description', + field: 'appManifest', headerName: 'Description', filterParams: { filterOptions: ['contains', 'startsWith', 'endsWith'], defaultOption: 'startsWith', }, width: 500, + valueFormatter: (params) => { + return params.data?.appManifest + ? params.data?.appManifest.description + : 'Application Missing application manifest! Application may have been deleted from Fusion app service.'; + }, }, { diff --git a/client/apps/portal-administration/src/query/apps-mutations.ts b/client/apps/portal-administration/src/query/apps-mutations.ts index 50ae2d09b..a603db5d1 100644 --- a/client/apps/portal-administration/src/query/apps-mutations.ts +++ b/client/apps/portal-administration/src/query/apps-mutations.ts @@ -1,5 +1,5 @@ import { QueryClient } from '@tanstack/react-query'; -import { PortalApplication } from '../types'; +import { PortalApplication } from '../types'; export const mutatePortalApps = (queryClient: QueryClient, portalId: string | undefined, apps: PortalApplication[]) => { queryClient.cancelQueries({ queryKey: ['portal-onboarded-apps', portalId] }); @@ -26,8 +26,10 @@ export const mutateDeletePortalApps = ( queryClient.cancelQueries({ queryKey: ['portal-onboarded-apps', portalId] }); const prevApps = queryClient.getQueryData(['portal-onboarded-apps', portalId]) || []; - const appKeys = apps.map((app) => app.appManifest.appKey); - const newApps = prevApps?.map((prevApp) => (appKeys.includes(prevApp.appManifest.appKey) ? { ...prevApp, isActive: false } : prevApp)); + const appKeys = apps.map((app) => app.appKey); + const newApps = prevApps?.map((prevApp) => + appKeys.includes(prevApp.appKey) ? { ...prevApp, isActive: false } : prevApp + ); queryClient.setQueryData(['portal-onboarded-apps', portalId], newApps); return { prevApps, newApps }; }; diff --git a/client/apps/portal-administration/src/query/apps-queries.ts b/client/apps/portal-administration/src/query/apps-queries.ts index 6f97a2edd..17339c55d 100644 --- a/client/apps/portal-administration/src/query/apps-queries.ts +++ b/client/apps/portal-administration/src/query/apps-queries.ts @@ -165,7 +165,7 @@ export const removePortalApps = async (client: IHttpClient, portalApps: PortalAp const results: Result[] = []; for (const app of portalApps) { - const result = await removePortalApp(client, app.appManifest.appKey, portalId); + const result = await removePortalApp(client, app.appKey, portalId); results.push(result); } diff --git a/client/apps/portal-administration/src/types/index.ts b/client/apps/portal-administration/src/types/index.ts index d42fa27e5..78b378634 100644 --- a/client/apps/portal-administration/src/types/index.ts +++ b/client/apps/portal-administration/src/types/index.ts @@ -58,6 +58,7 @@ export type FormattedError = { export type PortalApp = { name: string; + displayName: string; id: string; appKey: string; isLegacy: boolean;