diff --git a/e2e/content-services/upload/remove-upload.e2e.ts b/e2e/content-services/upload/remove-upload.e2e.ts index 60100b4fb4..10bc747755 100644 --- a/e2e/content-services/upload/remove-upload.e2e.ts +++ b/e2e/content-services/upload/remove-upload.e2e.ts @@ -27,7 +27,6 @@ import TestConfig = require('../../test.config'); import resources = require('../../util/resources'); import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api'; -import { browser } from 'protractor'; describe('Upload component', () => { const contentServicesPage = new ContentServicesPage(); @@ -81,7 +80,7 @@ describe('Upload component', () => { .clickOnCloseButton(); }); - it('should revert to last version when remove uploaded version file', () => { + it('should not have remove action if uploaded file is a file version', () => { contentServicesPage.uploadFile(docxFileModel.location); uploadDialog.fileIsUploaded(docxFileModel.name); contentServicesPage.checkContentIsDisplayed(docxFileModel.name); @@ -92,10 +91,7 @@ describe('Upload component', () => { fileModelVersion.location ); versionManagePage.closeVersionDialog(); - uploadDialog - .removeUploadedFile(fileModelVersion.name) - .fileIsCancelled(fileModelVersion.name); - browser.refresh(); - contentServicesPage.checkContentIsDisplayed(docxFileModel.name); + uploadDialog.removeUploadedFile(fileModelVersion.name); + contentServicesPage.checkContentIsDisplayed(fileModelVersion.name); }); }); diff --git a/lib/content-services/i18n/en.json b/lib/content-services/i18n/en.json index bfbfd692ae..9034f6f2ee 100644 --- a/lib/content-services/i18n/en.json +++ b/lib/content-services/i18n/en.json @@ -128,6 +128,9 @@ "TITLE": "Cancel Upload", "TEXT": "Stop uploading and remove files already uploaded." } + }, + "ARIA-LABEL": { + "VERSION": "File version" } }, "FILE_UPLOAD": { diff --git a/lib/content-services/upload/components/file-uploading-dialog.component.scss b/lib/content-services/upload/components/file-uploading-dialog.component.scss index caf12dbfd1..500f28f13e 100644 --- a/lib/content-services/upload/components/file-uploading-dialog.component.scss +++ b/lib/content-services/upload/components/file-uploading-dialog.component.scss @@ -87,9 +87,5 @@ text-transform: uppercase; } } - - & mat-icon { - cursor: pointer; - } } } diff --git a/lib/content-services/upload/components/file-uploading-list-row.component.html b/lib/content-services/upload/components/file-uploading-list-row.component.html index 1a50d171d2..729b18c1ee 100644 --- a/lib/content-services/upload/components/file-uploading-list-row.component.html +++ b/lib/content-services/upload/components/file-uploading-list-row.component.html @@ -12,7 +12,7 @@ - {{ + {{ versionNumber }} @@ -34,7 +34,7 @@
@@ -51,6 +51,16 @@
+
+ + check_circle + +
+
{ '.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( { name: 'fake-name' }); + component.file.options = { 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(); + }); }); diff --git a/lib/content-services/upload/components/file-uploading-list.component.spec.ts b/lib/content-services/upload/components/file-uploading-list.component.spec.ts index c2e5789511..4afa46c18e 100644 --- a/lib/content-services/upload/components/file-uploading-list.component.spec.ts +++ b/lib/content-services/upload/components/file-uploading-list.component.spec.ts @@ -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( { name: 'fake-name' }); - file.options = { 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( { name: 'fake-name' }); - file.options = { 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) => { diff --git a/lib/content-services/upload/components/file-uploading-list.component.ts b/lib/content-services/upload/components/file-uploading-list.component.ts index c1954a11c8..bd31019ec8 100644 --- a/lib/content-services/upload/components/file-uploading-list.component.ts +++ b/lib/content-services/upload/components/file-uploading-list.component.ts @@ -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 = 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 { - 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(