mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1550] Metadata Card configuration from an extension plugin (#668)
* [ACA-1550] use local component for metadata * [ACA-1550] get component local for metadata properties * [ACA-1550] test metadata-plugin * [ACA-1550] overwrite content-metadata settings from app.config.json * [ACA-1550] fix and remove test content * [ACA-1550] have the app default metadata config in the app.extensions.json * [ACA-1550] there can be only one presets for content-metadata * [ACA-1550] filter disabled * [ACA-1550] rebase fixes * [ACA-1550] prettier fix * [ACA-1550] unit test * [ACA-1550] manage app config directly from the App Extension Service
This commit is contained in:
committed by
Denys Vuika
parent
457fa74048
commit
6e9109930b
@@ -540,6 +540,35 @@ describe('AppExtensionService', () => {
|
|||||||
expect(items.length).toBe(1);
|
expect(items.length).toBe(1);
|
||||||
expect(items[0].id).toBe(2);
|
expect(items[0].id).toBe(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should filter out all disabled items', () => {
|
||||||
|
const items = [
|
||||||
|
{ id: '1', disabled: true },
|
||||||
|
{
|
||||||
|
id: '2',
|
||||||
|
someItems: [
|
||||||
|
{ id: '21', disabled: true },
|
||||||
|
{ id: '22', disabled: false },
|
||||||
|
{ id: '23' }
|
||||||
|
],
|
||||||
|
someObjectProp: {
|
||||||
|
innerItems: [{ id: '24' }, { id: '25', disabled: true }]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ id: 3, disabled: true }
|
||||||
|
];
|
||||||
|
|
||||||
|
const result = service.filterDisabled(items);
|
||||||
|
|
||||||
|
expect(result.length).toBe(1);
|
||||||
|
expect(result[0].id).toBe('2');
|
||||||
|
expect(result[0].someItems.length).toBe(2);
|
||||||
|
expect(result[0].someItems[0].id).toBe('22');
|
||||||
|
expect(result[0].someItems[1].id).toBe('23');
|
||||||
|
expect(result[0].someObjectProp).not.toBeNull();
|
||||||
|
expect(result[0].someObjectProp.innerItems.length).toBe(1);
|
||||||
|
expect(result[0].someObjectProp.innerItems[0].id).toBe('24');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should reduce duplicate separators', () => {
|
it('should reduce duplicate separators', () => {
|
||||||
|
@@ -46,8 +46,10 @@ import {
|
|||||||
reduceSeparators,
|
reduceSeparators,
|
||||||
reduceEmptyMenus,
|
reduceEmptyMenus,
|
||||||
ExtensionService,
|
ExtensionService,
|
||||||
ProfileState
|
ProfileState,
|
||||||
|
mergeObjects
|
||||||
} from '@alfresco/adf-extensions';
|
} from '@alfresco/adf-extensions';
|
||||||
|
import { AppConfigService } from '@alfresco/adf-core';
|
||||||
|
|
||||||
@Injectable({
|
@Injectable({
|
||||||
providedIn: 'root'
|
providedIn: 'root'
|
||||||
@@ -68,6 +70,7 @@ export class AppExtensionService implements RuleContext {
|
|||||||
createActions: Array<ContentActionRef> = [];
|
createActions: Array<ContentActionRef> = [];
|
||||||
navbar: Array<NavBarGroupRef> = [];
|
navbar: Array<NavBarGroupRef> = [];
|
||||||
sidebar: Array<SidebarTabRef> = [];
|
sidebar: Array<SidebarTabRef> = [];
|
||||||
|
contentMetadata: any;
|
||||||
|
|
||||||
selection: SelectionState;
|
selection: SelectionState;
|
||||||
navigation: NavigationState;
|
navigation: NavigationState;
|
||||||
@@ -77,7 +80,8 @@ export class AppExtensionService implements RuleContext {
|
|||||||
private store: Store<AppStore>,
|
private store: Store<AppStore>,
|
||||||
private loader: ExtensionLoaderService,
|
private loader: ExtensionLoaderService,
|
||||||
private extensions: ExtensionService,
|
private extensions: ExtensionService,
|
||||||
public permissions: NodePermissionService
|
public permissions: NodePermissionService,
|
||||||
|
private appConfig: AppConfigService
|
||||||
) {
|
) {
|
||||||
this.store.select(ruleContext).subscribe(result => {
|
this.store.select(ruleContext).subscribe(result => {
|
||||||
this.selection = result.selection;
|
this.selection = result.selection;
|
||||||
@@ -133,6 +137,7 @@ export class AppExtensionService implements RuleContext {
|
|||||||
config,
|
config,
|
||||||
'features.sidebar'
|
'features.sidebar'
|
||||||
);
|
);
|
||||||
|
this.contentMetadata = this.loadContentMetadata(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected loadNavBar(config: ExtensionConfig): Array<NavBarGroupRef> {
|
protected loadNavBar(config: ExtensionConfig): Array<NavBarGroupRef> {
|
||||||
@@ -159,6 +164,40 @@ export class AppExtensionService implements RuleContext {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
loadContentMetadata(config: ExtensionConfig): any {
|
||||||
|
const elements = this.loader.getElements<any>(
|
||||||
|
config,
|
||||||
|
'features.content-metadata-presets'
|
||||||
|
);
|
||||||
|
let presets = {};
|
||||||
|
presets = this.filterDisabled(mergeObjects(presets, ...elements));
|
||||||
|
|
||||||
|
try {
|
||||||
|
this.appConfig.config['content-metadata'] = { presets };
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return presets;
|
||||||
|
}
|
||||||
|
|
||||||
|
filterDisabled(object) {
|
||||||
|
if (Array.isArray(object)) {
|
||||||
|
return object
|
||||||
|
.filter(item => !item.disabled)
|
||||||
|
.map(item => this.filterDisabled(item));
|
||||||
|
} else if (typeof object === 'object') {
|
||||||
|
if (!object.disabled) {
|
||||||
|
Object.keys(object).forEach(prop => {
|
||||||
|
object[prop] = this.filterDisabled(object[prop]);
|
||||||
|
});
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
getNavigationGroups(): Array<NavBarGroupRef> {
|
getNavigationGroups(): Array<NavBarGroupRef> {
|
||||||
return this.navbar;
|
return this.navbar;
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,8 @@
|
|||||||
"plugin1.json",
|
"plugin1.json",
|
||||||
"dev.tools.json",
|
"dev.tools.json",
|
||||||
"app.header.json",
|
"app.header.json",
|
||||||
"app.create.json"
|
"app.create.json",
|
||||||
|
"metadata-plugin.json"
|
||||||
],
|
],
|
||||||
|
|
||||||
"rules": [
|
"rules": [
|
||||||
@@ -827,6 +828,37 @@
|
|||||||
"title": "APP.INFO_DRAWER.TABS.VERSIONS",
|
"title": "APP.INFO_DRAWER.TABS.VERSIONS",
|
||||||
"component": "app.components.tabs.versions"
|
"component": "app.components.tabs.versions"
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"content-metadata-presets": [
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.custom",
|
||||||
|
"custom": [
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.customGroup",
|
||||||
|
"title": "APP.CONTENT_METADATA.EXIF_GROUP_TITLE",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.exifAspect",
|
||||||
|
"aspect": "exif:exif",
|
||||||
|
"properties": [
|
||||||
|
"exif:pixelXDimension",
|
||||||
|
"exif:pixelYDimension",
|
||||||
|
"exif:dateTimeOriginal",
|
||||||
|
"exif:exposureTime",
|
||||||
|
"exif:fNumber",
|
||||||
|
"exif:flash",
|
||||||
|
"exif:focalLength",
|
||||||
|
"exif:isoSpeedRatings",
|
||||||
|
"exif:orientation",
|
||||||
|
"exif:manufacturer",
|
||||||
|
"exif:model",
|
||||||
|
"exif:software"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -294,6 +294,127 @@
|
|||||||
"type": "boolean"
|
"type": "boolean"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"content-metadata-aspect": {
|
||||||
|
"description": "Content metadata's aspect definition",
|
||||||
|
"type": "object",
|
||||||
|
"patternProperties": {
|
||||||
|
".*": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"description": "Wildcard for every property",
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^\\*$"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"description": "Properties array",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"description": "Property name",
|
||||||
|
"type": "string"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"content-metadata-layout-group": {
|
||||||
|
"description": "Content metadata's layout groups definition",
|
||||||
|
"type": "array",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"description": "Content metadata's one layout group definition",
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"title",
|
||||||
|
"items"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"title": {
|
||||||
|
"type": "string",
|
||||||
|
"description": "Content metadata's one layout group definition's title"
|
||||||
|
},
|
||||||
|
"items": {
|
||||||
|
"type": "array",
|
||||||
|
"description": "Content metadata's one layout group definition's items",
|
||||||
|
"items": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"aspect",
|
||||||
|
"properties"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"aspect": {
|
||||||
|
"description": "Aspect group",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"description": "Wildcard character",
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^\\*$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"aspect",
|
||||||
|
"properties"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"aspect": {
|
||||||
|
"description": "Aspect group",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"description": "list of aspect properties",
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"type",
|
||||||
|
"properties"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"description": "Type group",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"description": "Wildcard character",
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^\\*$"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "object",
|
||||||
|
"required": [
|
||||||
|
"type",
|
||||||
|
"properties"
|
||||||
|
],
|
||||||
|
"properties": {
|
||||||
|
"type": {
|
||||||
|
"description": "Type group",
|
||||||
|
"type": "string"
|
||||||
|
},
|
||||||
|
"properties": {
|
||||||
|
"description": "list of type properties",
|
||||||
|
"type": "array"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -407,6 +528,27 @@
|
|||||||
"type": "array",
|
"type": "array",
|
||||||
"items": { "$ref": "#/definitions/contentActionRef" },
|
"items": { "$ref": "#/definitions/contentActionRef" },
|
||||||
"minItems": 1
|
"minItems": 1
|
||||||
|
},
|
||||||
|
"content-metadata-presets": {
|
||||||
|
"description": "Configuration for the presets for content metadata component",
|
||||||
|
"type": "array",
|
||||||
|
"items": {
|
||||||
|
"type": "object",
|
||||||
|
"required": ["id"],
|
||||||
|
"patternProperties": {
|
||||||
|
".*": {
|
||||||
|
"oneOf": [
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"pattern": "^\\*$",
|
||||||
|
"description": "Wildcard for every aspect"
|
||||||
|
},
|
||||||
|
{ "$ref": "#/definitions/content-metadata-aspect" },
|
||||||
|
{ "$ref": "#/definitions/content-metadata-layout-group" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
56
src/assets/plugins/metadata-plugin.json
Normal file
56
src/assets/plugins/metadata-plugin.json
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
{
|
||||||
|
"$schema": "../../../extension.schema.json",
|
||||||
|
"$version": "1.0.0",
|
||||||
|
"$name": "metadata-plugin",
|
||||||
|
"$description": "metadata card configuration plugin - testing purpose",
|
||||||
|
"features": {
|
||||||
|
"content-metadata-presets": [
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.custom",
|
||||||
|
"custom": [
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.customGroup",
|
||||||
|
"title": "testing extension props",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.exifAspect",
|
||||||
|
"disabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.exifAspect2",
|
||||||
|
"aspect": "exif:exif",
|
||||||
|
"properties": [
|
||||||
|
"exif:orientation",
|
||||||
|
"exif:manufacturer",
|
||||||
|
"exif:model",
|
||||||
|
"exif:software"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.customGroup2",
|
||||||
|
"title": "testing extension props2",
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"id": "app.content.metadata.exifAspect",
|
||||||
|
"aspect": "exif:exif",
|
||||||
|
"properties": [
|
||||||
|
"exif:pixelXDimension",
|
||||||
|
"exif:pixelYDimension",
|
||||||
|
"exif:dateTimeOriginal"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"kitten-images": {
|
||||||
|
"custom:aspect": "*",
|
||||||
|
"exif:exif": [ "exif:pixelXDimension", "exif:pixelYDimension"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user