mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
[ACA-1619] automatically show content metadata (#1104)
* [ACA-1619] overwrite the app.config metadata settings only of the 'content-metadata-presets' is non-empty * [ACA-1619] app config to show automatically all metadata aspects - not extendable version * [ACA-1619] app extension to show automatically all metadata aspects - extendable version - the app.config setting is overwritten by the one with ids from app.extensions - could remove completely the content metadata setting from app.json * [ACA-1619] allow 'disabled' property on content metadata configuration * [ACA-1619] test content-metadata plugin extension - allow 'disabled' property on content metadata configuration * [ACA-1619] remove test reference to metadata plugin * [ACA-1619] backwards compatibility for metadata plugin extensions - add back initial structure (& ids) of content-metadata "custom" preset - revert change to sample metadata extension plugin * [ACA-1619] forgotten change * [ACA-1619] tests
This commit is contained in:
committed by
Denys Vuika
parent
b4e6b43787
commit
5ffdf75f52
@@ -27,7 +27,7 @@ import { MetadataTabComponent } from './metadata-tab.component';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { AppTestingModule } from '../../../testing/app-testing.module';
|
||||
import { setupTestBed } from '@alfresco/adf-core';
|
||||
import { AppConfigService, setupTestBed } from '@alfresco/adf-core';
|
||||
import { ContentMetadataModule } from '@alfresco/adf-content-services';
|
||||
import { Store } from '@ngrx/store';
|
||||
import {
|
||||
@@ -35,28 +35,60 @@ import {
|
||||
AppState
|
||||
} from '@alfresco/aca-shared/store';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { AppExtensionService } from '../../../extensions/extension.service';
|
||||
|
||||
describe('MetadataTabComponent', () => {
|
||||
let fixture: ComponentFixture<MetadataTabComponent>;
|
||||
let component: MetadataTabComponent;
|
||||
let store: Store<AppState>;
|
||||
let appConfig: AppConfigService;
|
||||
let extensions: AppExtensionService;
|
||||
|
||||
setupTestBed({
|
||||
imports: [AppTestingModule, ContentMetadataModule],
|
||||
declarations: [MetadataTabComponent]
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
store = TestBed.get(Store);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
});
|
||||
|
||||
describe('content-metadata configuration', () => {
|
||||
beforeEach(() => {
|
||||
appConfig = TestBed.get(AppConfigService);
|
||||
extensions = TestBed.get(AppExtensionService);
|
||||
});
|
||||
|
||||
it('should remain unchanged when metadata extension is missing', () => {
|
||||
appConfig.config['content-metadata'] = 'initial config';
|
||||
extensions.contentMetadata = null;
|
||||
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
|
||||
expect(appConfig.config['content-metadata']).toEqual('initial config');
|
||||
});
|
||||
|
||||
it('should be overwritten by the one from extension', () => {
|
||||
appConfig.config['content-metadata'] = 'initial config';
|
||||
extensions.contentMetadata = [{ 'new config': true }];
|
||||
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
|
||||
expect(appConfig.config['content-metadata']).not.toEqual(
|
||||
'initial config'
|
||||
);
|
||||
expect(appConfig.config['content-metadata']).toEqual(
|
||||
extensions.contentMetadata
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('canUpdateNode()', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
it('should return true if node is not locked and has update permission', () => {
|
||||
const node = <Node>{
|
||||
isLocked: false,
|
||||
@@ -102,6 +134,12 @@ describe('MetadataTabComponent', () => {
|
||||
});
|
||||
|
||||
describe('displayAspect', () => {
|
||||
beforeEach(() => {
|
||||
fixture = TestBed.createComponent(MetadataTabComponent);
|
||||
store = TestBed.get(Store);
|
||||
component = fixture.componentInstance;
|
||||
});
|
||||
|
||||
it('show pass empty when store is in initial state', () => {
|
||||
const initialState = fixture.debugElement.query(
|
||||
By.css('adf-content-metadata-card')
|
||||
|
@@ -59,15 +59,10 @@ export class MetadataTabComponent {
|
||||
private appConfig: AppConfigService,
|
||||
private store: Store<AppStore>
|
||||
) {
|
||||
try {
|
||||
if (this.extensions.contentMetadata) {
|
||||
this.appConfig.config[
|
||||
'content-metadata'
|
||||
] = this.extensions.contentMetadata;
|
||||
} catch (error) {
|
||||
console.error(
|
||||
error,
|
||||
'- could not change content-metadata from app.config'
|
||||
);
|
||||
}
|
||||
this.displayAspect$ = this.store.select(infoDrawerMetadataAspect);
|
||||
}
|
||||
|
Reference in New Issue
Block a user