Skip to content

Commit

Permalink
[MNT-24660] version list action cannot be disabled using app conf (#1…
Browse files Browse the repository at this point in the history
…0308)

* 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
  • Loading branch information
AleksanderSklorz authored Oct 21, 2024
1 parent 1d739ed commit 8ebb8d1
Show file tree
Hide file tree
Showing 21 changed files with 577 additions and 216 deletions.
5 changes: 3 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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) ![Experimental](docassets/images/ExperimentalIcon.png) | 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) ![Experimental](docassets/images/ExperimentalIcon.png) | 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) ![Experimental](docassets/images/ExperimentalIcon.png) | 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) ![Experimental](docassets/images/ExperimentalIcon.png) | 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

Expand Down
52 changes: 52 additions & 0 deletions docs/content-services/components/new-version-uploader.dialog.md
Original file line number Diff line number Diff line change
@@ -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.

![Version Manager](../../docassets/images/new-version-uploader.png)
### 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)
29 changes: 16 additions & 13 deletions docs/content-services/components/version-list.component.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
Title: Version List component
Added: v2.0.0
Status: Experimental
Status: Active
Last reviewed: 2019-01-16
---

Expand All @@ -19,21 +19,22 @@ 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 |
| 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 |
| 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 |

## Details

Expand All @@ -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)
32 changes: 19 additions & 13 deletions docs/content-services/components/version-manager.component.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
Title: Version Manager Component
Added: v2.0.0
Status: Experimental
Status: Active
Last reviewed: 2019-01-16
---

Expand All @@ -11,8 +11,6 @@ Displays the version history of a node with the ability to upload a new version.

![Version Manager](../../docassets/images/version-manager.png)

`This component is still in experimental phase. It has several limitations which will be resolved soon.`

## Basic Usage

```html
Expand All @@ -27,13 +25,16 @@ 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). |
| 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

Expand All @@ -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.

| Action | Versions | Description |
| ------ | -------- | ----------- |
| Restore | All | Revert the current version to the selected one with creating a new version of it. |
| 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)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Binary file added docs/docassets/images/new-version-uploader.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/docassets/images/version-manager.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 9 additions & 0 deletions docs/versionIndex.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ <h1 class="adf-new-version-uploader-dialog-title" mat-dialog-title data-automati
<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)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@

.adf-version-list-element {
overflow: auto;
width: 100%;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
});
});
});
Loading

0 comments on commit 8ebb8d1

Please sign in to comment.