mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-24 17:31:52 +00:00
[ACS-9083][ADW] Comment creation is available after document is retained (declared as record) (#4359)
This commit is contained in:
committed by
GitHub
parent
2c1e2c63d6
commit
75f25e9741
@@ -29,17 +29,22 @@ import { NodePermissionService } from '@alfresco/aca-shared';
|
|||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { of } from 'rxjs';
|
import { of } from 'rxjs';
|
||||||
import { AuthenticationService } from '@alfresco/adf-core';
|
import { AuthenticationService } from '@alfresco/adf-core';
|
||||||
|
import { ExternalNodePermissionCommentsTabService } from '@alfresco/aca-content';
|
||||||
|
|
||||||
describe('CommentsTabComponent', () => {
|
describe('CommentsTabComponent', () => {
|
||||||
let component: CommentsTabComponent;
|
let component: CommentsTabComponent;
|
||||||
let fixture: ComponentFixture<CommentsTabComponent>;
|
let fixture: ComponentFixture<CommentsTabComponent>;
|
||||||
let nodePermissionService: NodePermissionService;
|
let nodePermissionService: NodePermissionService;
|
||||||
let checked: string[];
|
let checked: string[];
|
||||||
|
let canAddComment = true;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
imports: [AppTestingModule, CommentsTabComponent],
|
imports: [AppTestingModule, CommentsTabComponent],
|
||||||
providers: [{ provide: AuthenticationService, useValue: { onLogout: of({}) } }]
|
providers: [
|
||||||
|
{ provide: ExternalNodePermissionCommentsTabService, useValue: { canAddComments: () => canAddComment } },
|
||||||
|
{ provide: AuthenticationService, useValue: { onLogout: of({}) } }
|
||||||
|
]
|
||||||
});
|
});
|
||||||
|
|
||||||
nodePermissionService = TestBed.inject(NodePermissionService);
|
nodePermissionService = TestBed.inject(NodePermissionService);
|
||||||
@@ -48,6 +53,7 @@ describe('CommentsTabComponent', () => {
|
|||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
checked = null;
|
checked = null;
|
||||||
|
canAddComment = true;
|
||||||
spyOn(nodePermissionService, 'check').and.callFake((_source, permissions) => {
|
spyOn(nodePermissionService, 'check').and.callFake((_source, permissions) => {
|
||||||
checked = permissions;
|
checked = permissions;
|
||||||
return true;
|
return true;
|
||||||
@@ -107,4 +113,28 @@ describe('CommentsTabComponent', () => {
|
|||||||
expect(checked).toContain('update');
|
expect(checked).toContain('update');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('should return false if node permissions are correct and external service is not allowing it', async () => {
|
||||||
|
canAddComment = false;
|
||||||
|
component.node = {
|
||||||
|
id: 'test-node-id',
|
||||||
|
isFile: true,
|
||||||
|
isFolder: false
|
||||||
|
} as Node;
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expect(component.canUpdateNode).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should return true if node permissions are correct and external service is allowing it', async () => {
|
||||||
|
canAddComment = true;
|
||||||
|
component.node = {
|
||||||
|
id: 'test-node-id',
|
||||||
|
isFile: true,
|
||||||
|
isFolder: false
|
||||||
|
} as Node;
|
||||||
|
fixture.detectChanges();
|
||||||
|
await fixture.whenStable();
|
||||||
|
expect(component.canUpdateNode).toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -22,11 +22,12 @@
|
|||||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Component, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
import { Component, Input, OnInit, Optional, ViewEncapsulation } from '@angular/core';
|
||||||
import { Node } from '@alfresco/js-api';
|
import { Node } from '@alfresco/js-api';
|
||||||
import { NodePermissionService, isLocked } from '@alfresco/aca-shared';
|
import { isLocked, NodePermissionService } from '@alfresco/aca-shared';
|
||||||
import { MatCardModule } from '@angular/material/card';
|
import { MatCardModule } from '@angular/material/card';
|
||||||
import { NodeCommentsModule } from '@alfresco/adf-content-services';
|
import { NodeCommentsModule } from '@alfresco/adf-content-services';
|
||||||
|
import { ExternalNodePermissionCommentsTabService } from './external-node-permission-comments-tab.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
standalone: true,
|
standalone: true,
|
||||||
@@ -45,7 +46,10 @@ export class CommentsTabComponent implements OnInit {
|
|||||||
|
|
||||||
canUpdateNode = false;
|
canUpdateNode = false;
|
||||||
|
|
||||||
constructor(private permission: NodePermissionService) {}
|
constructor(
|
||||||
|
private readonly permission: NodePermissionService,
|
||||||
|
@Optional() private readonly externalPermissionNodeService: ExternalNodePermissionCommentsTabService
|
||||||
|
) {}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if (!this.node) {
|
if (!this.node) {
|
||||||
@@ -53,6 +57,9 @@ export class CommentsTabComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
if (this.node.isFolder || (this.node.isFile && !isLocked({ entry: this.node }))) {
|
if (this.node.isFolder || (this.node.isFile && !isLocked({ entry: this.node }))) {
|
||||||
this.canUpdateNode = this.permission.check(this.node, ['update']);
|
this.canUpdateNode = this.permission.check(this.node, ['update']);
|
||||||
|
if (this.externalPermissionNodeService) {
|
||||||
|
this.canUpdateNode &&= this.externalPermissionNodeService.canAddComments(this.node);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -0,0 +1,29 @@
|
|||||||
|
/*!
|
||||||
|
* Copyright © 2005-2024 Hyland Software, Inc. and its affiliates. All rights reserved.
|
||||||
|
*
|
||||||
|
* Alfresco Example Content Application
|
||||||
|
*
|
||||||
|
* This file is part of the Alfresco Example Content Application.
|
||||||
|
* If the software was purchased under a paid Alfresco license, the terms of
|
||||||
|
* the paid license agreement will prevail. Otherwise, the software is
|
||||||
|
* provided under the following open source license terms:
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* The Alfresco Example Content Application is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import { Node } from '@alfresco/js-api';
|
||||||
|
|
||||||
|
export abstract class ExternalNodePermissionCommentsTabService {
|
||||||
|
abstract canAddComments(node: Node): boolean;
|
||||||
|
}
|
@@ -31,4 +31,5 @@ export * from './lib/aca-content.routes';
|
|||||||
export * from './lib/extensions/core.extensions.module';
|
export * from './lib/extensions/core.extensions.module';
|
||||||
export * from './lib/store/initial-state';
|
export * from './lib/store/initial-state';
|
||||||
export * from './lib/services/content-url.service';
|
export * from './lib/services/content-url.service';
|
||||||
|
export * from './lib/components/info-drawer/comments-tab/external-node-permission-comments-tab.service';
|
||||||
export * from './lib/utils/aca-search-utils';
|
export * from './lib/utils/aca-search-utils';
|
||||||
|
Reference in New Issue
Block a user