ACS-7408: version manager as standalone

This commit is contained in:
Denys Vuika
2024-07-25 12:23:21 -04:00
parent f24003ca1b
commit 2e75d64995
10 changed files with 87 additions and 60 deletions

View File

@@ -25,7 +25,7 @@ import { DocumentListModule } from './document-list/document-list.module';
import { UploadModule } from './upload/upload.module'; import { UploadModule } from './upload/upload.module';
import { SearchModule } from './search/search.module'; import { SearchModule } from './search/search.module';
import { BREADCRUMB_DIRECTIVES } from './breadcrumb/breadcrumb.module'; import { BREADCRUMB_DIRECTIVES } from './breadcrumb/breadcrumb.module';
import { VersionManagerModule } from './version-manager/version-manager.module'; import { CONTENT_VERSION_DIRECTIVES } from './version-manager/version-manager.module';
import { ContentNodeSelectorModule } from './content-node-selector/content-node-selector.module'; import { ContentNodeSelectorModule } from './content-node-selector/content-node-selector.module';
import { ContentNodeShareModule } from './content-node-share/content-node-share.module'; import { ContentNodeShareModule } from './content-node-share/content-node-share.module';
import { ContentDirectiveModule } from './directives/content-directive.module'; import { ContentDirectiveModule } from './directives/content-directive.module';
@@ -68,7 +68,7 @@ import { NewVersionUploaderDialogComponent } from './new-version-uploader';
...CONTENT_METADATA_DIRECTIVES, ...CONTENT_METADATA_DIRECTIVES,
ContentDirectiveModule, ContentDirectiveModule,
PermissionManagerModule, PermissionManagerModule,
VersionManagerModule, ...CONTENT_VERSION_DIRECTIVES,
TreeViewModule, TreeViewModule,
ContentTypeModule, ContentTypeModule,
AspectListModule, AspectListModule,
@@ -95,7 +95,7 @@ import { NewVersionUploaderDialogComponent } from './new-version-uploader';
...CONTENT_DIALOG_DIRECTIVES, ...CONTENT_DIALOG_DIRECTIVES,
ContentDirectiveModule, ContentDirectiveModule,
PermissionManagerModule, PermissionManagerModule,
VersionManagerModule, ...CONTENT_VERSION_DIRECTIVES,
TreeViewModule, TreeViewModule,
AspectListModule, AspectListModule,
ContentTypeModule, ContentTypeModule,

View File

