Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
Extract VCSSetupWizard and add the VCSCreate route
天舟349bff3b364b
diff --git a/frontend/src/components/VCSSetupWizard.vue b/frontend/src/components/VCSSetupWizard.vuenew file mode 100644index 0000000000..d94b41b557--- /dev/null+++ b/frontend/src/components/VCSSetupWizard.vue@@ -0,0 +1,110 @@+<template>+ <BBStepTab+ :stepItemList="stepList"+ :allowNext="allowNext"+ @select-step="selectStep"+ @finish="finishSetup"+ >+ <template v-slot:0>+ <VCSProviderSelectionPanel :config="state.config" />+ </template>+ <template v-slot:1>+ <VCSProviderInfoPanel :config="state.config" />+ </template>+ <template v-slot:2>+ <VCSProviderConfigPanel :config="state.config" />+ </template>+ </BBStepTab>+</template>++<script lang="ts">+import { computed } from "@vue/runtime-core";+import { reactive } from "@vue/reactivity";+import { BBStepTabItem } from "../bbkit/types";+import VCSProviderSelectionPanel from "./VCSProviderSelectionPanel.vue";+import VCSProviderInfoPanel from "./VCSProviderInfoPanel.vue";+import VCSProviderConfigPanel from "./VCSProviderConfigPanel.vue";+import {+ isValidVCSApplicationIdOrSecret,+ VCSConfig,+ VCSCreate,+} from "../types";+import { isURL } from "../utils";+import { useStore } from "vuex";++const stepList: BBStepTabItem[] = [+ { title: "Choose Git provider" },+ { title: "Fill basic info" },+ { title: "Configure settings" },+];++interface LocalState {+ config: VCSConfig;+ currentStep: number;+}++export default {+ name: "VCSSetupWizard",+ props: {},+ components: {+ VCSProviderSelectionPanel,+ VCSProviderInfoPanel,+ VCSProviderConfigPanel,+ },+ setup(props, ctx) {+ const store = useStore();++ const currentUser = computed(() => store.getters["auth/currentUser"]());++ const state = reactive<LocalState>({+ config: {+ type: "GITLAB_SELF_HOST",+ name: "",+ instanceURL: "",+ applicationId: "",+ secret: "",+ },+ currentStep: 0,+ });++ const allowNext = computed((): boolean => {+ if (state.currentStep == 0) {+ return true;+ } else if (state.currentStep == 1) {+ return isURL(state.config.instanceURL);+ } else if (state.currentStep == 2) {+ return (+ isValidVCSApplicationIdOrSecret(state.config.applicationId) &&+ isValidVCSApplicationIdOrSecret(state.config.secret)+ );+ }+ return true;+ });++ const selectStep = (step: number) => {+ state.currentStep = step;+ };++ const finishSetup = () => {+ if (state.config.name == "") {+ if (state.config.type == "GITLAB_SELF_HOST") {+ state.config.name = state.config.instanceURL;+ }+ }+ const vcsCreate: VCSCreate = {+ creatorId: currentUser.value.id,+ ...state.config,+ };+ store.dispatch("vcs/createVCS", vcsCreate);+ };++ return {+ stepList,+ state,+ allowNext,+ selectStep,+ finishSetup,+ };+ },+};+</script>diff --git a/frontend/src/router/index.ts b/frontend/src/router/index.tsindex 4276b7d9eb..955d8da9d4 100644--- a/frontend/src/router/index.ts+++ b/frontend/src/router/index.ts@@ -258,6 +258,14 @@ const routes: Array<RouteRecordRaw> = [component: () => import("../views/SettingWorkspaceVCS.vue"),props: true,},+ {+ path: "version-control/new",+ name: "setting.workspace.version-control.create",+ meta: { title: () => "Add Git Provider" },+ component: () =>+ import("../views/SettingWorkspaceVCSCreate.vue"),+ props: true,+ },{path: "plan",name: "setting.workspace.plan",diff --git a/frontend/src/views/SettingWorkspaceVCS.vue b/frontend/src/views/SettingWorkspaceVCS.vueindex 1753169374..7d47bfb414 100644--- a/frontend/src/views/SettingWorkspaceVCS.vue+++ b/frontend/src/views/SettingWorkspaceVCS.vue@@ -1,80 +1,48 @@<template>- <template v-if="vcsList.length > 0">- <template v-for="(vcs, index) in vcsList" :key="index">- <VCSCard :vcs="vcs" />- </template>- </template>- <template v-else>- <BBStepTab- :stepItemList="stepList"- :allowNext="allowNext"- @select-step="selectStep"- @finish="finishSetup"- >- <template v-slot:0>- <VCSProviderSelectionPanel :config="state.config" />+ <div class="space-y-4 divide-y divide-block-border">+ <div class="flex items-center justify-end">+ <button+ type="button"+ class="btn-primary ml-3 inline-flex justify-center py-2 px-4"+ @click.prevent="addVCSProvider"+ >+ Add a version control provider+ </button>+ </div>+ <div class="pt-4">+ <template v-if="vcsList.length > 0">+ <template v-for="(vcs, index) in vcsList" :key="index">+ <VCSCard :vcs="vcs" />+ </template></template>- <template v-slot:1>- <VCSProviderInfoPanel :config="state.config" />+ <template v-else>+ <VCSSetupWizard /></template>- <template v-slot:2>- <VCSProviderConfigPanel :config="state.config" />- </template>- </BBStepTab>- </template>+ </div>+ </div></template><script lang="ts">import { computed, watchEffect } from "@vue/runtime-core";import { reactive } from "@vue/reactivity";-import { BBStepTabItem } from "../bbkit/types";-import VCSProviderSelectionPanel from "./VCSProviderSelectionPanel.vue";-import VCSProviderInfoPanel from "./VCSProviderInfoPanel.vue";-import VCSProviderConfigPanel from "./VCSProviderConfigPanel.vue";+import { useRouter } from "vue-router";import VCSCard from "../components/VCSCard.vue";-import {- isValidVCSApplicationIdOrSecret,- VCSConfig,- VCSCreate,-} from "../types";-import { isURL } from "../utils";+import VCSSetupWizard from "../components/VCSSetupWizard.vue";import { useStore } from "vuex";-const stepList: BBStepTabItem[] = [- { title: "Choose Git provider" },- { title: "Fill provider basic info" },- { title: "Configure settings" },-];--interface LocalState {- config: VCSConfig;- currentStep: number;-}+interface LocalState {}export default {name: "SettingWorkspaceVCS",props: {},components: {- VCSProviderSelectionPanel,- VCSProviderInfoPanel,- VCSProviderConfigPanel,VCSCard,+ VCSSetupWizard,},setup(props, ctx) {const store = useStore();-- const currentUser = computed(() => store.getters["auth/currentUser"]());-- const state = reactive<LocalState>({- config: {- type: "GITLAB_SELF_HOST",- name: "",- instanceURL: "",- applicationId: "",- secret: "",- },- currentStep: 0,- });+ const router = useRouter();+ const state = reactive<LocalState>({});const prepareVCSList = () => {store.dispatch("vcs/fetchVCSList");@@ -86,40 +54,16 @@ export default {return store.getters["vcs/vcsList"]();});- const allowNext = computed((): boolean => {- if (state.currentStep == 0) {- return true;- } else if (state.currentStep == 1) {- return isURL(state.config.instanceURL);- } else if (state.currentStep == 2) {- return (- isValidVCSApplicationIdOrSecret(state.config.applicationId) &&- isValidVCSApplicationIdOrSecret(state.config.secret)- );- }- return true;- });-- const selectStep = (step: number) => {- state.currentStep = step;- };-- const finishSetup = () => {- console.log("finish", state.config);- const vcsCreate: VCSCreate = {- creatorId: currentUser.value.id,- ...state.config,- };- store.dispatch("vcs/createVCS", vcsCreate);+ const addVCSProvider = () => {+ router.push({+ name: "setting.workspace.version-control.create",+ });};return {- stepList,state,vcsList,- allowNext,- selectStep,- finishSetup,+ addVCSProvider,};},};diff --git a/frontend/src/views/SettingWorkspaceVCSCreate.vue b/frontend/src/views/SettingWorkspaceVCSCreate.vuenew file mode 100644index 0000000000..9dd46b85e1--- /dev/null+++ b/frontend/src/views/SettingWorkspaceVCSCreate.vue@@ -0,0 +1,38 @@+<template>+ <div class="mt-4 space-y-4 divide-y divide-block-border">+ <div class="flex items-center justify-begin">+ <div class="text-sm text-control">+ To enable GitOps workflow where the database migration scripts are+ stored in the Git repository and automatically applies DDL changes after+ scripts being modified in the repository, Bytebase needs to access the+ corresponding version control system (VCS) instance. Below are the steps+ to configure OAuth with your VCS to obtain that access.+ </div>+ </div>+ <div class="pt-4">+ <VCSSetupWizard />+ </div>+ </div>+</template>++<script lang="ts">+import { reactive } from "@vue/reactivity";+import VCSSetupWizard from "../components/VCSSetupWizard.vue";++interface LocalState {}++export default {+ name: "SettingWorkspaceVCSCreate",+ props: {},+ components: {+ VCSSetupWizard,+ },+ setup(props, ctx) {+ const state = reactive<LocalState>({});++ return {+ state,+ };+ },+};+</script>