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): share ONE sheet among multiple tasks in an issue (#12265)
Liu Ji16fef1896c80
diff --git a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vueindex f81dfea20d..562a1871af 100644--- a/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue+++ b/frontend/src/components/AlterSchemaPrepForm/AlterSchemaPrepForm.vue@@ -291,6 +291,7 @@ import {useEnvironmentV1List,useProjectV1Store,useDBGroupStore,+ usePageMode,} from "@/store";import type { ComposedDatabase, FeatureType } from "@/types";import { UNKNOWN_ID, DEFAULT_PROJECT_V1_NAME } from "@/types";@@ -356,6 +357,9 @@ const currentUserV1 = useCurrentUserV1();const projectV1Store = useProjectV1Store();const databaseV1Store = useDatabaseV1Store();const dbGroupStore = useDBGroupStore();+const pageMode = usePageMode();++const isStandaloneMode = computed(() => pageMode.value === "STANDALONE");const featureModalContext = ref<{feature?: FeatureType;@@ -615,7 +619,12 @@ const generateMultiDb = async () => {(id) => selectableDatabaseList.value.find((db) => db.uid === id)!);- if (isEditSchema.value && allowUsingSchemaEditor(selectedDatabaseList)) {+ if (+ selectedDatabaseList.length === 1 &&+ isEditSchema.value &&+ allowUsingSchemaEditor(selectedDatabaseList) &&+ !isStandaloneMode.value+ ) {schemaEditorContext.value.databaseIdList = [...flattenSelectedDatabaseUidList.value,];diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vueindex d94822c6eb..b74ce7188f 100644--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue@@ -17,15 +17,6 @@🎈{{ $t("sql-review.unlock-full-feature") }}</NButton></div>-- <NButton- v-if="isCreating && allowApplyTaskStateToOthers"- :disabled="isEmpty(state.statement)"- size="tiny"- @click.prevent="applyTaskStateToOthers"- >- {{ $t("issue.apply-to-other-tasks") }}- </NButton></div><div@@ -216,7 +207,7 @@<script setup lang="ts">import { useElementSize } from "@vueuse/core";-import { cloneDeep, head } from "lodash-es";+import { cloneDeep, head, uniq } from "lodash-es";import { ExpandIcon } from "lucide-vue-next";import { NButton, NTooltip, useDialog } from "naive-ui";import { v1 as uuidv1 } from "uuid";@@ -226,7 +217,6 @@ import { useRoute } from "vue-router";import { ErrorList } from "@/components/IssueV1/components/common";import {databaseForTask,- getLocalSheetByName,useIssueContext,allowUserToEditStatementForTask,stageForTask,@@ -258,7 +248,6 @@ import {dialectOfEngineV1,} from "@/types";import { IssueStatus } from "@/types/proto/v1/issue_service";-import { TenantMode } from "@/types/proto/v1/project_service";import type { Task } from "@/types/proto/v1/rollout_service";import { Task_Type } from "@/types/proto/v1/rollout_service";import { Sheet } from "@/types/proto/v1/sheet_service";@@ -267,9 +256,9 @@ import {flattenTaskV1List,getSheetStatement,setSheetStatement,- sheetNameOfTaskV1,useInstanceV1EditorLanguage,getStatementSize,+ sheetNameOfTaskV1,} from "@/utils";import { useSQLAdviceMarkers } from "../useSQLAdviceMarkers";import FormatOnSaveCheckbox from "./FormatOnSaveCheckbox.vue";@@ -408,26 +397,6 @@ const shouldShowEditButton = computed(() => {return true;});-const allowApplyTaskStateToOthers = computed(() => {- if (!isCreating.value) {- return false;- }- if (!rolloutMode.value) {- return false;- }- if (project.value.tenantMode === TenantMode.TENANT_MODE_ENABLED) {- return !isDeploymentConfigChangeTaskV1(issue.value, selectedTask.value);- }-- const taskList = flattenTaskV1List(issue.value.rolloutEntity);- // Allowed when more than one tasks need SQL statement or sheet.- const count = taskList.filter((task) =>- TaskTypeListWithStatement.includes(task.type)- ).length;-- return count > 1;-});-const allowSaveSQL = computed((): boolean => {if (state.statement === "") {// Not allowed if the statement is empty.@@ -515,6 +484,35 @@ const chooseUpdateStatementTarget = () => {return d.promise;}+ const distinctSheetIds = uniq(+ targets.ALL.map((task) => sheetNameOfTaskV1(task))+ );+ // For new multiple-database issues, one sheet is shared among multiple tasks+ // So we should notice that the change will be applied to all tasks+ if (distinctSheetIds.length === 1 && targets.ALL.length > 1) {+ dialog.info({+ title: t("issue.update-statement.self", { type: statementTitle.value }),+ content: t(+ "issue.update-statement.current-change-will-apply-to-all-tasks"+ ),+ type: "info",+ autoFocus: false,+ closable: false,+ maskClosable: false,+ closeOnEsc: false,+ showIcon: false,+ positiveText: t("common.confirm"),+ negativeText: t("common.cancel"),+ onPositiveClick: () => {+ d.resolve({ target: "ALL", tasks: targets.ALL });+ },+ onNegativeClick: () => {+ d.resolve({ target: "CANCELED", tasks: [] });+ },+ });+ return d.promise;+ }+const $d = dialog.create({title: t("issue.update-statement.self", { type: statementTitle.value }),content: t("issue.update-statement.apply-current-change-to"),@@ -642,19 +640,6 @@ const handleUpdateStatement = async (statement: string, filename: string) => {}};-const applyTaskStateToOthers = async () => {- const taskList = flattenTaskV1List(issue.value.rolloutEntity).filter((task) =>- TaskTypeListWithStatement.includes(task.type)- );- for (let i = 0; i < taskList.length; i++) {- const task = taskList[i];- const sheetName = sheetNameOfTaskV1(task);- if (!sheetName) continue;- const sheet = getLocalSheetByName(sheetName);- setSheetStatement(sheet, state.statement);- }-};-const updateStatement = async (statement: string) => {const planPatch = cloneDeep(issue.value.planEntity);if (!planPatch) {diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.tsindex e197976c2c..8291d52180 100644--- a/frontend/src/components/IssueV1/logic/initialize/create.ts+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts@@ -159,7 +159,7 @@ export const buildPlan = async (params: CreateIssueParams) => {}} else {// build standard plan- plan.steps = await buildSteps(databaseUIDList, params, undefined);+ plan.steps = await buildSteps(databaseUIDList, params, nextUID());}return plan;};diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vueindex b9fca39973..d89d211c2d 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue@@ -292,6 +292,7 @@ const generateMultiDb = async (| "bb.issue.database.data.export") => {if (+ props.databases.length === 1 &&type === "bb.issue.database.schema.update" &&allowUsingSchemaEditor(props.databases) &&!isStandaloneMode.valuediff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex ee2dfdae08..07bd20742d 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1166,7 +1166,8 @@"selected-stage": "Selected stage","all-tasks": "All tasks"},- "current-change-will-apply-to-all-tasks-in-batch-mode": "In batch mode, current change will be applied to all tasks."+ "current-change-will-apply-to-all-tasks-in-batch-mode": "In batch mode, current change will be applied to all tasks.",+ "current-change-will-apply-to-all-tasks": "Current change will be applied to all tasks."},"not-editable-legacy-issue": "This issue is not editable because it was created in an old version of Bytebase","action-anyway": "{action} anyway",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 11e226df6a..c631fb81ca 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1166,7 +1166,8 @@"selected-stage": "Etapa seleccionada","all-tasks": "Todas las tareas"},- "current-change-will-apply-to-all-tasks-in-batch-mode": "En el modo por lotes, el cambio actual se aplicará a todas las tareas."+ "current-change-will-apply-to-all-tasks-in-batch-mode": "En el modo por lotes, el cambio actual se aplicará a todas las tareas.",+ "current-change-will-apply-to-all-tasks": "El cambio actual se aplicará a todas las tareas."},"not-editable-legacy-issue": "Este problema no es editable porque se creó en una versión anterior de Bytebase","action-anyway": "{action} de todos modos",@@ -3530,4 +3531,4 @@"self": "Última actualización"}}-}\ No newline at end of file+}diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex fdcadcf41c..5851f8bb74 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -1166,7 +1166,8 @@"selected-stage": "選択したステージ","all-tasks": "すべてのタスク"},- "current-change-will-apply-to-all-tasks-in-batch-mode": "バッチ モードでは、現在の変更がすべてのタスクに適用されます。"+ "current-change-will-apply-to-all-tasks-in-batch-mode": "バッチ モードでは、現在の変更がすべてのタスクに適用されます。",+ "current-change-will-apply-to-all-tasks": "現在の変更はすべてのタスクに適用されます。"},"not-editable-legacy-issue": "このチケットは古いバージョンの Bytebase で作成されたため編集できません。","action-anyway": "まだ {action} が必要です",@@ -3530,4 +3531,4 @@"self": "最後の更新"}}-}\ No newline at end of file+}diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 159c167b26..efacf136f0 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1166,7 +1166,8 @@"selected-stage": "选中的阶段","all-tasks": "所有任务"},- "current-change-will-apply-to-all-tasks-in-batch-mode": "在批量模式下,当前更改将应用于所有任务。"+ "current-change-will-apply-to-all-tasks-in-batch-mode": "在批量模式下,当前更改将应用于所有任务。",+ "current-change-will-apply-to-all-tasks": "当前更改将应用于所有任务。"},"not-editable-legacy-issue": "这个工单不可编辑,因为它是在旧版本的 Bytebase 中创建的。","action-anyway": "仍要{action}",