Skip to content

Commit a97219e

Browse files
committed
feat(Backup): enhance delete repository modal with data encryption key notice and improved loading states
1 parent e320c12 commit a97219e

2 files changed

Lines changed: 69 additions & 13 deletions

File tree

core/ui/public/i18n/en/translation.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,10 @@
482482
"applications": "Application | Applications",
483483
"delete_destination": "Delete destination",
484484
"delete_repository_confirm": "Delete backup destination '{name}'?",
485-
"delete_repo_explanation_1": "Any scheduled backup using this destination will be deleted too, but your backed up data will be left intact on the original destination. This action is NOT reversible.",
485+
"delete_repo_notice_title": "Preserve the data encryption key",
486+
"delete_repo_notice_description": "The cluster backup contains the data encryption key for the backup destination. This key is required to access backup data in the future. Download it now and make sure it is stored safely.",
487+
"delete_repo_scheduled_warning": "Any scheduled backup using this destination will be deleted too. Backup up data will be left intact on the original destination.",
488+
"delete_repo_explanation_1": "This action cannot be undone.",
486489
"data_encryption_key": "Data encryption key",
487490
"type_repo_password_to_confirm": "Type destination password to confirm deletion",
488491
"select_backup_provider": "Select backup provider",

core/ui/src/views/Backup.vue

Lines changed: 65 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,7 @@
681681
:isShown="isShownDeleteRepoModal"
682682
:name="currentRepo.name"
683683
:title="$t('backup.delete_destination')"
684-
:warning="$t('common.please_read_carefully')"
684+
:isWarningShown="false"
685685
:description="
686686
$t('backup.delete_repository_confirm', {
687687
name: currentRepo.name,
@@ -692,6 +692,28 @@
692692
@hide="hideDeleteRepoModal"
693693
@confirmDelete="deleteRepo(currentRepo)"
694694
>
695+
<template slot="description">
696+
<NsInlineNotification
697+
kind="info"
698+
:title="$t('backup.delete_repo_notice_title')"
699+
:showCloseButton="false"
700+
:loading="loading.downloadClusterBackupNotice"
701+
v-if="currentRepo.password"
702+
@action="downloadClusterConfigurationBackup(false, true)"
703+
:actionLabel="$t('backup.download_cluster_configuration_backup')"
704+
:description="$t('backup.delete_repo_notice_description')"
705+
/>
706+
<p class="mg-top-sm">
707+
{{
708+
$t("backup.delete_repository_confirm", {
709+
name: currentRepo.name,
710+
})
711+
}}
712+
</p>
713+
<p class="mg-bottom-sm">
714+
{{ $t("backup.delete_repo_scheduled_warning") }}
715+
</p>
716+
</template>
695717
<template slot="explanation">
696718
<p class="mg-top-sm">{{ $t("backup.delete_repo_explanation_1") }}</p>
697719
</template>
@@ -866,6 +888,7 @@ export default {
866888
listBackups: true,
867889
alterBackup: false,
868890
downloadClusterBackup: false,
891+
downloadClusterBackupNotice: false,
869892
passwordClusterBackup: false,
870893
},
871894
error: {
@@ -1389,8 +1412,16 @@ export default {
13891412
this.loading.alterBackup = false;
13901413
this.listBackups();
13911414
},
1392-
async downloadClusterConfigurationBackup() {
1393-
this.loading.downloadClusterBackup = true;
1415+
async downloadClusterConfigurationBackup(
1416+
showLoading = true,
1417+
showNoticeLoading = false
1418+
) {
1419+
if (showLoading) {
1420+
this.loading.downloadClusterBackup = true;
1421+
}
1422+
if (showNoticeLoading) {
1423+
this.loading.downloadClusterBackupNotice = true;
1424+
}
13941425
const taskAction = "download-cluster-backup";
13951426
const eventId = this.getUuid();
13961427
@@ -1422,16 +1453,30 @@ export default {
14221453
if (err) {
14231454
console.error(`error creating task ${taskAction}`, err);
14241455
this.error.downloadClusterBackup = this.getErrorMessage(err);
1456+
this.loading.downloadClusterBackup = false;
1457+
this.loading.downloadClusterBackupNotice = false;
14251458
return;
14261459
}
14271460
},
14281461
downloadClusterBackupAborted(taskResult, taskContext) {
14291462
console.error(`${taskContext.action} aborted`, taskResult);
14301463
this.loading.downloadClusterBackup = false;
1464+
this.loading.downloadClusterBackupNotice = false;
14311465
},
14321466
downloadClusterBackupCompleted(taskContext, taskResult) {
14331467
this.loading.downloadClusterBackup = false;
1434-
const downloadUrl = `${window.location.protocol}//${window.location.hostname}/cluster-admin/backup/${taskResult.output.path}`;
1468+
this.loading.downloadClusterBackupNotice = false;
1469+
const path = taskResult && taskResult.output && taskResult.output.path;
1470+
1471+
if (!path) {
1472+
this.error.downloadClusterBackup = this.$t(
1473+
"error.cannot_retrieve_task_status"
1474+
);
1475+
return;
1476+
}
1477+
1478+
const apiBase = this.$root.apiUrl.replace(/\/api$/, "");
1479+
const downloadUrl = `${apiBase}/backup/${path}`;
14351480
14361481
const fileName =
14371482
"cluster-configuration-backup " +
@@ -1442,14 +1487,22 @@ export default {
14421487
url: downloadUrl,
14431488
method: "GET",
14441489
responseType: "blob",
1445-
}).then((response) => {
1446-
const url = window.URL.createObjectURL(new Blob([response.data]));
1447-
const link = document.createElement("a");
1448-
link.href = url;
1449-
link.setAttribute("download", fileName);
1450-
document.body.appendChild(link);
1451-
link.click();
1452-
});
1490+
timeout: 60000,
1491+
})
1492+
.then((response) => {
1493+
const blobUrl = window.URL.createObjectURL(new Blob([response.data]));
1494+
const link = document.createElement("a");
1495+
link.href = blobUrl;
1496+
link.setAttribute("download", fileName);
1497+
document.body.appendChild(link);
1498+
link.click();
1499+
link.remove();
1500+
window.URL.revokeObjectURL(blobUrl);
1501+
})
1502+
.catch((err) => {
1503+
console.error("downloadClusterBackupCompleted", err);
1504+
this.error.downloadClusterBackup = this.getErrorMessage(err);
1505+
});
14531506
},
14541507
reloadBackupRepositories() {
14551508
this.isSetClusterBackupPassword = true;

0 commit comments

Comments
 (0)