Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: disable {{ENV_NAME}} for tenant project version control panel (#563)
Liu Jib97d2ffd38fe
diff --git a/frontend/src/components/RepositoryConfigPanel.vue b/frontend/src/components/RepositoryConfigPanel.vueindex c736ff3be8..3ab19e1d89 100644--- a/frontend/src/components/RepositoryConfigPanel.vue+++ b/frontend/src/components/RepositoryConfigPanel.vue@@ -5,18 +5,19 @@:vcs-name="config.vcs.name":repository-info="config.repositoryInfo":repository-config="config.repositoryConfig"+ :project="project"/></template><script lang="ts">-import { reactive, PropType } from "vue";+import { reactive, PropType, defineComponent } from "vue";import RepositoryForm from "./RepositoryForm.vue";-import { ProjectRepositoryConfig } from "../types";+import { Project, ProjectRepositoryConfig } from "../types";// eslint-disable-next-line @typescript-eslint/no-empty-interfaceinterface LocalState {}-export default {+export default defineComponent({name: "RepositoryConfigPanel",components: { RepositoryForm },props: {@@ -24,6 +25,10 @@ export default {required: true,type: Object as PropType<ProjectRepositoryConfig>,},+ project: {+ required: true,+ type: Object as PropType<Project>,+ },},emits: ["next"],setup() {@@ -33,5 +38,5 @@ export default {state,};},-};+});</script>diff --git a/frontend/src/components/RepositoryForm.vue b/frontend/src/components/RepositoryForm.vueindex 3b854f7e1b..63d3e263cc 100644--- a/frontend/src/components/RepositoryForm.vue+++ b/frontend/src/components/RepositoryForm.vue@@ -2,7 +2,9 @@<div class="space-y-4"><div><div class="flex flex-row space-x-2 items-center">- <label for="gitprovider" class="textlabel"> {{ $t('repository.git-provider') }} </label>+ <label for="gitprovider" class="textlabel">+ {{ $t("repository.git-provider") }}+ </label><template v-if="vcsType.startsWith('GITLAB')"><img class="h-4 w-auto" src="../assets/gitlab-logo.svg" /></template>@@ -18,13 +20,15 @@</div><div><div class="flex flex-row space-x-2 items-center">- <label for="repository" class="textlabel"> {{ $t('common.repository') }} </label>+ <label for="repository" class="textlabel">+ {{ $t("common.repository") }}+ </label><divv-if="!create && allowEdit"class="ml-1 normal-link text-sm"@click.prevent="$emit('change-repository')">- {{ $t('common.change') }}+ {{ $t("common.change") }}</div></div><input@@ -37,9 +41,11 @@/></div><div>- <div class="textlabel">{{ $t('common.branch') }} <span class="text-red-600">*</span></div>+ <div class="textlabel">+ {{ $t("common.branch") }} <span class="text-red-600">*</span>+ </div><div class="mt-1 textinfolabel">- {{ $t('repository.branch-observe-file-change') }}+ {{ $t("repository.branch-observe-file-change") }}</div><inputid="branch"@@ -51,13 +57,13 @@:disabled="!allowEdit"/><div v-if="vcsType == 'GITLAB_SELF_HOST'" class="mt-2 textinfolabel">- {{ $t('repository.branch-specify-tip') }}+ {{ $t("repository.branch-specify-tip") }}</div></div><div>- <div class="textlabel">{{ $t('repository.base-directory') }}</div>+ <div class="textlabel">{{ $t("repository.base-directory") }}</div><div class="mt-1 textinfolabel">- {{ $t('repository.base-directory-description') }}+ {{ $t("repository.base-directory-description") }}</div><inputid="basedirectory"@@ -70,17 +76,18 @@</div><div><div class="textlabel">- {{ $t('repository.file-path-template') }} <span class="text-red-600">*</span>+ {{ $t("repository.file-path-template") }}+ <span class="text-red-600">*</span><ahref="https://docs.bytebase.com/use-bytebase/vcs-integration/organize-repository-files#file-path-template"target="__blank"class="font-normal normal-link">- {{ $t('common.config-guide') }}</a+ {{ $t("common.config-guide") }}</a></div><div class="mt-1 textinfolabel">- {{ $t('repository.file-path-template-description') }}+ {{ $t("repository.file-path-template-description") }}</div><inputid="filepathtemplate"@@ -91,12 +98,16 @@:disabled="!allowEdit"/><div class="mt-2 textinfolabel capitalize">- <span class="text-red-600">*</span> {{ $t('common.required-placeholder') }}:- {{ FILE_REQUIRED_PLACEHOLDER }}; {{ $t('common.optional-placeholder') }}:- {{ FILE_OPTIONAL_PLACEHOLDER }}+ <span class="text-red-600">*</span>+ {{ $t("common.required-placeholder") }}:+ {{ FILE_REQUIRED_PLACEHOLDER }};+ <template v-if="fileOptionalPlaceholder.length > 0">+ {{ $t("common.optional-placeholder") }}:+ {{ fileOptionalPlaceholder.join(", ") }}+ </template></div><div class="mt-2 textinfolabel">- • {{ $t('repository.file-path-example-normal-migration') }}:+ • {{ $t("repository.file-path-example-normal-migration") }}:{{sampleFilePath(repositoryConfig.baseDirectory,@@ -106,7 +117,7 @@}}</div><div class="mt-2 textinfolabel">- • {{ $t('repository.file-path-example-baseline-migration') }}:+ • {{ $t("repository.file-path-example-baseline-migration") }}:{{sampleFilePath(repositoryConfig.baseDirectory,@@ -118,20 +129,20 @@</div><div><div class="textlabel">- {{ $t('repository.schema-path-template') }}+ {{ $t("repository.schema-path-template") }}<ahref="https://docs.bytebase.com/use-bytebase/vcs-integration/organize-repository-files#schema-path-template"target="__blank"class="font-normal normal-link">- {{ $t('common.config-guide') }}</a+ {{ $t("common.config-guide") }}</a></div><div class="mt-1 textinfolabel">- {{ $t('repository.schema-writeback-description') }}- <span class="font-medium text-main"- >{{ $t('repository.schema-writeback-protected-branch') }}</span- >+ {{ $t("repository.schema-writeback-description") }}+ <span class="font-medium text-main">{{+ $t("repository.schema-writeback-protected-branch")+ }}</span></div><inputid="schemapathtemplate"@@ -142,15 +153,19 @@:disabled="!allowEdit"/><div class="mt-2 textinfolabel">- <span class="text-red-600">*</span> {{ $t('repository.if-specified') }}, {{ $t('common.required-placeholder') }}:- {{ SCHEMA_REQUIRED_PLACEHOLDER }}; {{ $t('common.optional-placeholder') }}:- {{ SCHEMA_OPTIONAL_PLACEHOLDER }}+ <span class="text-red-600">*</span> {{ $t("repository.if-specified") }},+ {{ $t("common.required-placeholder") }}:+ {{ SCHEMA_REQUIRED_PLACEHOLDER }};+ <template v-if="schemaOptionalTagPlaceholder.length > 0">+ {{ $t("common.optional-placeholder") }}:+ {{ schemaOptionalTagPlaceholder.join(", ") }}+ </template></div><divv-if="repositoryConfig.schemaPathTemplate"class="mt-2 textinfolabel">- • {{ $t('repository.schema-path-example') }}:+ • {{ $t("repository.schema-path-example") }}:{{sampleSchemaPath(repositoryConfig.baseDirectory,@@ -163,18 +178,21 @@</template><script lang="ts">-import { reactive, PropType } from "vue";-import { ExternalRepositoryInfo, RepositoryConfig, VCSType } from "../types";+import { reactive, PropType, defineComponent, computed } from "vue";+import {+ ExternalRepositoryInfo,+ Project,+ RepositoryConfig,+ VCSType,+} from "../types";const FILE_REQUIRED_PLACEHOLDER = "{{DB_NAME}}, {{VERSION}}, {{TYPE}}";-const FILE_OPTIONAL_PLACEHOLDER = "{{ENV_NAME}}, {{DESCRIPTION}}";const SCHEMA_REQUIRED_PLACEHOLDER = "{{DB_NAME}}";-const SCHEMA_OPTIONAL_PLACEHOLDER = "{{ENV_NAME}}";// eslint-disable-next-line @typescript-eslint/no-empty-interfaceinterface LocalState {}-export default {+export default defineComponent({name: "RepositoryForm",props: {allowEdit: {@@ -201,11 +219,19 @@ export default {required: true,type: Object as PropType<RepositoryConfig>,},+ project: {+ required: true,+ type: Object as PropType<Project>,+ },},emits: ["change-repository"],- setup() {+ setup(props) {const state = reactive<LocalState>({});+ const isTenantProject = computed(() => {+ return props.project.tenantMode === "TENANT";+ });+const sampleFilePath = (baseDirectory: string,filePathTemplate: string,@@ -271,15 +297,30 @@ export default {return result;};+ const fileOptionalPlaceholder = computed(() => {+ const tags = [] as string[];+ // Only allows {{ENV_NAME}} to be an optional placeholder for non-tenant mode projects+ if (!isTenantProject.value) tags.push("{{ENV_NAME}}");+ tags.push("{{DESCRIPTION}}");+ return tags;+ });++ const schemaOptionalTagPlaceholder = computed(() => {+ const tags = [] as string[];+ // Only allows {{ENV_NAME}} to be an optional placeholder for non-tenant mode projects+ if (!isTenantProject.value) tags.push("{{ENV_NAME}}");+ return tags;+ });+return {FILE_REQUIRED_PLACEHOLDER,- FILE_OPTIONAL_PLACEHOLDER,+ fileOptionalPlaceholder,SCHEMA_REQUIRED_PLACEHOLDER,- SCHEMA_OPTIONAL_PLACEHOLDER,+ schemaOptionalTagPlaceholder,state,sampleFilePath,sampleSchemaPath,};},-};+});</script>diff --git a/frontend/src/components/RepositoryPanel.vue b/frontend/src/components/RepositoryPanel.vueindex 3ede7a9035..c3a1d880bb 100644--- a/frontend/src/components/RepositoryPanel.vue+++ b/frontend/src/components/RepositoryPanel.vue@@ -54,6 +54,7 @@:vcs-name="repository.vcs.name":repository-info="repositoryInfo":repository-config="state.repositoryConfig"+ :project="project"@change-repository="$emit('change-repository')"/><div v-if="allowEdit" class="mt-4 pt-4 flex border-t justify-between">@@ -80,7 +81,7 @@</template><script lang="ts">-import { computed, PropType, reactive, watch } from "vue";+import { computed, defineComponent, PropType, reactive, watch } from "vue";import isEmpty from "lodash-es/isEmpty";import RepositoryForm from "./RepositoryForm.vue";import {@@ -97,7 +98,7 @@ interface LocalState {repositoryConfig: RepositoryConfig;}-export default {+export default defineComponent({name: "RepositoryPanel",components: { RepositoryForm },props: {@@ -222,5 +223,5 @@ export default {doUpdate,};},-};+});</script>diff --git a/frontend/src/components/RepositorySetupWizard.vue b/frontend/src/components/RepositorySetupWizard.vueindex 953f6b3a67..951831eaa1 100644--- a/frontend/src/components/RepositorySetupWizard.vue+++ b/frontend/src/components/RepositorySetupWizard.vue@@ -28,14 +28,14 @@<RepositorySelectionPanel :config="state.config" @next="next()" /></template><template #2>- <RepositoryConfigPanel :config="state.config" />+ <RepositoryConfigPanel :config="state.config" :project="project" /></template></BBStepTab></div></template><script lang="ts">-import { reactive, computed, PropType } from "vue";+import { reactive, computed, PropType, defineComponent } from "vue";import { useStore } from "vuex";import { useRouter } from "vue-router";import isEmpty from "lodash-es/isEmpty";@@ -59,6 +59,11 @@ const DEFAULT_FILE_PATH_TEMPLATE =// Default schema path template is co-locate with the corresponding db's migration files and use .(dot) to appear the first.const DEFAULT_SCHEMA_PATH_TEMPLATE = "{{ENV_NAME}}/.{{DB_NAME}}__LATEST.sql";+// For tenant mode projects, {{ENV_NAME}} is not supported.+const DEFAULT_TENANT_MODE_FILE_PATH_TEMPLATE =+ "{{DB_NAME}}__{{VERSION}}__{{TYPE}}__{{DESCRIPTION}}.sql";+const DEFAULT_TENANT_MODE_SCHEMA_PATH_TEMPLATE = ".{{DB_NAME}}__LATEST.sql";+const CHOOSE_PROVIDER_STEP = 0;// const CHOOSE_REPOSITORY_STEP = 1;const CONFIGURE_DEPLOY_STEP = 2;@@ -68,7 +73,7 @@ interface LocalState {currentStep: number;}-export default {+export default defineComponent({name: "RepositorySetupWizard",components: {RepositoryVCSProviderPanel,@@ -99,6 +104,10 @@ export default {{ title: t("repository.configure-deploy") },];+ const isTenantProject = computed(() => {+ return props.project.tenantMode === "TENANT";+ });+const state = reactive<LocalState>({config: {vcs: unknown("VCS") as VCS,@@ -117,8 +126,12 @@ export default {repositoryConfig: {baseDirectory: "",branchFilter: "",- filePathTemplate: DEFAULT_FILE_PATH_TEMPLATE,- schemaPathTemplate: DEFAULT_SCHEMA_PATH_TEMPLATE,+ filePathTemplate: isTenantProject.value+ ? DEFAULT_TENANT_MODE_FILE_PATH_TEMPLATE+ : DEFAULT_FILE_PATH_TEMPLATE,+ schemaPathTemplate: isTenantProject.value+ ? DEFAULT_TENANT_MODE_SCHEMA_PATH_TEMPLATE+ : DEFAULT_SCHEMA_PATH_TEMPLATE,},},currentStep: CHOOSE_PROVIDER_STEP,@@ -203,5 +216,5 @@ export default {cancel,};},-};+});</script>