Skip to content

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

UX enhancement for VCS setup workflow

天舟4f37611dbc40
diff --git a/frontend/src/components/VCSCard.vue b/frontend/src/components/VCSCard.vue
index 39054cf95a..fe91ce5cac 100644
--- a/frontend/src/components/VCSCard.vue
+++ b/frontend/src/components/VCSCard.vue
@@ -111,6 +111,8 @@ export default {
}
};
+ store.dispatch("vcs/fetchRepositoryListByVCS", props.vcs);
+
onUnmounted(() => {
window.removeEventListener(OAuthWindowEvent, eventListener);
});
diff --git a/frontend/src/components/VCSProviderConfigPanel.vue b/frontend/src/components/VCSProviderConfigPanel.vue
deleted file mode 100644
index 763f24cd7c..0000000000
--- a/frontend/src/components/VCSProviderConfigPanel.vue
+++ /dev/null
@@ -1,122 +0,0 @@
-<template>
- <div class="textlabel">
- Application ID <span class="text-red-600">*</span>
- </div>
- <BBTextField
- class="mt-2 w-full"
- :placeholder="'ex. 5333b60a6c9f234272dac2ee6b3422aaf224e0a66def54e0d243b77be7a8edda'"
- :value="config.applicationId"
- @input="changeApplicatonId($event.target.value)"
- />
- <p v-if="state.showApplicationIdError" class="mt-2 text-sm text-error">
- Application ID must be a 64-character alphanumeric string
- </p>
- <div class="mt-4 textlabel">Secret <span class="text-red-600">*</span></div>
- <BBTextField
- class="mt-2 w-full"
- :placeholder="'ex. b9e0efc7a233403799b42620c60ff98c146895a27b6219912ad15f4e2251cc3a'"
- :value="config.secret"
- @input="changeSecret($event.target.value)"
- />
- <p v-if="state.showSecretError" class="mt-2 text-sm text-error">
- Secret must be a 64-character alphanumeric string
- </p>
-</template>
-
-<script lang="ts">
-import { onUnmounted, PropType, reactive } from "@vue/runtime-core";
-import isEmpty from "lodash-es/isEmpty";
-import {
- isValidVCSApplicationIdOrSecret,
- TEXT_VALIDATION_DELAY,
- VCSConfig,
-} from "../types";
-
-interface LocalState {
- applicationIdValidationTimer?: ReturnType<typeof setTimeout>;
- showApplicationIdError: boolean;
- secretValidationTimer?: ReturnType<typeof setTimeout>;
- showSecretError: boolean;
-}
-
-export default {
- name: "VCSProviderConfigPanel",
- props: {
- config: {
- required: true,
- type: Object as PropType<VCSConfig>,
- },
- },
- setup(props, ctx) {
- const state = reactive<LocalState>({
- showApplicationIdError:
- !isEmpty(props.config.applicationId) &&
- !isValidVCSApplicationIdOrSecret(props.config.applicationId),
- showSecretError:
- !isEmpty(props.config.secret) &&
- !isValidVCSApplicationIdOrSecret(props.config.secret),
- });
-
- onUnmounted(() => {
- clearInterval(state.applicationIdValidationTimer);
- clearInterval(state.secretValidationTimer);
- });
-
- const changeApplicatonId = (value: string) => {
- props.config.applicationId = value;
-
- clearInterval(state.applicationIdValidationTimer);
- // If text becomes valid, we immediately clear the error.
- // otherwise, we delay TEXT_VALIDATION_DELAY to do the validation in case there is continous keystroke.
- if (isValidVCSApplicationIdOrSecret(props.config.applicationId)) {
- state.showApplicationIdError = false;
- } else {
- state.applicationIdValidationTimer = setTimeout(() => {
- // If error is already displayed, we hide the error only if there is valid input.
- // Otherwise, we hide the error if input is either empty or valid.
- if (state.showApplicationIdError) {
- state.showApplicationIdError = !isValidVCSApplicationIdOrSecret(
- props.config.applicationId
- );
- } else {
- state.showApplicationIdError =
- !isValidVCSApplicationIdOrSecret(props.config.applicationId) &&
- !isValidVCSApplicationIdOrSecret(props.config.applicationId);
- }
- }, TEXT_VALIDATION_DELAY);
- }
- };
-
- const changeSecret = (value: string) => {
- props.config.secret = value;
-
- clearInterval(state.secretValidationTimer);
- // If text becomes valid, we immediately clear the error.
- // otherwise, we delay TEXT_VALIDATION_DELAY to do the validation in case there is continous keystroke.
- if (isValidVCSApplicationIdOrSecret(props.config.secret)) {
- state.showSecretError = false;
- } else {
- state.secretValidationTimer = setTimeout(() => {
- // If error is already displayed, we hide the error only if there is valid input.
- // Otherwise, we hide the error if input is either empty or valid.
- if (state.showSecretError) {
- state.showSecretError = !isValidVCSApplicationIdOrSecret(
- props.config.secret
- );
- } else {
- state.showSecretError =
- !isEmpty(props.config.secret) &&
- !isValidVCSApplicationIdOrSecret(props.config.secret);
- }
- }, TEXT_VALIDATION_DELAY);
- }
- };
-
- return {
- state,
- changeApplicatonId,
- changeSecret,
- };
- },
-};
-</script>
diff --git a/frontend/src/components/VCSProviderInfoPanel.vue b/frontend/src/components/VCSProviderInfoPanel.vue
index e9f7b4a390..7c649faab4 100644
--- a/frontend/src/components/VCSProviderInfoPanel.vue
+++ b/frontend/src/components/VCSProviderInfoPanel.vue
@@ -4,7 +4,7 @@
</div>
<p class="mt-1 textinfolabel">
The VCS instance URL. Make sure this instance and Bytebase are network
- accessible from each other.
+ reachable from each other.
</p>
<BBTextField
class="mt-2 w-full"
diff --git a/frontend/src/components/VCSProviderOAuthPanel.vue b/frontend/src/components/VCSProviderOAuthPanel.vue
new file mode 100644
index 0000000000..00ed6cca98
--- /dev/null
+++ b/frontend/src/components/VCSProviderOAuthPanel.vue
@@ -0,0 +1,210 @@
+<template>
+ <div class="space-y-4">
+ <div class="textlabel">
+ <template v-if="config.type == 'GITLAB_SELF_HOST'">
+ Register Bytebase as a GitLab system OAuth application.
+ </template>
+ </div>
+ <ol class="textinfolabel space-y-2">
+ <template v-if="config.type == 'GITLAB_SELF_HOST'">
+ <li>
+ 1. Login as an Admin user to the GitLab instance. The account must be
+ an Admin of the entire GitLab instance (not just a particular
+ project).
+ </li>
+ <li>
+ 2. Visit the Admin page, then navigate to "Applications" section and
+ click "New application" button.
+ <a
+ :href="createAdminApplicationURL"
+ target="_blank"
+ class="normal-link"
+ >Visit now</a
+ >
+ </li>
+ <li>
+ 3. Create our Bytebase OAuth application with the following info.
+ <div class="m-4 flex justify-center">
+ <dl
+ class="
+ divide-y divide-block-border
+ border border-block-border
+ shadow
+ rounded-lg
+ "
+ >
+ <div class="grid grid-cols-2 gap-4 px-4 py-2">
+ <dt class="text-sm font-medium text-control-light text-right">
+ Name
+ </dt>
+ <dd class="text-sm text-main">Bytebase</dd>
+ </div>
+ <div class="grid grid-cols-2 gap-4 px-4 py-2">
+ <dt class="text-sm font-medium text-control-light text-right">
+ Redirect URI
+ </dt>
+ <dd class="text-sm text-main">{{ redirectURL() }}</dd>
+ </div>
+ <div class="grid grid-cols-2 gap-4 px-4 py-2">
+ <dt class="text-sm font-medium text-control-light text-right">
+ Trusted
+ </dt>
+ <dd class="text-sm text-main">Yes</dd>
+ </div>
+ <div class="grid grid-cols-2 gap-4 px-4 py-2">
+ <dt class="text-sm font-medium text-control-light text-right">
+ Confidential
+ </dt>
+ <dd class="text-sm text-main">Yes</dd>
+ </div>
+ <div class="grid grid-cols-2 gap-4 px-4 py-2">
+ <dt class="text-sm font-medium text-control-light text-right">
+ Scopes
+ </dt>
+ <dd class="text-sm text-main">api</dd>
+ </div>
+ </dl>
+ </div>
+ </li>
+ <li>
+ 4. Paste the Application ID and Secret from that just created
+ application into fields below.
+ </li>
+ </template>
+ </ol>
+ <div>
+ <div class="textlabel">
+ Application ID <span class="text-red-600">*</span>
+ </div>
+ <BBTextField
+ class="mt-2 w-full"
+ :placeholder="'ex. 5333b60a6c9f234272dac2ee6b3422aaf224e0a66def54e0d243b77be7a8edda'"
+ :value="config.applicationId"
+ @input="changeApplicatonId($event.target.value)"
+ />
+ <p v-if="state.showApplicationIdError" class="mt-2 text-sm text-error">
+ Application ID must be a 64-character alphanumeric string
+ </p>
+ <div class="mt-4 textlabel">
+ Secret <span class="text-red-600">*</span>
+ </div>
+ <BBTextField
+ class="mt-2 w-full"
+ :placeholder="'ex. b9e0efc7a233403799b42620c60ff98c146895a27b6219912ad15f4e2251cc3a'"
+ :value="config.secret"
+ @input="changeSecret($event.target.value)"
+ />
+ <p v-if="state.showSecretError" class="mt-2 text-sm text-error">
+ Secret must be a 64-character alphanumeric string
+ </p>
+ </div>
+ </div>
+</template>
+
+<script lang="ts">
+import { computed, onUnmounted, PropType, reactive } from "@vue/runtime-core";
+import isEmpty from "lodash-es/isEmpty";
+import {
+ isValidVCSApplicationIdOrSecret,
+ TEXT_VALIDATION_DELAY,
+ VCSConfig,
+ redirectURL,
+} from "../types";
+
+interface LocalState {
+ applicationIdValidationTimer?: ReturnType<typeof setTimeout>;
+ showApplicationIdError: boolean;
+ secretValidationTimer?: ReturnType<typeof setTimeout>;
+ showSecretError: boolean;
+}
+
+export default {
+ name: "VCSProviderOAuthPanel",
+ props: {
+ config: {
+ required: true,
+ type: Object as PropType<VCSConfig>,
+ },
+ },
+ setup(props, ctx) {
+ const state = reactive<LocalState>({
+ showApplicationIdError:
+ !isEmpty(props.config.applicationId) &&
+ !isValidVCSApplicationIdOrSecret(props.config.applicationId),
+ showSecretError:
+ !isEmpty(props.config.secret) &&
+ !isValidVCSApplicationIdOrSecret(props.config.secret),
+ });
+
+ onUnmounted(() => {
+ clearInterval(state.applicationIdValidationTimer);
+ clearInterval(state.secretValidationTimer);
+ });
+
+ const createAdminApplicationURL = computed((): string => {
+ if (props.config.type == "GITLAB_SELF_HOST") {
+ return `${props.config.instanceURL}/admin/applications/new`;
+ }
+ return "";
+ });
+
+ const changeApplicatonId = (value: string) => {
+ props.config.applicationId = value;
+
+ clearInterval(state.applicationIdValidationTimer);
+ // If text becomes valid, we immediately clear the error.
+ // otherwise, we delay TEXT_VALIDATION_DELAY to do the validation in case there is continous keystroke.
+ if (isValidVCSApplicationIdOrSecret(props.config.applicationId)) {
+ state.showApplicationIdError = false;
+ } else {
+ state.applicationIdValidationTimer = setTimeout(() => {
+ // If error is already displayed, we hide the error only if there is valid input.
+ // Otherwise, we hide the error if input is either empty or valid.
+ if (state.showApplicationIdError) {
+ state.showApplicationIdError = !isValidVCSApplicationIdOrSecret(
+ props.config.applicationId
+ );
+ } else {
+ state.showApplicationIdError =
+ !isValidVCSApplicationIdOrSecret(props.config.applicationId) &&
+ !isValidVCSApplicationIdOrSecret(props.config.applicationId);
+ }
+ }, TEXT_VALIDATION_DELAY);
+ }
+ };
+
+ const changeSecret = (value: string) => {
+ props.config.secret = value;
+
+ clearInterval(state.secretValidationTimer);
+ // If text becomes valid, we immediately clear the error.
+ // otherwise, we delay TEXT_VALIDATION_DELAY to do the validation in case there is continous keystroke.
+ if (isValidVCSApplicationIdOrSecret(props.config.secret)) {
+ state.showSecretError = false;
+ } else {
+ state.secretValidationTimer = setTimeout(() => {
+ // If error is already displayed, we hide the error only if there is valid input.
+ // Otherwise, we hide the error if input is either empty or valid.
+ if (state.showSecretError) {
+ state.showSecretError = !isValidVCSApplicationIdOrSecret(
+ props.config.secret
+ );
+ } else {
+ state.showSecretError =
+ !isEmpty(props.config.secret) &&
+ !isValidVCSApplicationIdOrSecret(props.config.secret);
+ }
+ }, TEXT_VALIDATION_DELAY);
+ }
+ };
+
+ return {
+ redirectURL,
+ state,
+ createAdminApplicationURL,
+ changeApplicatonId,
+ changeSecret,
+ };
+ },
+};
+</script>
diff --git a/frontend/src/components/VCSSetupWizard.vue b/frontend/src/components/VCSSetupWizard.vue
index d94b41b557..20c8ed7f48 100644
--- a/frontend/src/components/VCSSetupWizard.vue
+++ b/frontend/src/components/VCSSetupWizard.vue
@@ -1,9 +1,12 @@
<template>
+ <BBAttention :description="attentionText" />
<BBStepTab
+ class="mt-4"
:stepItemList="stepList"
:allowNext="allowNext"
@select-step="selectStep"
@finish="finishSetup"
+ @cancel="cancelSetup"
>
<template v-slot:0>
<VCSProviderSelectionPanel :config="state.config" />
@@ -12,7 +15,7 @@
<VCSProviderInfoPanel :config="state.config" />
</template>
<template v-slot:2>
- <VCSProviderConfigPanel :config="state.config" />
+ <VCSProviderOAuthPanel :config="state.config" />
</template>
</BBStepTab>
</template>
@@ -20,10 +23,11 @@
<script lang="ts">
import { computed } from "@vue/runtime-core";
import { reactive } from "@vue/reactivity";
+import { useRouter } from "vue-router";
import { BBStepTabItem } from "../bbkit/types";
import VCSProviderSelectionPanel from "./VCSProviderSelectionPanel.vue";
import VCSProviderInfoPanel from "./VCSProviderInfoPanel.vue";
-import VCSProviderConfigPanel from "./VCSProviderConfigPanel.vue";
+import VCSProviderOAuthPanel from "./VCSProviderOAuthPanel.vue";
import {
isValidVCSApplicationIdOrSecret,
VCSConfig,
@@ -34,8 +38,8 @@ import { useStore } from "vuex";
const stepList: BBStepTabItem[] = [
{ title: "Choose Git provider" },
- { title: "Fill basic info" },
- { title: "Configure settings" },
+ { title: "Basic info" },
+ { title: "OAuth application info" },
];
interface LocalState {
@@ -49,10 +53,11 @@ export default {
components: {
VCSProviderSelectionPanel,
VCSProviderInfoPanel,
- VCSProviderConfigPanel,
+ VCSProviderOAuthPanel,
},
setup(props, ctx) {
const store = useStore();
+ const router = useRouter();
const currentUser = computed(() => store.getters["auth/currentUser"]());
@@ -81,6 +86,13 @@ export default {
return true;
});
+ const attentionText = computed((): string => {
+ if (state.config.type == "GITLAB_SELF_HOST") {
+ return "You need to be an Admin of your chosen GitLab instance to configure this. Otherwise, you need to ask your GitLab instance Admin to register a system OAuth application for Bytebase, then provide you that Application ID and Secret to fill in Step 3.";
+ }
+ return "";
+ });
+
const selectStep = (step: number) => {
state.currentStep = step;
};
@@ -98,12 +110,20 @@ export default {
store.dispatch("vcs/createVCS", vcsCreate);
};
+ const cancelSetup = () => {
+ router.push({
+ name: "setting.workspace.version-control",
+ });
+ };
+
return {
stepList,
state,
allowNext,
+ attentionText,
selectStep,
finishSetup,
+ cancelSetup,
};
},
};
diff --git a/frontend/src/views/SettingWorkspaceVCS.vue b/frontend/src/views/SettingWorkspaceVCS.vue
index 7d47bfb414..6bb462d3c8 100644
--- a/frontend/src/views/SettingWorkspaceVCS.vue
+++ b/frontend/src/views/SettingWorkspaceVCS.vue
@@ -6,7 +6,7 @@
class="btn-primary ml-3 inline-flex justify-center py-2 px-4"
@click.prevent="addVCSProvider"
>
- Add a version control provider
+ Add a Git provider
</button>
</div>
<div class="pt-4">
diff --git a/frontend/src/views/SettingWorkspaceVCSCreate.vue b/frontend/src/views/SettingWorkspaceVCSCreate.vue
index 9dd46b85e1..dcbffa1e05 100644
--- a/frontend/src/views/SettingWorkspaceVCSCreate.vue
+++ b/frontend/src/views/SettingWorkspaceVCSCreate.vue
@@ -1,13 +1,11 @@
<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 class="textinfolabel">
+ Before any project can enable version control workflow to automatically
+ apply DDL on database migration scripts changes in the Git repository,
+ Bytebase first needs to integrate with the corresponding version control
+ system (VCS) by registering as an OAuth application in that VCS. Below are
+ the steps to configure this.
</div>
<div class="pt-4">
<VCSSetupWizard />