[ADF-4410] Upload dialog - remove delete action of version upload (#4618)

* undo remove node version implementation

* clean up style

* version upload row style

* upload version row cells

* update tests

* fix aria label
This commit is contained in:
Cilibiu Bogdan
2019-04-18 16:36:37 +03:00
committed by Eugenio Romano
parent 7826eea946
commit cc53d96698
8 changed files with 43 additions and 79 deletions

View File

@@ -87,9 +87,5 @@
text-transform: uppercase;
}
}
& mat-icon {
cursor: pointer;
}
}
}

View File

@@ -12,7 +12,7 @@
</span>
<span *ngIf="isUploadVersion()" class="adf-file-uploading-row__version">
<mat-chip aria-label="file version" color="primary" disabled>{{
<mat-chip color="primary" [attr.aria-label]="'ADF_FILE_UPLOAD.ARIA-LABEL.VERSION' | translate" [title]="'version' + versionNumber" disabled>{{
versionNumber
}}</mat-chip>
</span>
@@ -34,7 +34,7 @@
</div>
<div
*ngIf="file.status === FileUploadStatus.Complete"
*ngIf="file.status === FileUploadStatus.Complete && !isUploadVersion()"
(click)="onRemove(file)"
class="adf-file-uploading-row__group adf-file-uploading-row__group--toggle"
title="{{ 'ADF_FILE_UPLOAD.BUTTON.REMOVE_FILE' | translate }}">
@@ -51,6 +51,16 @@
</mat-icon>
</div>
<div
*ngIf="file.status === FileUploadStatus.Complete && isUploadVersion()"
class="adf-file-uploading-row__file-version">
<mat-icon
mat-list-icon
class="adf-file-uploading-row__status--done">
check_circle
</mat-icon>
</div>
<div
*ngIf="file.status === FileUploadStatus.Pending"
(click)="onCancel(file)"

View File

@@ -30,7 +30,7 @@
padding: 0 1em 0 0.5em;
}
&__group, &__block {
&__group, &__block, &__file-version {
min-width: 100px;
display: flex;
justify-content: flex-end;

View File

@@ -16,7 +16,7 @@
*/
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { FileModel, CoreModule, FileUploadOptions } from '@alfresco/adf-core';
import { FileModel, CoreModule, FileUploadOptions, FileUploadStatus } from '@alfresco/adf-core';
import { UploadModule } from '../upload.module';
import { FileUploadingListRowComponent } from './file-uploading-list-row.component';
@@ -70,4 +70,18 @@ describe('FileUploadingListRowComponent', () => {
'.adf-file-uploading-row__version'
).textContent).toContain('1');
});
it('should not emit remove event on a version file', () => {
spyOn(component.remove, 'emit');
component.file = new FileModel(<File> { name: 'fake-name' });
component.file.options = <FileUploadOptions> { newVersion: true };
component.file.data = { entry: { properties: { 'cm:versionLabel': '1' } } };
component.file.status = FileUploadStatus.Complete;
fixture.detectChanges();
const uploadCompleteIcon = document.querySelector('.adf-file-uploading-row__file-version .adf-file-uploading-row__status--done');
uploadCompleteIcon.dispatchEvent(new MouseEvent('click'));
expect(component.remove.emit).not.toHaveBeenCalled();
});
});

View File

