Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore(frontend): branch and schema editor UI improvements (#10248)

Liu Jic6f005f4de2d
diff --git a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
index 58aa8b05e9..71cd6186db 100644
--- a/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
+++ b/frontend/src/components/AlterSchemaPrepForm/SchemaEditorModal.vue
@@ -497,7 +497,7 @@ const handlePreviewIssue = async () => {
pushNotification({
module: "bytebase",
style: "WARN",
- title: t("common.error"),
+ title: t("common.warning"),
description: t("schema-editor.nothing-changed-for-database", {
database,
}),
diff --git a/frontend/src/components/Branch/BranchMergeView/MergeBranchStep.vue b/frontend/src/components/Branch/BranchMergeView/MergeBranchStep.vue
index 2ec815ba58..8ee7b6c4e4 100644
--- a/frontend/src/components/Branch/BranchMergeView/MergeBranchStep.vue
+++ b/frontend/src/components/Branch/BranchMergeView/MergeBranchStep.vue
@@ -39,6 +39,7 @@
<script setup lang="ts">
import { ref, watch } from "vue";
+import { DiffEditor } from "@/components/MonacoEditor";
import SchemaEditorLite from "@/components/SchemaEditorLite";
import { useDatabaseV1Store } from "@/store";
import { ComposedProject } from "@/types";
diff --git a/frontend/src/components/Branch/BranchRolloutView/BranchRolloutView.vue b/frontend/src/components/Branch/BranchRolloutView/BranchRolloutView.vue
index f1c1f0437a..a4a1f1b96c 100644
--- a/frontend/src/components/Branch/BranchRolloutView/BranchRolloutView.vue
+++ b/frontend/src/components/Branch/BranchRolloutView/BranchRolloutView.vue
@@ -106,6 +106,7 @@
:content="rawSQLPreviewState.value"
:readonly="true"
:auto-focus="false"
+ :placeholder="rawSQLPreviewPlaceholder"
/>
</div>
@@ -170,6 +171,11 @@ const rawSQLPreviewState = reactive({
value: "",
isFetching: false,
});
+const rawSQLPreviewPlaceholder = computed(() => {
+ if (rawSQLPreviewState.isFetching) return undefined;
+ if (rawSQLPreviewPlaceholder.value) return undefined;
+ return t("schema-editor.generated-ddl-is-empty");
+});
const router = useRouter();
const schemaEditorRef = ref<InstanceType<typeof SchemaEditorLite>>();
diff --git a/frontend/src/components/Branch/SchemaDesignEditorLite.vue b/frontend/src/components/Branch/SchemaDesignEditorLite.vue
index b35105035c..44c614a211 100644
--- a/frontend/src/components/Branch/SchemaDesignEditorLite.vue
+++ b/frontend/src/components/Branch/SchemaDesignEditorLite.vue
@@ -60,6 +60,7 @@
:content="rawSQLPreviewState.value"
:readonly="true"
:auto-focus="false"
+ :placeholder="rawSQLPreviewPlaceholder"
/>
</div>
</div>
@@ -100,6 +101,11 @@ const rawSQLPreviewState = reactive({
value: "",
isFetching: false,
});
+const rawSQLPreviewPlaceholder = computed(() => {
+ if (rawSQLPreviewState.isFetching) return undefined;
+ if (rawSQLPreviewPlaceholder.value) return undefined;
+ return t("schema-editor.generated-ddl-is-empty");
+});
const database = computed(() => {
return useDatabaseV1Store().getDatabaseByName(props.branch.baselineDatabase);
});
diff --git a/frontend/src/components/MonacoEditor/MonacoTextModelEditor.vue b/frontend/src/components/MonacoEditor/MonacoTextModelEditor.vue
index 5becd12d54..9884dab700 100644
--- a/frontend/src/components/MonacoEditor/MonacoTextModelEditor.vue
+++ b/frontend/src/components/MonacoEditor/MonacoTextModelEditor.vue
@@ -6,6 +6,18 @@
>
<BBSpin />
</div>
+ <div
+ v-if="ready && !content && placeholder"
+ class="absolute pointer-events-none font-mono text-control-placeholder"
+ style="
+ font-family: 'Droid Sans Mono', monospace;
+ font-size: 14px;
+ left: 52px;
+ top: 8px;
+ "
+ >
+ {{ placeholder }}
+ </div>
</div>
</template>
@@ -19,6 +31,7 @@ import {
onBeforeUnmount,
watch,
watchEffect,
+ computed,
} from "vue";
import { useLegacyAutoComplete } from "@/plugins/sql-lsp/client";
import type { SQLDialect } from "@/types";
@@ -59,6 +72,7 @@ const props = withDefaults(
advices?: AdviceOption[];
lineHighlights?: LineHighlightOption[];
options?: IStandaloneEditorConstructionOptions;
+ placeholder?: string;
}>(),
{
model: undefined,
@@ -70,6 +84,7 @@ const props = withDefaults(
advices: () => [],
lineHighlights: () => [],
options: undefined,
+ placeholder: undefined,
}
);
@@ -147,6 +162,10 @@ onMounted(async () => {
}
});
+const content = computed(() => {
+ return props.model?.getValue();
+});
+
onBeforeUnmount(() => {
editorRef.value?.dispose();
});
diff --git a/frontend/src/components/MonacoEditor/editor.ts b/frontend/src/components/MonacoEditor/editor.ts
index 054251a1f7..f472fd5780 100644
--- a/frontend/src/components/MonacoEditor/editor.ts
+++ b/frontend/src/components/MonacoEditor/editor.ts
@@ -132,7 +132,7 @@ export const defaultDiffEditorOptions =
minimap: {
enabled: false,
},
- wordWrap: "on",
+ wordWrap: "off",
fixedOverflowWidgets: true,
fontSize: 14,
lineHeight: 24,
diff --git a/frontend/src/components/SQLCheck/SQLCheckButton.vue b/frontend/src/components/SQLCheck/SQLCheckButton.vue
index c2aee843a3..1c007369b3 100644
--- a/frontend/src/components/SQLCheck/SQLCheckButton.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckButton.vue
@@ -152,9 +152,6 @@ const runChecks = async () => {
advices.value = [];
}
const { statement, errors } = await props.getStatement();
- if (statement.length === 0) {
- return handleErrors([t("common.nothing-changed")]);
- }
if (statement.length > SKIP_CHECK_THRESHOLD) {
return handleErrors([t("issue.sql-check.statement-is-too-large")]);
}
diff --git a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/OperationCell.vue b/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/OperationCell.vue
index 584687e418..79f532ec18 100644
--- a/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/OperationCell.vue
+++ b/frontend/src/components/SchemaEditorLite/Panels/IndexesEditor/components/OperationCell.vue
@@ -6,7 +6,9 @@
<TrashIcon class="w-4 h-4" />
</MiniActionButton>
</template>
- <template #default> asdf </template>
+ <template #default>
+ {{ $t("branch.index.drop-index-confirm") }}
+ </template>
</NPopconfirm>
</div>
</template>
diff --git a/frontend/src/components/SchemaEditorLite/common.ts b/frontend/src/components/SchemaEditorLite/common.ts
index 81e1187dd1..4c634ea1a3 100644
--- a/frontend/src/components/SchemaEditorLite/common.ts
+++ b/frontend/src/components/SchemaEditorLite/common.ts
@@ -33,15 +33,7 @@ export const generateDiffDDL = async (
};
if (isEqual(source, target)) {
- return finish(
- "",
- [
- t("schema-editor.nothing-changed-for-database", {
- database: database.databaseName,
- }),
- ],
- true
- );
+ return finish("", [], false);
}
const validationMessages = validateDatabaseMetadata(target);
@@ -75,15 +67,7 @@ export const generateDiffDDL = async (
true
);
}
- return finish(
- "",
- [
- t("schema-editor.nothing-changed-for-database", {
- database: database.databaseName,
- }),
- ],
- true
- );
+ return finish("", [], false);
}
return finish(diff, [], false);
} catch (ex) {
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index cecf172c98..ce16c0f8d9 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2380,7 +2380,8 @@
"indexes": "Indexes",
"edit-indexes": "Edit indexes",
"unique": "Unique"
- }
+ },
+ "generated-ddl-is-empty": "Generated DDL is empty"
},
"label": {
"empty-label-value": "Empty",
@@ -3421,6 +3422,9 @@
"baseline-version": "Baseline version",
"parent-branch": "Parent branch",
"self": "Source"
+ },
+ "index": {
+ "drop-index-confirm": "Drop index?"
}
}
}
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 340bc53d90..d5ee5fe45f 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2376,7 +2376,8 @@
"indexes": "Índices",
"edit-indexes": "Editar índices",
"unique": "Único"
- }
+ },
+ "generated-ddl-is-empty": "El DDL generado está vacío"
},
"label": {
"empty-label-value": "Valor",
@@ -3419,6 +3420,9 @@
"baseline-version": "Versión básica",
"parent-branch": "Rama principal",
"self": "Fuente"
+ },
+ "index": {
+ "drop-index-confirm": "¿Índice de caída?"
}
}
}
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index f852dc9847..c525477b75 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2376,7 +2376,8 @@
"indexes": "索引",
"edit-indexes": "编辑索引",
"unique": "唯一"
- }
+ },
+ "generated-ddl-is-empty": "生成的 DDL 为空"
},
"label": {
"empty-label-value": "空",
@@ -3414,6 +3415,9 @@
"baseline-version": "基线版本",
"parent-branch": "父分支",
"self": "来源"
+ },
+ "index": {
+ "drop-index-confirm": "删除索引?"
}
}
}