Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat(frontend): show disable database auto backup dialog (#2769)
Liu Ji40b7f2954949
diff --git a/frontend/src/components/EnvironmentForm.vue b/frontend/src/components/EnvironmentForm.vueindex a295c2fff2..43bad6291f 100644--- a/frontend/src/components/EnvironmentForm.vue+++ b/frontend/src/components/EnvironmentForm.vue@@ -29,7 +29,7 @@<div class="flex space-x-4"><BBCheckbox:value="(state.environmentTierPolicy.payload as EnvironmentTierPolicyPayload).environmentTier === 'PROTECTED'"- @toggle="on => {+ @toggle="(on: boolean) => {(state.environmentTierPolicy.payload as EnvironmentTierPolicyPayload).environmentTier = on ? 'PROTECTED' : 'UNPROTECTED'}"/>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 0bf4954e72..4292187fbc 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -209,7 +209,9 @@"show-help": "Show help","success": "Succeed","load-more": "Load more",- "access-denied": "Access denied"+ "access-denied": "Access denied",+ "no": "No",+ "yes": "Yes"},"error-page": {"go-back-home": "Go back home"@@ -670,7 +672,11 @@"create": "Create Environment","restore": "Restore this environment","successfully-updated-environment": "Successfully updated environment '{name}'.",- "protected": "Protected"+ "protected": "Protected",+ "disable-auto-backup": {+ "self": "Disable database automatic backup",+ "content": "Disabling automatic backup policy is not applied retroactively.\nAre you sure about applying to all databases in this environment?"+ }},"quick-start": {"bookmark-an-issue": "Bookmark an issue",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex fa62c4b159..c199e05e1b 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -209,7 +209,9 @@"show-help": "查看帮助","success": "成功","load-more": "加载更多",- "access-denied": "拒绝访问"+ "access-denied": "拒绝访问",+ "no": "否",+ "yes": "是"},"error-page": {"go-back-home": "回到主页"@@ -670,7 +672,11 @@"create": "创建环境","restore": "恢复此环境","successfully-updated-environment": "环境'{0}'更新成功",- "protected": "受保护的"+ "protected": "受保护的",+ "disable-auto-backup": {+ "self": "禁用数据库自动备份",+ "content": "禁用自动备份策略仅对新添加的数据库生效。\n是否要将该设置应用到当前环境下的所有数据库?"+ }},"quick-start": {"bookmark-an-issue": "收藏工单",diff --git a/frontend/src/store/modules/backup.ts b/frontend/src/store/modules/backup.tsindex c60e9cf4c7..0b40b10ed9 100644--- a/frontend/src/store/modules/backup.ts+++ b/frontend/src/store/modules/backup.ts@@ -9,6 +9,7 @@ import {BackupSettingUpsert,BackupState,DatabaseId,+ EnvironmentId,ResourceObject,unknown,} from "@/types";@@ -193,6 +194,19 @@ export const useBackupStore = defineStore("backup", {return updatedBackupSetting;},++ async upsertBackupSettingByEnvironmentId(+ environmentId: EnvironmentId,+ backupSettingUpsert: Omit<BackupSettingUpsert, "databaseId">+ ) {+ const url = `/api/environment/${environmentId}/backup-setting`;+ await axios.patch(url, {+ data: {+ type: "backupSettingUpsert",+ attributes: backupSettingUpsert,+ },+ });+ },},});diff --git a/frontend/src/views/EnvironmentDetail.vue b/frontend/src/views/EnvironmentDetail.vueindex b32a33e1fb..e8a8d87db1 100644--- a/frontend/src/views/EnvironmentDetail.vue+++ b/frontend/src/views/EnvironmentDetail.vue@@ -20,10 +20,38 @@:feature="state.missingRequiredFeature"@cancel="state.missingRequiredFeature = undefined"/>+ <BBModal+ v-if="state.showDisableAutoBackupModal"+ :title="$t('environment.disable-auto-backup.self')"+ @close="state.showDisableAutoBackupModal = false"+ >+ <div class="space-y-2 textinfolabel pr-16">+ <p v-for="(line, i) in disableAutoBackupContent.split('\n')" :key="i">+ {{ line }}+ </p>+ </div>++ <div class="flex items-center justify-end pt-4 mt-4 border-t">+ <button+ type="button"+ class="btn-normal py-2 px-4"+ @click="state.showDisableAutoBackupModal = false"+ >+ {{ $t("common.no") }}+ </button>+ <button+ type="submit"+ class="btn-primary ml-3 inline-flex justify-center py-2 px-4"+ @click="disableEnvironmentAutoBackup"+ >+ {{ $t("common.yes") }}+ </button>+ </div>+ </BBModal></template><script lang="ts">-import { defineComponent, reactive, watchEffect } from "vue";+import { computed, defineComponent, reactive, watchEffect } from "vue";import ArchiveBanner from "../components/ArchiveBanner.vue";import EnvironmentForm from "../components/EnvironmentForm.vue";import {@@ -43,10 +71,12 @@ import { idFromSlug } from "../utils";import {hasFeature,pushNotification,+ useBackupStore,useEnvironmentStore,usePolicyStore,} from "@/store";import { useI18n } from "vue-i18n";+import BBModal from "@/bbkit/BBModal.vue";interface LocalState {environment: Environment;@@ -58,6 +88,7 @@ interface LocalState {| "bb.feature.approval-policy"| "bb.feature.backup-policy"| "bb.feature.environment-tier-policy";+ showDisableAutoBackupModal: boolean;}export default defineComponent({@@ -65,6 +96,7 @@ export default defineComponent({components: {ArchiveBanner,EnvironmentForm,+ BBModal,},props: {environmentSlug: {@@ -76,6 +108,7 @@ export default defineComponent({setup(props, { emit }) {const environmentStore = useEnvironmentStore();const policyStore = usePolicyStore();+ const backupStore = useBackupStore();const { t } = useI18n();const state = reactive<LocalState>({@@ -83,6 +116,7 @@ export default defineComponent({idFromSlug(props.environmentSlug)),showArchiveModal: false,+ showDisableAutoBackupModal: false,});const preparePolicy = () => {@@ -168,6 +202,16 @@ export default defineComponent({});};+ const success = () => {+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("environment.successfully-updated-environment", {+ name: state.environment.name,+ }),+ });+ };+const updatePolicy = (environmentId: EnvironmentId,type: PolicyType,@@ -221,23 +265,46 @@ export default defineComponent({policy.payload as EnvironmentTierPolicyPayload).environmentTier;}+ success();- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: t("environment.successfully-updated-environment", {- name: state.environment.name,- }),- });+ if (type === "bb.policy.backup-plan") {+ const payload = state.backupPolicy!+ .payload as BackupPlanPolicyPayload;+ if (payload.schedule === "UNSET") {+ // Changing backup policy from "DAILY"|"WEEKLY" to "UNSET"+ state.showDisableAutoBackupModal = true;+ }+ }});};+ const disableAutoBackupContent = computed(() => {+ return t("environment.disable-auto-backup.content");+ });++ const disableEnvironmentAutoBackup = async () => {+ await backupStore.upsertBackupSettingByEnvironmentId(+ state.environment.id,+ {+ enabled: false,+ hour: 0,+ dayOfWeek: 0,+ retentionPeriodTs: 0,+ hookUrl: "",+ }+ );+ success();+ state.showDisableAutoBackupModal = false;+ };+return {state,doUpdate,doArchive,doRestore,updatePolicy,+ disableAutoBackupContent,+ disableEnvironmentAutoBackup,};},});