mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-05-12 17:04:57 +00:00
[MNT-24660] version list action cannot be disabled using app conf (#10308)
* MNT-24660 Added possibility to hide and show viewing of versions when calling openUploadNewVersionDialog function * MNT-24660 Unit tests * MNT-24660 Allow to set allowVersionDelete and showActions by new version uploader service * MNT-24660 Unit tests and documentation * MNT-24660 Reformated documentation table * MNT-24660 Fixed sonar issues * MNT-24660 Fix sonar and additional fixes
This commit is contained in:
parent
1d739ed15a
commit
8ebb8d1b43
@ -314,9 +314,10 @@ for more information about installing and using the source code.
|
||||
| [Upload Drag Area Component](content-services/components/upload-drag-area.component.md) | Adds a drag and drop area to upload files to ACS. | [Source](../lib/content-services/src/lib/upload/components/upload-drag-area.component.ts) |
|
||||
| [Upload Version Button Component (Workaround)](content-services/components/upload-version-button.component.md)  | Activates a file version upload. | [Source](../lib/content-services/src/lib/upload/components/upload-version-button.component.ts) |
|
||||
| [Version Comparison Component](content-services/components/version-comparison.component.md) | Displays the side by side comparison between the current target node (type, name, icon) and the new file that should update it's version. | [Source](../lib/content-services/src/lib/version-manager/version-comparison.component.ts) |
|
||||
| [Version List component](content-services/components/version-list.component.md)  | Displays the version history of a node in a Version Manager component. | [Source](../lib/content-services/src/lib/version-manager/version-list.component.ts) |
|
||||
| [Version Manager Component](content-services/components/version-manager.component.md)  | Displays the version history of a node with the ability to upload a new version. | [Source](../lib/content-services/src/lib/version-manager/version-manager.component.ts) |
|
||||
| [Version List component](content-services/components/version-list.component.md) | Displays the version history of a node in a Version Manager component. | [Source](../lib/content-services/src/lib/version-manager/version-list.component.ts) |
|
||||
| [Version Manager Component](content-services/components/version-manager.component.md) | Displays the version history of a node with the ability to upload a new version. | [Source](../lib/content-services/src/lib/version-manager/version-manager.component.ts) |
|
||||
| [Version Upload component](content-services/components/version-upload.component.md)  | Displays the new version's minor/major changes and the optional comment of a node in a Version Manager component. | [Source](../lib/content-services/src/lib/version-manager/version-upload.component.ts) |
|
||||
| [New Version Uploader dialog](content-services/components/new-version-uploader.dialog.md) | Displays list of versions history of a node in a dialog. | [Source](../lib/content-services/src/lib/new-version-uploader/new-version-uploader.dialog.ts) |
|
||||
|
||||
### Directives
|
||||
|
||||
|
@ -0,0 +1,52 @@
|
||||
---
|
||||
Title: Version List component
|
||||
Added: v4.1.1
|
||||
Status: Active
|
||||
Last reviewed: 2024-10-21
|
||||
---
|
||||
|
||||
# [New Version Uploader dialog](../../../lib/content-services/src/lib/new-version-uploader/new-version-uploader.dialog.ts "Defined in new-version-uploader.dialog.ts")
|
||||
|
||||
Displays list of versions history of a node in a dialog.
|
||||
|
||||

|
||||
### Basic Usage
|
||||
|
||||
```ts
|
||||
this.dialog.open<NewVersionUploaderDialogComponent, NewVersionUploaderDialogData>(
|
||||
NewVersionUploaderDialogComponent,
|
||||
{
|
||||
data: {
|
||||
file,
|
||||
node,
|
||||
currentVersion: version,
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: true,
|
||||
allowViewVersions: true,
|
||||
allowVersionDelete: true,
|
||||
showActions: true
|
||||
},
|
||||
width: '630px'
|
||||
}
|
||||
)
|
||||
```
|
||||
|
||||
## Class members
|
||||
|
||||
### Events
|
||||
|
||||
| Name | Type | Description |
|
||||
|--------------|--------------------------------------------------------------------------------------|-----------------------------------|
|
||||
| dialogAction | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<NewVersionUploaderData>` | Emitted when any action occurs. |
|
||||
| uploadError | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<any>` | Emitted when upload error occurs. |
|
||||
|
||||
## Details
|
||||
|
||||
This component can be used by calling openUploadNewVersionDialog function of [New Version Uploader service](../services/new-version-uploader.dialog.service.md).
|
||||
|
||||
## See also
|
||||
|
||||
- [Version manager component](version-manager.component.md)
|
||||
- [New Version Uploader service](../services/new-version-uploader.dialog.service.md)
|
||||
- [Version List component](version-list.component.md)
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
Title: Version List component
|
||||
Added: v2.0.0
|
||||
Status: Experimental
|
||||
Status: Active
|
||||
Last reviewed: 2019-01-16
|
||||
---
|
||||
|
||||
@ -20,17 +20,18 @@ Displays the version history of a node in a [Version Manager component](version-
|
||||
### Properties
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| ---- | ---- | ------------- | ----------- |
|
||||
|--------------------|-----------|---------------|-----------------------------------------------------------|
|
||||
| allowDownload | `boolean` | true | Enable/disable downloading a version of the current node. |
|
||||
| allowViewVersions | `boolean` | true | Enable/disable viewing a version of the current node. |
|
||||
| node | `Node` | | The target node. |
|
||||
| showActions | `boolean` | true | Toggles showing/hiding of version actions |
|
||||
| showComments | `boolean` | true | Toggles showing/hiding of comments |
|
||||
| allowVersionDelete | `boolean` | true | Enable/disable deletion of version |
|
||||
|
||||
### Events
|
||||
|
||||
| Name | Type | Description |
|
||||
| ---- | ---- | ----------- |
|
||||
|-------------|----------------------------------------------------------------------|------------------------------------|
|
||||
| deleted | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<Node>` | Emitted when a version is deleted |
|
||||
| restored | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<Node>` | Emitted when a version is restored |
|
||||
| viewVersion | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when viewing a version |
|
||||
@ -49,3 +50,5 @@ If you want show readonly version list you set this component with showActions f
|
||||
## See also
|
||||
|
||||
- [Version manager component](version-manager.component.md)
|
||||
- [New Version Uploader service](../services/new-version-uploader.dialog.service.md)
|
||||
- [New Version Uploader component](new-version-uploader.dialog.md)
|
||||
|
@ -1,7 +1,7 @@
|
||||
---
|
||||
Title: Version Manager Component
|
||||
Added: v2.0.0
|
||||
Status: Experimental
|
||||
Status: Active
|
||||
Last reviewed: 2019-01-16
|
||||
---
|
||||
|
||||
@ -11,8 +11,6 @@ Displays the version history of a node with the ability to upload a new version.
|
||||
|
||||

|
||||
|
||||
`This component is still in experimental phase. It has several limitations which will be resolved soon.`
|
||||
|
||||
## Basic Usage
|
||||
|
||||
```html
|
||||
@ -28,12 +26,15 @@ Displays the version history of a node with the ability to upload a new version.
|
||||
### Properties
|
||||
|
||||
| Name | Type | Default value | Description |
|
||||
| ---- | ---- | ------------- | ----------- |
|
||||
|-----------------------|-----------|---------------|-------------------------------------------------------------------------------------------------------------------------------|
|
||||
| allowDownload | `boolean` | true | Enable/disable downloading a version of the current node. |
|
||||
| newFileVersion | `File` | | New file for updating current version. |
|
||||
| node | `Node` | | Target node to manage version history. |
|
||||
| showComments | `boolean` | true | Toggles showing/hiding of comments. |
|
||||
| showVersionComparison | `boolean` | false | Toggles showing/hiding the [version comparison component](../../content-services/components/version-comparison.component.md). |
|
||||
| showActions | `boolean` | true | Toggles showing/hiding of version actions. |
|
||||
| allowViewVersions | `boolean` | true | Enable/disable viewing versions of the current node. |
|
||||
| allowVersionDelete | `boolean` | true | Enable/disable deletion of version |
|
||||
|
||||
### Events
|
||||
|
||||
@ -51,10 +52,15 @@ Displays the version history of a node with the ability to upload a new version.
|
||||
Each version has a context menu on the right, with the following actions.
|
||||
|
||||
| Action | Versions | Description |
|
||||
| ------ | -------- | ----------- |
|
||||
|----------|----------|-----------------------------------------------------------------------------------|
|
||||
| View | All | View selected version. |
|
||||
| Restore | All | Revert the current version to the selected one with creating a new version of it. |
|
||||
| Download | All | Download selected version. |
|
||||
| Delete | All | Delete selected version. |
|
||||
|
||||
## See also
|
||||
|
||||
- [Version list component](version-list.component.md)
|
||||
- [Document list component](document-list.component.md)
|
||||
- [New Version Uploader service](../services/new-version-uploader.dialog.service.md)
|
||||
- [New Version Uploader component](new-version-uploader.dialog.md)
|
||||
|
@ -88,6 +88,6 @@ yourFunctionToOpenDialog(){
|
||||
|
||||
## See Also
|
||||
|
||||
- [Version list component](../components/docs/content-services/components/version-list.component.md)
|
||||
- [Version Comparison Component](../components/docs/content-services/components/version-comparison.component.md)
|
||||
- [Version Upload Component](../components/docs/content-services/components/version-upload.component.md)
|
||||
- [Version list component](../components/version-list.component.md)
|
||||
- [Version Comparison Component](../components/version-comparison.component.md)
|
||||
- [Version Upload Component](../components/version-upload.component.md)
|
||||
|
BIN
docs/docassets/images/new-version-uploader.png
Normal file
BIN
docs/docassets/images/new-version-uploader.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 158 KiB |
Binary file not shown.
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 97 KiB |
@ -26,6 +26,7 @@ backend services have been tested with each released version of ADF.
|
||||
- [v4.4.0](#v440)
|
||||
- [v4.3.0](#v430)
|
||||
- [v4.2.0](#v420)
|
||||
- [v4.1.1](#v411)
|
||||
- [v4.1.0](#v410)
|
||||
- [v4.0.0](#v400)
|
||||
- [v3.9.0](#v390)
|
||||
@ -196,6 +197,14 @@ backend services have been tested with each released version of ADF.
|
||||
|
||||
<!--v420 end-->
|
||||
|
||||
## v4.1.1
|
||||
|
||||
<!--v411 start-->
|
||||
|
||||
- [New version uploader dialog](content-services/components/new-version-uploader.dialog.md)
|
||||
|
||||
<!--v411 end-->
|
||||
|
||||
## v4.1.0
|
||||
|
||||
<!--v410 start-->
|
||||
|
@ -25,7 +25,10 @@ export interface NewVersionUploaderDialogData {
|
||||
currentVersion?: Version;
|
||||
showVersionsOnly?: boolean;
|
||||
showComments?: boolean;
|
||||
showActions?: boolean;
|
||||
allowDownload?: boolean;
|
||||
allowViewVersions?: boolean;
|
||||
allowVersionDelete?: boolean;
|
||||
}
|
||||
|
||||
export type NewVersionUploaderData = VersionManagerUploadData | ViewVersion | RefreshData;
|
||||
|
@ -19,7 +19,10 @@
|
||||
<adf-version-list
|
||||
[node]="data.node"
|
||||
[showComments]="data.showComments"
|
||||
[showActions]="data.showActions"
|
||||
[allowDownload]="data.allowDownload"
|
||||
[allowViewVersions]="data.allowViewVersions"
|
||||
[allowVersionDelete]="data.allowVersionDelete"
|
||||
(deleted)="refresh($event)"
|
||||
(restored)="refresh($event)"
|
||||
(viewVersion)="onViewingVersion($event)"
|
||||
|
@ -66,6 +66,7 @@
|
||||
|
||||
.adf-version-list-element {
|
||||
overflow: auto;
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,8 @@ import { mockFile, mockNode } from '../mock';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { NewVersionUploaderDataAction } from './models';
|
||||
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { VersionListComponent } from '../version-manager/version-list.component';
|
||||
|
||||
describe('NewVersionUploaderDialog', () => {
|
||||
let component: NewVersionUploaderDialogComponent;
|
||||
@ -138,6 +140,8 @@ describe('NewVersionUploaderDialog', () => {
|
||||
describe('Manage Versions', () => {
|
||||
const expectedManageVersionsTitle = 'ADF-NEW-VERSION-UPLOADER.DIALOG_LIST.TITLE';
|
||||
|
||||
const getVersionListComponent = (): VersionListComponent => fixture.debugElement.query(By.css(cssSelectors.adfVersionList)).componentInstance;
|
||||
|
||||
it('should display adf version list if showVersionsOnly is passed as true from parent component', () => {
|
||||
component.data.showVersionsOnly = true;
|
||||
fixture.detectChanges();
|
||||
@ -182,5 +186,53 @@ describe('NewVersionUploaderDialog', () => {
|
||||
const matDialogTitle = nativeElement.querySelector(cssSelectors.title);
|
||||
expect(matDialogTitle.innerHTML).toEqual('TEST_TITLE');
|
||||
});
|
||||
|
||||
it('should have assigned allowViewVersions to true if allowViewVersions from data is true', () => {
|
||||
component.data.showVersionsOnly = true;
|
||||
component.data.allowViewVersions = true;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(getVersionListComponent().allowViewVersions).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned allowViewVersions to false if allowViewVersions from data is false', () => {
|
||||
component.data.showVersionsOnly = true;
|
||||
component.data.allowViewVersions = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(getVersionListComponent().allowViewVersions).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have assigned showActions to true if showActions from data is true', () => {
|
||||
component.data.showVersionsOnly = true;
|
||||
component.data.showActions = true;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(getVersionListComponent().showActions).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned showActions to false if showActions from data is false', () => {
|
||||
component.data.showVersionsOnly = true;
|
||||
component.data.showActions = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(getVersionListComponent().showActions).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have assigned allowVersionDelete to true if allowVersionDelete from data is true', () => {
|
||||
component.data.showVersionsOnly = true;
|
||||
component.data.allowVersionDelete = true;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(getVersionListComponent().allowVersionDelete).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned allowVersionDelete to false if allowVersionDelete from data is false', () => {
|
||||
component.data.showVersionsOnly = true;
|
||||
component.data.allowVersionDelete = false;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(getVersionListComponent().allowVersionDelete).toBeFalse();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -31,6 +31,7 @@ import {
|
||||
} from './models';
|
||||
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
||||
import { NewVersionUploaderService } from './new-version-uploader.service';
|
||||
import { Version, VersionPaging } from '@alfresco/js-api';
|
||||
|
||||
@Component({
|
||||
template: ''
|
||||
@ -75,13 +76,22 @@ describe('NewVersionUploaderService', () => {
|
||||
});
|
||||
|
||||
describe('openUploadNewVersionDialog', () => {
|
||||
describe('Mat Dialog configuration', () => {
|
||||
let mockNewVersionUploaderDialogData: NewVersionUploaderDialogData;
|
||||
let expectedConfig: MatDialogConfig<NewVersionUploaderDialogData>;
|
||||
|
||||
beforeEach(() => {
|
||||
spyOn(service.versionsApi, 'listVersionHistory').and.returnValue(
|
||||
Promise.resolve({
|
||||
list: { entries: [{ entry: '2' }] }
|
||||
} as any)
|
||||
list: {
|
||||
entries: [
|
||||
{
|
||||
entry: {
|
||||
id: '2'
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
} as VersionPaging)
|
||||
);
|
||||
mockNewVersionUploaderDialogData = {
|
||||
node: mockNode,
|
||||
@ -89,86 +99,61 @@ describe('NewVersionUploaderService', () => {
|
||||
showComments: true,
|
||||
allowDownload: true
|
||||
};
|
||||
});
|
||||
|
||||
it('Should open dialog with default configuration', fakeAsync(() => {
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
expectedConfig = {
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
currentVersion: {
|
||||
id: '2'
|
||||
} as Version,
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: undefined
|
||||
showVersionsOnly: undefined,
|
||||
allowViewVersions: true,
|
||||
allowVersionDelete: true,
|
||||
showActions: true
|
||||
},
|
||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-upload'],
|
||||
width: '630px'
|
||||
} as any);
|
||||
};
|
||||
});
|
||||
|
||||
it('should open dialog with default configuration', fakeAsync(() => {
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
}));
|
||||
|
||||
it('Should override default dialog panelClass', fakeAsync(() => {
|
||||
it('should override default dialog panelClass', fakeAsync(() => {
|
||||
const mockDialogConfiguration: MatDialogConfig = {
|
||||
panelClass: 'adf-custom-class',
|
||||
width: '500px'
|
||||
};
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, mockDialogConfiguration).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: undefined
|
||||
},
|
||||
panelClass: 'adf-custom-class',
|
||||
width: '500px'
|
||||
} as any);
|
||||
expectedConfig.panelClass = 'adf-custom-class';
|
||||
expectedConfig.width = '500px';
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
}));
|
||||
|
||||
it('Should set dialog height', fakeAsync(() => {
|
||||
it('should set dialog height', fakeAsync(() => {
|
||||
const mockDialogConfiguration: MatDialogConfig = {
|
||||
height: '600px'
|
||||
};
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, mockDialogConfiguration).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: undefined
|
||||
},
|
||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-upload'],
|
||||
width: '630px',
|
||||
height: '600px'
|
||||
} as any);
|
||||
expectedConfig.height = '600px';
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
}));
|
||||
|
||||
it('Should not override dialog configuration, if dialog configuration is empty', fakeAsync(() => {
|
||||
it('should not override dialog configuration, if dialog configuration is empty', fakeAsync(() => {
|
||||
const mockDialogConfiguration: MatDialogConfig = {};
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, mockDialogConfiguration).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: undefined
|
||||
},
|
||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-upload'],
|
||||
width: '630px'
|
||||
} as any);
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
}));
|
||||
|
||||
it('Should dialog add list css class if showVersionsOnly is true', fakeAsync(() => {
|
||||
it('should dialog add list css class if showVersionsOnly is true', fakeAsync(() => {
|
||||
const mockNewVersionUploaderDialogDataWithVersionsOnly = {
|
||||
node: mockNode,
|
||||
file: mockFile,
|
||||
@ -178,19 +163,73 @@ describe('NewVersionUploaderService', () => {
|
||||
};
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogDataWithVersionsOnly).toPromise();
|
||||
tick();
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
||||
data: {
|
||||
file: mockFile,
|
||||
node: mockNode,
|
||||
currentVersion: '2',
|
||||
showComments: true,
|
||||
allowDownload: true,
|
||||
showVersionsOnly: true
|
||||
},
|
||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-list'],
|
||||
width: '630px'
|
||||
} as any);
|
||||
expectedConfig.data.showVersionsOnly = true;
|
||||
expectedConfig.panelClass = ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-list'];
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
}));
|
||||
|
||||
it('should open dialog with correct configuration when allowViewVersions is true', (done) => {
|
||||
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||
mockNewVersionUploaderDialogData.allowViewVersions = true;
|
||||
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should open dialog with correct configuration when allowViewVersions is false', (done) => {
|
||||
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||
mockNewVersionUploaderDialogData.allowViewVersions = false;
|
||||
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||
expectedConfig.data.allowViewVersions = false;
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should open dialog with correct configuration when allowVersionDelete is true', (done) => {
|
||||
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||
mockNewVersionUploaderDialogData.allowVersionDelete = true;
|
||||
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should open dialog with correct configuration when allowVersionDelete is false', (done) => {
|
||||
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||
mockNewVersionUploaderDialogData.allowVersionDelete = false;
|
||||
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||
expectedConfig.data.allowVersionDelete = false;
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should open dialog with correct configuration when showActions is true', (done) => {
|
||||
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||
mockNewVersionUploaderDialogData.showActions = true;
|
||||
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should open dialog with correct configuration when showActions is false', (done) => {
|
||||
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||
mockNewVersionUploaderDialogData.showActions = false;
|
||||
|
||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||
expectedConfig.data.showActions = false;
|
||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Subscribe events from Dialog', () => {
|
||||
@ -279,4 +318,3 @@ describe('NewVersionUploaderService', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -62,7 +62,17 @@ export class NewVersionUploaderService {
|
||||
const dialogRef = this.dialog.open<NewVersionUploaderDialogComponent, NewVersionUploaderDialogData>(
|
||||
NewVersionUploaderDialogComponent,
|
||||
{
|
||||
data: { file, node, currentVersion: versionPaging.list.entries[0].entry, showComments, allowDownload, showVersionsOnly },
|
||||
data: {
|
||||
file,
|
||||
node,
|
||||
currentVersion: versionPaging.list.entries[0].entry,
|
||||
showComments,
|
||||
allowDownload,
|
||||
showVersionsOnly,
|
||||
allowViewVersions: data.allowViewVersions ?? true,
|
||||
allowVersionDelete: data.allowVersionDelete ?? true,
|
||||
showActions: data.showActions ?? true
|
||||
},
|
||||
panelClass: this.composePanelClass(showVersionsOnly),
|
||||
width: '630px',
|
||||
...(config && Object.keys(config).length > 0 && config)
|
||||
|
@ -1,7 +1,7 @@
|
||||
<mat-progress-bar *ngIf="isLoading" data-automation-id="version-history-loading-bar" mode="indeterminate"
|
||||
color="accent"></mat-progress-bar>
|
||||
<mat-list class="adf-version-list adf-version-list-element" [hidden]="isLoading">
|
||||
<cdk-virtual-scroll-viewport #viewport itemSize="88" class="adf-version-list-viewport">
|
||||
<cdk-virtual-scroll-viewport #viewport itemSize="88" class="adf-version-list-viewport" [minBufferPx]="440" [maxBufferPx]="528">
|
||||
<mat-list-item class="adf-version-list-item"
|
||||
*cdkVirtualFor="let version of versionsDataSource; let idx = index; let latestVersion = first">
|
||||
<mat-icon class="adf-version-list-icon" matListItemIcon>insert_drive_file</mat-icon>
|
||||
@ -50,6 +50,7 @@
|
||||
{{ 'ADF_VERSION_LIST.ACTIONS.DOWNLOAD' | translate }}
|
||||
</button>
|
||||
<button
|
||||
*ngIf="allowVersionDelete"
|
||||
[disabled]="!canDelete()"
|
||||
[id]="'adf-version-list-action-delete-' + version.entry.id"
|
||||
(click)="deleteVersion(version.entry.id)"
|
||||
|
@ -25,6 +25,7 @@ import { Node, NodeEntry, VersionEntry, Version } from '@alfresco/js-api';
|
||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||
import { ContentVersionService } from './content-version.service';
|
||||
import { take } from 'rxjs/operators';
|
||||
import { CdkFixedSizeVirtualScroll } from '@angular/cdk/scrolling';
|
||||
|
||||
describe('VersionListComponent', () => {
|
||||
let component: VersionListComponent;
|
||||
@ -257,6 +258,14 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
|
||||
describe('Actions buttons', () => {
|
||||
const testDeleteButtonVisibility = (done: DoneFn, visible = true) => {
|
||||
fixture.whenStable().then(() => {
|
||||
getActionMenuButton('1.1').click();
|
||||
expect(getDeleteButton() !== null).toBe(visible);
|
||||
done();
|
||||
});
|
||||
};
|
||||
|
||||
const getActionMenuButton = (version = '1.0'): HTMLButtonElement => {
|
||||
fixture.detectChanges();
|
||||
return fixture.debugElement.query(By.css(`[id="adf-version-list-action-menu-button-${version}"]`))?.nativeElement;
|
||||
@ -267,6 +276,8 @@ describe('VersionListComponent', () => {
|
||||
return fixture.debugElement.query(By.css(`[id="adf-version-list-action-restore-${version}"]`))?.nativeElement;
|
||||
};
|
||||
|
||||
const getDeleteButton = (version = '1.1') => fixture.debugElement.query(By.css(`[id="adf-version-list-action-delete-${version}"]`));
|
||||
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
versionTest[1].entry.id = '1.1';
|
||||
@ -355,5 +366,45 @@ describe('VersionListComponent', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Delete action', () => {
|
||||
beforeEach(() => {
|
||||
component.node = { id: nodeId, allowableOperations: ['update', 'delete'] } as Node;
|
||||
});
|
||||
|
||||
it('should show delete action by default', (done) => {
|
||||
fixture.detectChanges();
|
||||
testDeleteButtonVisibility(done);
|
||||
});
|
||||
|
||||
it('should show delete action if allowVersionDelete is true', (done) => {
|
||||
component.allowVersionDelete = true;
|
||||
fixture.detectChanges();
|
||||
testDeleteButtonVisibility(done);
|
||||
});
|
||||
|
||||
it('should hide delete action if allowVersionDelete is false', (done) => {
|
||||
component.allowVersionDelete = false;
|
||||
fixture.detectChanges();
|
||||
testDeleteButtonVisibility(done, false);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Virtual list viewport', () => {
|
||||
let virtualListViewport: CdkFixedSizeVirtualScroll;
|
||||
|
||||
beforeEach(() => {
|
||||
fixture.detectChanges();
|
||||
virtualListViewport = fixture.debugElement.query(By.directive(CdkFixedSizeVirtualScroll)).injector.get(CdkFixedSizeVirtualScroll);
|
||||
});
|
||||
|
||||
it('should have assigned correct minBufferPx', () => {
|
||||
expect(virtualListViewport.minBufferPx).toBe(440);
|
||||
});
|
||||
|
||||
it('should have assigned correct maxBufferPx', () => {
|
||||
expect(virtualListViewport.maxBufferPx).toBe(528);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -113,6 +113,10 @@ export class VersionListComponent implements OnChanges, OnInit, OnDestroy {
|
||||
@Input()
|
||||
showActions = true;
|
||||
|
||||
/** Enable/disable deletion of version */
|
||||
@Input()
|
||||
allowVersionDelete = true;
|
||||
|
||||
/** Emitted when a version is restored */
|
||||
@Output()
|
||||
restored = new EventEmitter<Node>();
|
||||
|
@ -22,6 +22,7 @@
|
||||
<div>
|
||||
<button mat-raised-button
|
||||
id="adf-show-version-upload-button"
|
||||
class="adf-version-manager-upload-button"
|
||||
(click)="toggleNewVersion()" color="primary"
|
||||
*ngIf="uploadState ==='close'">{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.ADD' | translate }}
|
||||
</button>
|
||||
@ -32,6 +33,9 @@
|
||||
[node]="node"
|
||||
[allowDownload]="allowDownload"
|
||||
[showComments]="showComments"
|
||||
[showActions]="showActions"
|
||||
[allowViewVersions]="allowViewVersions"
|
||||
[allowVersionDelete]="allowVersionDelete"
|
||||
(deleted)="refresh($event)"
|
||||
(restored)="refresh($event)"
|
||||
(viewVersion)="onViewVersion($event)">
|
||||
|
@ -41,6 +41,15 @@ adf-version-manager {
|
||||
|
||||
.adf-version-list-table {
|
||||
width: 100%;
|
||||
|
||||
.adf-version-manager-upload-button {
|
||||
margin-left: 20px;
|
||||
}
|
||||
|
||||
adf-version-list {
|
||||
display: flex;
|
||||
height: 538px;
|
||||
}
|
||||
}
|
||||
|
||||
.adf-version-upload-table {
|
||||
|
@ -118,4 +118,106 @@ describe('VersionManagerComponent', () => {
|
||||
expect(component.uploadState).toEqual('open');
|
||||
});
|
||||
});
|
||||
|
||||
describe('Version list', () => {
|
||||
it('should have assigned showActions to true by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.showActions).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned showActions to true if true is passed to showActions for component', () => {
|
||||
component.showActions = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.showActions).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned showActions to false if false is passed to showActions for component', () => {
|
||||
component.showActions = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.showActions).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have assigned allowViewVersions to true by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.allowViewVersions).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned allowViewVersions to true if true is passed to allowViewVersions for component', () => {
|
||||
component.allowViewVersions = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.allowViewVersions).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned allowViewVersions to false if false is passed to allowViewVersions for component', () => {
|
||||
component.allowViewVersions = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.allowViewVersions).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have assigned allowVersionDelete to true by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.allowVersionDelete).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned allowVersionDelete to true if true is passed to allowVersionDelete for component', () => {
|
||||
component.allowVersionDelete = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.allowVersionDelete).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned allowVersionDelete to false if false is passed to allowVersionDelete for component', () => {
|
||||
component.allowVersionDelete = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.allowVersionDelete).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have assigned showComments to true by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.showComments).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned showComments to true if true is passed to showComments for component', () => {
|
||||
component.showComments = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.showComments).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned showComments to false if false is passed to showComments for component', () => {
|
||||
component.showComments = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.showComments).toBeFalse();
|
||||
});
|
||||
|
||||
it('should have assigned allowDownload to true by default', () => {
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.showComments).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned allowDownload to true if true is passed to allowDownload for component', () => {
|
||||
component.allowDownload = true;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.allowDownload).toBeTrue();
|
||||
});
|
||||
|
||||
it('should have assigned allowDownload to false if false is passed to allowDownload for component', () => {
|
||||
component.allowDownload = false;
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(component.versionListComponent.allowDownload).toBeFalse();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -65,6 +65,18 @@ export class VersionManagerComponent implements OnInit {
|
||||
@Input()
|
||||
allowDownload = true;
|
||||
|
||||
/** Toggles showing/hiding of version actions. */
|
||||
@Input()
|
||||
showActions = true;
|
||||
|
||||
/** Enable/disable viewing versions of the current node. */
|
||||
@Input()
|
||||
allowViewVersions = true;
|
||||
|
||||
/** Enable/disable deletion of version */
|
||||
@Input()
|
||||
allowVersionDelete = true;
|
||||
|
||||
/** Emitted when a file is uploaded successfully. */
|
||||
@Output()
|
||||
uploadSuccess = new EventEmitter<Node>();
|
||||
|
Loading…
x
Reference in New Issue
Block a user