Allow to use extension value in addition to passing JSON file name (#9192)

* [AAE-18136] Allow to use extension value

* Apply suggestions from code review

Co-authored-by: Robert Duda <robert.duda@hyland.com>

---------

Co-authored-by: Robert Duda <robert.duda@hyland.com>
This commit is contained in:
Bartosz Sekula
2023-12-23 12:39:48 +01:00
committed by GitHub
parent e9c769bc30
commit a1b4c54b16
4 changed files with 109 additions and 8 deletions

View File

@@ -42,6 +42,11 @@ export const EXTENSION_JSONS = new InjectionToken<string[][]>('extension-jsons',
factory: extensionJsonsFactory
});
export const EXTENSION_JSON_VALUES = new InjectionToken<string[][]>('extension-jsons-values', {
providedIn: 'root',
factory: extensionJsonsFactory
});
// eslint-disable-next-line prefer-arrow/prefer-arrow-functions
/**
* Provides the extension json values for the angular modules
@@ -57,6 +62,20 @@ export function provideExtensionConfig(jsons: string[]) {
};
};
/**
* Provides the extension json raw values for the angular modules
*
* @param extensionConfigValue config value
* @returns a provider section
*/
export function provideExtensionConfigValues(extensionConfigValue: ExtensionConfig[]) {
return {
provide: EXTENSION_JSON_VALUES,
useValue: extensionConfigValue,
multi: true
};
};
@Injectable({
providedIn: 'root'
})
@@ -78,7 +97,8 @@ export class ExtensionService {
protected loader: ExtensionLoaderService,
protected componentRegister: ComponentRegisterService,
protected ruleService: RuleService,
@Inject(EXTENSION_JSONS) protected extensionJsons: string[]
@Inject(EXTENSION_JSONS) protected extensionJsons: string[],
@Inject(EXTENSION_JSON_VALUES) protected extensionJsonValues: ExtensionConfig[]
) {
this.setup$ = this.onSetup$.asObservable();
}
@@ -92,8 +112,10 @@ export class ExtensionService {
const config = await this.loader.load(
this.configPath,
this.pluginsPath,
this.extensionJsons.flat()
this.extensionJsons.flat(),
this.extensionJsonValues.flat()
);
this.setup(config);
return config;
}