[ACA-4445] - disabled edit aspect button on content card for ACS version below 7 (#7043)

This commit is contained in:
Vito 2021-05-19 17:18:57 +01:00 committed by GitHub
parent f03d133899
commit c533b4ec35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View File

@ -13,7 +13,7 @@
</mat-card-content> </mat-card-content>
<mat-card-footer class="adf-content-metadata-card-footer" fxLayout="row" fxLayoutAlign="space-between stretch"> <mat-card-footer class="adf-content-metadata-card-footer" fxLayout="row" fxLayoutAlign="space-between stretch">
<div> <div>
<button *ngIf="!readOnly && hasAllowableOperations()" <button *ngIf="isEditAspectSupported()"
mat-icon-button mat-icon-button
(click)="openAspectDialog()" (click)="openAspectDialog()"
[attr.title]="'CORE.METADATA.ACTIONS.EDIT_ASPECTS' | translate" [attr.title]="'CORE.METADATA.ACTIONS.EDIT_ASPECTS' | translate"

View File

@ -59,6 +59,7 @@ describe('ContentMetadataCardComponent', () => {
component.node = node; component.node = node;
component.preset = preset; component.preset = preset;
component.editAspectSupported = true;
nodeAspectService = TestBed.inject(NodeAspectService); nodeAspectService = TestBed.inject(NodeAspectService);
spyOn(contentMetadataService, 'getContentTypeProperty').and.returnValue(of([])); spyOn(contentMetadataService, 'getContentTypeProperty').and.returnValue(of([]));
fixture.detectChanges(); fixture.detectChanges();
@ -220,6 +221,7 @@ describe('ContentMetadataCardComponent', () => {
component.node.id = 'fake-node-id'; component.node.id = 'fake-node-id';
component.node.allowableOperations = [AllowableOperationsEnum.UPDATE]; component.node.allowableOperations = [AllowableOperationsEnum.UPDATE];
spyOn(nodeAspectService, 'updateNodeAspects').and.stub(); spyOn(nodeAspectService, 'updateNodeAspects').and.stub();
fixture.detectChanges(); fixture.detectChanges();
const button = fixture.debugElement.query(By.css('[data-automation-id="meta-data-card-edit-aspect"]')); const button = fixture.debugElement.query(By.css('[data-automation-id="meta-data-card-edit-aspect"]'));
@ -228,4 +230,17 @@ describe('ContentMetadataCardComponent', () => {
expect(nodeAspectService.updateNodeAspects).toHaveBeenCalledWith('fake-node-id'); expect(nodeAspectService.updateNodeAspects).toHaveBeenCalledWith('fake-node-id');
}); });
it('should not show the edit aspect button if ACS version is not supported', () => {
component.editable = true;
component.node.id = 'fake-node-id';
component.node.allowableOperations = [AllowableOperationsEnum.UPDATE];
spyOn(nodeAspectService, 'updateNodeAspects').and.stub();
component.editAspectSupported = false;
fixture.detectChanges();
const button = fixture.debugElement.query(By.css('[data-automation-id="meta-data-card-edit-aspect"]'));
expect(button).toBeNull();
});
}); });

View File

@ -17,7 +17,7 @@
import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core'; import { Component, Input, OnChanges, SimpleChanges, ViewEncapsulation } from '@angular/core';
import { Node } from '@alfresco/js-api'; import { Node } from '@alfresco/js-api';
import { ContentService, AllowableOperationsEnum } from '@alfresco/adf-core'; import { ContentService, AllowableOperationsEnum, VersionCompatibilityService } from '@alfresco/adf-core';
import { NodeAspectService } from '../../../aspect-list/node-aspect.service'; import { NodeAspectService } from '../../../aspect-list/node-aspect.service';
@Component({ @Component({
selector: 'adf-content-metadata-card', selector: 'adf-content-metadata-card',
@ -81,7 +81,10 @@ export class ContentMetadataCardComponent implements OnChanges {
expanded: boolean; expanded: boolean;
constructor(private contentService: ContentService, private nodeAspectService: NodeAspectService) { editAspectSupported = false;
constructor(private contentService: ContentService, private nodeAspectService: NodeAspectService, private versionCompatibilityService: VersionCompatibilityService) {
this.editAspectSupported = this.versionCompatibilityService.isVersionSupported('7');
} }
ngOnChanges(changes: SimpleChanges): void { ngOnChanges(changes: SimpleChanges): void {
@ -109,4 +112,8 @@ export class ContentMetadataCardComponent implements OnChanges {
openAspectDialog() { openAspectDialog() {
this.nodeAspectService.updateNodeAspects(this.node.id); this.nodeAspectService.updateNodeAspects(this.node.id);
} }
isEditAspectSupported(): boolean {
return !this.readOnly && this.hasAllowableOperations() && this.editAspectSupported;
}
} }