mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
[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:
committed by
Eugenio Romano
parent
7826eea946
commit
cc53d96698
@@ -27,7 +27,6 @@ import TestConfig = require('../../test.config');
|
|||||||
import resources = require('../../util/resources');
|
import resources = require('../../util/resources');
|
||||||
|
|
||||||
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
|
import { AlfrescoApiCompatibility as AlfrescoApi } from '@alfresco/js-api';
|
||||||
import { browser } from 'protractor';
|
|
||||||
|
|
||||||
describe('Upload component', () => {
|
describe('Upload component', () => {
|
||||||
const contentServicesPage = new ContentServicesPage();
|
const contentServicesPage = new ContentServicesPage();
|
||||||
@@ -81,7 +80,7 @@ describe('Upload component', () => {
|
|||||||
.clickOnCloseButton();
|
.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);
|
contentServicesPage.uploadFile(docxFileModel.location);
|
||||||
uploadDialog.fileIsUploaded(docxFileModel.name);
|
uploadDialog.fileIsUploaded(docxFileModel.name);
|
||||||
contentServicesPage.checkContentIsDisplayed(docxFileModel.name);
|
contentServicesPage.checkContentIsDisplayed(docxFileModel.name);
|
||||||
@@ -92,10 +91,7 @@ describe('Upload component', () => {
|
|||||||
fileModelVersion.location
|
fileModelVersion.location
|
||||||
);
|
);
|
||||||
versionManagePage.closeVersionDialog();
|
versionManagePage.closeVersionDialog();
|
||||||
uploadDialog
|
uploadDialog.removeUploadedFile(fileModelVersion.name);
|
||||||
.removeUploadedFile(fileModelVersion.name)
|
contentServicesPage.checkContentIsDisplayed(fileModelVersion.name);
|
||||||
.fileIsCancelled(fileModelVersion.name);
|
|
||||||
browser.refresh();
|
|
||||||
contentServicesPage.checkContentIsDisplayed(docxFileModel.name);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@@ -128,6 +128,9 @@
|
|||||||
"TITLE": "Cancel Upload",
|
"TITLE": "Cancel Upload",
|
||||||
"TEXT": "Stop uploading and remove files already uploaded."
|
"TEXT": "Stop uploading and remove files already uploaded."
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"ARIA-LABEL": {
|
||||||
|
"VERSION": "File version"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"FILE_UPLOAD": {
|
"FILE_UPLOAD": {
|
||||||
|
@@ -87,9 +87,5 @@
|
|||||||
text-transform: uppercase;
|
text-transform: uppercase;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& mat-icon {
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@
|
|||||||
</span>
|
</span>
|
||||||
|
|
||||||
<span *ngIf="isUploadVersion()" class="adf-file-uploading-row__version">
|
<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
|
versionNumber
|
||||||
}}</mat-chip>
|
}}</mat-chip>
|
||||||
</span>
|
</span>
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
*ngIf="file.status === FileUploadStatus.Complete"
|
*ngIf="file.status === FileUploadStatus.Complete && !isUploadVersion()"
|
||||||
(click)="onRemove(file)"
|
(click)="onRemove(file)"
|
||||||
class="adf-file-uploading-row__group adf-file-uploading-row__group--toggle"
|
class="adf-file-uploading-row__group adf-file-uploading-row__group--toggle"
|
||||||
title="{{ 'ADF_FILE_UPLOAD.BUTTON.REMOVE_FILE' | translate }}">
|
title="{{ 'ADF_FILE_UPLOAD.BUTTON.REMOVE_FILE' | translate }}">
|
||||||
@@ -51,6 +51,16 @@
|
|||||||
</mat-icon>
|
</mat-icon>
|
||||||
</div>
|
</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
|
<div
|
||||||
*ngIf="file.status === FileUploadStatus.Pending"
|
*ngIf="file.status === FileUploadStatus.Pending"
|
||||||
(click)="onCancel(file)"
|
(click)="onCancel(file)"
|
||||||
|
@@ -30,7 +30,7 @@
|
|||||||
padding: 0 1em 0 0.5em;
|
padding: 0 1em 0 0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__group, &__block {
|
&__group, &__block, &__file-version {
|
||||||
min-width: 100px;
|
min-width: 100px;
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: flex-end;
|
justify-content: flex-end;
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
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 { UploadModule } from '../upload.module';
|
||||||
import { FileUploadingListRowComponent } from './file-uploading-list-row.component';
|
import { FileUploadingListRowComponent } from './file-uploading-list-row.component';
|
||||||
|
|
||||||
@@ -70,4 +70,18 @@ describe('FileUploadingListRowComponent', () => {
|
|||||||
'.adf-file-uploading-row__version'
|
'.adf-file-uploading-row__version'
|
||||||
).textContent).toContain('1');
|
).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();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
@@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||||
import { TranslationService, FileUploadStatus, NodesApiService, UploadService,
|
import { TranslationService, FileUploadStatus, NodesApiService, UploadService,
|
||||||
setupTestBed, CoreModule, AlfrescoApiService, AlfrescoApiServiceMock, FileModel, FileUploadOptions
|
setupTestBed, CoreModule, AlfrescoApiService, AlfrescoApiServiceMock
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
import { of, throwError } from 'rxjs';
|
import { of, throwError } from 'rxjs';
|
||||||
import { UploadModule } from '../upload.module';
|
import { UploadModule } from '../upload.module';
|
||||||
@@ -30,7 +30,6 @@ describe('FileUploadingListComponent', () => {
|
|||||||
let uploadService: UploadService;
|
let uploadService: UploadService;
|
||||||
let nodesApiService: NodesApiService;
|
let nodesApiService: NodesApiService;
|
||||||
let translateService: TranslationService;
|
let translateService: TranslationService;
|
||||||
let alfrescoApiService: AlfrescoApiService;
|
|
||||||
let file: any;
|
let file: any;
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
@@ -56,7 +55,6 @@ describe('FileUploadingListComponent', () => {
|
|||||||
|
|
||||||
translateService = TestBed.get(TranslationService);
|
translateService = TestBed.get(TranslationService);
|
||||||
fixture = TestBed.createComponent(FileUploadingListComponent);
|
fixture = TestBed.createComponent(FileUploadingListComponent);
|
||||||
alfrescoApiService = TestBed.get(AlfrescoApiService);
|
|
||||||
component = fixture.componentInstance;
|
component = fixture.componentInstance;
|
||||||
|
|
||||||
spyOn(translateService, 'get').and.returnValue(of('some error message'));
|
spyOn(translateService, 'get').and.returnValue(of('some error message'));
|
||||||
@@ -108,30 +106,6 @@ describe('FileUploadingListComponent', () => {
|
|||||||
expect(uploadService.cancelUpload).toHaveBeenCalled();
|
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', () => {
|
describe('Events', () => {
|
||||||
|
|
||||||
it('should throw an error event if delete file goes wrong', (done) => {
|
it('should throw an error event if delete file goes wrong', (done) => {
|
||||||
|
@@ -19,7 +19,6 @@ import {
|
|||||||
FileModel,
|
FileModel,
|
||||||
FileUploadStatus,
|
FileUploadStatus,
|
||||||
NodesApiService,
|
NodesApiService,
|
||||||
AlfrescoApiService,
|
|
||||||
TranslationService,
|
TranslationService,
|
||||||
UploadService
|
UploadService
|
||||||
} from '@alfresco/adf-core';
|
} from '@alfresco/adf-core';
|
||||||
@@ -31,7 +30,7 @@ import {
|
|||||||
TemplateRef,
|
TemplateRef,
|
||||||
EventEmitter
|
EventEmitter
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { Observable, forkJoin, of, from } from 'rxjs';
|
import { Observable, forkJoin, of } from 'rxjs';
|
||||||
import { map, catchError } from 'rxjs/operators';
|
import { map, catchError } from 'rxjs/operators';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@@ -53,7 +52,6 @@ export class FileUploadingListComponent {
|
|||||||
error: EventEmitter<any> = new EventEmitter();
|
error: EventEmitter<any> = new EventEmitter();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private alfrescoApiService: AlfrescoApiService,
|
|
||||||
private uploadService: UploadService,
|
private uploadService: UploadService,
|
||||||
private nodesApi: NodesApiService,
|
private nodesApi: NodesApiService,
|
||||||
private translateService: TranslationService
|
private translateService: TranslationService
|
||||||
@@ -78,23 +76,14 @@ export class FileUploadingListComponent {
|
|||||||
* @memberOf FileUploadingListComponent
|
* @memberOf FileUploadingListComponent
|
||||||
*/
|
*/
|
||||||
removeFile(file: FileModel): void {
|
removeFile(file: FileModel): void {
|
||||||
if (file.options && file.options.newVersion) {
|
this.deleteNode(file).subscribe(() => {
|
||||||
this.deleteNodeVersion(file).subscribe(() => {
|
if (file.status === FileUploadStatus.Error) {
|
||||||
if (file.status === FileUploadStatus.Error) {
|
this.notifyError(file);
|
||||||
this.notifyError(file);
|
}
|
||||||
}
|
|
||||||
this.uploadService.cancelUpload(file);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.deleteNode(file).subscribe(() => {
|
|
||||||
if (file.status === FileUploadStatus.Error) {
|
|
||||||
this.notifyError(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.cancelNodeVersionInstances(file);
|
this.cancelNodeVersionInstances(file);
|
||||||
this.uploadService.cancelUpload(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) {
|
private cancelNodeVersionInstances(file) {
|
||||||
this.files
|
this.files
|
||||||
.filter(
|
.filter(
|
||||||
|
Reference in New Issue
Block a user