Skip to content

Commit

Permalink
feat: add landing page feature flag and update portal routing logic (#…
Browse files Browse the repository at this point in the history
…889)

Co-authored-by: Noggling <[email protected]>
  • Loading branch information
Noggling and Noggling authored Dec 10, 2024
1 parent 6953d9a commit 3595482
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/pr-889-2225772499.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

---
"fusion-project-portal": minor
---
Loading new landing page apps on routes
21 changes: 19 additions & 2 deletions client/packages/core/src/modules/portal-config/portal.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<PortalState, Actions>;

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();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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<PortalRoute> }) => {
const { feature } = useFeature('landing-page');
switch (prop.route?.pageKey) {
case 'project-portal':
return <ProjectPortalPage />;
return (
<>
{feature?.enabled ? (
<LoadPage
pageKey="project-portal-landingpage"
path={prop.route.path}
messages={prop.route.messages}
/>
) : (
<ProjectPortalPage />
)}
</>
);
case 'project':
return <ProjectPage />;
return (
<>
{feature?.enabled ? (
<LoadPage
pageKey="project-landingpage"
path={prop.route?.path}
messages={prop.route?.messages}
/>
) : (
<ProjectPage />
)}
</>
);
case 'facility':
return <FacilityPage />;
return (
<>
{feature?.enabled ? (
<LoadPage
pageKey="facility-landingpage"
path={prop.route?.path}
messages={prop.route?.messages}
/>
) : (
<FacilityPage />
)}
</>
);
default:
return <LoadPage {...prop.route} />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 3595482

Please sign in to comment.