Skip to content

Commit

Permalink
fix(legacy): mapping legacy apploader to new api
Browse files Browse the repository at this point in the history
  • Loading branch information
eikeland committed Jun 13, 2024
1 parent 02cb70b commit c72429e
Show file tree
Hide file tree
Showing 12 changed files with 23 additions and 18 deletions.
8 changes: 5 additions & 3 deletions packages/app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import type { AnyModule } from '@equinor/fusion-framework-module';

import type {
AppConfig,
AppManifest,
AppModulesInstance,
ComponentRenderArgs,
} from '@equinor/fusion-framework-module-app';

import { ApplicationManifest } from '@equinor/fusion-framework-module-app';

export { ApplicationManifest } from '@equinor/fusion-framework-module-app';

import type { IAppConfigurator } from './AppConfigurator';

export type {
AppModules,
AppManifest,
AppConfig,
AppModulesInstance,
} from '@equinor/fusion-framework-module-app';
Expand All @@ -28,7 +30,7 @@ export type {
export type AppEnv<TConfig = unknown, TProps = unknown> = {
/** base routing path of the application */
basename?: string;
manifest: AppManifest;
manifest: ApplicationManifest;
config?: AppConfig<TConfig>;
props?: TProps;
};
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/app/src/AppConfigurator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type { QueryCtorOptions } from '@equinor/fusion-query';
import { moduleKey } from './module';

import type { AppConfig, ApiApp, ApiAppVersionConfig } from './types';
import { ApplicationManifest } from './helpers';
import { ApplicationManifest } from './ApplicationManifest';
import { map } from 'rxjs/operators';

export interface AppModuleConfig {
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/app/src/AppModuleProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { EventModule } from '@equinor/fusion-framework-module-event';
import { Query } from '@equinor/fusion-query';

import type { AppConfig, CurrentApp } from './types';
import { ApplicationManifest } from './helpers';
import { ApplicationManifest } from './ApplicationManifest';

import { App, filterEmpty, IApp } from './app/App';
import { AppModuleConfig } from './AppConfigurator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { AppManifest, ApiApp, AppOwnerOrAdmin, AppBuild, AzureId } from './
export class ApplicationManifest implements AppManifest {
constructor(protected model: ApiApp) {}

#convertAzureId(user: AppOwnerOrAdmin) {
protected convertAzureId(user: AppOwnerOrAdmin) {
const { azureUniqueId: azureId, ...rest } = user;
return {
azureId,
Expand All @@ -12,11 +12,11 @@ export class ApplicationManifest implements AppManifest {
}

get admins() {
return this.model.admins?.map(this.#convertAzureId);
return this.model.admins?.map(this.convertAzureId);
}

get owners() {
return this.model.owners?.map(this.#convertAzureId);
return this.model.owners?.map(this.convertAzureId);
}

get key() {
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/app/src/app/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { actions, Actions } from './actions';
import { AppBundleState, AppBundleStateInitial } from './types';

import './events';
import { ApplicationManifest } from '../helpers';
import { ApplicationManifest } from '../ApplicationManifest';

// TODO - move globally
export function filterEmpty<T>(): OperatorFunction<T | null | undefined, T> {
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/app/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
createAsyncAction,
} from '@equinor/fusion-observable';
import type { AppConfig, AppModulesInstance, AppScriptModule } from '../types';
import { ApplicationManifest } from '../helpers';
import { ApplicationManifest } from '../ApplicationManifest';

const createActions = () => ({
/** Manifest loading */
Expand Down
2 changes: 1 addition & 1 deletion packages/modules/app/src/app/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { AppConfig, AppModulesInstance, AppScriptModule } from '../types';
import { ApplicationManifest } from '../helpers';
import { ApplicationManifest } from '../ApplicationManifest';

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export type AppBundleState<TConfig = any, TModules = any> = {
Expand Down
2 changes: 2 additions & 0 deletions packages/modules/app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export { AppModuleProvider } from './AppModuleProvider';

export { IApp } from './app/App';

export { ApplicationManifest } from './ApplicationManifest';

export * from './events';
export * from './types';

Expand Down
2 changes: 1 addition & 1 deletion packages/modules/app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { HttpModule } from '@equinor/fusion-framework-module-http';
import type { MsalModule } from '@equinor/fusion-framework-module-msal';
import type { ServiceDiscoveryModule } from '@equinor/fusion-framework-module-service-discovery';
import IApp from './app';
import { ApplicationManifest } from './helpers';
import { ApplicationManifest } from './ApplicationManifest';

// TODO
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion packages/react/app/src/feature-flag/enable-feature-flag.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export function enableFeatureFlag(
enableFeatureFlagging(configurator, async (builder) => {
builder.addPlugin(
createLocalStoragePlugin(localFlags, {
name: (configurator as AppConfigurator).env?.manifest.key,
name: (configurator as AppConfigurator).env?.manifest.key ?? undefined,
}),
);
builder.addPlugin(createUrlPlugin(urlFlags));
Expand Down
3 changes: 2 additions & 1 deletion packages/react/app/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ export type {
AppModuleInitiator,
AppModules,
AppModulesInstance,
AppManifest,
AppRenderFn,
IAppConfigurator,
} from '@equinor/fusion-framework-app';

export { ApplicationManifest } from '@equinor/fusion-framework-module-app';

export { useAppModule } from './useAppModule';
export { useAppModules } from './useAppModules';
export { useAppEnvironmentVariables } from './useAppEnvironmentVariables';
Expand Down
8 changes: 4 additions & 4 deletions packages/react/legacy-interopt/src/LegacyAppContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TelemetryLogger,
} from '@equinor/fusion';

import { AppManifest } from '@equinor/fusion-framework-app';
import { ApplicationManifest } from '@equinor/fusion-framework-module-app';
import { ActionTypes, createAction, createReducer, FlowSubject } from '@equinor/fusion-observable';

import { original } from 'immer';
Expand Down Expand Up @@ -284,11 +284,11 @@ export class LegacyAppContainer extends EventEmitter<AppContainerEvents> {

async setCurrentAppAsync(appKey: string | null): Promise<void> {
if (appKey) {
const manifest = this.get(appKey) as unknown as AppManifest;
const manifest = this.get(appKey);
const appProvider = this.#framework.modules.app;
const currentApp = appProvider.current;
if (currentApp && currentApp.appKey === appKey) {
currentApp.updateManifest(manifest);
currentApp.updateManifest(manifest as unknown as ApplicationManifest);
await currentApp.getConfigAsync();
} else {
if (currentApp?.appKey !== appKey) {
Expand All @@ -303,7 +303,7 @@ export class LegacyAppContainer extends EventEmitter<AppContainerEvents> {
'these lines should newer been reached',
);
}
const newApp = appProvider.createApp({ appKey, manifest });
const newApp = appProvider.createApp({ appKey });
await newApp.getConfigAsync();
appProvider.setCurrentApp(newApp);
}
Expand Down

0 comments on commit c72429e

Please sign in to comment.