[ACS-5611] Add custom metadata side panels as new extension feature (#3466)

* [ACS-5611] Add custom metadata panels as new extensions feature

* [ACS-5611] Add custom metadata panels unit tests

* [ACS-5611] Minor fixes

* [ACS-5611] Text ellipsis for name column to always display badges

* [ACS-5611] Use latest ADF and JS-API

* [ACS-5611] Unit test fix

* [ACS-5611] Click action only if exists
This commit is contained in:
MichalKinas
2023-10-16 10:43:04 +02:00
committed by GitHub
parent bc98af0968
commit 928c6b5731
12 changed files with 166 additions and 59 deletions

View File

@@ -5,10 +5,10 @@
"license": "LGPL-3.0",
"scripts": {},
"peerDependencies": {
"@alfresco/adf-content-services": ">=6.4.0-6341205853",
"@alfresco/adf-core": ">=6.4.0-6341205853",
"@alfresco/adf-extensions": ">=6.4.0-6341205853",
"@alfresco/js-api": ">=7.1.0-1349",
"@alfresco/adf-content-services": ">=6.4.0-6497510485",
"@alfresco/adf-core": ">=6.4.0-6497510485",
"@alfresco/adf-extensions": ">=6.4.0-6497510485",
"@alfresco/js-api": ">=7.1.0-1384",
"@angular/animations": ">=14.1.3",
"@angular/common": ">=14.1.3",
"@angular/compiler": ">=14.1.3",

View File

@@ -1736,4 +1736,60 @@ describe('AppExtensionService', () => {
done();
});
});
it('should get custom metadata panels from config', (done) => {
extensions.setEvaluators({
'action.enabled': () => true
});
applyConfig({
$id: 'test',
$name: 'test',
$version: '1.0.0',
$license: 'MIT',
$vendor: 'Good company',
$runtime: '1.5.0',
features: {
customMetadataPanels: [
{
id: 'panel1-id',
title: 'testTitle',
component: 'testComponent1',
rules: {
visible: 'action.enabled'
}
},
{
id: 'panel2-id',
title: 'testTitle2',
component: 'testComponent2',
rules: {
visible: 'action.enabled'
}
}
]
}
});
const node: NodeEntry = {
entry: {
id: 'testId',
name: 'testName',
nodeType: 'test',
isFile: true,
isFolder: false,
modifiedAt: undefined,
createdAt: undefined,
modifiedByUser: undefined,
createdByUser: undefined
}
};
service.getCustomMetadataPanels(node).subscribe((panels) => {
expect(panels.length).toBe(2);
expect(panels[0].id).toEqual('panel1-id');
expect(panels[1].id).toEqual('panel2-id');
done();
});
});
});

View File

@@ -81,6 +81,7 @@ export class AppExtensionService implements RuleContext {
private _sidebarActions = new BehaviorSubject<Array<ContentActionRef>>([]);
private _badges = new BehaviorSubject<Array<Badge>>([]);
private _filesDocumentListPreset = new BehaviorSubject<Array<DocumentListPresetRef>>([]);
private _customMetadataPanels = new BehaviorSubject<Array<ContentActionRef>>([]);
documentListPresets: {
libraries: Array<DocumentListPresetRef>;
@@ -160,6 +161,7 @@ export class AppExtensionService implements RuleContext {
this._mainActions.next(this.loader.getFeatures(config).mainAction);
this._badges.next(this.loader.getElements<Badge>(config, 'features.badges'));
this._filesDocumentListPreset.next(this.getDocumentListPreset(config, 'files'));
this._customMetadataPanels.next(this.loader.getElements<ContentActionRef>(config, 'features.customMetadataPanels'));
this.navbar = this.loadNavBar(config);
this.sidebarTabs = this.loader.getElements<SidebarTabRef>(config, 'features.sidebar.tabs');
@@ -375,6 +377,10 @@ export class AppExtensionService implements RuleContext {
return this._badges.pipe(map((badges) => badges.filter((badge) => this.evaluateRule(badge.rules.visible, node))));
}
getCustomMetadataPanels(node: NodeEntry): Observable<Array<ContentActionRef>> {
return this._customMetadataPanels.pipe(map((panels) => panels.filter((panel) => this.evaluateRule(panel.rules.visible, node))));
}
private buildMenu(actionRef: ContentActionRef): ContentActionRef {
if (actionRef.type === ContentActionType.menu && actionRef.children && actionRef.children.length > 0) {
const children = actionRef.children.filter((action) => this.filterVisible(action)).map((action) => this.buildMenu(action));