[ACA-3447] Cancel upload of new version removes existing version (#5815)

* instead of deleting the whole node when we upload and then cancel a new version, we delete the version in case

* reverting wrong auto indent

* fix case name of the unit test

* fix auto indent

* fix auto indent
This commit is contained in:
Urse Daniel
2020-06-24 20:14:18 +03:00
committed by GitHub
parent ed68ebb751
commit de975d22b8
2 changed files with 56 additions and 1 deletions

View File

@@ -275,7 +275,11 @@ export class UploadService {
.on('success', (data) => {
if (this.abortedFile === file.name) {
this.onUploadAborted(file);
this.deleteAbortedNode(data.entry.id);
if (file.id === undefined) {
this.deleteAbortedNode(data.entry.id);
} else {
this.deleteAbortedNodeVersion(data.entry.id, data.entry.properties['cm:versionLabel']);
}
if (emitter) {
emitter.emit({ value: 'File deleted' });
}
@@ -405,6 +409,13 @@ export class UploadService {
.then(() => (this.abortedFile = undefined));
}
private deleteAbortedNodeVersion(nodeId: string, versionId: string) {
this.apiService
.getInstance()
.core.versionsApi.deleteVersion(nodeId, versionId)
.then(() => (this.abortedFile = undefined));
}
private isSaveToAbortFile(file: FileModel): boolean {
return (
file.size > MIN_CANCELLABLE_FILE_SIZE &&