[ACS-6252] support disabling the tags and categories feature in the applications (#3533)

* ACS-6252 Allow to hide tags and categories from metadata panel and to hide tags column from personal files

* ACS-6252 Allow to hide tags column from all other lists

* ACS-6252 Allow to hide tags and categories from search filters

* ACS-6252 Set type for search field

* ACS-6252 Hide displaying tags and categories related operators, properties and aspects in folder rules when that feature is disabled

* ACS-6252 Get from service information if tags and categories are disabled

* ACS-6252 Handled case when tags and categories configuration is missing in app.config.json

* ACS-6252 Unit tests for changes for RuleActionUiComponent

* ACS-6252 Unit tests for changes for RuleSimpleConditionUiComponent

* ACS-6252 Unit tests for changes for MetadataTabComponent

* ACS-6252 Unit tests for changes for app rules

* ACS-6252 Unit tests for changes for AppExtensionService

* ACS-6252 Removed redundant private from constructor parameter and corrected unit test title

* ACS-6252 Hide link to category action if categories feature is disabled

* ACS-6252 Move to beforeEach
This commit is contained in:
AleksanderSklorz
2023-11-28 14:09:00 +01:00
committed by GitHub
parent 6a326f776a
commit 2c69887e08
16 changed files with 535 additions and 64 deletions

View File

@@ -244,7 +244,9 @@ export class ContentServiceExtensionModule {
'app.isContentServiceEnabled': rules.isContentServiceEnabled,
'app.isUploadSupported': rules.isUploadSupported,
'app.canCreateLibrary': rules.canCreateLibrary,
'app.isSearchSupported': rules.isSearchSupported
'app.isSearchSupported': rules.isSearchSupported,
'app.areTagsEnabled': rules.areTagsEnabled,
'app.areCategoriesEnabled': rules.areCategoriesEnabled
});
}
}

View File

