mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user