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: deprecate db transfer out quick action (#9816)
ecmadaoee53c9c43d63
diff --git a/frontend/src/components/Project/ProjectSwitchModal.vue b/frontend/src/components/Project/ProjectSwitchModal.vueindex 7bad852534..aaf885cb79 100644--- a/frontend/src/components/Project/ProjectSwitchModal.vue+++ b/frontend/src/components/Project/ProjectSwitchModal.vue@@ -7,8 +7,8 @@class="w-[48rem] max-w-full h-128 max-h-full"@close="$emit('dismiss')">- <div class="space-y-2 my-4">- <div class="w-full sticky top-0 mb-4">+ <div class="space-y-2 h-full overflow-y-auto py-2 relative">+ <div class="w-full bg-white sticky top-0 mb-2 z-50"><div class="flex items-center justify-between space-x-2"><SearchBoxv-model:value="state.searchText"diff --git a/frontend/src/components/ProjectDatabasesPanel.vue b/frontend/src/components/ProjectDatabasesPanel.vueindex a092df2815..cced042842 100644--- a/frontend/src/components/ProjectDatabasesPanel.vue+++ b/frontend/src/components/ProjectDatabasesPanel.vue@@ -21,57 +21,62 @@:databases="selectedDatabases"/>- <template v-if="databaseList.length > 0">- <DatabaseV1Table- mode="PROJECT"- table-class="border"- :show-selection-column="true"- :database-list="filteredDatabaseList"- >- <template #selection-all="{ databaseList: selectedDatabaseList }">- <input- v-if="selectedDatabaseList.length > 0"- type="checkbox"- class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"- v-bind="getAllSelectionState(selectedDatabaseList as ComposedDatabase[])"- @input="- toggleDatabasesSelection(- selectedDatabaseList as ComposedDatabase[],- ($event.target as HTMLInputElement).checked- )- "- />- </template>- <template #selection="{ database }">- <input- type="checkbox"- class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"- :checked="isDatabaseSelected(database as ComposedDatabase)"- @click.stop="- toggleDatabasesSelection(- [database as ComposedDatabase],- ($event.target as HTMLInputElement).checked- )- "- />- </template>- </DatabaseV1Table>- </template>- <div v-else class="text-center textinfolabel">- <i18n-t- v-if="showEmptyActions"- keypath="project.overview.no-db-prompt"- tag="p"- >- <template #newDb>- <span class="text-main">{{ $t("quick-action.new-db") }}</span>- </template>- <template #transferInDb>- <span class="text-main">{{ $t("quick-action.transfer-in-db") }}</span>- </template>- </i18n-t>- <i18n-t v-else keypath="common.no-data" tag="p"></i18n-t>- </div>+ <DatabaseV1Table+ mode="PROJECT"+ table-class="border"+ :show-selection-column="true"+ :show-placeholder="true"+ :database-list="filteredDatabaseList"+ >+ <template #selection-all="{ databaseList: selectedDatabaseList }">+ <input+ v-if="selectedDatabaseList.length > 0"+ type="checkbox"+ class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"+ v-bind="getAllSelectionState(selectedDatabaseList as ComposedDatabase[])"+ @input="+ toggleDatabasesSelection(+ selectedDatabaseList as ComposedDatabase[],+ ($event.target as HTMLInputElement).checked+ )+ "+ />+ </template>+ <template #selection="{ database }">+ <input+ type="checkbox"+ class="h-4 w-4 text-accent rounded disabled:cursor-not-allowed border-control-border focus:ring-accent"+ :checked="isDatabaseSelected(database as ComposedDatabase)"+ @click.stop="+ toggleDatabasesSelection(+ [database as ComposedDatabase],+ ($event.target as HTMLInputElement).checked+ )+ "+ />+ </template>+ <template v-if="databaseList.length === 0" #placeholder>+ <div class="p-8 text-center textinfolabel">+ <i18n-t+ v-if="showEmptyActions"+ keypath="project.overview.no-db-prompt"+ tag="p"+ >+ <template #newDb>+ <span class="text-main font-bold">{{+ $t("quick-action.new-db")+ }}</span>+ </template>+ <template #transferInDb>+ <span class="text-main font-bold">{{+ $t("quick-action.transfer-in-db")+ }}</span>+ </template>+ </i18n-t>+ <i18n-t v-else keypath="common.no-data" tag="p"></i18n-t>+ </div>+ </template>+ </DatabaseV1Table></div></template>diff --git a/frontend/src/components/QuickActionPanel.vue b/frontend/src/components/QuickActionPanel.vueindex a5928d5891..4772065c0f 100644--- a/frontend/src/components/QuickActionPanel.vue+++ b/frontend/src/components/QuickActionPanel.vue@@ -54,14 +54,6 @@:project-id="projectId"@dismiss="state.quickActionType = undefined"/>- <TransferOutDatabaseForm- v-if="- projectId &&- state.quickActionType === 'quickaction.bb.project.database.transfer-out'- "- :project-id="projectId"- @dismiss="state.quickActionType = undefined"- /></Drawer><RequestQueryPanel@@ -92,7 +84,6 @@ import {ListOrderedIcon,GalleryHorizontalEndIcon,ChevronsDownIcon,- ChevronsUpIcon,FileSearchIcon,FileDownIcon,} from "lucide-vue-next";@@ -106,7 +97,6 @@ import RequestExportPanel from "@/components/Issue/panel/RequestExportPanel/indeimport RequestQueryPanel from "@/components/Issue/panel/RequestQueryPanel/index.vue";import ProjectCreatePanel from "@/components/Project/ProjectCreatePanel.vue";import TransferDatabaseForm from "@/components/TransferDatabaseForm.vue";-import TransferOutDatabaseForm from "@/components/TransferOutDatabaseForm";import { Drawer } from "@/components/v2";import {useInstanceV1Store,@@ -189,10 +179,6 @@ const transferDatabase = () => {state.quickActionType = "quickaction.bb.project.database.transfer";};-const transferOutDatabase = () => {- state.quickActionType = "quickaction.bb.project.database.transfer-out";-};-const createInstance = () => {const instanceList = useInstanceV1Store().activeInstanceList;if (subscriptionStore.instanceCountLimit <= instanceList.length) {@@ -276,12 +262,6 @@ const availableQuickActionList = computed((): QuickAction[] => {action: transferDatabase,icon: h(ChevronsDownIcon),},- {- type: "quickaction.bb.project.database.transfer-out",- title: t("quick-action.transfer-out-db"),- action: transferOutDatabase,- icon: h(ChevronsUpIcon),- },{type: "quickaction.bb.issue.grant.request.querier",title: t("quick-action.request-query-permission"),diff --git a/frontend/src/components/TransferOutDatabaseForm/TransferOutDatabaseForm.vue b/frontend/src/components/TransferOutDatabaseForm/TransferOutDatabaseForm.vueindex 915e8cd506..88d703a4ed 100644--- a/frontend/src/components/TransferOutDatabaseForm/TransferOutDatabaseForm.vue+++ b/frontend/src/components/TransferOutDatabaseForm/TransferOutDatabaseForm.vue@@ -73,7 +73,6 @@</template><script setup lang="ts">-import { cloneDeep } from "lodash-es";import {NTransfer,NTree,@@ -88,11 +87,10 @@ import { ProjectV1Name, ProjectSelect, DrawerContent } from "@/components/v2";import {pushNotification,useDatabaseV1Store,- useGracefulRequest,useProjectV1ByUID,useProjectV1Store,} from "@/store";-import { ComposedDatabase, PresetRoleType, UNKNOWN_ID } from "@/types";+import { PresetRoleType, UNKNOWN_ID } from "@/types";import { Project } from "@/types/proto/v1/project_service";import Label from "./Label.vue";import {@@ -232,39 +230,25 @@ const doTransfer = async () => {const target = targetProject.value!;if (!target) return;- const transferOneDatabase = async (database: ComposedDatabase) => {- const databasePatch = cloneDeep(database);- databasePatch.project = target.name;- const updateMask = ["project"];- const updated = await useDatabaseV1Store().updateDatabase({- database: databasePatch,- updateMask,- });- return updated;- };-const databaseList = selectedDatabaseList.value;try {loading.value = true;- await useGracefulRequest(async () => {- const requests = databaseList.map((db) => {- transferOneDatabase(db);- });- await Promise.all(requests);+ await useDatabaseV1Store().transferDatabases(+ selectedDatabaseList.value,+ target.name+ );+ const displayDatabaseName =+ databaseList.length > 1+ ? `${databaseList.length} databases`+ : `'${databaseList[0].databaseName}'`;- const displayDatabaseName =- databaseList.length > 1- ? `${databaseList.length} databases`- : `'${databaseList[0].databaseName}'`;-- pushNotification({- module: "bytebase",- style: "SUCCESS",- title: `Successfully transferred ${displayDatabaseName} to project '${target.title}'.`,- });- emit("dismiss");+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: `Successfully transferred ${displayDatabaseName} to project '${target.title}'.`,});+ emit("dismiss");} finally {loading.value = false;}diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vueindex a5aadc1a1c..f460493d23 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseOperations.vue@@ -26,7 +26,7 @@</NButton></template><span class="w-56 text-sm">- {{ action.tooltip(action.text) }}+ {{ action.tooltip(action.text.toLowerCase()) }}</span></NTooltip></template>@@ -40,19 +40,6 @@@close="state.showSchemaEditorModal = false"/>- <Drawer- v-if="selectedProjectUid"- :show="state.showTransferOutDatabaseForm"- :auto-focus="true"- @close="state.showTransferOutDatabaseForm = false"- >- <TransferOutDatabaseForm- :project-id="selectedProjectUid"- :selected-database-uid-list="selectedDatabaseUidList"- @dismiss="state.showTransferOutDatabaseForm = false"- />- </Drawer>-<LabelEditorDrawer:show="state.showLabelEditorDrawer":readonly="false"@@ -65,18 +52,34 @@@dismiss="state.showLabelEditorDrawer = false"@apply="onLabelsApply($event)"/>++ <BBAlert+ v-if="state.showUnassignAlert"+ :style="'WARN'"+ :ok-text="$t('database.unassign')"+ :title="$t('database.unassign-alert-title')"+ :description="$t('database.unassign-alert-description')"+ @ok="+ () => {+ state.showUnassignAlert = false;+ unAssignDatabases();+ }+ "+ @cancel="state.showUnassignAlert = false"+ /></template><script lang="ts" setup>+import {+ UnlinkIcon,+ RefreshCcwIcon,+ TagIcon,+ PencilIcon,+ PenSquareIcon,+} from "lucide-vue-next";import { computed, h, VNode, reactive, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";-import PencilIcon from "~icons/heroicons-outline/pencil";-import PencilAltIcon from "~icons/heroicons-outline/pencil-alt";-import RefreshIcon from "~icons/heroicons-outline/refresh";-import SwitchHorizontalIcon from "~icons/heroicons-outline/switch-horizontal";-import TagIcon from "~icons/heroicons-outline/tag";-import { Drawer } from "@/components/v2";import {useCurrentUserV1,useCurrentUserIamPolicy,@@ -110,7 +113,7 @@ interface DatabaseAction {interface LocalState {loading: boolean;showSchemaEditorModal: boolean;- showTransferOutDatabaseForm: boolean;+ showUnassignAlert: boolean;showLabelEditorDrawer: boolean;}@@ -121,7 +124,7 @@ const props = defineProps<{const state = reactive<LocalState>({loading: false,showSchemaEditorModal: false,- showTransferOutDatabaseForm: false,+ showUnassignAlert: false,showLabelEditorDrawer: false,});const schemaEditorContext = ref<{@@ -145,15 +148,19 @@ const selectedProjectNames = computed(() => {return new Set(props.databases.map((db) => db.project));});+const assignedDatabases = computed(() => {+ return props.databases.filter((db) => db.project !== DEFAULT_PROJECT_V1_NAME);+});+const getDisabledTooltip = (action: string) => {if (selectedProjectNames.value.size > 1) {return t("database.batch-action-disabled", {- action: action.toLowerCase(),+ action,});}if (selectedProjectNames.value.has(DEFAULT_PROJECT_V1_NAME)) {return t("database.batch-action-disabled-for-unassigned", {- action: action.toLowerCase(),+ action,});}return "";@@ -323,30 +330,41 @@ const syncSchema = async () => {}};+const unAssignDatabases = async () => {+ if (state.loading) {+ return;+ }+ try {+ await useDatabaseV1Store().transferDatabases(+ assignedDatabases.value,+ DEFAULT_PROJECT_V1_NAME+ );+ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("database.successfully-transferred-databases"),+ });+ } catch {+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: t("db.failed-to-sync-schema"),+ });+ } finally {+ state.loading = false;+ }+};+const actions = computed((): DatabaseAction[] => {const resp: DatabaseAction[] = [];if (!isStandaloneMode.value) {resp.push({- icon: h(RefreshIcon),+ icon: h(RefreshCcwIcon),text: t("common.sync"),disabled: props.databases.length < 1,click: syncSchema,tooltip: (action) => getDisabledTooltip(action),});- resp.unshift({- icon: h(SwitchHorizontalIcon),- text: t("database.transfer-project"),- disabled: !allowTransferProject.value || !selectedProjectUid.value,- click: () => (state.showTransferOutDatabaseForm = true),- tooltip: (action) => {- if (!allowTransferProject.value) {- return t("database.batch-action-permission-denied", {- action,- });- }- return getDisabledTooltip(action);- },- });resp.push({icon: h(TagIcon),text: t("database.edit-labels"),@@ -381,7 +399,7 @@ const actions = computed((): DatabaseAction[] => {},},{- icon: h(PencilAltIcon),+ icon: h(PenSquareIcon),text: t("database.edit-schema"),disabled:!databaseSupportAlterSchema.value ||@@ -402,6 +420,23 @@ const actions = computed((): DatabaseAction[] => {},});++ if (allowTransferProject.value && assignedDatabases.value.length > 0) {+ resp.push({+ icon: h(UnlinkIcon),+ text: t("database.unassign"),+ disabled: false,+ click: () => (state.showUnassignAlert = true),+ tooltip: (action) => {+ if (!allowTransferProject.value) {+ return t("database.batch-action-permission-denied", {+ action,+ });+ }+ return getDisabledTooltip(action);+ },+ });+ }return resp;});diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vueindex ee7fa22ae2..fdc1cdbb90 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue@@ -75,6 +75,10 @@</template></template>+ <template #placeholder-content>+ <slot name="placeholder"></slot>+ </template>+<template #footer><divv-if="hasReservedDatabases && !state.showReservedDatabaseList"diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 18a266acf6..28517736f2 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -1513,6 +1513,9 @@"filter-database": "Filter database","database-backup": "database backup","transfer-project": "Transfer Project",+ "unassign": "Unassign",+ "unassign-alert-title": "Unassign databases",+ "unassign-alert-description": "Selected databases will transfer out from their project","edit-schema": "Edit Schema","edit-schema-in-vcs": "Edit Schema in VCS","edit-labels": "Edit Labels",@@ -1532,6 +1535,7 @@"batch-action-permission-denied": "Don't have permission to {action} for databases","batch-action-disabled": "Can not {action} for the databases from different projects","batch-action-disabled-for-unassigned": "Can not {action} for unassigned database",+ "successfully-transferred-databases": "Successfully transferred databases","successfully-transferred-updateddatabase-name-to-project-updateddatabase-project-name": "Successfully transferred '{0}' to project '{1}'.","backup-name": "Backup name","create-backup": "Create backup",diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 3641d3e5ae..fb5e0ed578 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -1512,6 +1512,9 @@"filter-database": "Filtrar base de datos","database-backup": "copia de seguridad de la base de datos","transfer-project": "Transferir proyecto",+ "unassign": "Desasignar",+ "unassign-alert-title": "Desasignar bases de datos",+ "unassign-alert-description": "Las bases de datos seleccionadas se transferirán desde su proyecto.","edit-schema": "Modificar esquema","edit-schema-in-vcs": "Modificar esquema en VCS","edit-labels": "Editar etiquetas",@@ -1531,6 +1534,7 @@"batch-action-permission-denied": "No tengo permiso para {action} para bases de datos","batch-action-disabled": "No se puede {action} para las bases de datos de diferentes proyectos","batch-action-disabled-for-unassigned": "No se puede {action} para una base de datos no asignada",+ "successfully-transferred-databases": "Bases de datos transferidas exitosamente","successfully-transferred-updateddatabase-name-to-project-updateddatabase-project-name": "Se transfirió correctamente '{0}' al proyecto '{1}'.","backup-name": "Nombre de la copia de seguridad","create-backup": "Crear copia de seguridad",diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex 245e6b50a1..c6047cd499 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -1509,6 +1509,9 @@"sync-status": "同步状态","filter-database": "过滤数据库","transfer-project": "转移项目",+ "unassign": "取消分配",+ "unassign-alert-title": "取消分配数据库",+ "unassign-alert-description": "选定的数据库将从其项目中转出","edit-schema": "变更 Schema","edit-schema-in-vcs": "变更 Schema (VCS)","edit-labels": "编辑标签",@@ -1528,6 +1531,7 @@"batch-action-permission-denied": "没有权限对数据库{action}","batch-action-disabled": "无法对来自不同项目的数据库{action}","batch-action-disabled-for-unassigned": "无法对未分配的数据库{action}",+ "successfully-transferred-databases": "数据库转移完成","successfully-transferred-updateddatabase-name-to-project-updateddatabase-project-name": "成功将'{0}'转移到项目'{1}'。","database-backup": "数据库备份","backup-name": "备份名称",diff --git a/frontend/src/store/modules/v1/database.ts b/frontend/src/store/modules/v1/database.tsindex 57815ea542..2211c9274d 100644--- a/frontend/src/store/modules/v1/database.ts+++ b/frontend/src/store/modules/v1/database.ts@@ -26,6 +26,7 @@ import {hasWorkspacePermissionV1,isMemberOfProjectV1,} from "@/utils";+import { useGracefulRequest } from "../utils";import { useEnvironmentV1Store } from "./environment";import { useInstanceV1Store } from "./instance";import { useProjectV1Store } from "./project";@@ -171,6 +172,29 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {return resp;};+ const transferOneDatabase = async (database: Database, project: string) => {+ const updated = await useDatabaseV1Store().updateDatabase({+ database: {+ ...database,+ project: project,+ },+ updateMask: ["project"],+ });+ return updated;+ };++ const transferDatabases = async (+ databaseList: Database[],+ project: string+ ) => {+ await useGracefulRequest(async () => {+ const requests = databaseList.map((db) => {+ transferOneDatabase(db, project);+ });+ await Promise.all(requests);+ });+ };+return {reset,databaseList,@@ -190,6 +214,7 @@ export const useDatabaseV1Store = defineStore("database_v1", () => {fetchDatabaseSchema,updateDatabaseInstance,diffSchema,+ transferDatabases,};});diff --git a/frontend/src/types/quickAction.ts b/frontend/src/types/quickAction.tsindex 1fa85ec946..0c2f2dd5b7 100644--- a/frontend/src/types/quickAction.ts+++ b/frontend/src/types/quickAction.ts@@ -3,8 +3,7 @@ export type EnvironmentQuickActionType =| "quickaction.bb.environment.reorder";export type ProjectQuickActionType =| "quickaction.bb.project.create"- | "quickaction.bb.project.database.transfer"- | "quickaction.bb.project.database.transfer-out";+ | "quickaction.bb.project.database.transfer";export type InstanceQuickActionType = "quickaction.bb.instance.create";export type DatabaseQuickActionType =| "quickaction.bb.database.create" // Used by DBA and Ownerdiff --git a/frontend/src/views/project/ProjectDatabaseDashboard.vue b/frontend/src/views/project/ProjectDatabaseDashboard.vueindex 7e20735a56..e8d881d217 100644--- a/frontend/src/views/project/ProjectDatabaseDashboard.vue+++ b/frontend/src/views/project/ProjectDatabaseDashboard.vue@@ -69,7 +69,6 @@ const quickActionMapByRole = computed(() => {"quickaction.bb.database.data.update","quickaction.bb.database.create","quickaction.bb.project.database.transfer",- "quickaction.bb.project.database.transfer-out",];const DEVELOPER_QUICK_ACTION_LIST: QuickActionType[] = [];@@ -98,8 +97,7 @@ const quickActionMapByRole = computed(() => {)) {DEVELOPER_QUICK_ACTION_LIST.push(- "quickaction.bb.project.database.transfer",- "quickaction.bb.project.database.transfer-out"+ "quickaction.bb.project.database.transfer");}if (!isOwnerOfProjectV1(project.value.iamPolicy, currentUserV1.value)) {