Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
VCS panel UI work to wire the input fields
天舟6557bab6bc2a
diff --git a/frontend/src/assets/github-logo.svg b/frontend/src/assets/github-logo.svgnew file mode 100644index 0000000000..a8d1174049--- /dev/null+++ b/frontend/src/assets/github-logo.svg@@ -0,0 +1,3 @@+<svg width="1024" height="1024" viewBox="0 0 1024 1024" fill="none" xmlns="http://www.w3.org/2000/svg">+<path fill-rule="evenodd" clip-rule="evenodd" d="M8 0C3.58 0 0 3.58 0 8C0 11.54 2.29 14.53 5.47 15.59C5.87 15.66 6.02 15.42 6.02 15.21C6.02 15.02 6.01 14.39 6.01 13.72C4 14.09 3.48 13.23 3.32 12.78C3.23 12.55 2.84 11.84 2.5 11.65C2.22 11.5 1.82 11.13 2.49 11.12C3.12 11.11 3.57 11.7 3.72 11.94C4.44 13.15 5.59 12.81 6.05 12.6C6.12 12.08 6.33 11.73 6.56 11.53C4.78 11.33 2.92 10.64 2.92 7.58C2.92 6.71 3.23 5.99 3.74 5.43C3.66 5.23 3.38 4.41 3.82 3.31C3.82 3.31 4.49 3.1 6.02 4.13C6.66 3.95 7.34 3.86 8.02 3.86C8.7 3.86 9.38 3.95 10.02 4.13C11.55 3.09 12.22 3.31 12.22 3.31C12.66 4.41 12.38 5.23 12.3 5.43C12.81 5.99 13.12 6.7 13.12 7.58C13.12 10.65 11.25 11.33 9.47 11.53C9.76 11.78 10.01 12.26 10.01 13.01C10.01 14.08 10 14.94 10 15.21C10 15.42 10.15 15.67 10.55 15.59C13.71 14.53 16 11.53 16 8C16 3.58 12.42 0 8 0Z" transform="scale(64)" fill="#1B1F23"/>+</svg>diff --git a/frontend/src/assets/gitlab-logo.svg b/frontend/src/assets/gitlab-logo.svgnew file mode 100644index 0000000000..e0e22ac32e--- /dev/null+++ b/frontend/src/assets/gitlab-logo.svg@@ -0,0 +1,25 @@+<?xml version="1.0" encoding="UTF-8" standalone="no"?>+<svg width="210px" height="194px" viewBox="0 0 210 194" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sketch="http://www.bohemiancoding.com/sketch/ns">+ <!-- Generator: Sketch 3.3.2 (12043) - http://www.bohemiancoding.com/sketch -->+ <title>Group</title>+ <desc>Created with Sketch.</desc>+ <defs></defs>+ <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" sketch:type="MSPage">+ <g id="Fill-1-+-Group-24" sketch:type="MSLayerGroup">+ <g id="Group-24" sketch:type="MSShapeGroup">+ <g id="Group">+ <path d="M105.0614,193.655 L105.0614,193.655 L143.7014,74.734 L66.4214,74.734 L105.0614,193.655 L105.0614,193.655 Z" id="Fill-4" fill="#E24329"></path>+ <path id="Fill-6" fill="#FC6D26"></path>+ <path d="M105.0614,193.6548 L66.4214,74.7338 L12.2684,74.7338 L105.0614,193.6548 Z" id="Fill-8" fill="#FC6D26"></path>+ <path id="Fill-10" fill="#FC6D26"></path>+ <path d="M12.2685,74.7341 L12.2685,74.7341 L0.5265,110.8731 C-0.5445,114.1691 0.6285,117.7801 3.4325,119.8171 L105.0615,193.6551 L12.2685,74.7341 Z" id="Fill-12" fill="#FCA326"></path>+ <path id="Fill-14" fill="#FC6D26"></path>+ <path d="M12.2685,74.7342 L66.4215,74.7342 L43.1485,3.1092 C41.9515,-0.5768 36.7375,-0.5758 35.5405,3.1092 L12.2685,74.7342 Z" id="Fill-16" fill="#E24329"></path>+ <path d="M105.0614,193.6548 L143.7014,74.7338 L197.8544,74.7338 L105.0614,193.6548 Z" id="Fill-18" fill="#FC6D26"></path>+ <path d="M197.8544,74.7341 L197.8544,74.7341 L209.5964,110.8731 C210.6674,114.1691 209.4944,117.7801 206.6904,119.8171 L105.0614,193.6551 L197.8544,74.7341 Z" id="Fill-20" fill="#FCA326"></path>+ <path d="M197.8544,74.7342 L143.7014,74.7342 L166.9744,3.1092 C168.1714,-0.5768 173.3854,-0.5758 174.5824,3.1092 L197.8544,74.7342 Z" id="Fill-22" fill="#E24329"></path>+ </g>+ </g>+ </g>+ </g>+</svg>\ No newline at end of filediff --git a/frontend/src/types/common.ts b/frontend/src/types/common.tsindex 748a0d9e5a..44e88f8859 100644--- a/frontend/src/types/common.ts+++ b/frontend/src/types/common.ts@@ -21,6 +21,9 @@ export const DEFAULT_PROJECT_ID = 1;export const ALL_DATABASE_NAME = "*";+// For text input, we do validation if there is no further keystroke after 1s+export const TEXT_VALIDATION_DELAY = 1000;+// RowStatusexport type RowStatus = "NORMAL" | "ARCHIVED" | "PENDING_DELETE";diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.tsindex 3ca61fb7c6..4bc3036fa3 100644--- a/frontend/src/types/index.ts+++ b/frontend/src/types/index.ts@@ -14,6 +14,7 @@ export * from "./sql";export * from "./bookmark";export * from "./activity";export * from "./message";+export * from "./vcs";export * from "./auth";export * from "./notification";export * from "./plan";diff --git a/frontend/src/types/vcs.ts b/frontend/src/types/vcs.tsnew file mode 100644index 0000000000..0964bd174a--- /dev/null+++ b/frontend/src/types/vcs.ts@@ -0,0 +1,13 @@+export type VCSType = "GITLAB_SELF_HOST";++export interface VCSConfig {+ vcsType: VCSType;+ name: string;+ instanceURL: string;+ applicationId: string;+ secret: string;+}++export function isValidApplicationIdOrSecret(str: string): boolean {+ return /^[a-zA-Z0-9_]{64}$/.test(str);+}diff --git a/frontend/src/utils/util.ts b/frontend/src/utils/util.tsindex 1e262dcaeb..68d62b0af8 100644--- a/frontend/src/utils/util.ts+++ b/frontend/src/utils/util.ts@@ -50,6 +50,18 @@ export function urlfy(str: string) {return result;}+export function isUrl(str: string) {+ let url;++ try {+ url = new URL(str);+ } catch (_) {+ return false;+ }++ return url.protocol === "http:" || url.protocol === "https:";+}+// Performs inline swap, also handles negative index (counting from the end)// array_swap([1, 2, 3, 4], 1, 2) => [1, 3, 2, 4]// array_swap([1, 2, 3, 4], -1, -2) => [1, 2, 4, 3]diff --git a/frontend/src/views/SettingWorkspaceVCS.vue b/frontend/src/views/SettingWorkspaceVCS.vueindex 9db1782773..971d723ee9 100644--- a/frontend/src/views/SettingWorkspaceVCS.vue+++ b/frontend/src/views/SettingWorkspaceVCS.vue@@ -2,17 +2,31 @@<h1>VCS</h1><BBStepTab:stepItemList="stepList"+ :allowNext="allowNext"@select-step="selectStep"@finish="finishSetup">- <template v-slot:0> choose git provider </template>- <template v-slot:1> fill provider basic info </template>- <template v-slot:2> configure settings </template>+ <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 { isValidApplicationIdOrSecret, VCSConfig } from "../types";+import { isUrl } from "../utils";const stepList: BBStepTabItem[] = [{ title: "Choose Git provider" },@@ -20,20 +34,57 @@ const stepList: BBStepTabItem[] = [{ title: "Configure settings" },];+interface LocalState {+ config: VCSConfig;+ currentStep: number;+}+export default {name: "SettingWorkspaceVCS",props: {},+ components: {+ VCSProviderSelectionPanel,+ VCSProviderInfoPanel,+ VCSProviderConfigPanel,+ },setup(props, ctx) {+ const state = reactive<LocalState>({+ config: {+ vcsType: "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 (+ isValidApplicationIdOrSecret(state.config.applicationId) &&+ isValidApplicationIdOrSecret(state.config.secret)+ );+ }+ return true;+ });+const selectStep = (step: number) => {- console.log("select step", step);+ state.currentStep = step;};const finishSetup = () => {- console.log("finish");+ console.log("finish", state.config);};return {stepList,+ state,+ allowNext,selectStep,finishSetup,};diff --git a/frontend/src/views/VCSProviderConfigPanel.vue b/frontend/src/views/VCSProviderConfigPanel.vuenew file mode 100644index 0000000000..9e0d9aaae3--- /dev/null+++ b/frontend/src/views/VCSProviderConfigPanel.vue@@ -0,0 +1,124 @@+<template>+ <div class="text-lg leading-6 font-medium text-control">+ 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 text-lg leading-6 font-medium text-control">+ 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 {+ isValidApplicationIdOrSecret,+ 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) &&+ !isValidApplicationIdOrSecret(props.config.applicationId),+ showSecretError:+ !isEmpty(props.config.secret) &&+ !isValidApplicationIdOrSecret(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 (isValidApplicationIdOrSecret(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 = !isValidApplicationIdOrSecret(+ props.config.applicationId+ );+ } else {+ state.showApplicationIdError =+ !isValidApplicationIdOrSecret(props.config.applicationId) &&+ !isValidApplicationIdOrSecret(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 (isValidApplicationIdOrSecret(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 = !isValidApplicationIdOrSecret(+ props.config.secret+ );+ } else {+ state.showSecretError =+ !isEmpty(props.config.secret) &&+ !isValidApplicationIdOrSecret(props.config.secret);+ }+ }, TEXT_VALIDATION_DELAY);+ }+ };++ return {+ state,+ changeApplicatonId,+ changeSecret,+ };+ },+};+</script>diff --git a/frontend/src/views/VCSProviderInfoPanel.vue b/frontend/src/views/VCSProviderInfoPanel.vuenew file mode 100644index 0000000000..fa3f1b6d4d--- /dev/null+++ b/frontend/src/views/VCSProviderInfoPanel.vue@@ -0,0 +1,78 @@+<template>+ <div class="text-lg leading-6 font-medium text-control">Name</div>+ <BBTextField+ class="mt-2 w-full"+ :placeholder="'GitLab self-host'"+ :value="config.name"+ @input="config.name = $event.target.value"+ />+ <div class="mt-4 text-lg leading-6 font-medium text-control">+ GitLab Instance URL <span class="text-red-600">*</span>+ </div>+ <BBTextField+ class="mt-2 w-full"+ :placeholder="'https://gitlab.example.com'"+ :value="config.instanceURL"+ @input="changeUrl($event.target.value)"+ />+ <p v-if="state.showURLError" class="mt-2 text-sm text-error">+ Instance URL must begin with https:// or http://+ </p>+</template>++<script lang="ts">+import { onUnmounted, PropType, reactive } from "@vue/runtime-core";+import isEmpty from "lodash-es/isEmpty";+import { TEXT_VALIDATION_DELAY, VCSConfig } from "../types";+import { isUrl } from "../utils";++interface LocalState {+ urlValidationTimer?: ReturnType<typeof setTimeout>;+ showURLError: boolean;+}++export default {+ name: "VCSProviderInfoPanel",+ props: {+ config: {+ required: true,+ type: Object as PropType<VCSConfig>,+ },+ },+ setup(props, ctx) {+ const state = reactive<LocalState>({+ showURLError:+ !isEmpty(props.config.instanceURL) && !isUrl(props.config.instanceURL),+ });++ onUnmounted(() => {+ clearInterval(state.urlValidationTimer);+ });++ const changeUrl = (value: string) => {+ props.config.instanceURL = value;++ clearInterval(state.urlValidationTimer);+ // 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 (isUrl(props.config.instanceURL)) {+ state.showURLError = false;+ } else {+ state.urlValidationTimer = 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.showURLError) {+ state.showURLError = !isUrl(props.config.instanceURL);+ } else {+ state.showURLError =+ !isEmpty(props.config.instanceURL) &&+ !isUrl(props.config.instanceURL);+ }+ }, TEXT_VALIDATION_DELAY);+ }+ };++ return { state, changeUrl };+ },+};+</script>diff --git a/frontend/src/views/VCSProviderSelectionPanel.vue b/frontend/src/views/VCSProviderSelectionPanel.vuenew file mode 100644index 0000000000..9388d8eb53--- /dev/null+++ b/frontend/src/views/VCSProviderSelectionPanel.vue@@ -0,0 +1,68 @@+<template>+ <div class="flex flex-row radio-set">+ <div class="radio space-x-2">+ <input+ name="Self-host GitLab"+ tabindex="-1"+ type="radio"+ class="btn"+ value="GITLAB_SELF_HOST"+ v-model="config.vcsType"+ />+ <img class="h-6 w-auto" src="../assets/gitlab-logo.svg" />+ <label class="whitespace-nowrap"+ >Self-host GitLab Enterprise Edition (EE) or Community Edition (CE)+ </label>+ </div>+ </div>+ <div class="mt-2 relative">+ <div class="absolute inset-0 flex items-center" aria-hidden="true">+ <div class="w-full border-t border-block-border"></div>+ </div>+ <div class="relative flex justify-start">+ <span class="pr-2 bg-white text-sm text-control-light">+ Coming later+ </span>+ </div>+ </div>+ <div class="space-y-2">+ <div class="mt-2 flex flex-row space-x-2 items-center text-control">+ <div class="h-5 w-5">+ <img src="../assets/gitlab-logo.svg" />+ </div>+ <label class="whitespace-nowrap">GitLab.com </label>+ </div>+ <div class="flex flex-row space-x-2 items-center text-control">+ <div class="h-5 w-5">+ <img src="../assets/github-logo.svg" />+ </div>+ <label class="whitespace-nowrap">GitHub Enterprise </label>+ </div>+ <div class="flex flex-row space-x-2 items-center text-control">+ <div class="h-5 w-5">+ <img src="../assets/github-logo.svg" />+ </div>+ <label class="whitespace-nowrap">GitHub.com </label>+ </div>+ </div>+</template>++<script lang="ts">+import { PropType } from "@vue/runtime-core";+import { VCSConfig } from "../types";+export default {+ name: "VCSProviderSelectionPanel",+ props: {+ config: {+ required: true,+ type: Object as PropType<VCSConfig>,+ },+ },+ setup(props, ctx) {+ const selectGitLabOnPrem = () => {+ props.config.vcsType = "GITLAB_SELF_HOST";+ };+ return { selectGitLabOnPrem };+ },+};+</script>