Skip to content

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

fix: detech branch detail props changes (#8898)

boojack85ff0f5c031e
diff --git a/frontend/src/components/Branch/BranchCreateView.vue b/frontend/src/components/Branch/BranchCreateView.vue
index ee42122150..abf8e410cc 100644
--- a/frontend/src/components/Branch/BranchCreateView.vue
+++ b/frontend/src/components/Branch/BranchCreateView.vue
@@ -66,6 +66,7 @@
<NButton
type="primary"
:disabled="!allowConfirm"
+ :loading="state.isCreating"
@click.prevent="handleConfirm"
>
{{ confirmText }}
@@ -129,6 +130,7 @@ interface LocalState {
baselineSchema: BaselineSchema;
schemaDesign: SchemaDesign;
parentBranchName?: string;
+ isCreating: boolean;
}
const props = defineProps({
@@ -153,6 +155,7 @@ const state = reactive<LocalState>({
schemaDesign: SchemaDesign.fromPartial({
type: SchemaDesign_Type.MAIN_BRANCH,
}),
+ isCreating: false,
});
const showProjectSelector = ref<boolean>(true);
const refreshId = ref<string>("");
@@ -272,7 +275,8 @@ const allowConfirm = computed(() => {
return (
state.projectId &&
state.schemaDesignTitle &&
- state.baselineSchema.databaseId
+ state.baselineSchema.databaseId &&
+ !state.isCreating
);
});
@@ -326,6 +330,7 @@ const handleConfirm = async () => {
return;
}
+ state.isCreating = true;
const metadata = mergeSchemaEditToMetadata(
branchSchema.schemaList,
cloneDeep(
@@ -376,6 +381,7 @@ const handleConfirm = async () => {
title: state.schemaDesignTitle,
});
}
+ state.isCreating = false;
pushNotification({
module: "bytebase",
style: "SUCCESS",
diff --git a/frontend/src/components/Branch/BranchDetailView.vue b/frontend/src/components/Branch/BranchDetailView.vue
index 440950bd4a..3bd7e56578 100644
--- a/frontend/src/components/Branch/BranchDetailView.vue
+++ b/frontend/src/components/Branch/BranchDetailView.vue
@@ -36,9 +36,12 @@
<NButton @click="handleCancelEdit">{{
$t("common.cancel")
}}</NButton>
- <NButton type="primary" @click="handleSaveBranch">{{
- $t("common.save")
- }}</NButton>
+ <NButton
+ type="primary"
+ :loading="state.isSaving"
+ @click="handleSaveBranch"
+ >{{ $t("common.save") }}</NButton
+ >
</template>
</div>
</div>
@@ -149,6 +152,7 @@ interface LocalState {
isEditing: boolean;
isEditingTitle: boolean;
showDiffEditor: boolean;
+ isSaving: boolean;
}
const props = defineProps<{
@@ -170,6 +174,7 @@ const state = reactive<LocalState>({
isEditing: false,
isEditingTitle: false,
showDiffEditor: false,
+ isSaving: false,
});
const mergeBranchPanelContext = ref<{
sourceBranchName: string;
@@ -361,6 +366,9 @@ const handleSaveBranch = async () => {
if (!state.isEditing) {
return;
}
+ if (state.isSaving) {
+ return;
+ }
const check = runSQLCheck.value;
if (check && !(await check())) {
return;
@@ -396,6 +404,7 @@ const handleSaveBranch = async () => {
updateMask.push("metadata");
}
+ state.isSaving = true;
if (updateMask.length !== 0) {
if (schemaDesign.value.type === SchemaDesign_Type.MAIN_BRANCH) {
const branchName = generateForkedBranchName(schemaDesign.value);
@@ -453,6 +462,7 @@ const handleSaveBranch = async () => {
description: error.details,
});
}
+ state.isSaving = false;
return;
}
@@ -483,6 +493,7 @@ const handleSaveBranch = async () => {
title: t("schema-designer.message.updated-succeed"),
});
}
+ state.isSaving = false;
state.isEditing = false;
};
diff --git a/frontend/src/views/branch/BranchDetail.vue b/frontend/src/views/branch/BranchDetail.vue
index 2ed89ad464..edd793f1bb 100644
--- a/frontend/src/views/branch/BranchDetail.vue
+++ b/frontend/src/views/branch/BranchDetail.vue
@@ -11,8 +11,7 @@
<script lang="ts" setup>
import { useTitle } from "@vueuse/core";
-import { computed, ref } from "vue";
-import { onMounted } from "vue";
+import { computed, ref, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import BranchCreateView from "@/components/Branch/BranchCreateView.vue";
@@ -34,29 +33,50 @@ const branch = computed(() => {
return schemaDesignStore.getSchemaDesignByName(branchName.value);
});
-onMounted(async () => {
- if (isCreating.value) {
- ready.value = true;
- return;
- }
+watch(
+ () => route.params,
+ async () => {
+ if (isCreating.value) {
+ return;
+ }
- // Prepare branch name from route params.
- const sheetId = (route.params.branchName as string) || "";
- if (!sheetId) {
- return { ready: false };
+ // Prepare branch name from route params.
+ const sheetId = (route.params.branchName as string) || "";
+ if (!sheetId) {
+ return;
+ }
+ const sheet = await sheetStore.getOrFetchSheetByUID(`${sheetId}`);
+ if (sheet) {
+ const [projectName] = getProjectAndSheetId(sheet.name);
+ await projectStore.getOrFetchProjectByName(`projects/${projectName}`);
+ branchName.value = `projects/${projectName}/schemaDesigns/${sheetId}`;
+ }
+ },
+ {
+ immediate: true,
+ deep: true,
}
- const sheet = await sheetStore.getOrFetchSheetByUID(`${sheetId}`);
- if (sheet) {
- const [projectName] = getProjectAndSheetId(sheet.name);
- await projectStore.getOrFetchProjectByName(`projects/${projectName}`);
- branchName.value = `projects/${projectName}/schemaDesigns/${sheetId}`;
+);
+
+watch(
+ () => branchName.value,
+ async () => {
+ ready.value = false;
+ if (isCreating.value || !branchName.value) {
+ ready.value = true;
+ return;
+ }
+
await schemaDesignStore.fetchSchemaDesignByName(
branchName.value,
false /* useCache */
);
ready.value = true;
+ },
+ {
+ immediate: true,
}
-});
+);
const documentTitle = computed(() => {
if (isCreating.value) {