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: add sync schema page in project (#8899)
ecmadao0398834006e7
diff --git a/frontend/src/components/Project/ProjectIssuesPanel.vue b/frontend/src/components/Project/ProjectIssuesPanel.vueindex 1f67d5bce9..9cd3500ea2 100644--- a/frontend/src/components/Project/ProjectIssuesPanel.vue+++ b/frontend/src/components/Project/ProjectIssuesPanel.vue@@ -1,35 +1,32 @@<template><div class="space-y-2">- <div class="flex justify-between">- <div class="flex items-center gap-x-1">- <p class="text-lg font-medium leading-7 text-main">- {{ $t("common.issue") }}- </p>- <button- type="button"- class="p-1 rounded bg-gray-200 hover:bg-gray-300 border border-gray-300"- @click="- () => {- router.replace({- name: 'workspace.issue',- query: {- project: project.uid,- autofocus: 1,- },- });- }- "- >- <heroicons-outline:search class="h-3.5 w-3.5 text-control" />- </button>- </div>- </div>-<div class="flex items-center"><div class="flex-1 overflow-hidden"><TabFilter v-model:value="state.tab" :items="tabItemList" /></div><div class="flex flex-row space-x-4 p-0.5">+ <div class="flex items-center gap-x-1">+ <p class="font-medium leading-7 text-main">+ {{ $t("issue.advanced-search.self") }}+ </p>+ <button+ type="button"+ class="p-1 rounded bg-gray-200 hover:bg-gray-300 border border-gray-300"+ @click="+ () => {+ router.replace({+ name: 'workspace.issue',+ query: {+ project: project.uid,+ autofocus: 1,+ },+ });+ }+ "+ >+ <heroicons-outline:search class="h-3.5 w-3.5 text-control" />+ </button>+ </div><SearchBox:value="state.searchText":placeholder="$t('common.filter-by-name')"diff --git a/frontend/src/components/Project/ProjectSidebar.vue b/frontend/src/components/Project/ProjectSidebar.vueindex 0a17c11ba5..41ac502d07 100644--- a/frontend/src/components/Project/ProjectSidebar.vue+++ b/frontend/src/components/Project/ProjectSidebar.vue@@ -36,6 +36,7 @@ import {Users,Link,Settings,+ RefreshCcw,} from "lucide-vue-next";import { computed, VNode, h, reactive, watch, nextTick } from "vue";import { useI18n } from "vue-i18n";@@ -131,12 +132,24 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {title: t("common.branches"),hash: "branches",icon: h(GitBranch),- hide: !currentUserIamPolicy.allowToChangeDatabaseOfProject(- project.value.name- ),+ hide:+ isDefaultProject.value ||+ !currentUserIamPolicy.allowToChangeDatabaseOfProject(+ project.value.name+ ),},// TODO: Changelists// TODO: Sync schema+ {+ title: t("database.sync-schema.title"),+ hash: "sync-schema",+ icon: h(RefreshCcw),+ hide:+ isDefaultProject.value ||+ !currentUserIamPolicy.allowToChangeDatabaseOfProject(+ project.value.name+ ),+ },{title: t("settings.sidebar.integration"),icon: h(Link),diff --git a/frontend/src/views/SyncDatabaseSchema/DatabaseSchemaSelector.vue b/frontend/src/components/SyncDatabaseSchema/DatabaseSchemaSelector.vuesimilarity index 98%rename from frontend/src/views/SyncDatabaseSchema/DatabaseSchemaSelector.vuerename to frontend/src/components/SyncDatabaseSchema/DatabaseSchemaSelector.vueindex adc97b7002..121c3962bc 100644--- a/frontend/src/views/SyncDatabaseSchema/DatabaseSchemaSelector.vue+++ b/frontend/src/components/SyncDatabaseSchema/DatabaseSchemaSelector.vue@@ -9,6 +9,7 @@<ProjectSelectclass="!w-60 shrink-0":project="state.projectId"+ :disabled="disableProjectSelect"@update:project="handleProjectSelect"/></div>@@ -110,6 +111,7 @@ import { ChangeHistorySourceSchema } from "./types";const props = defineProps<{selectState?: ChangeHistorySourceSchema;+ disableProjectSelect?: boolean;}>();const emit = defineEmits<{@@ -174,6 +176,8 @@ onMounted(async () => {} catch (error) {// do nothing.}+ } else if (props.selectState?.projectId) {+ state.projectId = props.selectState.projectId;}});diff --git a/frontend/src/views/SyncDatabaseSchema/DiffViewPanel.vue b/frontend/src/components/SyncDatabaseSchema/DiffViewPanel.vuesimilarity index 100%rename from frontend/src/views/SyncDatabaseSchema/DiffViewPanel.vuerename to frontend/src/components/SyncDatabaseSchema/DiffViewPanel.vuediff --git a/frontend/src/views/SyncDatabaseSchema/RawSQLEditor.vue b/frontend/src/components/SyncDatabaseSchema/RawSQLEditor.vuesimilarity index 98%rename from frontend/src/views/SyncDatabaseSchema/RawSQLEditor.vuerename to frontend/src/components/SyncDatabaseSchema/RawSQLEditor.vueindex 3030512564..c5b52c1128 100644--- a/frontend/src/views/SyncDatabaseSchema/RawSQLEditor.vue+++ b/frontend/src/components/SyncDatabaseSchema/RawSQLEditor.vue@@ -8,7 +8,7 @@}}</span><ProjectSelect:project="state.projectId"- :disabled="viewMode"+ :disabled="viewMode || disableProjectSelect"@update:project="handleProjectSelect"/></div>@@ -108,6 +108,7 @@ const props = defineProps<{statement?: string;sheetId?: number;viewMode?: boolean;+ disableProjectSelect?: boolean;}>();const emit = defineEmits<{diff --git a/frontend/src/views/SyncDatabaseSchema/RawSQLEditorPanel.vue b/frontend/src/components/SyncDatabaseSchema/RawSQLEditorPanel.vuesimilarity index 100%rename from frontend/src/views/SyncDatabaseSchema/RawSQLEditorPanel.vuerename to frontend/src/components/SyncDatabaseSchema/RawSQLEditorPanel.vuediff --git a/frontend/src/views/SyncDatabaseSchema/SchemaDesignSelector.vue b/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vuesimilarity index 97%rename from frontend/src/views/SyncDatabaseSchema/SchemaDesignSelector.vuerename to frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vueindex 0cab5ff435..c22914ff92 100644--- a/frontend/src/views/SyncDatabaseSchema/SchemaDesignSelector.vue+++ b/frontend/src/components/SyncDatabaseSchema/SchemaDesignSelector.vue@@ -81,6 +81,7 @@ const emit = defineEmits<{const props = defineProps<{selectedSchemaDesign?: SchemaDesign;+ projectName?: string;}>();const { t } = useI18n();@@ -88,8 +89,9 @@ const router = useRouter();const userV1Store = useUserStore();const projectV1Store = useProjectV1Store();const databaseV1Store = useDatabaseV1Store();-const { schemaDesignList, ready: schemaDesignListReady } =- useSchemaDesignList();+const { schemaDesignList, ready: schemaDesignListReady } = useSchemaDesignList(+ props.projectName+);const selectedSchemaDesign = ref<SchemaDesign | undefined>(props.selectedSchemaDesign);diff --git a/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue b/frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vuesimilarity index 100%rename from frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vuerename to frontend/src/components/SyncDatabaseSchema/SelectTargetDatabasesView.vuediff --git a/frontend/src/views/SyncDatabaseSchema/TargetDatabasesSelectPanel.vue b/frontend/src/components/SyncDatabaseSchema/TargetDatabasesSelectPanel.vuesimilarity index 100%rename from frontend/src/views/SyncDatabaseSchema/TargetDatabasesSelectPanel.vuerename to frontend/src/components/SyncDatabaseSchema/TargetDatabasesSelectPanel.vuediff --git a/frontend/src/views/SyncDatabaseSchema/index.vue b/frontend/src/components/SyncDatabaseSchema/index.vuesimilarity index 94%rename from frontend/src/views/SyncDatabaseSchema/index.vuerename to frontend/src/components/SyncDatabaseSchema/index.vueindex 9c8ddfbc78..e4c3bf63e2 100644--- a/frontend/src/views/SyncDatabaseSchema/index.vue+++ b/frontend/src/components/SyncDatabaseSchema/index.vue@@ -1,6 +1,6 @@<template><div class="w-full h-full overflow-hidden flex flex-col">- <p class="text-sm text-gray-500 px-4">+ <p class="text-sm text-gray-500">{{ $t("database.sync-schema.description") }}<LearnMoreLinkurl="https://www.bytebase.com/docs/change-database/synchronize-schema?source=console"@@ -8,7 +8,7 @@</p><BBStepTabref="bbStepTabRef"- class="p-4 flex-1 overflow-hidden flex flex-col"+ class="py-4 flex-1 overflow-hidden flex flex-col":step-item-list="stepTabList":show-cancel="false":allow-next="allowNext"@@ -32,10 +32,12 @@<DatabaseSchemaSelectorv-if="state.sourceSchemaType === 'SCHEMA_HISTORY_VERSION'":select-state="changeHistorySourceSchemaState"+ :disableProjectSelect="!!project"@update="handleChangeHistorySchameVersionChanges"/><SchemaDesignSelectorv-if="state.sourceSchemaType === 'SCHEMA_DESIGN'"+ :project-name="project?.name":selected-schema-design="schemaDesignState.selectedSchemaDesign"@select="(schemaDesign) =>@@ -48,6 +50,7 @@:engine="rawSQLState.engine":statement="rawSQLState.statement":sheet-id="rawSQLState.sheetId"+ :disableProjectSelect="!!project"@update="handleRawSQLStateChange"/></template>@@ -76,7 +79,7 @@ import { BBStepTab } from "@/bbkit";import { useProjectV1Store } from "@/store";import { useSchemaDesignStore } from "@/store/modules/schemaDesign";import { getProjectAndSchemaDesignSheetId } from "@/store/modules/v1/common";-import { UNKNOWN_ID } from "@/types";+import { UNKNOWN_ID, ComposedProject } from "@/types";import { Engine } from "@/types/proto/v1/common";import { SchemaDesign } from "@/types/proto/v1/schema_design_service";import DatabaseSchemaSelector from "./DatabaseSchemaSelector.vue";@@ -99,6 +102,11 @@ interface LocalState {currentStep: Step;}+const props = defineProps<{+ project?: ComposedProject;+ sourceSchemaType?: SourceSchemaType;+}>();+const { t } = useI18n();const router = useRouter();const dialog = useDialog();@@ -108,19 +116,25 @@ const schemaDesignStore = useSchemaDesignStore();const targetDatabaseViewRef =ref<InstanceType<typeof SelectTargetDatabasesView>>();const state = reactive<LocalState>({- sourceSchemaType: "SCHEMA_HISTORY_VERSION",+ sourceSchemaType: props.sourceSchemaType ?? "SCHEMA_HISTORY_VERSION",currentStep: SELECT_SOURCE_SCHEMA,});-const changeHistorySourceSchemaState = reactive<ChangeHistorySourceSchema>({});+const changeHistorySourceSchemaState = reactive<ChangeHistorySourceSchema>({+ projectId: props.project?.uid,+});const schemaDesignState = reactive<{selectedSchemaDesign?: SchemaDesign;}>({});const rawSQLState = reactive<RawSQLState>({+ projectId: props.project?.uid,engine: Engine.MYSQL,statement: "",});const projectId = computed(() => {+ if (props.project) {+ return props.project.uid;+ }if (state.sourceSchemaType === "SCHEMA_HISTORY_VERSION") {return changeHistorySourceSchemaState.projectId;} else if (state.sourceSchemaType === "SCHEMA_DESIGN") {diff --git a/frontend/src/views/SyncDatabaseSchema/types.ts b/frontend/src/components/SyncDatabaseSchema/types.tssimilarity index 100%rename from frontend/src/views/SyncDatabaseSchema/types.tsrename to frontend/src/components/SyncDatabaseSchema/types.tsdiff --git a/frontend/src/components/v2/Select/ProjectSelect.vue b/frontend/src/components/v2/Select/ProjectSelect.vueindex 815a51f35d..32570af9bd 100644--- a/frontend/src/components/v2/Select/ProjectSelect.vue+++ b/frontend/src/components/v2/Select/ProjectSelect.vue@@ -6,6 +6,7 @@:placeholder="$t('project.select')":filterable="true":filter="filterByName"+ :disabled="disabled"class="bb-project-select"style="width: 12rem"@update:value="$emit('update:project', $event)"@@ -34,6 +35,7 @@ interface ProjectSelectOption extends SelectOption {const props = withDefaults(defineProps<{+ disabled?: boolean;project?: string | undefined; // UNKNOWN_ID(-1) to "ALL"allowedProjectRoleList?: string[]; // Empty array([]) to "ALL"allowedProjectTenantModeList?: TenantMode[];@@ -45,6 +47,7 @@ const props = withDefaults(filter?: (project: Project, index: number) => boolean;}>(),{+ disabled: false,project: undefined,allowedProjectRoleList: () => [],allowedProjectTenantModeList: () => [diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex f009029723..402943921d 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -301,7 +301,7 @@ const routes: Array<RouteRecordRaw> = [name: "workspace.sync-schema",meta: { title: () => startCase(t("database.sync-schema.title")) },components: {- content: () => import("../views/SyncDatabaseSchema/index.vue"),+ content: () => import("../views/SyncDatabaseSchema.vue"),leftSidebar: DashboardSidebar,},props: {diff --git a/frontend/src/store/modules/schemaDesign.ts b/frontend/src/store/modules/schemaDesign.tsindex 1e4920f8af..e8262c1e46 100644--- a/frontend/src/store/modules/schemaDesign.ts+++ b/frontend/src/store/modules/schemaDesign.ts@@ -23,10 +23,10 @@ export const useSchemaDesignStore = defineStore("schema_design", () => {>();// Actions- const fetchSchemaDesignList = async () => {+ const fetchSchemaDesignList = async (projectName: string = "projects/-") => {const { schemaDesigns } = await schemaDesignServiceClient.listSchemaDesigns({- parent: "projects/-",+ parent: projectName,view: SchemaDesignView.SCHEMA_DESIGN_VIEW_FULL,});@@ -165,7 +165,9 @@ export const useSchemaDesignStore = defineStore("schema_design", () => {};});-export const useSchemaDesignList = () => {+export const useSchemaDesignList = (+ projectName: string | undefined = undefined+) => {const store = useSchemaDesignStore();const ready = ref(false);const schemaDesignList = ref<SchemaDesign[]>([]);@@ -173,7 +175,7 @@ export const useSchemaDesignList = () => {watchEffect(() => {ready.value = false;schemaDesignList.value = [];- store.fetchSchemaDesignList().then((response) => {+ store.fetchSchemaDesignList(projectName).then((response) => {ready.value = true;schemaDesignList.value = response;});diff --git a/frontend/src/views/ProjectDetail.vue b/frontend/src/views/ProjectDetail.vueindex 372d835429..7f3eac7e73 100644--- a/frontend/src/views/ProjectDetail.vue+++ b/frontend/src/views/ProjectDetail.vue@@ -17,6 +17,9 @@:database-list="databaseV1List"/></template>+ <template v-if="hash === 'sync-schema'">+ <SyncDatabaseSchema :project="project" />+ </template><template v-if="hash === 'slow-query'"><ProjectSlowQueryPanel :project="project" /></template>@@ -58,6 +61,7 @@ import { computed } from "vue";import { useRoute } from "vue-router";import ProjectDatabaseGroupPanel from "@/components/DatabaseGroup/ProjectDatabaseGroupPanel.vue";import ProjectBranchesPanel from "@/components/ProjectBranchesPanel.vue";+import SyncDatabaseSchema from "@/components/SyncDatabaseSchema/index.vue";import {useSearchDatabaseV1List,useDatabaseV1Store,diff --git a/frontend/src/views/SyncDatabaseSchema.vue b/frontend/src/views/SyncDatabaseSchema.vuenew file mode 100644index 0000000000..6477e696fe--- /dev/null+++ b/frontend/src/views/SyncDatabaseSchema.vue@@ -0,0 +1,9 @@+<template>+ <div class="px-4">+ <SyncDatabaseSchema />+ </div>+</template>++<script setup lang="ts">+import SyncDatabaseSchema from "@/components/SyncDatabaseSchema/index.vue";+</script>