@@ -34,6 +34,7 @@ import { AppExtensionService, NodePermissionService } from '@alfresco/aca-shared
import { Actions } from '@ngrx/effects';
import { of, Subject } from 'rxjs';
import { ContentActionType } from '@alfresco/adf-extensions';
import { CategoryService, ContentMetadataCardComponent, TagService } from '@alfresco/adf-content-services';
describe('MetadataTabComponent', () => {
let fixture: ComponentFixture<MetadataTabComponent>;
@@ -251,26 +252,70 @@ describe('MetadataTabComponent', () => {
});
});
describe('displayAspect', () => {
describe('ContentMetadataCardComponent', () => {
const getContentMetadataCard = (): ContentMetadataCardComponent =>
fixture.debugElement.query(By.directive(ContentMetadataCardComponent)).componentInstance;
beforeEach(() => {
fixture = TestBed.createComponent(MetadataTabComponent);
store = TestBed.inject(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'));
expect(initialState.componentInstance.displayAspect).toBeFalsy();
describe('displayAspect', () => {
beforeEach(() => {
store = TestBed.inject(Store);
});
it('should show pass empty when store is in initial state', () => {
expect(getContentMetadataCard().displayAspect).toBeFalsy();
});
it('should update the exif if store got updated', () => {
store.dispatch(new SetInfoDrawerMetadataAspectAction('EXIF'));
component.displayAspect$.subscribe((aspect) => {
expect(aspect).toBe('EXIF');
});
fixture.detectChanges();
expect(getContentMetadataCard().displayAspect).toBe('EXIF');
});
});
it('should update the exif if store got updated', () => {
store.dispatch(new SetInfoDrawerMetadataAspectAction('EXIF'));
component.displayAspect$.subscribe((aspect) => {
expect(aspect).toBe('EXIF');
describe('Tags and categories', () => {
it('should have assigned displayCategories to true if categoryService.areCategoriesEnabled returns true', () => {
const categoryService = TestBed.inject(CategoryService);
spyOn(categoryService, 'areCategoriesEnabled').and.returnValue(true);
fixture.detectChanges();
expect(categoryService.areCategoriesEnabled).toHaveBeenCalled();
expect(getContentMetadataCard().displayCategories).toBeTrue();
});
it('should have assigned displayCategories to false if categoryService.areCategoriesEnabled returns false', () => {
const categoryService = TestBed.inject(CategoryService);
spyOn(categoryService, 'areCategoriesEnabled').and.returnValue(false);
fixture.detectChanges();
expect(categoryService.areCategoriesEnabled).toHaveBeenCalled();
expect(getContentMetadataCard().displayCategories).toBeFalse();
});
it('should have assigned displayTags to true if tagService.areTagsEnabled returns true', () => {
const tagService = TestBed.inject(TagService);
spyOn(tagService, 'areTagsEnabled').and.returnValue(true);
fixture.detectChanges();
expect(tagService.areTagsEnabled).toHaveBeenCalled();
expect(getContentMetadataCard().displayTags).toBeTrue();
});
it('should have assigned displayTags to false if tagService.areTagsEnabled returns false', () => {
const tagService = TestBed.inject(TagService);
spyOn(tagService, 'areTagsEnabled').and.returnValue(false);
fixture.detectChanges();
expect(tagService.areTagsEnabled).toHaveBeenCalled();
expect(getContentMetadataCard().displayTags).toBeFalse();
});
fixture.detectChanges();
const initialState = fixture.debugElement.query(By.css('adf-content-metadata-card'));
expect(initialState.componentInstance.displayAspect).toBe('EXIF');
});
});

View File

@@ -29,7 +29,13 @@ import { AppStore, EditOfflineAction, infoDrawerMetadataAspect, NodeActionTypes
import { AppConfigService, NotificationService } from '@alfresco/adf-core';
import { Observable, Subject } from 'rxjs';
import { Store } from '@ngrx/store';
import { ContentMetadataModule, ContentMetadataService, ContentMetadataCustomPanel } from '@alfresco/adf-content-services';
import {
ContentMetadataModule,
ContentMetadataService,
ContentMetadataCustomPanel,
TagService,
CategoryService
} from '@alfresco/adf-content-services';
import { filter, map, takeUntil } from 'rxjs/operators';
import { CommonModule } from '@angular/common';
import { Actions, ofType } from '@ngrx/effects';
@@ -46,6 +52,8 @@ import { Actions, ofType } from '@ngrx/effects';
[displayAspect]="displayAspect$ | async"
[customPanels]="customPanels | async"
[(editable)]="editable"
[displayCategories]="displayCategories"
[displayTags]="displayTags"
>
</adf-content-metadata-card>
`,
@@ -54,6 +62,8 @@ import { Actions, ofType } from '@ngrx/effects';
})
export class MetadataTabComponent implements OnInit, OnDestroy {
protected onDestroy$ = new Subject<boolean>();
private _displayCategories = true;
private _displayTags = true;
@Input()
node: Node;
@@ -63,6 +73,14 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
editable = false;
customPanels: Observable<ContentMetadataCustomPanel[]>;
get displayCategories(): boolean {
return this._displayCategories;
}
get displayTags(): boolean {
return this._displayTags;
}
constructor(
private permission: NodePermissionService,
protected extensions: AppExtensionService,
@@ -70,7 +88,9 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
private store: Store<AppStore>,
private notificationService: NotificationService,
private contentMetadataService: ContentMetadataService,
private actions$: Actions
private actions$: Actions,
private tagService: TagService,
private categoryService: CategoryService
) {
if (this.extensions.contentMetadata) {
this.appConfig.config['content-metadata'].presets = this.extensions.contentMetadata.presets;
@@ -79,6 +99,8 @@ export class MetadataTabComponent implements OnInit, OnDestroy {
}
ngOnInit() {
this._displayTags = this.tagService.areTagsEnabled();
this._displayCategories = this.categoryService.areCategoriesEnabled();
this.contentMetadataService.error.pipe(takeUntil(this.onDestroy$)).subscribe((err: { message: string }) => {
this.notificationService.showError(err.message);
});