Skip to content

Commit

Permalink
Merge branch 'feature/fusion-apps-service-migration' of https://githu…
Browse files Browse the repository at this point in the history
…b.com/equinor/fusion-project-portal into feature/fusion-apps-service-migration
  • Loading branch information
kjetilhau committed Oct 16, 2024
2 parents 61b1235 + 06457dd commit 6653c89
Show file tree
Hide file tree
Showing 20 changed files with 207 additions and 128,658 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.4" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
</ItemGroup>

<ItemGroup>
Expand Down
12 changes: 6 additions & 6 deletions client/apps/legacyAppLoader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
"@equinor/eds-core-react": "^0.42.0",
"@equinor/fusion": "^3.4.16",
"@equinor/fusion-components": "^2.12.0",
"@equinor/fusion-framework-app": "^9.1.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8",
"@equinor/fusion-framework-module-app": "^6.0.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8",
"@equinor/fusion-framework-app": "^9.1.10",
"@equinor/fusion-framework-module-app": "^6.0.0",
"@equinor/fusion-framework-module-http": "^6.2.0",
"@equinor/fusion-framework-module-navigation": "^4.0.7",
"@equinor/fusion-framework-react": "^7.3.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8",
"@equinor/fusion-framework-react-app": "^5.2.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8",
"@equinor/fusion-framework-react": "^7.3.0",
"@equinor/fusion-framework-react-app": "^5.2.10",
"@equinor/fusion-observable": "^8.4.1",
"@equinor/fusion-react-styles": "^0.6.2",
"@types/react": "^17.0.70",
Expand All @@ -41,8 +41,8 @@
"vite-tsconfig-paths": "^4.2.0"
},
"devDependencies": {
"@equinor/fusion-framework-cli": "^10.0.0-next-499bdf0f6597dbdcfdabd563b94ed08de36bbfe4",
"@equinor/fusion-framework-cli": "^10.0.0",
"@types/react-router-dom": "^5.3.3",
"vite-plugin-static-copy": "^0.17.0"
}
}
}
17 changes: 8 additions & 9 deletions client/apps/legacyAppLoader/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ interface Client {
export const configure: AppModuleInitiator<
[NavigationModule],
Fusion<unknown>,
{ config: { environment: { endpoints: { client: Client; portal: Client } } } }
> = (configurator, env) => {
configurator.configureHttpClient('portal-client', env.env.config?.environment.endpoints.client);
configurator.configureHttpClient('portal', env.env.config?.environment.endpoints.portal);
{ config: { environment: { endpoints: { client: Client; portal: Client; fusion: Client } } } }
> = (configurator, { env, fusion }) => {
configurator.configureHttpClient('portal-client', env.config?.environment.endpoints.client);
configurator.configureHttpClient('portal', env.config?.environment.endpoints.portal);

window['clientBaseUri'] = env.env.config?.environment.endpoints.client.baseUri;
window['clientBaseUri'] = env.config?.environment.endpoints.client.baseUri;
// configurator.logger.level = 4;
configurator.configureHttpClient('app', {
baseUri: new URL('/apps-proxy/', location.origin).href,
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
defaultScopes: env.config?.environment.endpoints.fusion.defaultScopes,
});

enableAppModule(configurator);
Expand All @@ -41,9 +41,8 @@ export const configure: AppModuleInitiator<
if (nav.action !== 'PUSH') return;

if (
nav.location.pathname
.split('/')
.filter((path) => path === env.fusion.modules.context.currentContext?.id).length > 1
nav.location.pathname.split('/').filter((path) => path === fusion.modules.context.currentContext?.id)
.length > 1
) {
instance.navigation.navigator.go(-1);
}
Expand Down
2 changes: 1 addition & 1 deletion client/apps/legacyAppLoader/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { AppComponent } from './App';
/** Render function */
export const renderApp = (el: HTMLElement, args: ComponentRenderArgs) => {
const component = AppComponent(args);
console.log('args', args.env.config);

render(component, el);

return () => {
Expand Down
49 changes: 25 additions & 24 deletions client/apps/legacyAppLoader/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -312,22 +312,22 @@
optionalDependencies:
fsevents "^2.3.2"

"@equinor/fusion-framework-app@^9.1.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8":
version "9.1.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-app/-/fusion-framework-app-9.1.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8.tgz#a9e931e200ec07421ce319d7196754114abba8bf"
integrity sha512-cQXX3NV9D3xpNmYY+go6HFog9WK6yEAQAI79ICycm/gZNyfP0B+gWHyvs3hIDlqknERpXA6nzEoDEZeanay/FA==
"@equinor/fusion-framework-app@^9.1.10":
version "9.1.10"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-app/-/fusion-framework-app-9.1.10.tgz#098f22318ac83e7db8a574a0a0d0ee8bfe786af3"
integrity sha512-uySslJS73MQG6+DBQYhM5RnSU0Ts81BHqFiVtKAfKzvoEXFIZYYLN91N1ewGhic1U6cPa6XwHBWqy4L0qKcfLg==
dependencies:
"@equinor/fusion-framework" "^7.2.8"
"@equinor/fusion-framework-module" "^4.3.5"
"@equinor/fusion-framework-module-app" "^6.0.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8"
"@equinor/fusion-framework-module-app" "^6.0.0"
"@equinor/fusion-framework-module-event" "^4.2.4"
"@equinor/fusion-framework-module-http" "^6.2.0"
"@equinor/fusion-framework-module-msal" "^3.1.5"

"@equinor/fusion-framework-cli@^10.0.0-next-499bdf0f6597dbdcfdabd563b94ed08de36bbfe4":
version "10.0.0-next-499bdf0f6597dbdcfdabd563b94ed08de36bbfe4"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-cli/-/fusion-framework-cli-10.0.0-next-499bdf0f6597dbdcfdabd563b94ed08de36bbfe4.tgz#815692ab553fcb4626b5133f6734ffe459af9aef"
integrity sha512-tZiPwg4KopxowJejJUF8zTlgVT3uTdy4zCx2dYgtp6lSG9j11rP4blctRt288VHAthkRBSce/KnyaHFh8yMqKg==
"@equinor/fusion-framework-cli@^10.0.0":
version "10.0.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-cli/-/fusion-framework-cli-10.0.0.tgz#9994331f4f25fe1dfeec62594ca9b158488472ae"
integrity sha512-/EC7A9QRxrM2ztbTJuk+6U12bzMk5MIf/e5ecbocHXj0NbiM/TfYNbDkAc3a1tQz7bgF9UZlNHt9Re05VclAKw==
dependencies:
"@vitejs/plugin-react" "^4.0.4"
adm-zip "^0.5.10"
Expand All @@ -348,11 +348,12 @@
vite-plugin-environment "^1.1.3"
vite-plugin-restart "^0.4.0"
vite-tsconfig-paths "^4.2.0"
zod "^3.23.8"

"@equinor/fusion-framework-module-app@^6.0.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8":
version "6.0.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-app/-/fusion-framework-module-app-6.0.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8.tgz#1625135388a9be7ffe0664e2fa4f909d9e853dec"
integrity sha512-+OsDj9vCIhHyYN7Q6AriNkjBpzFM5I/2cYshIC2T0HDC7Zjf+4Xqyz0jg9SwxINnkRU6MhhWpa5qZIptlIHozw==
"@equinor/fusion-framework-module-app@^6.0.0":
version "6.0.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-module-app/-/fusion-framework-module-app-6.0.0.tgz#a1dde3692dc02e27097c2a8ebde686415c1ad960"
integrity sha512-fct0Ja2r7NKY1YYllVVi40tj7FXl4XxXkfYmbPNqOly+TdcBgUQ116UCIBKzji7sTn9aaiHu8jn1/gye7wxlcA==
dependencies:
"@equinor/fusion-observable" "^8.4.1"
"@equinor/fusion-query" "^5.1.3"
Expand Down Expand Up @@ -427,16 +428,16 @@
rxjs "^7.8.1"
semver "^7.5.4"

"@equinor/fusion-framework-react-app@^5.2.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8":
version "5.2.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-app/-/fusion-framework-react-app-5.2.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8.tgz#ca3878db216823d72cf9e8fafef4ade32b4f16d7"
integrity sha512-JOD+Wg7KQlHWDhtAJrHp2wP87iH72O+sArZno7n9mHuTgqGrY0wOUQreast6xQLRMuXGJhr1LENuCv9lOs3hVA==
"@equinor/fusion-framework-react-app@^5.2.10":
version "5.2.10"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react-app/-/fusion-framework-react-app-5.2.10.tgz#af42f0c1638ee5c4b63d72d0e8c40a5e668243b9"
integrity sha512-6G1qZmcPehcd+G8Sv9/o9RzpxqDQX7ZFtuewHomBNf2x/4p+zlkgCQsIfCbsB6pHVPWFXoG7dltbokzsGNJuAQ==
dependencies:
"@equinor/fusion-framework-app" "^9.1.10-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8"
"@equinor/fusion-framework-app" "^9.1.10"
"@equinor/fusion-framework-module" "^4.3.5"
"@equinor/fusion-framework-module-app" "^6.0.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8"
"@equinor/fusion-framework-module-app" "^6.0.0"
"@equinor/fusion-framework-module-navigation" "^4.0.7"
"@equinor/fusion-framework-react" "^7.3.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8"
"@equinor/fusion-framework-react" "^7.3.0"
"@equinor/fusion-framework-react-module" "^3.1.6"
"@equinor/fusion-framework-react-module-http" "^8.0.0"

Expand All @@ -452,10 +453,10 @@
dependencies:
"@equinor/fusion-framework-module" "^4.3.5"

"@equinor/fusion-framework-react@^7.3.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8":
version "7.3.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react/-/fusion-framework-react-7.3.0-next-9f6eec8c5a4cb3dd430fc6bee227442a3dc28bb8.tgz#7da32bbf96900cff64e451bea4f60ad94de7df29"
integrity sha512-5L8y5UW0S8uqJYAL3nDjm7fIRy9Y4j3yqZdAggDa3W8Xy/KjjxK0QkqzUJzLHTeuJHpDTOFGTmxcxQnj4glZ9g==
"@equinor/fusion-framework-react@^7.3.0":
version "7.3.0"
resolved "https://registry.yarnpkg.com/@equinor/fusion-framework-react/-/fusion-framework-react-7.3.0.tgz#4d4f9d387ebe197051b7d1643014f71236c77074"
integrity sha512-PDwCMng3g2SL3vpd2kQtF/2p3PFCy5k/t21JprhVrha35S3ZdOrrrdrdbMGc/A+QwM8h6q2bPoGLsTBvxU8Y7w==
dependencies:
"@equinor/fusion-framework" "^7.2.8"
"@equinor/fusion-framework-module" "^4.3.5"
Expand Down
26 changes: 13 additions & 13 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"private": true,
"devDependencies": {
"@equinor/fusion-framework-cli": "^10.0.0-next-499bdf0f6597dbdcfdabd563b94ed08de36bbfe4",
"@equinor/fusion-framework-cli": "^10.0.0",
"@hirez_io/observer-spy": "^2.2.0",
"@testing-library/jest-dom": "^6.1.4",
"@testing-library/react": "^14.0.0",
Expand Down Expand Up @@ -66,22 +66,22 @@
"@equinor/eds-core-react": "^0.36.0",
"@equinor/eds-icons": "^0.17.0",
"@equinor/eds-tokens": "^0.9.0",
"@equinor/fusion-framework": "^7.2.7",
"@equinor/fusion-framework-app": "^9.1.9-alpha-6ff6662450828ba21fa1bcf1c35b24bea98bce62",
"@equinor/fusion-framework": "^7.2.8",
"@equinor/fusion-framework-app": "^9.1.10",
"@equinor/fusion-framework-module-ag-grid": "^32.2.0",
"@equinor/fusion-framework-module-app": "^6.0.0-alpha-6ff6662450828ba21fa1bcf1c35b24bea98bce62",
"@equinor/fusion-framework-module-app": "^6.0.0",
"@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-http": "^6.2.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-framework-module-service-discovery": "^8.0.1",
"@equinor/fusion-framework-module-services": "^4.1.5",
"@equinor/fusion-framework-module-signalr": "^4.0.1",
"@equinor/fusion-framework-react": "^7.3.0",
"@equinor/fusion-framework-react-app": "^5.2.10",
"@equinor/fusion-framework-react-components-bookmark": "0.5.2",
"@equinor/fusion-framework-react-components-people-provider": "^1.4.9",
"@equinor/fusion-framework-react-module-signalr": "^3.0.16",
"@equinor/fusion-observable": "^8.4.1",
"@equinor/fusion-react-context-selector": "^0.6.6",
"@equinor/fusion-react-person": "^0.9.2",
Expand Down
13 changes: 6 additions & 7 deletions client/packages/core/src/app/hooks/mocks.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import { vi } from 'vitest';

import { AppConfig, AppManifest, AppModuleProvider } from '@equinor/fusion-framework-module-app';
import { AppConfig, AppManifest, AppModuleProvider, ConfigEnvironment } from '@equinor/fusion-framework-module-app';
import { BehaviorSubject } from 'rxjs';

const config: AppConfig = {
const config = {
environment: {
env: 'test',
home: '/',
},
endpoints: {},
};
} as AppConfig<ConfigEnvironment & { env: string }>;

export const getAppConfigMock = vi.fn();
export const getAppManifestMock = vi.fn();
export const getAppManifestsMock = vi.fn();
Expand All @@ -19,9 +18,9 @@ export const appProvider = new AppModuleProvider({
client: {
[Symbol.dispose]: vi.fn(),

getAppConfig: () => {
getAppConfig: <TEnv>() => {
getAppConfigMock();
return new BehaviorSubject<AppConfig<any>>(config);
return new BehaviorSubject(config as AppConfig<ConfigEnvironment & TEnv>);
},
getAppManifest: ({ appKey }) => {
getAppManifestMock();
Expand Down
8 changes: 7 additions & 1 deletion client/packages/core/src/app/hooks/use-app-loader.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,13 @@ let legacyAppScript = {};

vi.mock('./use-legacy-app-loader', async () => {
return {
useLegacyAppLoader: () => useMemo(() => legacyAppScript, []),
useLegacyAppLoader: () =>
useMemo(
() => ({
legacyAppScript,
}),
[]
),
};
});

Expand Down
36 changes: 28 additions & 8 deletions client/packages/core/src/app/hooks/use-app-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import { useAppModule } from './use-app-module';
import { useLegacyAppLoader } from './use-legacy-app-loader';
import { createAppElement } from '../utils/app-element';
import { appRender } from '../render';
import { getLegacyClientConfig, getFusionLegacyEnvIdentifier } from '../utils';
import { getLegacyClientConfig, getFusionLegacyEnvIdentifier, getLegacyFusionConfig } from '../utils';

import { AppConfig } from '@equinor/fusion-framework-app';
import { ConfigEnvironment } from '@equinor/fusion-framework-module-app';
import { Client } from '@portal/types';

export const useAppLoader = (appKey: string) => {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<Error | undefined>();

const { fusion, currentApp } = useAppModule(appKey);

const legacyAppScript = useLegacyAppLoader();
const { legacyAppScript, legacyAppError } = useLegacyAppLoader();

const appRef = useRef<HTMLDivElement>(createAppElement());

Expand Down Expand Up @@ -53,9 +57,20 @@ export const useAppLoader = (appKey: string) => {
loadingText: 'Loading',
endpoints: {
client: getLegacyClientConfig(),
fusion: getLegacyFusionConfig(),
},
},
},
} as AppConfig<
ConfigEnvironment & {
appKey: string;
env: string;
loadingText: string;
endpoints: {
client: Client;
fusion: Client;
};
}
>,
},
},
})
Expand All @@ -73,19 +88,24 @@ export const useAppLoader = (appKey: string) => {
);

/** remove app element when application unmounts */
subscription.add(() => appRef.current.remove());
// subscription.add(() => appRef.current.remove());
}
} catch (error) {
console.error('App loading Error: ', error);

setError(error as Error);
}
},
complete: () => {
setLoading(false);
},
error: (err) => {
console.error('App init Error: ', error);
setError(err);
error: (error) => {
console.error('App init Error: ', error, legacyAppError);
if (legacyAppError) {
setError(legacyAppError);
} else {
setError(error);
}
setLoading(false);
},
})
Expand All @@ -94,7 +114,7 @@ export const useAppLoader = (appKey: string) => {
return () => {
subscription.unsubscribe();
};
}, [currentApp, appRef, fusion, legacyAppScript]);
}, [currentApp, appRef, fusion, legacyAppScript, legacyAppError]);

return {
loading,
Expand Down
Loading

0 comments on commit 6653c89

Please sign in to comment.