Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: unify setting for deployment config (#15289)
ecmadao726ef8fa9959
diff --git a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vueindex 949937adcc..9f932aec89 100644--- a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue+++ b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue@@ -9,9 +9,14 @@</div><NDynamicTags:size="'large'"- :disabled="!allowEdit"+ :disabled="!allowEdit || loading":value="labelValues":render-tag="renderLabel"+ :input-props="{+ placeholder: $t('project.settings.issue-related.labels.placeholder'),+ clearable: true,+ }"+ :input-style="'min-width: 12rem;'"@update:value="onLabelsUpdate"/></div>@@ -26,7 +31,7 @@<NCheckboxv-model:checked="state.allowModifyStatement"size="large"- :disabled="!allowUpdateIssueProjectSetting"+ :disabled="!allowUpdateIssueProjectSetting || loading":label="$t('project.settings.issue-related.allow-modify-statement.self')"@@ -43,7 +48,7 @@<NCheckboxv-model:checked="state.autoResolveIssue"size="large"- :disabled="!allowUpdateIssueProjectSetting"+ :disabled="!allowUpdateIssueProjectSetting || loading":label="$t('project.settings.issue-related.auto-resolve-issue.self')"/><p class="text-sm text-gray-400 pl-6 ml-0.5">@@ -57,7 +62,9 @@v-model:checked="state.forceIssueLabels"size="large":disabled="- !allowUpdateIssueProjectSetting || state.issueLabels.length === 0+ !allowUpdateIssueProjectSetting ||+ state.issueLabels.length === 0 ||+ loading"><template #default>@@ -92,7 +99,7 @@<NCheckboxv-model:checked="state.enforceIssueTitle"size="large"- :disabled="!allowUpdateIssueProjectSetting"+ :disabled="!allowUpdateIssueProjectSetting || loading":label="$t('project.settings.issue-related.enforce-issue-title.self')"/><p class="text-sm text-gray-400 pl-6 ml-0.5">@@ -105,7 +112,7 @@<NCheckboxv-model:checked="state.allowSelfApproval"size="large"- :disabled="!allowUpdateIssueProjectSetting"+ :disabled="!allowUpdateIssueProjectSetting || loading":label="$t('project.settings.issue-related.allow-self-approval.self')"/><p class="text-sm text-gray-400 pl-6 ml-0.5">@@ -118,7 +125,7 @@<NCheckboxv-model:checked="state.autoEnableBackup"size="large"- :disabled="!allowUpdateIssueProjectSetting"+ :disabled="!allowUpdateIssueProjectSetting || loading":label="$t('project.settings.issue-related.auto-enable-backup.self')"/><p class="text-sm text-gray-400 pl-6 ml-0.5">@@ -131,7 +138,7 @@<NCheckboxv-model:checked="state.skipBackupErrors"size="large"- :disabled="!allowUpdateIssueProjectSetting"+ :disabled="!allowUpdateIssueProjectSetting || loading":label="$t('project.settings.issue-related.skip-backup-errors.self')"/><p class="text-sm text-gray-400 pl-6 ml-0.5">@@ -144,7 +151,7 @@<NCheckboxv-model:checked="state.postgresDatabaseTenantMode"size="large"- :disabled="!allowUpdateIssueProjectSetting"+ :disabled="!allowUpdateIssueProjectSetting || loading":label="$t('project.settings.issue-related.postgres-database-tenant-mode.self'@@ -173,7 +180,7 @@ import {NCheckbox,NTooltip,} from "naive-ui";-import { computed, reactive } from "vue";+import { computed, reactive, ref } from "vue";import { FeatureBadge } from "@/components/FeatureGuard";import { hasFeature, useProjectV1Store } from "@/store";import type { ComposedProject } from "@/types";@@ -215,6 +222,7 @@ const props = defineProps<{const projectStore = useProjectV1Store();const state = reactive<LocalState>(getInitialLocalState());+const loading = ref<boolean>(false);const labelValues = computed(() => state.issueLabels.map((l) => l.value));@@ -280,18 +288,25 @@ const renderLabel = (value: string, index: number) => {};const doUpdate = async () => {- const updateMask = getUpdateMask();- if (updateMask.length === 0) {+ if (loading.value) {return;}+ if (updateMask.value.length === 0) {+ return;+ }+ loading.value = true;const projectPatch = {...cloneDeep(props.project),...state,};- await projectStore.updateProject(projectPatch, updateMask);+ try {+ await projectStore.updateProject(projectPatch, updateMask.value);+ } finally {+ loading.value = false;+ }};-const getUpdateMask = () => {+const updateMask = computed(() => {const mask: string[] = [];if (!isEqual(state.issueLabels, props.project.issueLabels)) {mask.push("issue_labels");@@ -326,7 +341,7 @@ const getUpdateMask = () => {mask.push("postgres_database_tenant_mode");}return mask;-};+});defineExpose({isDirty: valueChanged,diff --git a/frontend/src/components/ProjectDeploymentConfigPanel.vue b/frontend/src/components/ProjectDeploymentConfigPanel.vueindex 4d9852a6f5..78759e8888 100644--- a/frontend/src/components/ProjectDeploymentConfigPanel.vue+++ b/frontend/src/components/ProjectDeploymentConfigPanel.vue@@ -32,44 +32,36 @@:description="$t('deployment-config.this-is-example-deployment-config')"></BBAttention>- <div v-else>- <DeploymentConfigTool- v-if="state.deployment.schedule"- :schedule="state.deployment.schedule"- :allow-edit="allowEdit"- :database-list="databaseList"- />- <div class="pt-4 border-t flex justify-between items-center">- <div class="flex items-center space-x-2">+ <DeploymentConfigTool+ v-else-if="state.deployment.schedule"+ :schedule="state.deployment.schedule"+ :allow-edit="allowEdit"+ :database-list="databaseList"+ />+ </div>+ <div v-if="isDeploymentConfigDirty" class="sticky bottom-0 z-10">+ <div+ class="flex justify-between w-full pt-4 border-t border-block-border bg-white"+ >+ <NButton @click.prevent="onCancel">+ {{ $t("common.cancel") }}+ </NButton>++ <NPopover :disabled="!state.error" trigger="hover">+ <template #trigger><NButton- :disabled="!allowResetToDefaultDeploymentConfig"- text- @click="resetToDefaultDeploymentConfig"+ type="primary"+ :disabled="!!state.error"+ @click="updateDeploymentConfig">- <template #icon>- <Undo2Icon class="w-4 h-auto" />- </template>- {{ $t("common.reset") }}+ {{ $t("common.confirm-and-update") }}</NButton>- </div>- <div v-if="allowEdit" class="flex items-center space-x-2">- <NPopover v-if="allowEdit" :disabled="!state.error" trigger="hover">- <template #trigger>- <NButton- type="primary"- :disabled="!allowUpdateDeploymentConfig"- @click="updateDeploymentConfig"- >- {{ $t("common.update") }}- </NButton>- </template>+ </template>- <span v-if="state.error" class="text-error">- {{ $t(state.error) }}- </span>- </NPopover>- </div>- </div>+ <span v-if="state.error" class="text-error">+ {{ $t(state.error) }}+ </span>+ </NPopover></div></div></div>@@ -79,13 +71,15 @@</template><script lang="ts" setup>+import { useEventListener } from "@vueuse/core";import { cloneDeep, isEqual } from "lodash-es";import { PlusIcon } from "lucide-vue-next";-import { Undo2Icon } from "lucide-vue-next";-import { NButton, NPopover, useDialog } from "naive-ui";+import { NButton, NPopover } from "naive-ui";import type { PropType } from "vue";import { computed, nextTick, reactive, watch, watchEffect } from "vue";import { useI18n } from "vue-i18n";+import { onBeforeRouteLeave } from "vue-router";+import { BBAttention, BBSpin } from "@/bbkit";import {getDefaultDeploymentConfig,pushNotification,@@ -104,7 +98,6 @@ import {validateDeploymentConfigV1,} from "../utils";import DeploymentConfigTool, { DeploymentMatrix } from "./DeploymentConfigTool";-import { BBAttention, BBSpin } from "@/bbkit";type LocalState = {ready: boolean;@@ -129,7 +122,6 @@ const props = defineProps({});const { t } = useI18n();-const dialog = useDialog();const deploymentConfigV1Store = useDeploymentConfigV1Store();const state = reactive<LocalState>({@@ -143,17 +135,6 @@ const isDeploymentConfigDirty = computed((): boolean => {return !isEqual(state.deployment, state.originalDeployment);});-const defaultDeploymentConfigSchedule = computed(- () => getDefaultDeploymentConfig().schedule-);--const allowResetToDefaultDeploymentConfig = computed((): boolean => {- return !isEqual(- defaultDeploymentConfigSchedule.value,- state.deployment?.schedule- );-});-const allowUpdateDeploymentConfig = computed((): boolean => {if (state.error) return false;if (!isDeploymentConfigDirty.value) return false;@@ -175,7 +156,10 @@ watchEffect(async () => {// We clone the saved deployment-config// <DeploymentConfigTool /> will mutate `state.deployment` directly// when update button clicked, we save the draft to backend.- state.deployment = cloneDeep(deploymentConfig);+ state.deployment = DeploymentConfig.fromPartial({+ ...getDefaultDeploymentConfig(),+ ...cloneDeep(deploymentConfig),+ });// clone the object to the backupstate.originalDeployment = cloneDeep(state.deployment);// clean up error and dirty status@@ -211,25 +195,9 @@ const validate = () => {state.error = validateDeploymentConfigV1(state.deployment);};-const resetToDefaultDeploymentConfig = () => {- dialog.create({- positiveText: t("common.confirm"),- negativeText: t("common.cancel"),- title: t("deployment-config.confirm-to-reset"),- autoFocus: false,- closable: false,- maskClosable: false,- closeOnEsc: false,- onNegativeClick: () => {- // nothing to do- },- onPositiveClick: () => {- state.deployment = DeploymentConfig.fromPartial({- ...cloneDeep(state.originalDeployment),- schedule: getDefaultDeploymentConfig().schedule,- });- resetStates();- },+const onCancel = () => {+ state.deployment = DeploymentConfig.fromPartial({+ ...cloneDeep(state.originalDeployment),});};@@ -263,4 +231,21 @@ watch(},{ deep: true });++useEventListener("beforeunload", (e) => {+ if (!isDeploymentConfigDirty.value) {+ return;+ }+ e.returnValue = t("common.leave-without-saving");+ return e.returnValue;+});++onBeforeRouteLeave((to, from, next) => {+ if (isDeploymentConfigDirty.value) {+ if (!window.confirm(t("common.leave-without-saving"))) {+ return;+ }+ }+ next();+});</script>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 87c75320b1..bfca6b79fe 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -217,7 +217,6 @@"resources": "Resources","closed": "Closed","options": "Options",- "reset": "Reset","refresh": "Refresh","rollback": "Rollback","rows": {@@ -1622,6 +1621,7 @@"self": "Labels","description": "Labels can be attached in the issues for management","configure-labels": "Configure labels",+ "placeholder": "Press Enter to add tag","force-issue-labels": {"self": "Require labels for all issues","description": "Require at least one label when creating issues.",@@ -1734,10 +1734,15 @@"this-is-example-deployment-config": "This is the deployment config example. You need to edit and save it.","add-stage": "Add stage","confirm-to-revert": "Confirm to revert your editing?",- "confirm-to-reset": "Confirm reset to default?","name-placeholder": "Stage name...","error": {- "env-in-selector-required": "\"Environment\" is required in each stage"+ "at-least-one-stage": "At least 1 stage",+ "stage-name-required": "Stage name is required",+ "at-least-one-selector": "At least 1 selector in each stage",+ "env-in-selector-required": "\"Environment\" is required in each stage",+ "env-selector-must-has-one-value": "\"Environment ID\" must has exactly one value",+ "key-required": "Key is required",+ "values-required": "Values are required"},"matched-databases": {"all": "All matched databases",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex eef8c73949..7c026bf9f3 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -217,7 +217,6 @@"resources": "Recursos","closed": "Cerrado","options": "Opciones",- "reset": "Reiniciar","refresh": "Actualizar","rollback": "Retroceder","rows": {@@ -1622,6 +1621,7 @@"self": "Etiquetas","description": "Se pueden colocar etiquetas en los problemas para su gestión.","configure-labels": "Configurar etiquetas",+ "placeholder": "Presione Enter para agregar etiqueta","force-issue-labels": {"self": "Requerir etiquetas para todos los problemas","description": "Exija al menos una etiqueta al crear problemas.",@@ -1734,10 +1734,15 @@"this-is-example-deployment-config": "Este es un ejemplo de configuración de implementación. Debe editarla y guardarla.","add-stage": "Agregar etapa","confirm-to-revert": "¿Confirmar para revertir la edición?",- "confirm-to-reset": "¿Confirmar el restablecimiento de los valores predeterminados?","name-placeholder": "Nombre de la etapa...","error": {- "env-in-selector-required": "Se requiere \"Entorno\" en cada etapa"+ "at-least-one-stage": "Al menos 1 etapa",+ "stage-name-required": "Se requiere el nombre de la etapa",+ "at-least-one-selector": "Al menos 1 selector en cada etapa",+ "env-in-selector-required": "Se requiere \"Entorno\" en cada etapa",+ "env-selector-must-has-one-value": "\"Entorno ID\" debe tener exactamente un valor",+ "key-required": "Se requiere una clave",+ "values-required": "Se requieren valores"},"matched-databases": {"all": "Todas las bases de datos coincidentes",diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex dd9a904271..fbc7dae264 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -217,7 +217,6 @@"resources": "リソース","closed": "閉まっている","options": "オプション",- "reset": "リセット","refresh": "リフレッシュ","rollback": "ロールバック","rows": {@@ -1622,6 +1621,7 @@"self": "ラベル","description": "問題にラベルを貼って管理できる","configure-labels": "ラベルを設定する",+ "placeholder": "Enterキーを押してタグを追加してください","force-issue-labels": {"self": "すべてのイシューにラベルが必要","description": "イシューを作成するときは、少なくとも 1 つのラベルが必要です。",@@ -1734,10 +1734,15 @@"this-is-example-deployment-config": "これはサンプルのデプロイ設定であり、編集して保存する必要があります。","add-stage": "ステージを追加","confirm-to-revert": "編集を元に戻してもよろしいですか?",- "confirm-to-reset": "デフォルトにリセットしますか?","name-placeholder": "芸名…","error": {- "env-in-selector-required": "各ステージには「環境」の選択条件が必要です"+ "at-least-one-stage": "少なくとも 1 つのステージが必要です",+ "stage-name-required": "ステージ名の指定が必要です",+ "at-least-one-selector": "各ステージには少なくとも 1 つの選択基準が必要です",+ "env-in-selector-required": "各ステージには「環境」の選択条件が必要です",+ "env-selector-must-has-one-value": "「環境 ID」の値は 1 つだけでなければなりません",+ "key-required": "キーを指定する必要があります",+ "values-required": "値を指定する必要があります"},"matched-databases": {"all": "一致したすべてのデータベース",diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 366a9d9dc5..c2f0de522c 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -217,7 +217,6 @@"resources": "Tài nguyên","closed": "Đã đóng","options": "Tùy chọn",- "reset": "Đặt lại","refresh": "Làm mới","rollback": "Hoàn tác","rows": {@@ -1622,6 +1621,7 @@"self": "Nhãn","description": "Có thể gắn nhãn vào các vấn đề để quản lý","configure-labels": "Cấu hình nhãn",+ "placeholder": "Nhấn Enter để thêm thẻ","force-issue-labels": {"self": "Yêu cầu nhãn cho tất cả các vấn đề","description": "Yêu cầu ít nhất một nhãn khi tạo vấn đề.",@@ -1734,10 +1734,15 @@"this-is-example-deployment-config": "Đây là ví dụ cấu hình triển khai. Bạn cần chỉnh sửa và lưu nó.","add-stage": "Thêm giai đoạn","confirm-to-revert": "Xác nhận hoàn tác chỉnh sửa của bạn?",- "confirm-to-reset": "Xác nhận đặt lại về mặc định?","name-placeholder": "Tên giai đoạn...","error": {- "env-in-selector-required": "\"Môi trường\" là bắt buộc trong mỗi giai đoạn"+ "at-least-one-stage": "Ít nhất 1 giai đoạn",+ "stage-name-required": "Tên sân khấu là bắt buộc",+ "at-least-one-selector": "Ít nhất 1 bộ chọn ở mỗi giai đoạn",+ "env-in-selector-required": "\"Môi trường\" là bắt buộc trong mỗi giai đoạn",+ "env-selector-must-has-one-value": "\"ID môi trường\" phải có đúng một giá trị",+ "key-required": "Chìa khóa là bắt buộc",+ "values-required": "Các giá trị được yêu cầu"},"matched-databases": {"all": "Tất cả cơ sở dữ liệu phù hợp",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 9e216aaa7b..ba5008d63d 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -217,7 +217,6 @@"resources": "资源","closed": "已关闭","options": "配置项",- "reset": "重置","refresh": "刷新","rollback": "回滚","rows": {@@ -1622,6 +1621,7 @@"self": "标签","description": "可以在工单中附加标签以便管理","configure-labels": "配置标签",+ "placeholder": "按 Enter 键添加标签","force-issue-labels": {"self": "要求所有工单都必须有标签","description": "创建工单时必须添加至少一个标签。",@@ -1734,10 +1734,15 @@"this-is-example-deployment-config": "这是部署配置的样例,您需要在此基础上编辑并保存。","add-stage": "添加阶段","confirm-to-revert": "确定撤销编辑?",- "confirm-to-reset": "确认重置为默认值吗?","name-placeholder": "阶段名称…","error": {- "env-in-selector-required": "每个阶段都需要有 \"Environment\" 选择条件"+ "at-least-one-stage": "至少需要 1 个阶段",+ "stage-name-required": "需要指定阶段名称",+ "at-least-one-selector": "每个阶段至少需要 1 个选择条件",+ "env-in-selector-required": "每个阶段都需要有 \"Environment\" 选择条件",+ "env-selector-must-has-one-value": "\"Environment ID\" 必须有且只有 1 个值",+ "key-required": "需要指定 Key",+ "values-required": "需要指定值"},"matched-databases": {"all": "所有匹配的数据库",diff --git a/frontend/src/utils/v1/deploymentConfig.ts b/frontend/src/utils/v1/deploymentConfig.tsindex dbb1de02d3..b296f5fb36 100644--- a/frontend/src/utils/v1/deploymentConfig.ts+++ b/frontend/src/utils/v1/deploymentConfig.ts@@ -1,4 +1,5 @@import { orderBy, uniq } from "lodash-es";+import { t } from "@/plugins/i18n";import type { ComposedDatabase } from "@/types";import type {DeploymentConfig,@@ -27,13 +28,13 @@ export const validateDeploymentConfigV1 = (): string | undefined => {const deployments = config.schedule?.deployments ?? [];if (deployments.length === 0) {- return "deployment-config.error.at-least-one-stage";+ return t("deployment-config.error.at-least-one-stage");}for (let i = 0; i < deployments.length; i++) {const deployment = deployments[i];if (!deployment.title.trim()) {- return "deployment-config.error.stage-name-required";+ return t("deployment-config.error.stage-name-required");}const error = validateDeploymentSpecV1(deployment.spec);if (error) return error;@@ -47,27 +48,27 @@ export const validateDeploymentSpecV1 = (): string | undefined => {const rules = spec?.labelSelector?.matchExpressions ?? [];if (rules.length === 0) {- return "deployment-config.error.at-least-one-selector";+ return t("deployment-config.error.at-least-one-selector");}const envRule = rules.find((rule) => rule.key === "environment");if (!envRule || envRule.operator !== OperatorType.OPERATOR_TYPE_IN) {- return "deployment-config.error.env-in-selector-required";+ return t("deployment-config.error.env-in-selector-required");}if (envRule.values.length !== 1) {- return "deployment-config.error.env-selector-must-has-one-value";+ return t("deployment-config.error.env-selector-must-has-one-value");}for (let i = 0; i < rules.length; i++) {const rule = rules[i];if (!rule.key) {- return "deployment-config.error.key-required";+ return t("deployment-config.error.key-required");}if ((rule.operator === OperatorType.OPERATOR_TYPE_IN ||rule.operator === OperatorType.OPERATOR_TYPE_NOT_IN) &&rule.values.length === 0) {- return "deployment-config.error.values-required";+ return t("deployment-config.error.values-required");}}return undefined;