mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[ACA-3877] Add the possibility to ADF Extension to be used in compila… (#6097)
* [ACA-3877] Add the possibility to ADF Extension to be used in compilation time * Fix interface * Fix cspell * Fix unit tests * Add tests
This commit is contained in:
@@ -130,7 +130,8 @@
|
||||
"processwithstarteventform",
|
||||
"processstring",
|
||||
"typeahed",
|
||||
"minmax"
|
||||
"minmax",
|
||||
"jsons"
|
||||
],
|
||||
"dictionaries": [
|
||||
"html",
|
||||
|
@@ -48,5 +48,5 @@ export interface ContentActionRef extends ExtensionElement {
|
||||
export interface ActionRef {
|
||||
id: string;
|
||||
type: string;
|
||||
payload?: string;
|
||||
payload?: any;
|
||||
}
|
||||
|
@@ -25,7 +25,7 @@ export interface ExtensionRef {
|
||||
$version: string;
|
||||
$vendor: string;
|
||||
$license: string;
|
||||
$runtime: string;
|
||||
$runtime?: string;
|
||||
$description?: string;
|
||||
|
||||
$dependencies?: Array<string>;
|
||||
|
@@ -43,7 +43,7 @@ describe('ExtensionService', () => {
|
||||
loader = new ExtensionLoaderService(null);
|
||||
componentRegister = new ComponentRegisterService();
|
||||
ruleService = new RuleService(loader);
|
||||
service = new ExtensionService(loader, componentRegister, ruleService);
|
||||
service = new ExtensionService(loader, componentRegister, ruleService, []);
|
||||
});
|
||||
|
||||
it('should load and setup a config', async () => {
|
||||
@@ -56,6 +56,7 @@ describe('ExtensionService', () => {
|
||||
await service.load();
|
||||
|
||||
expect(loader.load).toHaveBeenCalled();
|
||||
expect(loader.load).toHaveBeenCalledWith('assets/app.extensions.json', 'assets/plugins', []);
|
||||
expect(service.setup).toHaveBeenCalledWith(blankConfig);
|
||||
});
|
||||
|
||||
|
@@ -15,9 +15,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { Injectable, Type } from '@angular/core';
|
||||
import { Injectable, Type, InjectionToken, Inject } from '@angular/core';
|
||||
import { RuleEvaluator, RuleRef, RuleContext } from '../config/rule.extensions';
|
||||
import { ExtensionConfig } from '../config/extension.config';
|
||||
import { ExtensionConfig, ExtensionRef } from '../config/extension.config';
|
||||
import { ExtensionLoaderService } from './extension-loader.service';
|
||||
import { RouteRef } from '../config/routing.extensions';
|
||||
import { ActionRef } from '../config/action.extensions';
|
||||
@@ -26,6 +26,19 @@ import { ComponentRegisterService } from './component-register.service';
|
||||
import { RuleService } from './rule.service';
|
||||
import { ExtensionElement } from '../config/extension-element';
|
||||
|
||||
const EXTENSION_JSONS = new InjectionToken<ExtensionRef[][]>('extension-jsons', {
|
||||
providedIn: 'root',
|
||||
factory: () => []
|
||||
});
|
||||
|
||||
export function provideExtensionConfig(jsons: ExtensionRef[]) {
|
||||
return {
|
||||
provide: EXTENSION_JSONS,
|
||||
useValue: jsons,
|
||||
multi: true
|
||||
};
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
@@ -44,7 +57,8 @@ export class ExtensionService {
|
||||
constructor(
|
||||
protected loader: ExtensionLoaderService,
|
||||
protected componentRegister: ComponentRegisterService,
|
||||
protected ruleService: RuleService
|
||||
protected ruleService: RuleService,
|
||||
@Inject(EXTENSION_JSONS) protected extensionJsons: ExtensionRef[]
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -55,7 +69,8 @@ export class ExtensionService {
|
||||
async load(): Promise<ExtensionConfig> {
|
||||
const config = await this.loader.load(
|
||||
this.configPath,
|
||||
this.pluginsPath
|
||||
this.pluginsPath,
|
||||
this.extensionJsons.flat()
|
||||
);
|
||||
this.setup(config);
|
||||
return config;
|
||||
|
@@ -29,7 +29,7 @@
|
||||
"@alfresco/adf-core": ["./core/"],
|
||||
"@alfresco/adf-insights": ["./analytics"]
|
||||
},
|
||||
"lib": ["es2018", "dom"],
|
||||
"lib": ["es2018", "esnext.array", "dom"],
|
||||
"suppressImplicitAnyIndexErrors": true
|
||||
},
|
||||
"exclude": [
|
||||
|
@@ -23,6 +23,7 @@
|
||||
],
|
||||
"lib": [
|
||||
"es2018",
|
||||
"esnext.array",
|
||||
"dom"
|
||||
],
|
||||
"paths": {
|
||||
|
Reference in New Issue
Block a user