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(frontend): sync-schema panel layout improvement (#6153)
Liu Jif1a4935b30a6
diff --git a/frontend/src/bbkit/BBStepTab.vue b/frontend/src/bbkit/BBStepTab.vueindex 187f086fef..8192315d0e 100644--- a/frontend/src/bbkit/BBStepTab.vue+++ b/frontend/src/bbkit/BBStepTab.vue@@ -43,7 +43,7 @@</div></li></ol>- <div class="mt-4 mb-4">+ <div class="mt-4 mb-4" :class="paneClass"><template v-for="(step, index) in stepItemList" :key="index"><slotv-if="state.currentStep == index"@@ -108,6 +108,7 @@<script lang="ts" setup>import { reactive, withDefaults } from "vue";import { BBStepTabItem } from "./types";+import { VueClass } from "@/utils/types";interface LocalState {done: boolean;@@ -121,12 +122,14 @@ withDefaults(allowNext?: boolean;finishTitle?: string;sticky?: boolean;+ paneClass?: VueClass;}>(),{showCancel: true,allowNext: true,finishTitle: "bbkit.common.finish",sticky: false,+ paneClass: undefined,});diff --git a/frontend/src/views/SyncDatabaseSchema/DiffViewPanel.vue b/frontend/src/views/SyncDatabaseSchema/DiffViewPanel.vueindex bb81120807..e5dbb84c6f 100644--- a/frontend/src/views/SyncDatabaseSchema/DiffViewPanel.vue+++ b/frontend/src/views/SyncDatabaseSchema/DiffViewPanel.vue@@ -1,62 +1,74 @@<template>- <NTabs v-model:value="tab">- <NTabPane name="diff" :tab="$t('database.sync-schema.schema-change')">- <div class="w-full flex flex-row justify-start items-center mb-2">- <span>{{ previewSchemaChangeMessage }}</span>- </div>- <code-diff- v-show="shouldShowDiff"- class="code-diff-container w-full h-auto max-h-96 overflow-y-auto border rounded"- :old-string="targetDatabaseSchema"- :new-string="sourceDatabaseSchema"- output-format="side-by-side"- />- <div- v-show="!shouldShowDiff"- class="w-full h-auto px-3 py-2 overflow-y-auto border rounded"- >- <p>- {{ $t("database.sync-schema.message.no-diff-found") }}- </p>- </div>- </NTabPane>+ <div class="w-full h-full flex flex-col gap-y-2">+ <NTabs v-model:value="tab">+ <NTab name="diff">+ {{ $t("database.sync-schema.schema-change") }}+ </NTab>+ <NTab name="ddl">+ {{ $t("database.sync-schema.generated-ddl-statement") }}+ </NTab>+ </NTabs>- <NTabPane- name="ddl"- :tab="$t('database.sync-schema.generated-ddl-statement')"- >- <div class="w-full flex flex-col justify-start mb-2">- <div class="flex flex-row justify-start items-center">- <span>{{ $t("database.sync-schema.synchronize-statements") }}</span>- <button- type="button"- class="btn-icon ml-2"- @click.prevent="$emit('copy-statement')"- >- <heroicons-outline:clipboard class="h-5 w-5" />- </button>+ <div class="flex-1 w-full flex flex-col gap-y-2 overflow-hidden">+ <template v-if="tab === 'diff'">+ <div class="w-full flex flex-row justify-start items-center">+ <span>{{ previewSchemaChangeMessage }}</span></div>- <div class="textinfolabel">- {{ $t("database.sync-schema.synchronize-statements-description") }}+ <div+ v-if="shouldShowDiff"+ class="w-full flex-1 overflow-y-scroll border"+ >+ <CodeDiff+ class="sync-schema-code-diff"+ :old-string="targetDatabaseSchema"+ :new-string="sourceDatabaseSchema"+ output-format="side-by-side"+ /></div>- </div>- <MonacoEditor- ref="editorRef"- class="w-full h-auto max-h-96 border rounded"- :value="statement"- :auto-focus="false"- :dialect="dialectOfEngine(engineType)"- @change="onStatementChange"- @ready="updateEditorHeight"- />- </NTabPane>- </NTabs>+ <div+ v-else+ class="w-full flex-1 border flex items-center justify-center"+ >+ <p>+ {{ $t("database.sync-schema.message.no-diff-found") }}+ </p>+ </div>+ </template>++ <template v-if="tab === 'ddl'">+ <div class="w-full flex flex-col justify-start">+ <div class="flex flex-row justify-start items-center">+ <span>{{ $t("database.sync-schema.synchronize-statements") }}</span>+ <button+ type="button"+ class="btn-icon ml-2"+ @click.prevent="$emit('copy-statement')"+ >+ <heroicons-outline:clipboard class="h-5 w-5" />+ </button>+ </div>+ <div class="textinfolabel">+ {{ $t("database.sync-schema.synchronize-statements-description") }}+ </div>+ </div>+ <MonacoEditor+ ref="editorRef"+ class="w-full flex-1 border"+ :value="statement"+ :auto-focus="false"+ :dialect="dialectOfEngine(engineType)"+ @change="onStatementChange"+ @ready="updateEditorHeight"+ />+ </template>+ </div>+ </div></template><script lang="ts" setup>import { computed, ref } from "vue";import { CodeDiff } from "v-code-diff";-import { NTabs, NTabPane } from "naive-ui";+import { NTabs, NTab } from "naive-ui";import MonacoEditor from "@/components/MonacoEditor/MonacoEditor.vue";import { Database, dialectOfEngine } from "@/types";@@ -96,3 +108,11 @@ const onStatementChange = (statement: string) => {});};</script>++<style lang="postcss">+.sync-schema-code-diff .d2h-file-wrapper {+ border: 0;+ border-radius: 0;+ margin-bottom: 0;+}+</style>diff --git a/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue b/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vueindex cdb950d831..286bdcb3d8 100644--- a/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue+++ b/frontend/src/views/SyncDatabaseSchema/SelectTargetDatabasesView.vue@@ -1,6 +1,8 @@<template>- <div class="w-full">- <div class="w-full flex flex-row justify-start items-start gap-8">+ <div+ class="select-target-database-view h-full overflow-y-hidden flex flex-col gap-y-4"+ >+ <div class="w-full flex flex-row gap-8"><span>{{ $t("database.sync-schema.source-schema") }}</span><div class="space-y-2"><div>@@ -46,7 +48,7 @@</div><div- class="relative border rounded-lg w-full h-144 flex flex-row overflow-hidden mt-4"+ class="relative border rounded-lg w-full flex flex-row flex-1 overflow-hidden"><div class="w-1/4 min-w-[256px] max-w-xs h-full border-r"><div@@ -147,36 +149,30 @@</div></div></div>- <div class="w-3/4 grow h-full">- <main ref="diffViewerRef" class="p-2 w-full h-full overflow-y-auto">- <div- v-show="selectedDatabase"- class="w-full h-auto flex flex-col justify-start items-start"- >- <DiffViewPanel- :statement="- state.selectedDatabaseId- ? databaseDiffCache[state.selectedDatabaseId].edited- : ''- "- :source-database="sourceDatabase"- :target-database-schema="targetDatabaseSchema"- :source-database-schema="sourceDatabaseSchema"- :should-show-diff="shouldShowDiff"- :preview-schema-change-message="previewSchemaChangeMessage"- @statement-change="onStatementChange"- @copy-statement="onCopyStatement"- />- </div>- <div- v-show="!selectedDatabase"- class="w-full h-full flex flex-col justify-center items-center"- >- {{- $t("database.sync-schema.message.select-a-target-database-first")- }}- </div>- </main>+ <div class="flex-1 h-full overflow-hidden p-2">+ <DiffViewPanel+ v-show="selectedDatabase"+ :statement="+ state.selectedDatabaseId+ ? databaseDiffCache[state.selectedDatabaseId].edited+ : ''+ "+ :source-database="sourceDatabase"+ :target-database-schema="targetDatabaseSchema"+ :source-database-schema="sourceDatabaseSchema"+ :should-show-diff="shouldShowDiff"+ :preview-schema-change-message="previewSchemaChangeMessage"+ @statement-change="onStatementChange"+ @copy-statement="onCopyStatement"+ />+ <div+ v-show="!selectedDatabase"+ class="w-full h-full flex flex-col justify-center items-center"+ >+ {{+ $t("database.sync-schema.message.select-a-target-database-first")+ }}+ </div><divv-show="state.isLoading"class="absolute inset-0 z-10 bg-white bg-opacity-40 backdrop-blur-sm w-full h-full flex flex-col justify-center items-center"diff --git a/frontend/src/views/SyncDatabaseSchema/index.vue b/frontend/src/views/SyncDatabaseSchema/index.vueindex ea82b1cad0..0099588f05 100644--- a/frontend/src/views/SyncDatabaseSchema/index.vue+++ b/frontend/src/views/SyncDatabaseSchema/index.vue@@ -1,123 +1,128 @@<template>- <p class="text-sm text-gray-500 px-4">- {{ $t("database.sync-schema.description") }}- <LearnMoreLink- url="https://www.bytebase.com/docs/change-database/synchronize-schema?source=console"- />- </p>- <BBStepTab- class="p-4 h-auto min-h-[calc(100%-40px)] overflow-y-auto"- :step-item-list="stepTabList"- :show-cancel="false"- :allow-next="allowNext"- :finish-title="$t('database.sync-schema.preview-issue')"- :current-step="state.currentStep"- @cancel="cancelSetup"- @try-change-step="tryChangeStep"- @try-finish="tryFinishSetup"- >- <template #0>- <div- class="w-full mx-auto flex flex-col justify-start items-start space-y-4 my-8"- >- <div class="w-full flex flex-row justify-start items-center">- <span class="flex w-40 items-center">- {{ $t("database.sync-schema.select-project") }}- </span>- <ProjectSelect- class="!w-60 shrink-0"- :selected-id="state.projectId"- @select-project-id="handleSourceProjectSelect"- />- </div>- <div class="w-full flex flex-row justify-start items-center">- <span class="flex w-40 items-center shrink-0">- {{ $t("database.sync-schema.source-database") }}- </span>- <EnvironmentSelect- class="!w-60 mr-4 shrink-0"- name="environment"- :selected-id="state.sourceSchema.environmentId"- :select-default="false"- @select-environment-id="handleSourceEnvironmentSelect"- />- <DatabaseSelect- class="!w-128"- :selected-id="(state.sourceSchema.databaseId as DatabaseId)"- :mode="'USER'"- :environment-id="state.sourceSchema.environmentId"- :project-id="state.projectId"- :engine-type-list="allowedEngineTypeList"- :sync-status="'OK'"- :customize-item="true"- @select-database-id="handleSourceDatabaseSelect"- >- <template #customizeItem="{ database }">- <div class="flex items-center">- <InstanceEngineIcon :instance="database.instance" />- <span class="mx-2">{{ database.name }}</span>- <span class="text-gray-400"- >({{ database.instance.name }})</span- >- </div>- </template>- </DatabaseSelect>- </div>- <div class="w-full flex flex-row justify-start items-center">- <span class="flex w-40 items-center shrink-0">- {{ $t("database.sync-schema.schema-version.self") }}- </span>- <div- class="w-192 flex flex-row justify-start items-center relative"- :class="isValidId(state.projectId) ? '' : 'opacity-50'"- >- <BBSelect- class="w-full"- :selected-item="state.sourceSchema.migrationHistory"- :item-list="- databaseMigrationHistoryList(state.sourceSchema.databaseId as DatabaseId)- "- :placeholder="$t('change-history.select')"- :show-prefix-item="databaseMigrationHistoryList(state.sourceSchema.databaseId as DatabaseId).length > 0"- @select-item="(migrationHistory: MigrationHistory) => handleSchemaVersionSelect(migrationHistory)"+ <div class="w-full h-full overflow-hidden flex flex-col">+ <p class="text-sm text-gray-500 px-4">+ {{ $t("database.sync-schema.description") }}+ <LearnMoreLink+ url="https://www.bytebase.com/docs/change-database/synchronize-schema?source=console"+ />+ </p>+ <BBStepTab+ class="p-4 flex-1 overflow-hidden flex flex-col"+ :step-item-list="stepTabList"+ :show-cancel="false"+ :allow-next="allowNext"+ :finish-title="$t('database.sync-schema.preview-issue')"+ :current-step="state.currentStep"+ pane-class="flex-1 overflow-y-auto"+ @cancel="cancelSetup"+ @try-change-step="tryChangeStep"+ @try-finish="tryFinishSetup"+ >+ <template #0>+ <div+ class="w-full mx-auto flex flex-col justify-start items-start space-y-4 my-8"+ >+ <div class="w-full flex flex-row justify-start items-center">+ <span class="flex w-40 items-center">+ {{ $t("database.sync-schema.select-project") }}+ </span>+ <ProjectSelect+ class="!w-60 shrink-0"+ :selected-id="state.projectId"+ @select-project-id="handleSourceProjectSelect"+ />+ </div>+ <div class="w-full flex flex-row justify-start items-center">+ <span class="flex w-40 items-center shrink-0">+ {{ $t("database.sync-schema.source-database") }}+ </span>+ <EnvironmentSelect+ class="!w-60 mr-4 shrink-0"+ name="environment"+ :selected-id="state.sourceSchema.environmentId"+ :select-default="false"+ @select-environment-id="handleSourceEnvironmentSelect"+ />+ <DatabaseSelect+ class="!w-128"+ :selected-id="(state.sourceSchema.databaseId as DatabaseId)"+ :mode="'USER'"+ :environment-id="state.sourceSchema.environmentId"+ :project-id="state.projectId"+ :engine-type-list="allowedEngineTypeList"+ :sync-status="'OK'"+ :customize-item="true"+ @select-database-id="handleSourceDatabaseSelect">- <template #menuItem="{ item: migrationHistory }">- <div class="flex justify-between mr-2">- <NEllipsis class="pr-2" :tooltip="false">- {{ migrationHistory.version }} -- {{ migrationHistory.description }}- </NEllipsis>- <span class="text-control-light">- {{- dayjs(migrationHistory.updatedTs * 1000).format(- "YYYY-MM-DD HH:mm:ss"- )- }}- </span>+ <template #customizeItem="{ database }">+ <div class="flex items-center">+ <InstanceEngineIcon :instance="database.instance" />+ <span class="mx-2">{{ database.name }}</span>+ <span class="text-gray-400"+ >({{ database.instance.name }})</span+ ></div></template>- <template v-if="shouldShowMoreVersionButton" #suffixItem>- <div- class="w-full flex flex-row justify-start items-center pl-3 leading-8 text-accent cursor-pointer hover:opacity-80"- @click.prevent.capture="() => (state.showFeatureModal = true)"- >- <heroicons-solid:sparkles class="w-4 h-auto mr-1" />- {{ $t("database.sync-schema.more-version") }}- </div>- </template>- </BBSelect>+ </DatabaseSelect>+ </div>+ <div class="w-full flex flex-row justify-start items-center">+ <span class="flex w-40 items-center shrink-0">+ {{ $t("database.sync-schema.schema-version.self") }}+ </span>+ <div+ class="w-192 flex flex-row justify-start items-center relative"+ :class="isValidId(state.projectId) ? '' : 'opacity-50'"+ >+ <BBSelect+ class="w-full"+ :selected-item="state.sourceSchema.migrationHistory"+ :item-list="+ databaseMigrationHistoryList(state.sourceSchema.databaseId as DatabaseId)+ "+ :placeholder="$t('change-history.select')"+ :show-prefix-item="databaseMigrationHistoryList(state.sourceSchema.databaseId as DatabaseId).length > 0"+ @select-item="(migrationHistory: MigrationHistory) => handleSchemaVersionSelect(migrationHistory)"+ >+ <template #menuItem="{ item: migrationHistory }">+ <div class="flex justify-between mr-2">+ <NEllipsis class="pr-2" :tooltip="false">+ {{ migrationHistory.version }} -+ {{ migrationHistory.description }}+ </NEllipsis>+ <span class="text-control-light">+ {{+ dayjs(migrationHistory.updatedTs * 1000).format(+ "YYYY-MM-DD HH:mm:ss"+ )+ }}+ </span>+ </div>+ </template>+ <template v-if="shouldShowMoreVersionButton" #suffixItem>+ <div+ class="w-full flex flex-row justify-start items-center pl-3 leading-8 text-accent cursor-pointer hover:opacity-80"+ @click.prevent.capture="+ () => (state.showFeatureModal = true)+ "+ >+ <heroicons-solid:sparkles class="w-4 h-auto mr-1" />+ {{ $t("database.sync-schema.more-version") }}+ </div>+ </template>+ </BBSelect>+ </div></div></div>- </div>- </template>- <template #1>- <SelectTargetDatabasesView- ref="targetDatabaseViewRef"- :project-id="state.projectId!"- :source-schema="state.sourceSchema as any"- />- </template>- </BBStepTab>+ </template>+ <template #1>+ <SelectTargetDatabasesView+ ref="targetDatabaseViewRef"+ :project-id="state.projectId!"+ :source-schema="state.sourceSchema as any"+ />+ </template>+ </BBStepTab>+ </div><FeatureModalv-if="state.showFeatureModal"