@@ -17,7 +17,7 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';
import { TranslationService, FileUploadStatus, NodesApiService, UploadService,
setupTestBed, CoreModule, AlfrescoApiService, AlfrescoApiServiceMock, FileModel, FileUploadOptions
setupTestBed, CoreModule, AlfrescoApiService, AlfrescoApiServiceMock
} from '@alfresco/adf-core';
import { of, throwError } from 'rxjs';
import { UploadModule } from '../upload.module';
@@ -30,7 +30,6 @@ describe('FileUploadingListComponent', () => {
let uploadService: UploadService;
let nodesApiService: NodesApiService;
let translateService: TranslationService;
let alfrescoApiService: AlfrescoApiService;
let file: any;
beforeEach(() => {
@@ -56,7 +55,6 @@ describe('FileUploadingListComponent', () => {
translateService = TestBed.get(TranslationService);
fixture = TestBed.createComponent(FileUploadingListComponent);
alfrescoApiService = TestBed.get(AlfrescoApiService);
component = fixture.componentInstance;
spyOn(translateService, 'get').and.returnValue(of('some error message'));
@@ -108,30 +106,6 @@ describe('FileUploadingListComponent', () => {
expect(uploadService.cancelUpload).toHaveBeenCalled();
});
it('should delete node version', () => {
spyOn(alfrescoApiService.versionsApi, 'deleteVersion').and.returnValue(of(file));
file = new FileModel(<File> { name: 'fake-name' });
file.options = <FileUploadOptions> { newVersion: true };
file.data = { entry: { id: 'nodeId', properties: { 'cm:versionLabel': '1' } } };
component.removeFile(file);
expect(alfrescoApiService.versionsApi.deleteVersion).toHaveBeenCalled();
});
it('should throw error when delete node version fails', (done) => {
spyOn(alfrescoApiService.versionsApi, 'deleteVersion').and.returnValue(throwError(file));
file = new FileModel(<File> { name: 'fake-name' });
file.options = <FileUploadOptions> { newVersion: true };
file.data = { entry: { id: 'nodeId', properties: { 'cm:versionLabel': '1' } } };
component.error.subscribe(() => {
done();
});
component.removeFile(file);
});
describe('Events', () => {
it('should throw an error event if delete file goes wrong', (done) => {

View File

@@ -19,7 +19,6 @@ import {
FileModel,
FileUploadStatus,
NodesApiService,
AlfrescoApiService,
TranslationService,
UploadService
} from '@alfresco/adf-core';
@@ -31,7 +30,7 @@ import {
TemplateRef,
EventEmitter
} from '@angular/core';
import { Observable, forkJoin, of, from } from 'rxjs';
import { Observable, forkJoin, of } from 'rxjs';
import { map, catchError } from 'rxjs/operators';
@Component({
@@ -53,7 +52,6 @@ export class FileUploadingListComponent {
error: EventEmitter<any> = new EventEmitter();
constructor(
private alfrescoApiService: AlfrescoApiService,
private uploadService: UploadService,
private nodesApi: NodesApiService,
private translateService: TranslationService
@@ -78,23 +76,14 @@ export class FileUploadingListComponent {
* @memberOf FileUploadingListComponent
*/
removeFile(file: FileModel): void {
if (file.options && file.options.newVersion) {
this.deleteNodeVersion(file).subscribe(() => {
if (file.status === FileUploadStatus.Error) {
this.notifyError(file);
}
this.uploadService.cancelUpload(file);
});
} else {
this.deleteNode(file).subscribe(() => {
if (file.status === FileUploadStatus.Error) {
this.notifyError(file);
}
this.deleteNode(file).subscribe(() => {
if (file.status === FileUploadStatus.Error) {
this.notifyError(file);
}
this.cancelNodeVersionInstances(file);
this.uploadService.cancelUpload(file);
});
}
this.cancelNodeVersionInstances(file);
this.uploadService.cancelUpload(file);
});
}
/**
@@ -168,24 +157,6 @@ export class FileUploadingListComponent {
);
}
private deleteNodeVersion(file: FileModel): Observable<FileModel> {
return from(
this.alfrescoApiService.versionsApi.deleteVersion(
file.data.entry.id,
file.data.entry.properties['cm:versionLabel']
)
).pipe(
map(() => {
file.status = FileUploadStatus.Deleted;
return file;
}),
catchError(() => {
file.status = FileUploadStatus.Error;
return of(file);
})
);
}
private cancelNodeVersionInstances(file) {
this.files
.filter(