Skip to content

Commit

Permalink
feat: new apps loading form new app service
Browse files Browse the repository at this point in the history
  • Loading branch information
Noggling committed Oct 3, 2024
1 parent a3c64d6 commit 1ca13a3
Show file tree
Hide file tree
Showing 8 changed files with 3,102 additions and 3,010 deletions.
42 changes: 22 additions & 20 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,26 +64,28 @@
"@equinor/eds-core-react": "^0.36.0",
"@equinor/eds-icons": "^0.17.0",
"@equinor/eds-tokens": "^0.9.0",
"@equinor/fusion-framework-app": "^8.1.1",
"@equinor/fusion-framework-module-ag-grid": "^31.0.1",
"@equinor/fusion-framework-module-app": "^5.2.13",
"@equinor/fusion-framework-module-context": "^4.0.21",
"@equinor/fusion-framework-module-feature-flag": "^1.0.2",
"@equinor/fusion-framework-module-http": "^5.1.6",
"@equinor/fusion-framework-module-navigation": "^3.1.4",
"@equinor/fusion-framework-module-services": "^3.2.4",
"@equinor/fusion-framework-module-signalr": "^2.0.19",
"@equinor/fusion-framework-react": "^6.0.2",
"@equinor/fusion-framework-react-app": "^4.3.3",
"@equinor/fusion-framework-react-components-bookmark": "0.3.7",
"@equinor/fusion-framework-react-components-people-provider": "^1.1.15",
"@equinor/fusion-framework-react-module-signalr": "^2.0.18",
"@equinor/fusion-observable": "^8.1.5",
"@equinor/fusion-react-context-selector": "^0.6.0",
"@equinor/fusion-react-person": "^0.7.0",
"@equinor/fusion-react-side-sheet": "1.3.0",
"@equinor/fusion-framework": "^7.2.7",
"@equinor/fusion-framework-app": "^9.1.9-alpha-6ff6662450828ba21fa1bcf1c35b24bea98bce62",
"@equinor/fusion-framework-module-ag-grid": "^32.2.0",
"@equinor/fusion-framework-module-app": "^6.0.0-alpha-6ff6662450828ba21fa1bcf1c35b24bea98bce62",
"@equinor/fusion-framework-module-context": "^5.0.12",
"@equinor/fusion-framework-module-feature-flag": "^1.1.9",
"@equinor/fusion-framework-module-http": "^6.1.0",
"@equinor/fusion-framework-module-navigation": "^4.0.7",
"@equinor/fusion-framework-module-service-discovery": "^8.0.0",
"@equinor/fusion-framework-module-services": "^4.1.4",
"@equinor/fusion-framework-module-signalr": "^4.0.0",
"@equinor/fusion-framework-react": "^7.3.0-alpha-6ff6662450828ba21fa1bcf1c35b24bea98bce62",
"@equinor/fusion-framework-react-app": "^5.2.9-alpha-6ff6662450828ba21fa1bcf1c35b24bea98bce62",
"@equinor/fusion-framework-react-components-bookmark": "0.5.0",
"@equinor/fusion-framework-react-components-people-provider": "^1.4.8-alpha-6ff6662450828ba21fa1bcf1c35b24bea98bce62",
"@equinor/fusion-framework-react-module-signalr": "^3.0.15",
"@equinor/fusion-observable": "^8.4.1",
"@equinor/fusion-react-context-selector": "^0.6.6",
"@equinor/fusion-react-person": "^0.9.2",
"@equinor/fusion-react-side-sheet": "1.3.3",
"@equinor/fusion-react-skeleton": "^0.3.0",
"@equinor/fusion-react-styles": "^0.6.1",
"@equinor/fusion-react-styles": "^0.6.2",
"@equinor/fusion-react-tooltip": "^1.1.11",
"@hookform/resolvers": "^3.3.2",
"@microsoft/applicationinsights-web": "^3.0.2",
Expand All @@ -107,4 +109,4 @@
"workspaces": [
"packages/**"
]
}
}
5 changes: 3 additions & 2 deletions client/packages/core/src/app/hooks/use-app-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@ export const useAppLoader = (appKey: string) => {
},
})
);

/** remove app element when application unmounts */
subscription.add(() => appRef.current.remove());
}
} catch (error) {
console.error('App loading Error: ', error);
setError(error as Error);
setLoading(false);
}
},
complete: () => {
Expand All @@ -81,7 +83,6 @@ export const useAppLoader = (appKey: string) => {
error: (err) => {
console.error('App init Error: ', error);
setError(err);
setLoading(false);
},
})
);
Expand Down
26 changes: 22 additions & 4 deletions client/packages/portal-client/src/lib/portal-framework-config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { enableNavigation, NavigationModule } from '@equinor/fusion-framework-mo