@@ -44,8 +44,14 @@ describe('NewVersionUploaderDialog', () => {
beforeEach(() => { beforeEach(() => {
TestBed.configureTestingModule({ TestBed.configureTestingModule({
imports: [ContentTestingModule, NewVersionUploaderDialogComponent], imports: [
declarations: [VersionListComponent, VersionUploadComponent, UploadVersionButtonComponent, VersionComparisonComponent], ContentTestingModule,
NewVersionUploaderDialogComponent,
VersionListComponent,
VersionUploadComponent,
VersionComparisonComponent
],
declarations: [UploadVersionButtonComponent],
providers: [ providers: [
{ provide: MAT_DIALOG_DATA, useValue: { node: mockNode, showVersionsOnly, file: mockFile } }, { provide: MAT_DIALOG_DATA, useValue: { node: mockNode, showVersionsOnly, file: mockFile } },
{ {

View File

@@ -1,6 +1,6 @@
<div class="adf-version-comparison-content"> <div class="adf-version-comparison-content">
<div class="adf-version-current"> <div class="adf-version-current">
<p>{{'ADF_VERSION_COMPARISON.CURRENT_VERSION'|translate }}</p> <p>{{'ADF_VERSION_COMPARISON.CURRENT_VERSION' | translate }}</p>
<img [attr.aria-label]="'ADF_VERSION_COMPARISON.ACCESSIBILITY.ICON_TEXT' | translate: <img [attr.aria-label]="'ADF_VERSION_COMPARISON.ACCESSIBILITY.ICON_TEXT' | translate:
{ type: (node.content.mimeType | fileType | uppercase) | translate }" { type: (node.content.mimeType | fileType | uppercase) | translate }"
[attr.alt]="'ADF_VERSION_COMPARISON.ACCESSIBILITY.ICON_TEXT' | translate: [attr.alt]="'ADF_VERSION_COMPARISON.ACCESSIBILITY.ICON_TEXT' | translate:
@@ -10,7 +10,7 @@
</div> </div>
<span class="material-icons adf-version-arrow-icon">keyboard_arrow_right</span> <span class="material-icons adf-version-arrow-icon">keyboard_arrow_right</span>
<div class="adf-version-new"> <div class="adf-version-new">
<p>{{'ADF_VERSION_COMPARISON.NEW_VERSION'|translate }}</p> <p>{{'ADF_VERSION_COMPARISON.NEW_VERSION' | translate }}</p>
<img [attr.aria-label]="'ADF_VERSION_COMPARISON.ACCESSIBILITY.ICON_TEXT' | translate: <img [attr.aria-label]="'ADF_VERSION_COMPARISON.ACCESSIBILITY.ICON_TEXT' | translate:
{ type: (newFileVersion.type | fileType | uppercase) | translate }" { type: (newFileVersion.type | fileType | uppercase) | translate }"
[attr.alt]="'ADF_VERSION_COMPARISON.ACCESSIBILITY.ICON_TEXT' | translate: [attr.alt]="'ADF_VERSION_COMPARISON.ACCESSIBILITY.ICON_TEXT' | translate:

View File

@@ -17,16 +17,19 @@
import { Component, Input, ViewEncapsulation } from '@angular/core'; import { Component, Input, ViewEncapsulation } from '@angular/core';
import { Node } from '@alfresco/js-api'; import { Node } from '@alfresco/js-api';
import { ThumbnailService } from '@alfresco/adf-core'; import { FileTypePipe, ThumbnailService } from '@alfresco/adf-core';
import { CommonModule } from '@angular/common';
import { TranslateModule } from '@ngx-translate/core';
@Component({ @Component({
selector: 'adf-version-comparison', selector: 'adf-version-comparison',
standalone: true,
imports: [CommonModule, TranslateModule, FileTypePipe],
templateUrl: './version-comparison.component.html', templateUrl: './version-comparison.component.html',
styleUrls: ['./version-comparison.component.scss'], styleUrls: ['./version-comparison.component.scss'],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class VersionComparisonComponent { export class VersionComparisonComponent {
/** Target node. */ /** Target node. */
@Input() @Input()
node: Node; node: Node;
@@ -35,7 +38,5 @@ export class VersionComparisonComponent {
@Input() @Input()
newFileVersion: File; newFileVersion: File;
constructor(public thumbnailService: ThumbnailService) { constructor(public thumbnailService: ThumbnailService) {}
}
} }

View File

@@ -24,7 +24,15 @@ import { ContentService } from '../common';
import { InfiniteScrollDatasource } from '../infinite-scroll-datasource'; import { InfiniteScrollDatasource } from '../infinite-scroll-datasource';
import { from, Observable, Subject } from 'rxjs'; import { from, Observable, Subject } from 'rxjs';
import { map, take, takeUntil } from 'rxjs/operators'; import { map, take, takeUntil } from 'rxjs/operators';
import { CdkVirtualScrollViewport } from '@angular/cdk/scrolling'; import { CdkFixedSizeVirtualScroll, CdkVirtualForOf, CdkVirtualScrollViewport } from '@angular/cdk/scrolling';
import { CommonModule } from '@angular/common';
import { MatProgressBarModule } from '@angular/material/progress-bar';
import { MatListModule } from '@angular/material/list';
import { MatIconModule } from '@angular/material/icon';
import { MatMenuModule } from '@angular/material/menu';
import { VersionCompatibilityModule } from '../version-compatibility';
import { TranslateModule } from '@ngx-translate/core';
import { MatButtonModule } from '@angular/material/button';
export class VersionListDataSource extends InfiniteScrollDatasource<VersionEntry> { export class VersionListDataSource extends InfiniteScrollDatasource<VersionEntry> {
constructor(private versionsApi: VersionsApi, private node: Node) { constructor(private versionsApi: VersionsApi, private node: Node) {
@@ -41,6 +49,20 @@ export class VersionListDataSource extends InfiniteScrollDatasource<VersionEntry
@Component({ @Component({
selector: 'adf-version-list', selector: 'adf-version-list',
standalone: true,
imports: [
CommonModule,
MatProgressBarModule,
MatListModule,
CdkVirtualScrollViewport,
CdkFixedSizeVirtualScroll,
CdkVirtualForOf,
MatIconModule,
MatMenuModule,
VersionCompatibilityModule,
TranslateModule,
MatButtonModule
],
templateUrl: './version-list.component.html', templateUrl: './version-list.component.html',
styleUrls: ['./version-list.component.scss'], styleUrls: ['./version-list.component.scss'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,

View File

@@ -1,7 +1,5 @@
<div class="adf-new-version-container"> <div class="adf-new-version-container">
<adf-version-comparison *ngIf="showVersionComparison" [node]="node" [newFileVersion]="newFileVersion"></adf-version-comparison> <adf-version-comparison *ngIf="showVersionComparison" [node]="node" [newFileVersion]="newFileVersion"></adf-version-comparison>
<div class="adf-new-version-uploader-container" id="adf-new-version-uploader-container" [@uploadToggle]="uploadState"> <div class="adf-new-version-uploader-container" id="adf-new-version-uploader-container" [@uploadToggle]="uploadState">
<table class="adf-version-upload" *ngIf="uploadState !== 'close' && !versionList.isLoading"> <table class="adf-version-upload" *ngIf="uploadState !== 'close' && !versionList.isLoading">
<tr> <tr>
@@ -19,20 +17,16 @@
</tr> </tr>
</table> </table>
</div> </div>
<div class="adf-version-list-container"> <div class="adf-version-list-container">
<div class="adf-version-list-table"> <div class="adf-version-list-table">
<div> <div>
<button mat-raised-button <button mat-raised-button
id="adf-show-version-upload-button" id="adf-show-version-upload-button"
(click)="toggleNewVersion()" color="primary" (click)="toggleNewVersion()" color="primary"
*ngIf="uploadState ==='close'">{{ *ngIf="uploadState ==='close'">{{ 'ADF_VERSION_LIST.ACTIONS.UPLOAD.ADD' | translate }}
'ADF_VERSION_LIST.ACTIONS.UPLOAD.ADD'|
translate }}
</button> </button>
</div> </div>
<div> <div>
<adf-version-list <adf-version-list
#versionList #versionList
[node]="node" [node]="node"

View File

@@ -22,29 +22,29 @@ import { trigger, state, style, animate, transition } from '@angular/animations'
import { ContentService } from '../common/services/content.service'; import { ContentService } from '../common/services/content.service';
import { NodesApiService } from '../common/services/nodes-api.service'; import { NodesApiService } from '../common/services/nodes-api.service';
import { FileUploadErrorEvent } from '../common/events/file.event'; import { FileUploadErrorEvent } from '../common/events/file.event';
import { CommonModule } from '@angular/common';
import { VersionComparisonComponent } from './version-comparison.component';
import { VersionUploadComponent } from './version-upload.component';
import { MatButtonModule } from '@angular/material/button';
import { TranslateModule } from '@ngx-translate/core';
@Component({ @Component({
selector: 'adf-version-manager', selector: 'adf-version-manager',
standalone: true,
imports: [CommonModule, VersionComparisonComponent, VersionUploadComponent, MatButtonModule, TranslateModule, VersionListComponent],
templateUrl: './version-manager.component.html', templateUrl: './version-manager.component.html',
styleUrls: ['./version-manager.component.scss'], styleUrls: ['./version-manager.component.scss'],
animations: [ animations: [
trigger('uploadToggle', [ trigger('uploadToggle', [
state('open', style({height: '175px', opacity: 1, visibility: 'visible'})), state('open', style({ height: '175px', opacity: 1, visibility: 'visible' })),
state('close', style({height: '0%', opacity: 0, visibility: 'hidden'})), state('close', style({ height: '0%', opacity: 0, visibility: 'hidden' })),
transition('open => close', [ transition('open => close', [style({ visibility: 'hidden' }), animate('0.4s cubic-bezier(0.25, 0.8, 0.25, 1)')]),
style({visibility: 'hidden'}), transition('close => open', [style({ visibility: 'visible' }), animate('0.4s cubic-bezier(0.25, 0.8, 0.25, 1)')])
animate('0.4s cubic-bezier(0.25, 0.8, 0.25, 1)')
]),
transition('close => open', [
style({visibility: 'visible'}),
animate('0.4s cubic-bezier(0.25, 0.8, 0.25, 1)')
])
]) ])
], ],
encapsulation: ViewEncapsulation.None encapsulation: ViewEncapsulation.None
}) })
export class VersionManagerComponent implements OnInit { export class VersionManagerComponent implements OnInit {
/** Target node to manage version history. */ /** Target node to manage version history. */
@Input() @Input()
node: Node; node: Node;
@@ -86,9 +86,7 @@ export class VersionManagerComponent implements OnInit {
uploadState: string = 'close'; uploadState: string = 'close';
constructor(private contentService: ContentService, constructor(private contentService: ContentService, private nodesApiService: NodesApiService) {}
private nodesApiService: NodesApiService) {
}
ngOnInit() { ngOnInit() {
if (this.newFileVersion) { if (this.newFileVersion) {

View File

@@ -15,23 +15,22 @@
* limitations under the License. * limitations under the License.
*/ */
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { MaterialModule } from '../material.module';
import { VersionUploadComponent } from './version-upload.component'; import { VersionUploadComponent } from './version-upload.component';
import { VersionManagerComponent } from './version-manager.component'; import { VersionManagerComponent } from './version-manager.component';
import { VersionListComponent } from './version-list.component'; import { VersionListComponent } from './version-list.component';
import { UploadModule } from '../upload/upload.module';
import { VersionCompatibilityModule } from '../version-compatibility/version-compatibility.module';
import { CoreModule, FileTypePipe } from '@alfresco/adf-core';
import { VersionComparisonComponent } from './version-comparison.component'; import { VersionComparisonComponent } from './version-comparison.component';
import { ScrollingModule } from '@angular/cdk/scrolling';
export const CONTENT_VERSION_DIRECTIVES = [
VersionUploadComponent,
VersionManagerComponent,
VersionListComponent,
VersionComparisonComponent
] as const;
/** @deprecated use `...CONTENT_VERSION_DIRECTIVES` instead */
@NgModule({ @NgModule({
imports: [CommonModule, MaterialModule, CoreModule, UploadModule, VersionCompatibilityModule, FormsModule, ScrollingModule, FileTypePipe], imports: [...CONTENT_VERSION_DIRECTIVES],
exports: [VersionUploadComponent, VersionManagerComponent, VersionListComponent, FormsModule, VersionComparisonComponent], exports: [...CONTENT_VERSION_DIRECTIVES]
declarations: [VersionUploadComponent, VersionManagerComponent, VersionListComponent, VersionComparisonComponent]
}) })
export class VersionManagerModule {} export class VersionManagerModule {}

View File

@@ -8,11 +8,12 @@
</mat-radio-button> </mat-radio-button>
</mat-radio-group> </mat-radio-group>
<mat-form-field class="adf-new-version-max-width" subscriptSizing="dynamic"> <mat-form-field class="adf-new-version-max-width" subscriptSizing="dynamic">
<mat-label>{{'ADF_VERSION_LIST.ACTIONS.UPLOAD.COMMENT' | translate}}</mat-label> <mat-label>{{'ADF_VERSION_LIST.ACTIONS.UPLOAD.COMMENT' | translate}}</mat-label>
<textarea matInput [(ngModel)]="comment" class="adf-new-version-text-area" id="adf-new-version-text-area" <textarea matInput
(change)="onCommentChange()"></textarea> [(ngModel)]="comment"
class="adf-new-version-text-area" id="adf-new-version-text-area"
(change)="onCommentChange()"></textarea>
</mat-form-field> </mat-form-field>
</div> </div>
<div class="adf-version-upload-buttons"> <div class="adf-version-upload-buttons">
<adf-upload-version-button *ngIf="showUploadButton" <adf-upload-version-button *ngIf="showUploadButton"

View File

@@ -22,16 +22,25 @@ import { takeUntil } from 'rxjs/operators';
import { ContentService } from '../common/services/content.service'; import { ContentService } from '../common/services/content.service';
import { UploadService } from '../common/services/upload.service'; import { UploadService } from '../common/services/upload.service';
import { FileUploadErrorEvent, FileUploadEvent } from '../common/events/file.event'; import { FileUploadErrorEvent, FileUploadEvent } from '../common/events/file.event';
import { CommonModule } from '@angular/common';
import { MatRadioModule } from '@angular/material/radio';
import { FormsModule } from '@angular/forms';
import { TranslateModule } from '@ngx-translate/core';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatInputModule } from '@angular/material/input';
import { UploadModule } from '../upload';
import { MatButtonModule } from '@angular/material/button';
@Component({ @Component({
selector: 'adf-version-upload', selector: 'adf-version-upload',
standalone: true,
imports: [CommonModule, MatRadioModule, FormsModule, TranslateModule, MatFormFieldModule, MatInputModule, UploadModule, MatButtonModule],
templateUrl: './version-upload.component.html', templateUrl: './version-upload.component.html',
styleUrls: ['./version-upload.component.scss'], styleUrls: ['./version-upload.component.scss'],
encapsulation: ViewEncapsulation.None, encapsulation: ViewEncapsulation.None,
host: { class: 'adf-version-upload' } host: { class: 'adf-version-upload' }
}) })
export class VersionUploadComponent implements OnInit, OnDestroy { export class VersionUploadComponent implements OnInit, OnDestroy {
semanticVersion: string = 'minor'; semanticVersion: string = 'minor';
comment: string; comment: string;
uploadVersion: boolean = false; uploadVersion: boolean = false;
@@ -89,16 +98,13 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
@Output() @Output()
uploadStarted = new EventEmitter<FileUploadEvent>(); uploadStarted = new EventEmitter<FileUploadEvent>();
constructor(private contentService: ContentService, private uploadService: UploadService) { constructor(private contentService: ContentService, private uploadService: UploadService) {}
}
ngOnInit() { ngOnInit() {
this.uploadService.fileUploadStarting this.uploadService.fileUploadStarting.pipe(takeUntil(this.onDestroy$)).subscribe((event: FileUploadEvent) => {
.pipe(takeUntil(this.onDestroy$)) this.disabled = true;
.subscribe((event: FileUploadEvent) => { this.uploadStarted.emit(event);
this.disabled = true; });
this.uploadStarted.emit(event);
});
} }
canUpload(): boolean { canUpload(): boolean {
@@ -143,8 +149,8 @@ export class VersionUploadComponent implements OnInit, OnDestroy {
} }
getNextMajorVersion(version: string): string { getNextMajorVersion(version: string): string {
const { major} = this.getParsedVersion(version); const { major } = this.getParsedVersion(version);
return `${major + 1 }.0`; return `${major + 1}.0`;
} }
private getParsedVersion(version: string) { private getParsedVersion(version: string) {