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 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) |
|
| [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 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 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 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) |
|
| [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
|
### 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
|
Title: Version List component
|
||||||
Added: v2.0.0
|
Added: v2.0.0
|
||||||
Status: Experimental
|
Status: Active
|
||||||
Last reviewed: 2019-01-16
|
Last reviewed: 2019-01-16
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -19,21 +19,22 @@ Displays the version history of a node in a [Version Manager component](version-
|
|||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| ---- | ---- | ------------- | ----------- |
|
|--------------------|-----------|---------------|-----------------------------------------------------------|
|
||||||
| allowDownload | `boolean` | true | Enable/disable downloading a version of the current node. |
|
| allowDownload | `boolean` | true | Enable/disable downloading a version of the current node. |
|
||||||
| allowViewVersions | `boolean` | true | Enable/disable viewing a version of the current node. |
|
| allowViewVersions | `boolean` | true | Enable/disable viewing a version of the current node. |
|
||||||
| node | `Node` | | The target node. |
|
| node | `Node` | | The target node. |
|
||||||
| showActions | `boolean` | true | Toggles showing/hiding of version actions |
|
| showActions | `boolean` | true | Toggles showing/hiding of version actions |
|
||||||
| showComments | `boolean` | true | Toggles showing/hiding of comments |
|
| showComments | `boolean` | true | Toggles showing/hiding of comments |
|
||||||
|
| allowVersionDelete | `boolean` | true | Enable/disable deletion of version |
|
||||||
|
|
||||||
### Events
|
### Events
|
||||||
|
|
||||||
| Name | Type | Description |
|
| Name | Type | Description |
|
||||||
| ---- | ---- | ----------- |
|
|-------------|----------------------------------------------------------------------|------------------------------------|
|
||||||
| deleted | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<Node>` | Emitted when a version is deleted |
|
| 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 |
|
| 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 |
|
| viewVersion | [`EventEmitter`](https://angular.io/api/core/EventEmitter)`<string>` | Emitted when viewing a version |
|
||||||
|
|
||||||
## Details
|
## Details
|
||||||
|
|
||||||
@ -49,3 +50,5 @@ If you want show readonly version list you set this component with showActions f
|
|||||||
## See also
|
## See also
|
||||||
|
|
||||||
- [Version manager component](version-manager.component.md)
|
- [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
|
Title: Version Manager Component
|
||||||
Added: v2.0.0
|
Added: v2.0.0
|
||||||
Status: Experimental
|
Status: Active
|
||||||
Last reviewed: 2019-01-16
|
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
|
## Basic Usage
|
||||||
|
|
||||||
```html
|
```html
|
||||||
@ -27,13 +25,16 @@ Displays the version history of a node with the ability to upload a new version.
|
|||||||
|
|
||||||
### Properties
|
### Properties
|
||||||
|
|
||||||
| Name | Type | Default value | Description |
|
| Name | Type | Default value | Description |
|
||||||
| ---- | ---- | ------------- | ----------- |
|
|-----------------------|-----------|---------------|-------------------------------------------------------------------------------------------------------------------------------|
|
||||||
| allowDownload | `boolean` | true | Enable/disable downloading a version of the current node. |
|
| allowDownload | `boolean` | true | Enable/disable downloading a version of the current node. |
|
||||||
| newFileVersion | `File` | | New file for updating current version. |
|
| newFileVersion | `File` | | New file for updating current version. |
|
||||||
| node | `Node` | | Target node to manage version history. |
|
| node | `Node` | | Target node to manage version history. |
|
||||||
| showComments | `boolean` | true | Toggles showing/hiding of comments. |
|
| 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). |
|
| 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
|
### Events
|
||||||
|
|
||||||
@ -50,11 +51,16 @@ 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.
|
Each version has a context menu on the right, with the following actions.
|
||||||
|
|
||||||
| Action | Versions | Description |
|
| Action | Versions | Description |
|
||||||
| ------ | -------- | ----------- |
|
|----------|----------|-----------------------------------------------------------------------------------|
|
||||||
| Restore | All | Revert the current version to the selected one with creating a new version of it. |
|
| 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
|
## See also
|
||||||
|
|
||||||
- [Version list component](version-list.component.md)
|
- [Version list component](version-list.component.md)
|
||||||
- [Document list component](document-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
|
## See Also
|
||||||
|
|
||||||
- [Version list component](../components/docs/content-services/components/version-list.component.md)
|
- [Version list component](../components/version-list.component.md)
|
||||||
- [Version Comparison Component](../components/docs/content-services/components/version-comparison.component.md)
|
- [Version Comparison Component](../components/version-comparison.component.md)
|
||||||
- [Version Upload Component](../components/docs/content-services/components/version-upload.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.4.0](#v440)
|
||||||
- [v4.3.0](#v430)
|
- [v4.3.0](#v430)
|
||||||
- [v4.2.0](#v420)
|
- [v4.2.0](#v420)
|
||||||
|
- [v4.1.1](#v411)
|
||||||
- [v4.1.0](#v410)
|
- [v4.1.0](#v410)
|
||||||
- [v4.0.0](#v400)
|
- [v4.0.0](#v400)
|
||||||
- [v3.9.0](#v390)
|
- [v3.9.0](#v390)
|
||||||
@ -196,6 +197,14 @@ backend services have been tested with each released version of ADF.
|
|||||||
|
|
||||||
<!--v420 end-->
|
<!--v420 end-->
|
||||||
|
|
||||||
|
## v4.1.1
|
||||||
|
|
||||||
|
<!--v411 start-->
|
||||||
|
|
||||||
|
- [New version uploader dialog](content-services/components/new-version-uploader.dialog.md)
|
||||||
|
|
||||||
|
<!--v411 end-->
|
||||||
|
|
||||||
## v4.1.0
|
## v4.1.0
|
||||||
|
|
||||||
<!--v410 start-->
|
<!--v410 start-->
|
||||||
|
@ -25,7 +25,10 @@ export interface NewVersionUploaderDialogData {
|
|||||||
currentVersion?: Version;
|
currentVersion?: Version;
|
||||||
showVersionsOnly?: boolean;
|
showVersionsOnly?: boolean;
|
||||||
showComments?: boolean;
|
showComments?: boolean;
|
||||||
|
showActions?: boolean;
|
||||||
allowDownload?: boolean;
|
allowDownload?: boolean;
|
||||||
|
allowViewVersions?: boolean;
|
||||||
|
allowVersionDelete?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type NewVersionUploaderData = VersionManagerUploadData | ViewVersion | RefreshData;
|
export type NewVersionUploaderData = VersionManagerUploadData | ViewVersion | RefreshData;
|
||||||
|
@ -19,7 +19,10 @@
|
|||||||
<adf-version-list
|
<adf-version-list
|
||||||
[node]="data.node"
|
[node]="data.node"
|
||||||
[showComments]="data.showComments"
|
[showComments]="data.showComments"
|
||||||
|
[showActions]="data.showActions"
|
||||||
[allowDownload]="data.allowDownload"
|
[allowDownload]="data.allowDownload"
|
||||||
|
[allowViewVersions]="data.allowViewVersions"
|
||||||
|
[allowVersionDelete]="data.allowVersionDelete"
|
||||||
(deleted)="refresh($event)"
|
(deleted)="refresh($event)"
|
||||||
(restored)="refresh($event)"
|
(restored)="refresh($event)"
|
||||||
(viewVersion)="onViewingVersion($event)"
|
(viewVersion)="onViewingVersion($event)"
|
||||||
|
@ -66,6 +66,7 @@
|
|||||||
|
|
||||||
.adf-version-list-element {
|
.adf-version-list-element {
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ import { mockFile, mockNode } from '../mock';
|
|||||||
import { ContentTestingModule } from '../testing/content.testing.module';
|
import { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
import { NewVersionUploaderDataAction } from './models';
|
import { NewVersionUploaderDataAction } from './models';
|
||||||
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
||||||
|
import { By } from '@angular/platform-browser';
|
||||||
|
import { VersionListComponent } from '../version-manager/version-list.component';
|
||||||
|
|
||||||
describe('NewVersionUploaderDialog', () => {
|
describe('NewVersionUploaderDialog', () => {
|
||||||
let component: NewVersionUploaderDialogComponent;
|
let component: NewVersionUploaderDialogComponent;
|
||||||
@ -138,6 +140,8 @@ describe('NewVersionUploaderDialog', () => {
|
|||||||
describe('Manage Versions', () => {
|
describe('Manage Versions', () => {
|
||||||
const expectedManageVersionsTitle = 'ADF-NEW-VERSION-UPLOADER.DIALOG_LIST.TITLE';
|
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', () => {
|
it('should display adf version list if showVersionsOnly is passed as true from parent component', () => {
|
||||||
component.data.showVersionsOnly = true;
|
component.data.showVersionsOnly = true;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
@ -182,5 +186,53 @@ describe('NewVersionUploaderDialog', () => {
|
|||||||
const matDialogTitle = nativeElement.querySelector(cssSelectors.title);
|
const matDialogTitle = nativeElement.querySelector(cssSelectors.title);
|
||||||
expect(matDialogTitle.innerHTML).toEqual('TEST_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';
|
} from './models';
|
||||||
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
import { NewVersionUploaderDialogComponent } from './new-version-uploader.dialog';
|
||||||
import { NewVersionUploaderService } from './new-version-uploader.service';
|
import { NewVersionUploaderService } from './new-version-uploader.service';
|
||||||
|
import { Version, VersionPaging } from '@alfresco/js-api';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: ''
|
template: ''
|
||||||
@ -75,208 +76,245 @@ describe('NewVersionUploaderService', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('openUploadNewVersionDialog', () => {
|
describe('openUploadNewVersionDialog', () => {
|
||||||
describe('Mat Dialog configuration', () => {
|
let mockNewVersionUploaderDialogData: NewVersionUploaderDialogData;
|
||||||
let mockNewVersionUploaderDialogData: NewVersionUploaderDialogData;
|
let expectedConfig: MatDialogConfig<NewVersionUploaderDialogData>;
|
||||||
beforeEach(() => {
|
|
||||||
spyOn(service.versionsApi, 'listVersionHistory').and.returnValue(
|
beforeEach(() => {
|
||||||
Promise.resolve({
|
spyOn(service.versionsApi, 'listVersionHistory').and.returnValue(
|
||||||
list: { entries: [{ entry: '2' }] }
|
Promise.resolve({
|
||||||
} as any)
|
list: {
|
||||||
);
|
entries: [
|
||||||
mockNewVersionUploaderDialogData = {
|
{
|
||||||
node: mockNode,
|
entry: {
|
||||||
|
id: '2'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
} as VersionPaging)
|
||||||
|
);
|
||||||
|
mockNewVersionUploaderDialogData = {
|
||||||
|
node: mockNode,
|
||||||
|
file: mockFile,
|
||||||
|
showComments: true,
|
||||||
|
allowDownload: true
|
||||||
|
};
|
||||||
|
expectedConfig = {
|
||||||
|
data: {
|
||||||
file: mockFile,
|
file: mockFile,
|
||||||
showComments: true,
|
|
||||||
allowDownload: true
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should open dialog with default configuration', fakeAsync(() => {
|
|
||||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).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);
|
|
||||||
}));
|
|
||||||
|
|
||||||
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);
|
|
||||||
}));
|
|
||||||
|
|
||||||
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);
|
|
||||||
}));
|
|
||||||
|
|
||||||
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);
|
|
||||||
}));
|
|
||||||
|
|
||||||
it('Should dialog add list css class if showVersionsOnly is true', fakeAsync(() => {
|
|
||||||
const mockNewVersionUploaderDialogDataWithVersionsOnly = {
|
|
||||||
node: mockNode,
|
node: mockNode,
|
||||||
file: mockFile,
|
currentVersion: {
|
||||||
showVersionsOnly: true,
|
id: '2'
|
||||||
|
} as Version,
|
||||||
showComments: true,
|
showComments: true,
|
||||||
allowDownload: true
|
allowDownload: true,
|
||||||
};
|
showVersionsOnly: undefined,
|
||||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogDataWithVersionsOnly).toPromise();
|
allowViewVersions: true,
|
||||||
tick();
|
allowVersionDelete: true,
|
||||||
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, {
|
showActions: true
|
||||||
data: {
|
},
|
||||||
file: mockFile,
|
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-upload'],
|
||||||
node: mockNode,
|
width: '630px'
|
||||||
currentVersion: '2',
|
};
|
||||||
showComments: true,
|
|
||||||
allowDownload: true,
|
|
||||||
showVersionsOnly: true
|
|
||||||
},
|
|
||||||
panelClass: ['adf-new-version-uploader-dialog', 'adf-new-version-uploader-dialog-list'],
|
|
||||||
width: '630px'
|
|
||||||
} as any);
|
|
||||||
}));
|
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('Subscribe events from Dialog', () => {
|
it('should open dialog with default configuration', fakeAsync(() => {
|
||||||
let mockNewVersionUploaderDialogData: NewVersionUploaderDialogData;
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).toPromise();
|
||||||
|
tick();
|
||||||
|
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||||
|
}));
|
||||||
|
|
||||||
beforeEach(() => {
|
it('should override default dialog panelClass', fakeAsync(() => {
|
||||||
spyOn(service.versionsApi, 'listVersionHistory').and.returnValue(
|
const mockDialogConfiguration: MatDialogConfig = {
|
||||||
Promise.resolve({
|
panelClass: 'adf-custom-class',
|
||||||
list: { entries: [{ entry: '2' }] }
|
width: '500px'
|
||||||
}) as any
|
};
|
||||||
);
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, mockDialogConfiguration).toPromise();
|
||||||
mockNewVersionUploaderDialogData = {
|
tick();
|
||||||
node: mockNode,
|
expectedConfig.panelClass = 'adf-custom-class';
|
||||||
file: mockFile
|
expectedConfig.width = '500px';
|
||||||
};
|
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should set dialog height', fakeAsync(() => {
|
||||||
|
const mockDialogConfiguration: MatDialogConfig = {
|
||||||
|
height: '600px'
|
||||||
|
};
|
||||||
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, mockDialogConfiguration).toPromise();
|
||||||
|
tick();
|
||||||
|
expectedConfig.height = '600px';
|
||||||
|
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||||
|
}));
|
||||||
|
|
||||||
|
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, expectedConfig);
|
||||||
|
}));
|
||||||
|
|
||||||
|
it('should dialog add list css class if showVersionsOnly is true', fakeAsync(() => {
|
||||||
|
const mockNewVersionUploaderDialogDataWithVersionsOnly = {
|
||||||
|
node: mockNode,
|
||||||
|
file: mockFile,
|
||||||
|
showVersionsOnly: true,
|
||||||
|
showComments: true,
|
||||||
|
allowDownload: true
|
||||||
|
};
|
||||||
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogDataWithVersionsOnly).toPromise();
|
||||||
|
tick();
|
||||||
|
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 return Refresh action', (done) => {
|
it('should open dialog with correct configuration when allowViewVersions is false', (done) => {
|
||||||
dialogRefSpyObj.componentInstance = {
|
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||||
dialogAction: new BehaviorSubject<RefreshData>({
|
mockNewVersionUploaderDialogData.allowViewVersions = false;
|
||||||
action: NewVersionUploaderDataAction.refresh,
|
|
||||||
node: mockNode
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||||
}),
|
expectedConfig.data.allowViewVersions = false;
|
||||||
uploadError: new Subject()
|
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||||
};
|
done();
|
||||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe((res) => {
|
|
||||||
expect(res).toEqual({ action: NewVersionUploaderDataAction.refresh, node: mockNode });
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Should return Upload action', (done) => {
|
it('should open dialog with correct configuration when allowVersionDelete is true', (done) => {
|
||||||
dialogRefSpyObj.componentInstance = {
|
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||||
dialogAction: new BehaviorSubject<VersionManagerUploadData>(mockNewVersionUploaderData),
|
mockNewVersionUploaderDialogData.allowVersionDelete = true;
|
||||||
uploadError: new Subject()
|
|
||||||
};
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe((res) => {
|
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||||
expect(res).toEqual(mockNewVersionUploaderData);
|
done();
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Should return View Version action', (done) => {
|
it('should open dialog with correct configuration when allowVersionDelete is false', (done) => {
|
||||||
dialogRefSpyObj.componentInstance = {
|
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||||
dialogAction: new BehaviorSubject<ViewVersion>({
|
mockNewVersionUploaderDialogData.allowVersionDelete = false;
|
||||||
action: NewVersionUploaderDataAction.view,
|
|
||||||
versionId: '2'
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||||
}),
|
expectedConfig.data.allowVersionDelete = false;
|
||||||
uploadError: new Subject()
|
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||||
};
|
done();
|
||||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe((res) => {
|
|
||||||
expect(res).toEqual({ action: NewVersionUploaderDataAction.view, versionId: '2' });
|
|
||||||
done();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('Should return upload error', (done) => {
|
it('should open dialog with correct configuration when showActions is true', (done) => {
|
||||||
dialogRefSpyObj.componentInstance = {
|
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||||
dialogAction: new Subject(),
|
mockNewVersionUploaderDialogData.showActions = true;
|
||||||
uploadError: new BehaviorSubject<any>({ value: 'Upload error' })
|
|
||||||
};
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||||
spyOnDialogOpen.and.returnValue(dialogRefSpyObj);
|
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(
|
done();
|
||||||
() => {
|
|
||||||
fail('An error should have been thrown');
|
|
||||||
},
|
|
||||||
(error) => {
|
|
||||||
expect(error).toEqual({ value: 'Upload error' });
|
|
||||||
done();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
it('should focus element indicated by passed selector after closing modal', (done) => {
|
it('should open dialog with correct configuration when showActions is false', (done) => {
|
||||||
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<VersionManagerUploadData>(mockNewVersionUploaderData);
|
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<NewVersionUploaderData>(mockNewVersionUploaderData);
|
||||||
const afterClosed$ = new BehaviorSubject<void>(undefined);
|
mockNewVersionUploaderDialogData.showActions = false;
|
||||||
dialogRefSpyObj.afterClosed = () => afterClosed$;
|
|
||||||
const elementToFocusSelector = 'button';
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(() => {
|
||||||
const elementToFocus = document.createElement(elementToFocusSelector);
|
expectedConfig.data.showActions = false;
|
||||||
spyOn(elementToFocus, 'focus').and.callFake(() => {
|
expect(spyOnDialogOpen).toHaveBeenCalledWith(NewVersionUploaderDialogComponent, expectedConfig);
|
||||||
expect(elementToFocus.focus).toHaveBeenCalled();
|
done();
|
||||||
done();
|
|
||||||
});
|
|
||||||
spyOn(document, 'querySelector').and.returnValue(elementToFocus);
|
|
||||||
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, undefined, elementToFocusSelector).subscribe();
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('Subscribe events from Dialog', () => {
|
||||||
|
let mockNewVersionUploaderDialogData: NewVersionUploaderDialogData;
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
spyOn(service.versionsApi, 'listVersionHistory').and.returnValue(
|
||||||
|
Promise.resolve({
|
||||||
|
list: { entries: [{ entry: '2' }] }
|
||||||
|
}) as any
|
||||||
|
);
|
||||||
|
mockNewVersionUploaderDialogData = {
|
||||||
|
node: mockNode,
|
||||||
|
file: mockFile
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should return Refresh action', (done) => {
|
||||||
|
dialogRefSpyObj.componentInstance = {
|
||||||
|
dialogAction: new BehaviorSubject<RefreshData>({
|
||||||
|
action: NewVersionUploaderDataAction.refresh,
|
||||||
|
node: mockNode
|
||||||
|
}),
|
||||||
|
uploadError: new Subject()
|
||||||
|
};
|
||||||
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe((res) => {
|
||||||
|
expect(res).toEqual({ action: NewVersionUploaderDataAction.refresh, node: mockNode });
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should return Upload action', (done) => {
|
||||||
|
dialogRefSpyObj.componentInstance = {
|
||||||
|
dialogAction: new BehaviorSubject<VersionManagerUploadData>(mockNewVersionUploaderData),
|
||||||
|
uploadError: new Subject()
|
||||||
|
};
|
||||||
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe((res) => {
|
||||||
|
expect(res).toEqual(mockNewVersionUploaderData);
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should return View Version action', (done) => {
|
||||||
|
dialogRefSpyObj.componentInstance = {
|
||||||
|
dialogAction: new BehaviorSubject<ViewVersion>({
|
||||||
|
action: NewVersionUploaderDataAction.view,
|
||||||
|
versionId: '2'
|
||||||
|
}),
|
||||||
|
uploadError: new Subject()
|
||||||
|
};
|
||||||
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe((res) => {
|
||||||
|
expect(res).toEqual({ action: NewVersionUploaderDataAction.view, versionId: '2' });
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should return upload error', (done) => {
|
||||||
|
dialogRefSpyObj.componentInstance = {
|
||||||
|
dialogAction: new Subject(),
|
||||||
|
uploadError: new BehaviorSubject<any>({ value: 'Upload error' })
|
||||||
|
};
|
||||||
|
spyOnDialogOpen.and.returnValue(dialogRefSpyObj);
|
||||||
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData).subscribe(
|
||||||
|
() => {
|
||||||
|
fail('An error should have been thrown');
|
||||||
|
},
|
||||||
|
(error) => {
|
||||||
|
expect(error).toEqual({ value: 'Upload error' });
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should focus element indicated by passed selector after closing modal', (done) => {
|
||||||
|
dialogRefSpyObj.componentInstance.dialogAction = new BehaviorSubject<VersionManagerUploadData>(mockNewVersionUploaderData);
|
||||||
|
const afterClosed$ = new BehaviorSubject<void>(undefined);
|
||||||
|
dialogRefSpyObj.afterClosed = () => afterClosed$;
|
||||||
|
const elementToFocusSelector = 'button';
|
||||||
|
const elementToFocus = document.createElement(elementToFocusSelector);
|
||||||
|
spyOn(elementToFocus, 'focus').and.callFake(() => {
|
||||||
|
expect(elementToFocus.focus).toHaveBeenCalled();
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
spyOn(document, 'querySelector').and.returnValue(elementToFocus);
|
||||||
|
service.openUploadNewVersionDialog(mockNewVersionUploaderDialogData, undefined, elementToFocusSelector).subscribe();
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@ -62,7 +62,17 @@ export class NewVersionUploaderService {
|
|||||||
const dialogRef = this.dialog.open<NewVersionUploaderDialogComponent, NewVersionUploaderDialogData>(
|
const dialogRef = this.dialog.open<NewVersionUploaderDialogComponent, NewVersionUploaderDialogData>(
|
||||||
NewVersionUploaderDialogComponent,
|
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),
|
panelClass: this.composePanelClass(showVersionsOnly),
|
||||||
width: '630px',
|
width: '630px',
|
||||||
...(config && Object.keys(config).length > 0 && config)
|
...(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"
|
<mat-progress-bar *ngIf="isLoading" data-automation-id="version-history-loading-bar" mode="indeterminate"
|
||||||
color="accent"></mat-progress-bar>
|
color="accent"></mat-progress-bar>
|
||||||
<mat-list class="adf-version-list adf-version-list-element" [hidden]="isLoading">
|
<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"
|
<mat-list-item class="adf-version-list-item"
|
||||||
*cdkVirtualFor="let version of versionsDataSource; let idx = index; let latestVersion = first">
|
*cdkVirtualFor="let version of versionsDataSource; let idx = index; let latestVersion = first">
|
||||||
<mat-icon class="adf-version-list-icon" matListItemIcon>insert_drive_file</mat-icon>
|
<mat-icon class="adf-version-list-icon" matListItemIcon>insert_drive_file</mat-icon>
|
||||||
@ -50,6 +50,7 @@
|
|||||||
{{ 'ADF_VERSION_LIST.ACTIONS.DOWNLOAD' | translate }}
|
{{ 'ADF_VERSION_LIST.ACTIONS.DOWNLOAD' | translate }}
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
|
*ngIf="allowVersionDelete"
|
||||||
[disabled]="!canDelete()"
|
[disabled]="!canDelete()"
|
||||||
[id]="'adf-version-list-action-delete-' + version.entry.id"
|
[id]="'adf-version-list-action-delete-' + version.entry.id"
|
||||||
(click)="deleteVersion(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 { ContentTestingModule } from '../testing/content.testing.module';
|
||||||
import { ContentVersionService } from './content-version.service';
|
import { ContentVersionService } from './content-version.service';
|
||||||
import { take } from 'rxjs/operators';
|
import { take } from 'rxjs/operators';
|
||||||
|
import { CdkFixedSizeVirtualScroll } from '@angular/cdk/scrolling';
|
||||||
|
|
||||||
describe('VersionListComponent', () => {
|
describe('VersionListComponent', () => {
|
||||||
let component: VersionListComponent;
|
let component: VersionListComponent;
|
||||||
@ -257,6 +258,14 @@ describe('VersionListComponent', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('Actions buttons', () => {
|
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 => {
|
const getActionMenuButton = (version = '1.0'): HTMLButtonElement => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
return fixture.debugElement.query(By.css(`[id="adf-version-list-action-menu-button-${version}"]`))?.nativeElement;
|
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;
|
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(() => {
|
beforeEach(() => {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
versionTest[1].entry.id = '1.1';
|
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()
|
@Input()
|
||||||
showActions = true;
|
showActions = true;
|
||||||
|
|
||||||
|
/** Enable/disable deletion of version */
|
||||||
|
@Input()
|
||||||
|
allowVersionDelete = true;
|
||||||
|
|
||||||
/** Emitted when a version is restored */
|
/** Emitted when a version is restored */
|
||||||
@Output()
|
@Output()
|
||||||
restored = new EventEmitter<Node>();
|
restored = new EventEmitter<Node>();
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<button mat-raised-button
|
<button mat-raised-button
|
||||||
id="adf-show-version-upload-button"
|
id="adf-show-version-upload-button"
|
||||||
|
class="adf-version-manager-upload-button"
|
||||||
(click)="toggleNewVersion()" color="primary"
|
(click)="toggleNewVersion()" color="primary"
|
||||||
*ngIf="uploadState ==='close'">{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.ADD' | translate }}
|
*ngIf="uploadState ==='close'">{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.ADD' | translate }}
|
||||||
</button>
|
</button>
|
||||||
@ -32,6 +33,9 @@
|
|||||||
[node]="node"
|
[node]="node"
|
||||||
[allowDownload]="allowDownload"
|
[allowDownload]="allowDownload"
|
||||||
[showComments]="showComments"
|
[showComments]="showComments"
|
||||||
|
[showActions]="showActions"
|
||||||
|
[allowViewVersions]="allowViewVersions"
|
||||||
|
[allowVersionDelete]="allowVersionDelete"
|
||||||
(deleted)="refresh($event)"
|
(deleted)="refresh($event)"
|
||||||
(restored)="refresh($event)"
|
(restored)="refresh($event)"
|
||||||
(viewVersion)="onViewVersion($event)">
|
(viewVersion)="onViewVersion($event)">
|
||||||
|
@ -41,6 +41,15 @@ adf-version-manager {
|
|||||||
|
|
||||||
.adf-version-list-table {
|
.adf-version-list-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
|
.adf-version-manager-upload-button {
|
||||||
|
margin-left: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
adf-version-list {
|
||||||
|
display: flex;
|
||||||
|
height: 538px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.adf-version-upload-table {
|
.adf-version-upload-table {
|
||||||
|
@ -118,4 +118,106 @@ describe('VersionManagerComponent', () => {
|
|||||||
expect(component.uploadState).toEqual('open');
|
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()
|
@Input()
|
||||||
allowDownload = true;
|
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. */
|
/** Emitted when a file is uploaded successfully. */
|
||||||
@Output()
|
@Output()
|
||||||
uploadSuccess = new EventEmitter<Node>();
|
uploadSuccess = new EventEmitter<Node>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user