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 step to BBStepTab component
天舟8b97e7686553
diff --git a/frontend/src/bbkit/BBStepTab.vue b/frontend/src/bbkit/BBStepTab.vuenew file mode 100644index 0000000000..be0be0b93c--- /dev/null+++ b/frontend/src/bbkit/BBStepTab.vue@@ -0,0 +1,154 @@+<template>+ <ol class="flex space-y-0 space-x-8">+ <li v-for="(step, index) in stepItemList" :key="index" class="flex-1">+ <div+ class="group flex flex-col pt-4 border-t-4"+ :class="+ state.currentStep >= index+ ? 'border-accent hover:border-accent-hover cursor-pointer'+ : 'border-control-border'+ "+ @click.prevent="+ () => {+ if (state.currentStep >= index) {+ switchStep(index);+ }+ }+ "+ >+ <div class="flex items-center justify-between">+ <div class="flex flex-col">+ <span+ class="text-xs font-semibold tracking-wide uppercase"+ :class="+ state.currentStep >= index+ ? 'text-accent group-hover:text-accent-hover'+ : 'text-control-light'+ "+ >Step {{ index + 1 }}</span+ >+ <span class="text-sm font-medium">{{ step.title }}</span>+ </div>+ <div+ v-if="state.currentStep > index || state.done"+ class="+ flex+ items-center+ justify-center+ w-6+ h-6+ bg-accent+ text-white+ rounded-full+ select-none+ "+ >+ <svg+ class="w-4 h-4"+ xmlns="http://www.w3.org/2000/svg"+ viewBox="0 0 20 20"+ fill="currentColor"+ aria-hidden="true"+ >+ <path+ fill-rule="evenodd"+ d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"+ clip-rule="evenodd"+ />+ </svg>+ </div>+ </div>+ </div>+ <slot v-if="state.currentStep == index" :name="index" />+ </li>+ </ol>+ <div class="pt-4 flex justify-between">+ <button type="button" class="btn-normal" @click.prevent="cancel">+ Cancel+ </button>+ <div class="flex flex-row space-x-2">+ <button+ v-if="state.currentStep != 0"+ type="button"+ class="btn-normal"+ @click.prevent="switchStep(state.currentStep - 1)"+ >+ <svg+ class="-ml-1 mr-1 h-5 w-5 text-control-light"+ fill="none"+ stroke="currentColor"+ viewBox="0 0 24 24"+ xmlns="http://www.w3.org/2000/svg"+ >+ <path+ stroke-linecap="round"+ stroke-linejoin="round"+ stroke-width="2"+ d="M15 19l-7-7 7-7"+ ></path>+ </svg>+ <span>Back</span>+ </button>+ <button+ v-if="state.currentStep == stepItemList.length - 1"+ type="button"+ class="btn-primary"+ @click.prevent="finish"+ >+ Finish+ </button>+ <button+ v-else+ type="button"+ class="btn-primary"+ @click.prevent="switchStep(state.currentStep + 1)"+ >+ Next+ </button>+ </div>+ </div>+</template>++<script lang="ts">+import { PropType, reactive } from "@vue/runtime-core";+import { BBStepTabItem } from "./types";++interface LocalState {+ done: boolean;+ currentStep: number;+}++export default {+ name: "BBStepTab",+ emits: ["select-step", "finish"],+ props: {+ stepItemList: {+ required: true,+ type: Object as PropType<BBStepTabItem[]>,+ },+ },+ setup(props, { emit }) {+ const state = reactive<LocalState>({+ done: false,+ currentStep: 0,+ });++ const switchStep = (step: number) => {+ state.done = false;+ state.currentStep = step;+ emit("select-step", step);+ };++ const finish = () => {+ state.done = true;+ emit("finish");+ };++ return {+ state,+ switchStep,+ finish,+ };+ },+};+</script>diff --git a/frontend/src/bbkit/index.ts b/frontend/src/bbkit/index.tsindex db4f01b13c..9196178dcd 100644--- a/frontend/src/bbkit/index.ts+++ b/frontend/src/bbkit/index.ts@@ -10,6 +10,7 @@ import BBOutline from "./BBOutline.vue";import BBSwitch from "./BBSwitch.vue";import BBSelect from "./BBSelect.vue";import BBStepBar from "./BBStepBar.vue";+import BBStepTab from "./BBStepTab.vue";import BBTab from "./BBTab.vue";import BBTabPanel from "./BBTabPanel.vue";import BBTextField from "./BBTextField.vue";@@ -33,6 +34,7 @@ export {BBOutline,BBSelect,BBStepBar,+ BBStepTab,BBSwitch,BBTab,BBTabPanel,diff --git a/frontend/src/bbkit/types.ts b/frontend/src/bbkit/types.tsindex 5a249e1552..121bf41a6e 100644--- a/frontend/src/bbkit/types.ts+++ b/frontend/src/bbkit/types.ts@@ -33,6 +33,10 @@ export type BBStep = {link(): string;};+export type BBStepTabItem = {+ title: string;+};+export type BBOutlineItem = {id: string;name: string;diff --git a/frontend/src/components/RepositorySetupPanel.vue b/frontend/src/components/RepositorySetupPanel.vueindex 7cb9042bce..f7f3c29d4f 100644--- a/frontend/src/components/RepositorySetupPanel.vue+++ b/frontend/src/components/RepositorySetupPanel.vue@@ -1,153 +1,35 @@<template>- <nav aria-label="Repository setup">- <ol class="flex space-y-0 space-x-8">- <li v-for="(step, index) in stepList" :key="index" class="flex-1">- <!-- Completed Step -->- <div- class="group flex flex-col pt-4 border-t-4"- :class="- state.currentStep >= index- ? 'border-accent hover:border-accent-hover cursor-pointer'- : 'border-control-border'- "- @click.prevent="- () => {- if (state.currentStep >= index) {- switchStep(index);- }- }- "- >- <div class="flex items-center justify-between">- <div class="flex flex-col">- <span- class="text-xs font-semibold tracking-wide uppercase"- :class="- state.currentStep >= index- ? 'text-accent group-hover:text-accent-hover'- : 'text-control-light'- "- >Step {{ index + 1 }}</span- >- <span class="text-sm font-medium">{{ step }}</span>- </div>- <div- v-if="state.currentStep > index"- class="- flex- items-center- justify-center- w-6- h-6- bg-accent- text-white- rounded-full- select-none- "- >- <svg- class="w-4 h-4"- xmlns="http://www.w3.org/2000/svg"- viewBox="0 0 20 20"- fill="currentColor"- aria-hidden="true"- >- <path- fill-rule="evenodd"- d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z"- clip-rule="evenodd"- />- </svg>- </div>- </div>- </div>- </li>- </ol>- </nav>- <template v-if="state.currentStep == SetupStep.CHOOSE_PROVIDER">- choose provider- </template>- <template v-else-if="state.currentStep == SetupStep.SELECT_REPO">- select repo- </template>- <template v-else-if="state.currentStep == SetupStep.CONFIGURE_DEPLOY">- configure deploy- </template>- <div class="pt-4 flex justify-between">- <button type="button" class="btn-normal" @click.prevent="cancel">- Cancel- </button>- <div class="flex flex-row space-x-2">- <button- v-if="state.currentStep != 0"- type="button"- class="btn-normal"- @click.prevent="switchStep(state.currentStep - 1)"- >- <svg- class="-ml-1 mr-1 h-5 w-5 text-control-light"- fill="none"- stroke="currentColor"- viewBox="0 0 24 24"- xmlns="http://www.w3.org/2000/svg"- >- <path- stroke-linecap="round"- stroke-linejoin="round"- stroke-width="2"- d="M15 19l-7-7 7-7"- ></path>- </svg>- <span>Back</span>- </button>- <button- v-if="state.currentStep == stepList.length - 1"- type="button"- class="btn-primary"- @click.prevent="finishSetup"- >- Finish- </button>- <button- v-else- type="button"- class="btn-primary"- @click.prevent="switchStep(state.currentStep + 1)"- >- Next- </button>- </div>- </div>+ <BBStepTab+ :stepItemList="stepList"+ @select-step="selectStep"+ @finish="finishSetup"+ >+ <template v-slot:0> choose provider </template>+ <template v-slot:1> select repo </template>+ <template v-slot:2> configure deploy </template>+ </BBStepTab></template><script lang="ts">import { reactive } from "@vue/reactivity";-enum SetupStep {- CHOOSE_PROVIDER = 0,- SELECT_REPO = 1,- CONFIGURE_DEPLOY = 2,-}+import { BBStepTabItem } from "../bbkit/types";-interface LocalState {- currentStep: SetupStep;-}+interface LocalState {}-const stepList = [- "Choose Git provider",- "Select repository",- "Configure deploy",+const stepList: BBStepTabItem[] = [+ { title: "Choose Git provider" },+ { title: "Select repository" },+ { title: "Configure deploy" },];export default {name: "RepositorySetupPanel",components: {},setup(props, ctx) {- const state = reactive<LocalState>({- currentStep: SetupStep.CHOOSE_PROVIDER,- });+ const state = reactive<LocalState>({});- const switchStep = (step: SetupStep) => {- state.currentStep = step;+ const selectStep = (step: number) => {+ console.log("select step", step);};const finishSetup = () => {@@ -155,10 +37,9 @@ export default {};return {- SetupStep,state,stepList,- switchStep,+ selectStep,finishSetup,};},diff --git a/frontend/src/main.ts b/frontend/src/main.tsindex 65beaf5c9e..7f7201cbc6 100644--- a/frontend/src/main.ts+++ b/frontend/src/main.ts@@ -22,6 +22,7 @@ import {BBOutline,BBSelect,BBStepBar,+ BBStepTab,BBSwitch,BBTab,BBTabPanel,@@ -175,6 +176,7 @@ app.component("BBOutline", BBOutline).component("BBSelect", BBSelect).component("BBStepBar", BBStepBar)+ .component("BBStepTab", BBStepTab).component("BBSwitch", BBSwitch).component("BBTab", BBTab).component("BBTabPanel", BBTabPanel)