[MNT-24660] version list action cannot be disabled using app conf (#4182)

* MNT-24660 Fixed config settings for version manager

* MNT-24660 Unit tests

* MNT-24660 Added possibility to hide and show delete version option

* MNT-24660 Property to show or hide version actions

* MNT-24660 Added more tests, updated documentation

* MNT-24660 Additional documentation

* MNT-24660 Additional fixes

* MNT-24660 Reverted not wanted change

* MNT-24660 Reverted not wanted change
This commit is contained in:
AleksanderSklorz 2024-10-21 23:27:48 +02:00 committed by GitHub
parent 0744dfcd55
commit dfa155df03
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 303 additions and 21 deletions

View File

@ -21,3 +21,6 @@ For more information, please check also the [Content Metadata Component](https:/
## Comments tab
The Comments tab displays all comments made on the selected node in the respoistory by using the [Comments Component](https://www.alfresco.com/abn/adf/core/comments.component/). Users can post new comments that will be displayed immediately.
## Versions tab
Versions tab displays all versions of the selected node.

View File

@ -8,12 +8,12 @@ The versions of a file can be viewed and managed by using the [Version Manager C
There are 2 ways users can access the Version Manager:
1) From the 'Manage Versions' option of the 'More actions' menu (check [Actions and the Actions Toolbar](/features/document-list-layout#actions-and-the-actions-toolbar)):
1) From the 'Manage Versions' option of the 'More actions' menu (check [Actions and the Actions Toolbar](../features/document-list-layout#actions-and-the-actions-toolbar)):
![Version Manager Menu](../images/version-manager-action.png)
![Version Manager Menu](../images/version-manager-action-toolbar.png)
![Version Manager Dialog](../images/version-manager-dialog.png)
2) From the [Info Drawer](/features/info-drawer) (the Details right panel):
2) From the [Info Drawer](../features/info-drawer) (the Details right panel):
![Version Manager Inline](../images/version-manager-tab.png)
@ -21,23 +21,35 @@ There are 2 ways users can access the Version Manager:
A new version for the selected file can be added by using this button. Users can upload a new file version using a file that is does not have the same name, or mime type as the current version, whilst allowing the user to choose the type of version (minor or major) and inputting supporting comments.
Please also check the [UploadVersionButtonComponent](https://www.alfresco.com/abn/adf/content-services/upload-version-button.component/).
Please also check the [UploadVersionButtonComponent](https://github.com/Alfresco/alfresco-ng2-components/blob/develop/docs/content-services/components/upload-version-button.component.md).
## Actions Menu
Each item in the version list has a couple of actions available: Restore, Download and Delete. These are displayed if user has permission to do that specific action. The 'Download' and 'Delete' can be also disabled from the app.config.
Each item in the version list has a couple of actions available: View, Restore, Download and Delete. These are displayed if user has permission to do that specific action.
In the app.config.json file, these are the current settings for the ACA version manager:
Some of these options can be also enabled/disabled in app.config.json file. All configurable options are listed below:
| Option | Default value | Description |
|--------------------|---------------|---------------------------------------------------------------------|
| allowComments | true | Show version's comment in list of versions if true, hide otherwise. |
| allowDownload | true | Allow to download versions if true, disallow otherwise. |
| allowViewVersions | true | Allow to view versions if true, disallow otherwise. |
| allowVersionDelete | true | Allow to delete versions if true, disallow otherwise. |
| showActions | true | Allow to open actions menu when true, otherwise hides it. |
Example of settings in the app.config.json file:
```json
{
"adf-version-manager": {
"allowComments": true,
"allowDownload": true
"allowDownload": true,
"allowViewVersions": true,
"allowVersionDelete": true,
"showActions": true
}
}
```
Set the allowComments to false if the version comments should not be displayed on the version list.
Clicking to delete a version of a file triggers a confirmation dialog. Please see the [Confirm Dialog Component](https://github.com/Alfresco/alfresco-ng2-components/blob/develop/lib/content-services/dialogs/confirm.dialog.ts) for more info.
Clicking to delete a version of a file triggers a confirmation dialog. Please see the [Confirm Dialog Component](https://github.com/Alfresco/alfresco-ng2-components/blob/develop/docs/core/dialogs/confirm.dialog.md) for more info.

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

After

Width:  |  Height:  |  Size: 161 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 81 KiB

After

Width:  |  Height:  |  Size: 365 KiB

View File

@ -23,9 +23,158 @@
*/
import { VersionsTabComponent } from './versions-tab.component';
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { AppSettingsService } from '@alfresco/aca-shared';
import { ContentTestingModule, VersionListDataSource, VersionManagerComponent } from '@alfresco/adf-content-services';
import { By } from '@angular/platform-browser';
import { of } from 'rxjs';
describe('VersionsTabComponent', () => {
it('should be defined', () => {
expect(VersionsTabComponent).toBeDefined();
let component: VersionsTabComponent;
let fixture: ComponentFixture<VersionsTabComponent>;
let appSettingsService: AppSettingsService;
beforeEach(() => {
TestBed.configureTestingModule({
imports: [VersionsTabComponent, ContentTestingModule]
});
fixture = TestBed.createComponent(VersionsTabComponent);
component = fixture.componentInstance;
appSettingsService = TestBed.inject(AppSettingsService);
spyOn(VersionListDataSource.prototype, 'connect').and.returnValue(of());
spyOn(VersionListDataSource.prototype, 'reset');
});
describe('Version manager', () => {
let uploadAllowDownloadSpy: jasmine.SpyAnd<() => boolean>;
let versionManagerAllowViewVersionsSpy: jasmine.SpyAnd<() => boolean>;
let versionManagerShowActionsSpy: jasmine.SpyAnd<() => boolean>;
let versionManagerAllowVersionDeleteSpy: jasmine.SpyAnd<() => boolean>;
let uploadAllowCommentsSpy: jasmine.SpyAnd<() => boolean>;
let versionManagerComponent: VersionManagerComponent;
beforeEach(() => {
component.node = {
nodeId: 'some id'
} as any;
uploadAllowDownloadSpy = spyOnProperty(appSettingsService, 'uploadAllowDownload').and;
versionManagerAllowViewVersionsSpy = spyOnProperty(appSettingsService, 'versionManagerAllowViewVersions').and;
versionManagerShowActionsSpy = spyOnProperty(appSettingsService, 'versionManagerShowActions').and;
versionManagerAllowVersionDeleteSpy = spyOnProperty(appSettingsService, 'versionManagerAllowVersionDelete').and;
uploadAllowCommentsSpy = spyOnProperty(appSettingsService, 'uploadAllowComments').and;
fixture.detectChanges();
versionManagerComponent = fixture.debugElement.query(By.directive(VersionManagerComponent)).componentInstance;
});
it('should have assigned true to showComments if settings.uploadAllowComments returns true', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.showComments).toBe(true);
});
it('should have assigned false to showComments if settings.uploadAllowComments returns false', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(false);
fixture.detectChanges();
expect(versionManagerComponent.showComments).toBe(false);
});
it('should have assigned true to allowDownload if settings.uploadAllowDownload returns true', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.allowDownload).toBe(true);
});
it('should have assigned false to allowDownload if settings.uploadAllowDownload returns false', () => {
uploadAllowDownloadSpy.returnValue(false);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.allowDownload).toBe(false);
});
it('should have assigned true to allowViewVersions if settings.versionManagerAllowViewVersions returns true', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.allowViewVersions).toBe(true);
});
it('should have assigned false to allowViewVersions if settings.versionManagerAllowViewVersions returns false', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(false);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.allowViewVersions).toBe(false);
});
it('should have assigned true to allowVersionDelete if settings.versionManagerAllowVersionDelete returns true', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.allowVersionDelete).toBe(true);
});
it('should have assigned false to allowVersionDelete if settings.versionManagerAllowVersionDelete returns false', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(false);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.allowVersionDelete).toBe(false);
});
it('should have assigned true to showActions if settings.versionManagerShowActions returns true', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.allowVersionDelete).toBe(true);
});
it('should have assigned false to showActions if settings.versionManagerShowActions returns false', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(false);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
fixture.detectChanges();
expect(versionManagerComponent.showActions).toBe(false);
});
});
});

