diff --git a/.changeset/pr-862-2174620281.md b/.changeset/pr-862-2174620281.md new file mode 100644 index 00000000..66c3e50d --- /dev/null +++ b/.changeset/pr-862-2174620281.md @@ -0,0 +1,5 @@ + +--- +"fusion-project-portal": minor +--- +Align portal administration application with the new app management models diff --git a/client/apps/portal-administration/src/components/Actions/ActivateSelectedWithContextButton.tsx b/client/apps/portal-administration/src/components/Actions/ActivateSelectedWithContextButton.tsx index 5d00eca8..d2fb2e0c 100644 --- a/client/apps/portal-administration/src/components/Actions/ActivateSelectedWithContextButton.tsx +++ b/client/apps/portal-administration/src/components/Actions/ActivateSelectedWithContextButton.tsx @@ -1,7 +1,8 @@ import { Button, Icon } from '@equinor/eds-core-react'; -import { PortalApp, PortalApplication } from '../../types'; +import { PortalApplication } from '../../types'; import { add_circle_filled } from '@equinor/eds-icons'; +import { useMemo } from 'react'; type ActivateSelectedWithContextButtonProps = { selection: PortalApplication[]; @@ -12,7 +13,9 @@ export const ActivateSelectedWithContextButton = ({ selection, activateSelectedWithContext, }: ActivateSelectedWithContextButtonProps) => { - const isActive = selection.some((a) => !a.isActive) && selection.length < 2; + + // Only active if one is selected or the selected has contextTypes active + const isActive = useMemo(()=> (!!selection.find(app => app.contextTypes.length !== 0) && selection.some((a) => !a.isActive) && selection.length < 2),[selection]); if (!isActive) { return null; diff --git a/client/apps/portal-administration/src/components/PortalApps/ContextAppSideSheet.tsx b/client/apps/portal-administration/src/components/PortalApps/ContextAppSideSheet.tsx index 44b3ca64..6e6b0a25 100644 --- a/client/apps/portal-administration/src/components/PortalApps/ContextAppSideSheet.tsx +++ b/client/apps/portal-administration/src/components/PortalApps/ContextAppSideSheet.tsx @@ -78,11 +78,11 @@ export function ContextAppSideSheet({ const { activeContexts, contextTypes } = useActiveOnboardedContext(); const [selectedContexts, setSelectedContexts] = useState([]); - const { data: activeApp, isLoading } = useGetPortalApp(activePortalId, app.key); + const { data: activeApp, isLoading } = useGetPortalApp(activePortalId, app.appManifest.appKey); const contexts: OnboardedContext[] = useMemo(() => { - if (!activeApp || !activeContexts) return []; + if (!activeApp || !activeContexts) return []; return activeContexts.map((context) => ({ ...context, isActive: activeApp.contextIds?.includes(context.contextId), @@ -103,7 +103,7 @@ export function ContextAppSideSheet({ minWidth={1200} isDismissable={true} > - + @@ -165,9 +165,9 @@ export function ContextAppSideSheet({ onCellValueChanged: (event) => { if (event.newValue) { console.log('Activate context', event.data); - add({ appKey: app.key, contextIds: [event.data.contextId] }); + add({ appKey: app.appManifest.appKey, contextIds: [event.data.contextId] }); } else { - remove({ appKey: app.key, contextIds: [event.data.contextId] }); + remove({ appKey: app.appManifest.appKey, contextIds: [event.data.contextId] }); } }, }, @@ -200,7 +200,7 @@ export function ContextAppSideSheet({