Skip to content

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

chore: add schema migration type selector in project setting page (#2575)

boojack4398b446a11a
diff --git a/frontend/src/components/ProjectGeneralSettingPanel.vue b/frontend/src/components/ProjectGeneralSettingPanel.vue
index e241fbbd7a..135463d6c1 100644
--- a/frontend/src/components/ProjectGeneralSettingPanel.vue
+++ b/frontend/src/components/ProjectGeneralSettingPanel.vue
@@ -28,7 +28,7 @@
<dd class="mt-1 text-sm text-main">
<input
id="projectKey"
- :value="state.key"
+ :value="project.key"
disabled
required
autocomplete="off"
@@ -39,6 +39,34 @@
</dl>
</div>
+ <div v-if="isDev">
+ <dl class="">
+ <div class="textlabel">
+ {{ $t("project.settings.schema-migration-type") }}
+ <span class="text-red-600">*</span>
+ </div>
+ <BBSelect
+ id="schemamigrationtype"
+ :selected-item="state.schemaMigrationType"
+ :item-list="['DDL', 'SDL']"
+ class="mt-1"
+ @select-item="
+ (type: SchemaMigrationType) => {
+ state.schemaMigrationType = type;
+ }
+ "
+ >
+ <template #menuItem="{ item }">
+ {{
+ $t(
+ `project.settings.select-schema-migration-type-${item.toLowerCase()}`
+ )
+ }}
+ </template>
+ </BBSelect>
+ </dl>
+ </div>
+
<div v-if="allowEdit" class="flex justify-end">
<button
type="button"
@@ -53,15 +81,20 @@
</template>
<script lang="ts">
-import { computed, defineComponent, PropType, reactive } from "vue";
import isEmpty from "lodash-es/isEmpty";
-import { DEFAULT_PROJECT_ID, Project, ProjectPatch } from "../types";
+import { computed, defineComponent, PropType, reactive } from "vue";
import { useI18n } from "vue-i18n";
+import {
+ DEFAULT_PROJECT_ID,
+ Project,
+ ProjectPatch,
+ SchemaMigrationType,
+} from "../types";
import { pushNotification, useProjectStore } from "@/store";
interface LocalState {
name: string;
- key: string;
+ schemaMigrationType: SchemaMigrationType;
}
export default defineComponent({
@@ -82,30 +115,28 @@ export default defineComponent({
const state = reactive<LocalState>({
name: props.project.name,
- key: props.project.key,
+ schemaMigrationType: props.project.schemaMigrationType,
});
const allowSave = computed((): boolean => {
return (
props.project.id != DEFAULT_PROJECT_ID &&
!isEmpty(state.name) &&
- !isEmpty(state.key) &&
- (state.name != props.project.name || state.key != props.project.key)
+ (state.name !== props.project.name ||
+ state.schemaMigrationType != props.project.schemaMigrationType)
);
});
const save = () => {
- const projectPatch: ProjectPatch = {
- name: state.name != props.project.name ? state.name : undefined,
- };
- let subject = "project settings";
- if (state.name != props.project.name && state.key != props.project.key) {
- subject = "project name and key";
- } else if (state.name != props.project.name) {
- subject = "project name";
- } else if (state.key != props.project.key) {
- subject = "project key";
+ const projectPatch: ProjectPatch = {};
+
+ if (state.name !== props.project.name) {
+ projectPatch.name = state.name;
}
+ if (state.schemaMigrationType !== props.project.schemaMigrationType) {
+ projectPatch.schemaMigrationType = state.schemaMigrationType;
+ }
+
projectStore
.patchProject({
projectId: props.project.id,
@@ -115,12 +146,10 @@ export default defineComponent({
pushNotification({
module: "bytebase",
style: "SUCCESS",
- title: t("project.settings.success-updated-prompt", {
- subject: subject,
- }),
+ title: t("project.settings.success-updated"),
});
state.name = updatedProject.name;
- state.key = updatedProject.key;
+ state.schemaMigrationType = updatedProject.schemaMigrationType;
});
};
diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vue
index 23d90cd8d8..6e9f122595 100644
--- a/frontend/src/components/RepositoryForm.vue
+++ b/frontend/src/components/RepositoryForm.vue
@@ -84,7 +84,7 @@
:item-list="['DDL', 'SDL']"
class="mt-1"
@select-item="
- (type) => {
+ (type: string) => {
$emit('change-schema-migration-type', type);
}
"
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index 0d8e97f889..070e345350 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1041,7 +1041,7 @@
}
},
"settings": {
- "success-updated-prompt": "Successfully updated {subject}.",
+ "success-updated": "Project settings updated successfully.",
"success-member-added-prompt": "Successfully added {name} to the project.",
"success-member-deleted-prompt": "Successfully revoked {name} access from the project.",
"member-placeholder": "Select user",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 94cfecc849..e486a54ba7 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1041,7 +1041,7 @@
}
},
"settings": {
- "success-updated-prompt": "成功更新 {subject}.",
+ "success-updated": "项目设置更新成功",
"success-member-added-prompt": "成功将 {name} 添加到当前项目中.",
"success-member-deleted-prompt": "成功将 {name} 从当前项目移除.",
"member-placeholder": "选择用户",