-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Remove legacyAppLoader files and configurations
- Loading branch information
Showing
43 changed files
with
144 additions
and
144 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
45 changes: 45 additions & 0 deletions
45
client/apps/legacyAppLoader/src/app-loader/components/LegacyAppLoader.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { lazy } from 'react'; | ||
import AppWrapperLegacy, { getLegacyFusion } from './LegacyAppWrapper'; | ||
|
||
import { AppConfig } from '@equinor/fusion-framework-module-app'; | ||
import { AppManifest as LegacyAppManifest } from '@equinor/fusion'; | ||
|
||
import LegacyAppContainer from '../legacy-interopt/LegacyAppContainer'; | ||
import { MessagePage } from './MessagePage'; | ||
export type LegacyEnv = { | ||
basename: string; | ||
config: AppConfig; | ||
manifest: LegacyAppManifest; | ||
}; | ||
|
||
export const createLegacyAppLoader = (appKey: string) => | ||
lazy(async () => { | ||
const appContainer = getLegacyFusion().app.container as LegacyAppContainer; | ||
const [basename] = window.location.pathname.match(/\/?apps\/[a-z|-]+\//) ?? ['']; | ||
|
||
if (Object.keys(appContainer.allApps).length === 0) { | ||
await appContainer.getAllAsync(); | ||
} | ||
|
||
const config = await appContainer.setCurrentAppAsync(appKey); | ||
|
||
if (!config) { | ||
return { | ||
default: () => <MessagePage type="Warning" title="No config" />, | ||
}; | ||
} | ||
|
||
const env = { | ||
basename, | ||
config, | ||
manifest: { ...appContainer.currentApp } as LegacyAppManifest, | ||
}; | ||
|
||
return { | ||
default: () => ( | ||
<> | ||
<AppWrapperLegacy appKey={appKey} env={env} /> | ||
</> | ||
), | ||
}; | ||
}); |
63 changes: 63 additions & 0 deletions
63
client/apps/legacyAppLoader/src/app-loader/components/LegacyAppWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { Suspense, useMemo } from 'react'; | ||
|
||
import { useFramework } from '@equinor/fusion-framework-react'; | ||
|
||
import { GLOBAL_FUSION_CONTEXT_KEY } from '../legacy-interopt/static'; | ||
import { createLegacyRender } from '../legacy-interopt'; | ||
|
||
import { MessagePage } from './MessagePage'; | ||
import { ProgressLoader } from './ProgressLoader'; | ||
|
||
import { LegacyEnv } from './LegacyAppLoader'; | ||
|
||
const DEBUG_LOG = false; | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
export const getLegacyFusion = () => window[GLOBAL_FUSION_CONTEXT_KEY]; | ||
/** | ||
* Legacy wrapper element | ||
* this should be removed in future when applications are moved over to ESM | ||
*/ | ||
|
||
export const AppWrapperLegacy = (props: { appKey: string; env: LegacyEnv }): JSX.Element => { | ||
const { appKey, env } = props; | ||
const fusion = useFramework(); | ||
const legacyFusion = getLegacyFusion(); | ||
const manifest = getLegacyFusion().app.container.get(appKey) || null; | ||
|
||
const AppComponent = useMemo(() => { | ||
if (!manifest) { | ||
console.warn('🌍❗️ Portal Legacy:', 'missing application manifest'); | ||
return null; | ||
} | ||
|
||
/** sanity check if the `registerApp` has been loaded */ | ||
if (!manifest.render && !manifest.AppComponent) { | ||
DEBUG_LOG && | ||
console.warn('🌍❗️ Portal Legacy:', 'no render or component, make sure app script is loading'); | ||
return null; | ||
} | ||
|
||
DEBUG_LOG && console.debug('🌍 Portal:', 'creating application component', manifest); | ||
|
||
const render = manifest.render ?? createLegacyRender(manifest, legacyFusion); | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment | ||
// @ts-ignore | ||
return render(fusion, env); | ||
}, [fusion, legacyFusion, manifest, env]); | ||
|
||
if (!AppComponent) { | ||
return ( | ||
<MessagePage title="Loader Error"> | ||
<p>Failed to render application, missing app component</p> | ||
</MessagePage> | ||
); | ||
} | ||
return ( | ||
<Suspense fallback={<ProgressLoader title="Loading" />}> | ||
<AppComponent /> | ||
</Suspense> | ||
); | ||
}; | ||
|
||
export default AppWrapperLegacy; |
23 changes: 23 additions & 0 deletions
23
client/apps/legacyAppLoader/src/app-loader/components/LegacyWrapper.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useFramework } from '@equinor/fusion-framework-react'; | ||
import { PropsWithChildren } from 'react'; | ||
|
||
import { AppModule } from '@equinor/fusion-framework-module-app'; | ||
import { NavigationModule } from '@equinor/fusion-framework-module-navigation'; | ||
import { LegacyFusionWrapper } from '../legacy-interopt/components'; | ||
import { useAppModules } from '@equinor/fusion-framework-react-app'; | ||
import { ProgressLoader } from './ProgressLoader'; | ||
|
||
export const LegacyWrapper = ({ children }: PropsWithChildren<unknown>) => { | ||
const framework = useFramework<[AppModule, NavigationModule]>(); | ||
const appFramework = useAppModules<[AppModule]>(); | ||
|
||
return ( | ||
<LegacyFusionWrapper | ||
framework={framework} | ||
loader={<ProgressLoader title="Loading" />} | ||
appFramework={appFramework} | ||
> | ||
{children} | ||
</LegacyFusionWrapper> | ||
); | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
47 changes: 0 additions & 47 deletions
47
legacyAppLoader/src/app-loader/components/LegacyAppLoader.tsx
This file was deleted.
Oops, something went wrong.
71 changes: 0 additions & 71 deletions
71
legacyAppLoader/src/app-loader/components/LegacyAppWrapper.tsx
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
legacyAppLoader/src/app-loader/components/LegacyWrapper.tsx
This file was deleted.
Oops, something went wrong.