mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2026-09-09 18:02:54 +00:00
[ACS-9765]: updates nodes commenting feature
This commit is contained in:
@@ -33,7 +33,12 @@ import {
|
||||
LibraryStatusColumnComponent,
|
||||
TrashcanNameColumnComponent
|
||||
} from '@alfresco/adf-content-services';
|
||||
import { DocumentBasePageService, ExtensionsDataLoaderGuard, provideContentAppExtensions } from '@alfresco/aca-shared';
|
||||
import {
|
||||
DocumentBasePageService,
|
||||
ExtensionsDataLoaderGuard,
|
||||
EXTERNAL_NODE_PERMISSION_COMMENTS_TAB_SERVICE,
|
||||
provideContentAppExtensions
|
||||
} from '@alfresco/aca-shared';
|
||||
import * as rules from '@alfresco/aca-shared/rules';
|
||||
import { AppStoreModule } from './store/app-store.module';
|
||||
import { provideAppExtensions, provideExtensions } from '@alfresco/adf-extensions';
|
||||
@@ -66,6 +71,7 @@ import { SHELL_NAVBAR_MIN_WIDTH, ShellLayoutComponent } from '@alfresco/adf-core
|
||||
import { UserMenuComponent } from './components/sidenav/user-menu/user-menu.component';
|
||||
import { MAT_DIALOG_DEFAULT_OPTIONS } from '@angular/material/dialog';
|
||||
import { SearchResultsRowComponent } from './components/search/search-results-row/search-results-row.component';
|
||||
import { AcaNodePermissionCommentsService } from './services/aca-node-permission-comments.service';
|
||||
import { BulkActionsDropdownComponent } from './components/bulk-actions-dropdown/bulk-actions-dropdown.component';
|
||||
import { AgentsButtonComponent } from './components/knowledge-retrieval/search-ai/agents-button/agents-button.component';
|
||||
import { SaveSearchSidenavComponent } from './components/search/search-save/sidenav/save-search-sidenav.component';
|
||||
@@ -86,6 +92,11 @@ import { IsFeatureSupportedInCurrentAcsPipe } from './pipes/is-feature-supported
|
||||
provide: MAT_DIALOG_DEFAULT_OPTIONS,
|
||||
useValue: { closeOnNavigation: true, hasBackdrop: true, autoFocus: true }
|
||||
},
|
||||
{
|
||||
provide: EXTERNAL_NODE_PERMISSION_COMMENTS_TAB_SERVICE,
|
||||
useClass: AcaNodePermissionCommentsService,
|
||||
multi: true
|
||||
},
|
||||
provideExtensions({
|
||||
authGuards: {
|
||||
'app.auth': AuthGuardEcm,
|
||||
|
||||
+2
-3
@@ -24,11 +24,10 @@
|
||||
|
||||
import { CommentsTabComponent } from './comments-tab.component';
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { NodePermissionService } from '@alfresco/aca-shared';
|
||||
import { EXTERNAL_NODE_PERMISSION_COMMENTS_TAB_SERVICE, NodePermissionService } from '@alfresco/aca-shared';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { of } from 'rxjs';
|
||||
import { AuthenticationService, NoopTranslateModule } from '@alfresco/adf-core';
|
||||
import { ExternalNodePermissionCommentsTabService } from '@alfresco/aca-content';
|
||||
import { AlfrescoApiService, AlfrescoApiServiceMock } from '@alfresco/adf-content-services';
|
||||
|
||||
describe('CommentsTabComponent', () => {
|
||||
@@ -43,7 +42,7 @@ describe('CommentsTabComponent', () => {
|
||||
imports: [NoopTranslateModule, CommentsTabComponent],
|
||||
providers: [
|
||||
{ provide: AlfrescoApiService, useClass: AlfrescoApiServiceMock },
|
||||
{ provide: ExternalNodePermissionCommentsTabService, useValue: { canAddComments: () => canAddComment } },
|
||||
{ provide: EXTERNAL_NODE_PERMISSION_COMMENTS_TAB_SERVICE, useValue: [{ canAddComments: () => canAddComment }] },
|
||||
{ provide: AuthenticationService, useValue: { onLogout: of({}) } }
|
||||
]
|
||||
});
|
||||
|
||||
+11
-6
@@ -22,12 +22,16 @@
|
||||
* from Hyland Software. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import { Component, Input, OnInit, Optional, ViewEncapsulation } from '@angular/core';
|
||||
import { Component, Inject, Input, OnInit, ViewEncapsulation } from '@angular/core';
|
||||
import { Node } from '@alfresco/js-api';
|
||||
import { isLocked, NodePermissionService } from '@alfresco/aca-shared';
|
||||
import {
|
||||
EXTERNAL_NODE_PERMISSION_COMMENTS_TAB_SERVICE,
|
||||
ExternalNodePermissionCommentsTabService,
|
||||
isLocked,
|
||||
NodePermissionService
|
||||
} from '@alfresco/aca-shared';
|
||||
import { MatCardModule } from '@angular/material/card';
|
||||
import { NodeCommentsComponent } from '@alfresco/adf-content-services';
|
||||
import { ExternalNodePermissionCommentsTabService } from './external-node-permission-comments-tab.service';
|
||||
|
||||
@Component({
|
||||
imports: [MatCardModule, NodeCommentsComponent],
|
||||
@@ -47,7 +51,8 @@ export class CommentsTabComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private readonly permission: NodePermissionService,
|
||||
@Optional() private readonly externalPermissionNodeService: ExternalNodePermissionCommentsTabService
|
||||
@Inject(EXTERNAL_NODE_PERMISSION_COMMENTS_TAB_SERVICE)
|
||||
private readonly externalPermissionNodeService: ExternalNodePermissionCommentsTabService[]
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
@@ -56,8 +61,8 @@ export class CommentsTabComponent implements OnInit {
|
||||
}
|
||||
if (this.node.isFolder || (this.node.isFile && !isLocked({ entry: this.node }))) {
|
||||
this.canUpdateNode = this.permission.check(this.node, ['update']);
|
||||
if (this.externalPermissionNodeService) {
|
||||
this.canUpdateNode &&= this.externalPermissionNodeService.canAddComments(this.node);
|
||||
if (this.externalPermissionNodeService?.length) {
|
||||
this.canUpdateNode &&= this.externalPermissionNodeService.every((service) => service.canAddComments(this.node));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
/*!
|
||||
* Copyright © 2005-2025 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';
|
||||
import { AcaNodePermissionCommentsService } from './aca-node-permission-comments.service';
|
||||
|
||||
describe('AcaNodePermissionCommentsService', () => {
|
||||
let service: AcaNodePermissionCommentsService;
|
||||
|
||||
beforeEach(() => {
|
||||
service = new AcaNodePermissionCommentsService();
|
||||
});
|
||||
|
||||
it('should return false when node type is blacklisted', () => {
|
||||
const node = { nodeType: 'rma:hold', aspectNames: [] } as Node;
|
||||
|
||||
expect(service.canAddComments(node)).toBeFalse();
|
||||
});
|
||||
|
||||
it('should return false when node has a blacklisted aspect', () => {
|
||||
const node = { nodeType: 'cm:content', aspectNames: ['rma:frozen'] } as Node;
|
||||
|
||||
expect(service.canAddComments(node)).toBeFalse();
|
||||
});
|
||||
|
||||
it('should return false when node has both blacklisted type and aspect', () => {
|
||||
const node = { nodeType: 'rma:hold', aspectNames: ['rma:frozen'] } as Node;
|
||||
|
||||
expect(service.canAddComments(node)).toBeFalse();
|
||||
});
|
||||
|
||||
it('should return true when node type and aspects are not blacklisted', () => {
|
||||
const node = { nodeType: 'cm:content', aspectNames: ['cm:titled'] } as Node;
|
||||
|
||||
expect(service.canAddComments(node)).toBeTrue();
|
||||
});
|
||||
|
||||
it('should return true when aspectNames is missing and node type is allowed', () => {
|
||||
const node = { nodeType: 'cm:content' } as Node;
|
||||
|
||||
expect(service.canAddComments(node)).toBeTrue();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,47 @@
|
||||
/*!
|
||||
* Copyright © 2005-2025 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';
|
||||
import { ExternalNodePermissionCommentsTabService } from '@alfresco/aca-shared';
|
||||
|
||||
type DenyRule = (node: Node) => boolean;
|
||||
|
||||
export class AcaNodePermissionCommentsService implements ExternalNodePermissionCommentsTabService {
|
||||
private readonly blacklistedTypes = new Set<string>(['rma:hold']);
|
||||
private readonly blacklistedAspects = new Set<string>(['rma:frozen']);
|
||||
|
||||
private readonly denyRules: ReadonlyArray<DenyRule> = [(node) => this.hasBlacklistedAspect(node), (node) => this.hasBlacklistedType(node)];
|
||||
|
||||
canAddComments(node: Node): boolean {
|
||||
return this.denyRules.every((rule) => !rule(node));
|
||||
}
|
||||
|
||||
private hasBlacklistedAspect(node: Node): boolean {
|
||||
return (node.aspectNames ?? []).some((aspect) => this.blacklistedAspects.has(aspect));
|
||||
}
|
||||
|
||||
private hasBlacklistedType(node: Node): boolean {
|
||||
return this.blacklistedTypes.has(node.nodeType ?? '');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
/*!
|
||||
* Copyright © 2005-2025 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 interface ExternalNodePermissionCommentsTabService {
|
||||
canAddComments(node: Node): boolean;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
/*!
|
||||
* Copyright © 2005-2025 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 { InjectionToken } from '@angular/core';
|
||||
import { ExternalNodePermissionCommentsTabService } from '../models/external-nodes-permission-comments.interface';
|
||||
|
||||
export const EXTERNAL_NODE_PERMISSION_COMMENTS_TAB_SERVICE = new InjectionToken<ExternalNodePermissionCommentsTabService[]>(
|
||||
'ExternalNodePermissionCommentsTabService'
|
||||
);
|
||||
@@ -46,6 +46,7 @@ export * from './lib/directives/pagination.directive';
|
||||
|
||||
export * from './lib/models/types';
|
||||
export * from './lib/models/viewer.rules';
|
||||
export * from './lib/models/external-nodes-permission-comments.interface';
|
||||
|
||||
export * from './lib/routing/shared.guard';
|
||||
export * from './lib/routing/plugin-enabled.guard';
|
||||
@@ -64,6 +65,7 @@ export * from './lib/services/navigation-history.service';
|
||||
export * from './lib/testing/lib-testing-module';
|
||||
|
||||
export * from './lib/utils/node.utils';
|
||||
export * from './lib/utils/external-node-comments-permissions.token';
|
||||
|
||||
export * from './lib/validators/no-whitespace.validator';
|
||||
export * from './lib/validators/no-leading-trailing-operators.validator';
|
||||
|
||||
Reference in New Issue
Block a user