View File

@ -36,7 +36,14 @@ import { AppSettingsService } from '@alfresco/aca-shared';
selector: 'app-versions-tab',
template: `
<ng-container *ngIf="isFileSelected; else empty">
<adf-version-manager [showComments]="settings.uploadAllowComments" [allowDownload]="settings.uploadAllowDownload" [node]="node">
<adf-version-manager
[showComments]="settings.uploadAllowComments"
[allowDownload]="settings.uploadAllowDownload"
[node]="node"
[allowViewVersions]="settings.versionManagerAllowViewVersions"
[allowVersionDelete]="settings.versionManagerAllowVersionDelete"
[showActions]="settings.versionManagerShowActions"
>
</adf-version-manager>
</ng-container>

View File

@ -49,7 +49,7 @@ import {
import { map } from 'rxjs/operators';
import { NodeEffects } from '../store/effects/node.effects';
import { AppTestingModule } from '../testing/app-testing.module';
import { AppHookService, ContentApiService } from '@alfresco/aca-shared';
import { AppHookService, AppSettingsService, ContentApiService } from '@alfresco/aca-shared';
import { Store } from '@ngrx/store';
import { ContentManagementService } from './content-management.service';
import { NodeActionsService } from './node-actions.service';
@ -61,6 +61,7 @@ import {
DocumentListService,
FileModel,
NewVersionUploaderDataAction,
NewVersionUploaderDialogData,
NewVersionUploaderService,
NodeAspectService,
NodesApiService,
@ -81,6 +82,7 @@ describe('ContentManagementService', () => {
let nodeAspectService: NodeAspectService;
let appHookService: AppHookService;
let newVersionUploaderService: NewVersionUploaderService;
let appSettingsService: AppSettingsService;
let showErrorSpy: jasmine.Spy;
let showInfoSpy: jasmine.Spy;
let showWarningSpy: jasmine.Spy;
@ -105,6 +107,7 @@ describe('ContentManagementService', () => {
nodeAspectService = TestBed.inject(NodeAspectService);
appHookService = TestBed.inject(AppHookService);
newVersionUploaderService = TestBed.inject(NewVersionUploaderService);
appSettingsService = TestBed.inject(AppSettingsService);
dialog = TestBed.inject(MatDialog);
});
@ -1555,6 +1558,12 @@ describe('ContentManagementService', () => {
let fakeNodeIsNotFile;
let spyOnOpenUploadNewVersionDialog: jasmine.Spy;
let spyOnDispatch: jasmine.Spy;
let uploadAllowCommentsSpy: jasmine.SpyAnd<() => boolean>;
let uploadAllowDownloadSpy: jasmine.SpyAnd<() => boolean>;
let versionManagerAllowViewVersionsSpy: jasmine.SpyAnd<() => boolean>;
let versionManagerShowActionsSpy: jasmine.SpyAnd<() => boolean>;
let versionManagerAllowVersionDeleteSpy: jasmine.SpyAnd<() => boolean>;
let dialogData: NewVersionUploaderDialogData;
beforeEach(() => {
fakeNodeIsFile = { entry: { id: '1', name: 'name1', isFile: true } };
@ -1562,6 +1571,21 @@ describe('ContentManagementService', () => {
const viewVersionData: ViewVersion = { action: NewVersionUploaderDataAction.view, versionId: '1.0' };
spyOnOpenUploadNewVersionDialog = spyOn(newVersionUploaderService, 'openUploadNewVersionDialog').and.returnValue(of(viewVersionData));
spyOnDispatch = spyOn(store, 'dispatch');
dialogData = {
node: fakeNodeIsFile.entry,
showVersionsOnly: true,
title: 'VERSION.DIALOG.TITLE',
allowDownload: true,
showComments: true,
allowViewVersions: true,
showActions: true,
allowVersionDelete: true
};
uploadAllowCommentsSpy = spyOnProperty(appSettingsService, 'uploadAllowComments').and;
uploadAllowDownloadSpy = spyOnProperty(appSettingsService, 'uploadAllowDownload').and;
versionManagerAllowViewVersionsSpy = spyOnProperty(appSettingsService, 'versionManagerAllowViewVersions').and;
versionManagerShowActionsSpy = spyOnProperty(appSettingsService, 'versionManagerShowActions').and;
versionManagerAllowVersionDeleteSpy = spyOnProperty(appSettingsService, 'versionManagerAllowVersionDelete').and;
});
it('should call openUploadNewVersionDialog', () => {
@ -1570,17 +1594,78 @@ describe('ContentManagementService', () => {
});
it('should call openUploadNewVersionDialog passing dialog data', () => {
const expectedArgument = {
node: fakeNodeIsFile.entry,
showVersionsOnly: true,
title: 'VERSION.DIALOG.TITLE'
};
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
const elementToFocusSelector = 'some-selector';
contentManagementService.manageVersions(fakeNodeIsFile, elementToFocusSelector);
expect(spyOnOpenUploadNewVersionDialog['calls'].argsFor(0)[0]).toEqual(expectedArgument);
expect(spyOnOpenUploadNewVersionDialog['calls'].argsFor(0)[0]).toEqual(dialogData);
expect(spyOnOpenUploadNewVersionDialog['calls'].argsFor(0)[2]).toEqual(elementToFocusSelector);
});
it('should call openUploadNewVersionDialog with allowDownload assigned to false in passed data', () => {
uploadAllowDownloadSpy.returnValue(false);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
dialogData.allowDownload = false;
contentManagementService.manageVersions(fakeNodeIsFile);
expect(spyOnOpenUploadNewVersionDialog['calls'].argsFor(0)[0]).toEqual(dialogData);
});
it('should call openUploadNewVersionDialog with allowViewVersions assigned to false in passed data', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(false);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
dialogData.allowViewVersions = false;
contentManagementService.manageVersions(fakeNodeIsFile);
expect(spyOnOpenUploadNewVersionDialog['calls'].argsFor(0)[0]).toEqual(dialogData);
});
it('should call openUploadNewVersionDialog with showActions assigned to false in passed data', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(false);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(true);
dialogData.showActions = false;
contentManagementService.manageVersions(fakeNodeIsFile);
expect(spyOnOpenUploadNewVersionDialog['calls'].argsFor(0)[0]).toEqual(dialogData);
});
it('should call openUploadNewVersionDialog with allowVersionDelete assigned to false in passed data', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(false);
uploadAllowCommentsSpy.returnValue(true);
dialogData.allowVersionDelete = false;
contentManagementService.manageVersions(fakeNodeIsFile);
expect(spyOnOpenUploadNewVersionDialog['calls'].argsFor(0)[0]).toEqual(dialogData);
});
it('should call openUploadNewVersionDialog with showComments assigned to false in passed data', () => {
uploadAllowDownloadSpy.returnValue(true);
versionManagerAllowViewVersionsSpy.returnValue(true);
versionManagerShowActionsSpy.returnValue(true);
versionManagerAllowVersionDeleteSpy.returnValue(true);
uploadAllowCommentsSpy.returnValue(false);
dialogData.showComments = false;
contentManagementService.manageVersions(fakeNodeIsFile);
expect(spyOnOpenUploadNewVersionDialog['calls'].argsFor(0)[0]).toEqual(dialogData);
});
it('should dispatch RefreshPreviewAction and reload document list if dialog emit refresh action', () => {
spyOnOpenUploadNewVersionDialog.and.returnValue(of({ action: NewVersionUploaderDataAction.refresh, node: fakeNodeIsFile }));
spyOn(documentListService, 'reload');

View File

@ -570,7 +570,12 @@ export class ContentManagementService {
const newVersionUploaderDialogData: NewVersionUploaderDialogData = {
node,
showVersionsOnly: true,
title: 'VERSION.DIALOG.TITLE'
title: 'VERSION.DIALOG.TITLE',
allowDownload: this.appSettingsService.uploadAllowDownload,
showComments: this.appSettingsService.uploadAllowComments,
showActions: this.appSettingsService.versionManagerShowActions,
allowViewVersions: this.appSettingsService.versionManagerAllowViewVersions,
allowVersionDelete: this.appSettingsService.versionManagerAllowVersionDelete
};
this.newVersionUploaderService
.openUploadNewVersionDialog(newVersionUploaderDialogData, { width: '630px', role: 'dialog' }, focusedElementOnCloseSelector)

View File

@ -133,6 +133,27 @@ export class AppSettingsService {
return this.appConfig.get<boolean>('adf-version-manager.allowDownload', true);
}
/**
* Allow to view versions if true, disallow otherwise.
*/
get versionManagerAllowViewVersions(): boolean {
return this.appConfig.get<boolean>('adf-version-manager.allowViewVersions', true);
}
/**
* Allow to delete versions if true, disallow otherwise.
*/
get versionManagerAllowVersionDelete(): boolean {
return this.appConfig.get<boolean>('adf-version-manager.allowVersionDelete', true);
}
/**
* Allow to open actions menu when true, otherwise hides it.
*/
get versionManagerShowActions(): boolean {
return this.appConfig.get<boolean>('adf-version-manager.showActions', true);
}
/**
* Gets the enablement of the file auto tryDownload feature from the app settings.
*/