From 570b90a3841e04edc5342c6590c5f00c0c61d824 Mon Sep 17 00:00:00 2001 From: Volker Theile Date: Tue, 24 Oct 2023 09:51:07 +0200 Subject: [PATCH] Allow the deletion of specific object versions Fixes: https://github.com/aquarist-labs/s3gw/issues/764 Signed-off-by: Volker Theile --- CHANGELOG.md | 6 +++ ...object-version-datatable-page.component.ts | 49 ++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0e9a4910..d1dc6608 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.23.0] + +### Added + +Allow the deletion of specific object versions (gh#aquarist-labs/s3gw#764). + ## [0.22.0] ### Changed diff --git a/src/frontend/src/app/pages/user/object/object-version-datatable-page/object-version-datatable-page.component.ts b/src/frontend/src/app/pages/user/object/object-version-datatable-page/object-version-datatable-page.component.ts index d7475123..8e6231c7 100644 --- a/src/frontend/src/app/pages/user/object/object-version-datatable-page/object-version-datatable-page.component.ts +++ b/src/frontend/src/app/pages/user/object/object-version-datatable-page/object-version-datatable-page.component.ts @@ -101,6 +101,17 @@ export class ObjectVersionDatatablePageComponent implements OnInit { }, callback: (event: Event, action: DatatableAction, table: Datatable) => this.doRestore(table.selected[0] as S3ObjectVersion) + }, + { + type: 'button', + text: TEXT('Delete'), + icon: this.icons.delete, + enabledConstraints: { + minSelected: 1, + maxSelected: 1 + }, + callback: (event: Event, action: DatatableAction, table: Datatable) => + this.doDelete(table.selected[0] as S3ObjectVersion) } ]; this.datatableColumns = [ @@ -186,6 +197,14 @@ export class ObjectVersionDatatablePageComponent implements OnInit { icon: this.icons.restore, disabled: object.IsDeleted || object.IsLatest, callback: () => this.doRestore(object) + }, + { + type: 'divider' + }, + { + title: TEXT('Delete'), + icon: this.icons.delete, + callback: () => this.doDelete(object) } ]; return result; @@ -201,7 +220,7 @@ export class ObjectVersionDatatablePageComponent implements OnInit { this.modalDialogService.yesNo( format( TEXT( - 'Are you sure you want to restore the following object?
Key: {{ key | reverse | truncate(45) | reverse }}
Version ID: {{ versionId }}' + 'Are you sure you want to restore this object version?
Key: {{ key | reverse | truncate(45) | reverse }}
Version ID: {{ versionId }}' ), { key: object.Key, @@ -212,7 +231,7 @@ export class ObjectVersionDatatablePageComponent implements OnInit { if (!restore) { return; } - this.blockUiService.start(TEXT('Please wait, restoring object...')); + this.blockUiService.start(TEXT('Please wait, restoring object version...')); this.subscriptions.add( this.s3BucketService .restoreObject(this.bid, object.Key!, object.VersionId!) @@ -222,4 +241,30 @@ export class ObjectVersionDatatablePageComponent implements OnInit { } ); } + + private doDelete(object: S3ObjectVersion): void { + this.modalDialogService.yesNo( + format( + TEXT( + 'Do you really want to delete this object version?
Key: {{ key | reverse | truncate(45) | reverse }}
Version ID: {{ versionId }}' + ), + { + key: object.Key, + versionId: object.VersionId + } + ), + (restore: boolean) => { + if (!restore) { + return; + } + this.blockUiService.start(TEXT('Please wait, deleting object version...')); + this.subscriptions.add( + this.s3BucketService + .deleteObject(this.bid, object.Key!, object.VersionId!) + .pipe(finalize(() => this.blockUiService.stop())) + .subscribe(() => this.loadData()) + ); + } + ); + } }