Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ACA-3877] Add the possibility to ADF Extension to be used in compila… #6097

Merged
merged 5 commits into from
Sep 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,8 @@
"processwithstarteventform",
"processstring",
"typeahed",
"minmax"
"minmax",
"jsons"
],
"dictionaries": [
"html",
Expand Down
2 changes: 1 addition & 1 deletion lib/extensions/src/lib/config/action.extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ export interface ContentActionRef extends ExtensionElement {
export interface ActionRef {
id: string;
type: string;
payload?: string;
payload?: any;
}
2 changes: 1 addition & 1 deletion lib/extensions/src/lib/config/extension.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface ExtensionRef {
$version: string;
$vendor: string;
$license: string;
$runtime: string;
$runtime?: string;
$description?: string;

$dependencies?: Array<string>;
Expand Down
3 changes: 2 additions & 1 deletion lib/extensions/src/lib/services/extension.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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);
});

Expand Down
23 changes: 19 additions & 4 deletions lib/extensions/src/lib/services/extension.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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'
})
Expand All @@ -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[]
) {
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@alfresco/adf-core": ["./core/"],
"@alfresco/adf-insights": ["./analytics"]
},
"lib": ["es2018", "dom"],
"lib": ["es2018", "esnext.array", "dom"],
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
],
"lib": [
"es2018",
"esnext.array",
"dom"
],
"paths": {
Expand Down