import { enableSignalR } from '@equinor/fusion-framework-module-signalr';
import { enableBookmark } from '@equinor/fusion-framework-module-bookmark';
import { addPortalClient, configurePortalContext, appConfigurator } from '@equinor/portal-core';
import { addPortalClient, configurePortalContext } from '@equinor/portal-core';
import { skip } from 'rxjs';
import { replaceContextInPathname } from '../utils/context-utils';
import { enableAgGrid } from '@equinor/fusion-framework-module-ag-grid';
Expand All @@ -17,6 +17,7 @@ import { createLocalStoragePlugin } from '@equinor/fusion-framework-module-featu
import { FeatureLogger } from './feature-logger';
import { enablePortalConfig } from '@portal/core';
import { PortalConfig as PortalConfigModule } from '@portal/core';
import { enableServiceDiscovery } from '@equinor/fusion-framework-module-service-discovery';

const showInfo = false;

Expand All @@ -28,13 +29,20 @@ function getClientIdFormScope(scope: string): string | undefined {

export function createPortalFramework(portalConfig: PortalConfig) {
return (config: FusionConfigurator) => {
config.logger.level = (portalConfig.logger?.level as LoggerLevel) || 0;
config.logger.level = 4; // (portalConfig.logger?.level as LoggerLevel) || 0;

/** Legacy Fusion ClientId used in legacy auth provider */
(window as { clientId?: string }).clientId = getClientIdFormScope(
portalConfig.serviceDiscovery.client.defaultScopes[0]
);

config.configureHttpClient('service_discovery', {
baseUri: `https://discovery.fusion.equinor.com/service-registry/environments/${portalConfig.fusionLegacyEnvIdentifier}/services`,
defaultScopes: portalConfig.serviceDiscovery.client.defaultScopes,
});

enableServiceDiscovery(config);

enablePortalMenu(config);

enablePortalConfig(config, (builder) => {
Expand Down Expand Up @@ -102,9 +110,14 @@ export function createPortalFramework(portalConfig: PortalConfig) {
});

enableContext(config);
config.configureServiceDiscovery(portalConfig.serviceDiscovery);

enableAppModule(config, appConfigurator(portalConfig.portalClient.client));
// enableAppModule(config, appConfigurator(portalConfig.portalClient.client));
enableAppModule(config);

config.configureHttpClient('app', {
baseUri: new URL('/apps-proxy/', location.origin).href,
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
});

config.configureMsal(portalConfig.msal.client, portalConfig.msal.options);

Expand Down Expand Up @@ -254,6 +267,11 @@ export function createPortalFramework(portalConfig: PortalConfig) {
}

config.onInitialized<[NavigationModule, TelemetryModule, AppModule, PortalConfigModule]>(async (fusion) => {
// const appService = await fusion.serviceDiscovery.resolveService('apps');
// // eslint-disable-next-line @typescript-eslint/ban-ts-comment
// // @ts-ignore
// modules.http.config._clients.apps = { baseUri: appService.uri, defaultScopes: appService.scopes };

new FeatureLogger(fusion);

// Todo: should be moved to context module
Expand Down
14 changes: 14 additions & 0 deletions client/packages/portal-client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import tsconfig from 'vite-tsconfig-paths';

import env from 'vite-plugin-environment';
import { viteStaticCopy } from 'vite-plugin-static-copy';
import { appProxyPlugin } from '@equinor/fusion-framework-cli/plugin-app-proxy';

let token: string | undefined = undefined;
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const isProduction = mode === 'prod';
Expand All @@ -31,6 +33,17 @@ export default defineConfig(({ mode }) => {
},
],
}),
appProxyPlugin({
proxy: {
path: '/apps-proxy',
target: 'https://fusion-s-apps-ci.azurewebsites.net/',
onProxyReq: (proxyReq, req, res) => {
proxyReq.on('response', (res) => {
console.log(res.statusMessage ?? `${res.statusCode} `, res.req?.path, res.statusCode);
});
},
},
}),
],
assetsInclude: ['*.svg', '*.jpg', '*.jpeg', '*.png'],
preview: { port: 3000 },
Expand All @@ -47,6 +60,7 @@ export default defineConfig(({ mode }) => {
},
},
},
mode: process.env.NODE_ENV ?? 'development',
server: {
port: 3000,
host: true,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from "./app-configurator"
export * from "./portal-configurators"
export * from "./portal-context-configurators"
export * from "./portal-context-history"
export * from './portal-configurators';
export * from './portal-context-configurators';
export * from './portal-context-history';
Loading

0 comments on commit 1ca13a3

Please sign in to comment.