Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add landing page feature flag and update portal routing logic #889

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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