Skip to content

Commit

Permalink
Merge branch 'main' into feature/api-fusion-apps-migrate
Browse files Browse the repository at this point in the history
  • Loading branch information
kjetilhau committed Oct 24, 2024
2 parents 183bdca + 5dea2bc commit c9b4319
Show file tree
Hide file tree
Showing 18 changed files with 271 additions and 393 deletions.
27 changes: 27 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,32 @@
# fusion-project-portal

## 5.0.4

### Patch Changes

- bee97b4: Update key property in registerCurrentApps function call

## 5.0.3

### Patch Changes

- 6e599cf: Improve loading logic in LegacyAppContainer, by loading app from new app api with proxy

## 5.0.2

### Patch Changes

- c9b0ad5: providing the right env key to appLoader

## 5.0.1

### Patch Changes

- 0d4055d: - Remove unused import and code in app.config.ts
- Update dev:appLoader script in package.json
- Remove unused components in legacyAppLoader
- a59d1b5: fixing icon error and waring of div inside table

## 5.0.0

### Major Changes
Expand Down
1 change: 1 addition & 0 deletions client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
/tmp
/out-tsc
dist
appLegacyLoader.js

# dependencies
node_modules
Expand Down
44 changes: 21 additions & 23 deletions client/apps/legacyAppLoader/app.config.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
import { mergeAppConfigs, defineAppConfig } from '@equinor/fusion-framework-cli';
export default defineAppConfig((_env, { base }) =>
mergeAppConfigs(
{},
{
environment: {
endpoints: {
client: {
baseUri: 'https://backend-fusion-project-portal-test.radix.equinor.com',
defaultScopes: ['api://02f3484c-cad0-4d1d-853d-3a9e604b38f3/access_as_user'],
},
portal: {
baseUri: 'https://fusion-s-portal-ci.azurewebsites.net',
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
},
},
fusionEnv: 'ci',
loadingText: 'Loading',
appKey: 'handover-garden',
basename: 'localhost:3000/apps/handover-garden/',
import { defineAppConfig } from '@equinor/fusion-framework-cli';
export default defineAppConfig((_env) => ({
environment: {
endpoints: {
client: {
baseUri: 'https://backend-fusion-project-portal-test.radix.equinor.com',
defaultScopes: ['api://02f3484c-cad0-4d1d-853d-3a9e604b38f3/access_as_user'],
},
}
)
);
portal: {
baseUri: 'https://fusion-s-portal-ci.azurewebsites.net',
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
},
apps: {
defaultScopes: ['5a842df8-3238-415d-b168-9f16a6a6031b/.default'],
},
},
fusionEnv: 'ci',
loadingText: 'Loading',
appKey: 'project-control-and-analysis',
basename: 'localhost:3000/apps/project-control-and-analysis/',
},
}));
2 changes: 1 addition & 1 deletion client/apps/legacyAppLoader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"prebuild": "rm -f ../../packages/portal-client/src/assets/appLegacyLoader.js",
"build:appLoader": "fusion-framework-cli app build && mv ./dist/app-bundle.js ../../packages/portal-client/src/assets/appLegacyLoader.js",
"build:resources": "tsc && vite build",
"dev:appLoader": "fusion-framework-cli app dev -c vite.config.js",
"dev:appLoader": "fusion-framework-cli app dev",
"docker": "cd .. && sh docker-script.sh app-react",
"update:fusion": "ncu -i -f /fusion/"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,13 +228,13 @@ export class LegacyAppContainer extends EventEmitter<AppContainerEvents> {
* assume if the manifest missing AppComponent or render, that loading is required
*/

if (!AppComponent && !render) {
await this.#loadScript(key);
const manifest = this.#manifests.value[appKey] as unknown as AppManifest;

if (!AppComponent && !render && manifest.build) {
await this.#loadScript(manifest);
}
await new Promise((resolve) => window.requestAnimationFrame(resolve));

const manifest = this.#manifests.value[appKey] as unknown as AppManifest;

const currentApp = appProvider.current;

if (currentApp && currentApp.appKey === appKey) {
Expand Down Expand Up @@ -285,8 +285,9 @@ export class LegacyAppContainer extends EventEmitter<AppContainerEvents> {
return this.updateComplete;
}

async #loadScript(appKey: string): Promise<void> {
async #loadScript(manifest: AppManifest): Promise<void> {
return new Promise((resolve, reject) => {
const { appKey, build } = manifest;
const script = document.createElement('script');
script.async = true;
script.id = appKey;
Expand All @@ -296,16 +297,15 @@ export class LegacyAppContainer extends EventEmitter<AppContainerEvents> {
script.addEventListener('load', () => resolve());
script.addEventListener('abort', () => reject());
script.addEventListener('error', () => reject());
// Todo: Fix uri to mach the new structure
script.src = `${window['clientBaseUri']}/api/bundles/${appKey}.js`;
script.src = `/apps-proxy/bundles/apps/${appKey}/${build?.version}/${build?.entryPoint}`;
});
}

#update(): void {
console.log('Updating');
this.#updateTask = new Promise((resolve, reject) => {
this.#updateTask.state = 'pending';
this.#appModules.app.getAllAppManifests().subscribe({
this.#appModules.app.getAppManifests({ filterByCurrentUser: true }).subscribe({
complete: () => {
this.#updateTask.state = 'fulfilled';
this.#lastUpdated = Date.now();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export const LegacyFusionWrapper = (props: PropsWithChildren<LegacyFusionWrapper
[framework, options]
);

console.log('LegacyFusionWrapper!!!!');
return (
<Suspense fallback={loader}>
<LegacyContext>
Expand Down
Loading

0 comments on commit c9b4319

Please sign in to comment.