diff --git a/.changeset/pr-889-2225772499.md b/.changeset/pr-889-2225772499.md new file mode 100644 index 000000000..a3e07eac9 --- /dev/null +++ b/.changeset/pr-889-2225772499.md @@ -0,0 +1,5 @@ + +--- +"fusion-project-portal": minor +--- +Loading new landing page apps on routes diff --git a/client/packages/core/src/modules/portal-config/portal.ts b/client/packages/core/src/modules/portal-config/portal.ts index 5a7f2afb7..8d754a52c 100644 --- a/client/packages/core/src/modules/portal-config/portal.ts +++ b/client/packages/core/src/modules/portal-config/portal.ts @@ -1,4 +1,4 @@ -import { BaseConfig, Extensions, PortalConfigState, PortalRouter, PortalState } from './types'; +import { BaseConfig, ContextType, Extensions, PortalConfigState, PortalRouter, PortalState } from './types'; import { Observable, map, take } from 'rxjs'; import { FlowSubject } from '@equinor/fusion-observable'; @@ -19,18 +19,35 @@ export interface IPortal { getAppKeysByContext(contextId: string): void; getAppKeys(): void; clearAppKeys(): void; + portalAppConfig: PortalConfig; } +type PortalConfig = { + id?: string; + contextTypes: ContextType[]; + env: string; +}; + export type CurrentPortal = IPortal; export class Portal implements IPortal { #state: FlowSubject; - + portalAppConfig: PortalConfig; base: BaseConfig; constructor(args: { provider: PortalConfigProvider; base: BaseConfig; initialPortalConfig?: PortalState }) { this.base = args.base; this.#state = createState(args.provider, args.initialPortalConfig); + this.portalAppConfig = { + id: args.base.portalId, + contextTypes: [], + env: args.base.portalEnv, + }; + + this.portalConfig$.subscribe((portalConfig) => { + this.portalAppConfig.contextTypes = portalConfig.contexts || []; + }); + this.initialize(); } diff --git a/client/packages/portal-client/src/components/portal-router/PortalPage.tsx b/client/packages/portal-client/src/components/portal-router/PortalPage.tsx index fc1e6d44b..e9e5c5616 100644 --- a/client/packages/portal-client/src/components/portal-router/PortalPage.tsx +++ b/client/packages/portal-client/src/components/portal-router/PortalPage.tsx @@ -1,15 +1,53 @@ import { PortalRoute } from '@portal/core'; import { FacilityPage, ProjectPage, ProjectPortalPage } from '@equinor/portal-pages'; import { LoadPage } from './LoadPage'; +import { useFeature } from '@equinor/fusion-framework-react-app/feature-flag'; export const PortalPage = (prop: { route?: Partial }) => { + const { feature } = useFeature('landing-page'); switch (prop.route?.pageKey) { case 'project-portal': - return ; + return ( + <> + {feature?.enabled ? ( + + ) : ( + + )} + + ); case 'project': - return ; + return ( + <> + {feature?.enabled ? ( + + ) : ( + + )} + + ); case 'facility': - return ; + return ( + <> + {feature?.enabled ? ( + + ) : ( + + )} + + ); default: return ; } diff --git a/client/packages/portal-client/src/lib/portal-framework-config.tsx b/client/packages/portal-client/src/lib/portal-framework-config.tsx index 3af54efec..6366f1739 100644 --- a/client/packages/portal-client/src/lib/portal-framework-config.tsx +++ b/client/packages/portal-client/src/lib/portal-framework-config.tsx @@ -123,6 +123,13 @@ export function createPortalFramework(portalConfig: PortalConfig) { enableFeatureFlagging(config, (builder) => { builder.addPlugin( createLocalStoragePlugin([ + { + key: 'landing-page', + title: 'New Landing pages', + description: + 'When enabled you will get new landing pages in the portal. The functionality is the same but the loading is done differently', + enabled: false, + }, { key: 'project-prediction', title: 'Allocated Projects',