Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: add restrict issue creation setting (#9653)
boojackc803b5285bbf
diff --git a/frontend/src/components/GeneralSetting/SecuritySetting.vue b/frontend/src/components/GeneralSetting/SecuritySetting.vueindex 51dc1a71d5..c4bb742f33 100644--- a/frontend/src/components/GeneralSetting/SecuritySetting.vue+++ b/frontend/src/components/GeneralSetting/SecuritySetting.vue@@ -13,55 +13,79 @@</div><div class="flex-1 lg:px-4"><div class="mb-7 mt-4 lg:mt-0">- <NTooltip placement="top-start" :disabled="allowEdit">- <template #trigger>- <label- class="flex items-center gap-x-2"- :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"- >- <NCheckbox- :disabled="!allowEdit"- :checked="watermarkEnabled"- @update:checked="handleWatermarkToggle"- />- <span class="font-medium">{{- $t("settings.general.workspace.watermark.enable")- }}</span>- </label>- </template>- <span class="text-sm text-gray-400 -translate-y-2">+ <label+ class="flex items-center gap-x-2 tooltip-wrapper"+ :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"+ >+ <NCheckbox+ :disabled="!allowEdit"+ :checked="watermarkEnabled"+ @update:checked="handleWatermarkToggle"+ />+ <span class="font-medium">{{+ $t("settings.general.workspace.watermark.enable")+ }}</span>++ <span+ v-if="!allowEdit"+ class="text-sm text-gray-400 -translate-y-2 tooltip"+ >{{ $t("settings.general.workspace.watermark.only-admin-can-edit") }}</span>- </NTooltip>+ </label><div class="mb-3 text-sm text-gray-400">{{ $t("settings.general.workspace.watermark.description") }}</div></div><div v-if="!isSaaSMode" class="mb-7 mt-4 lg:mt-0">- <NTooltip placement="top-start" :disabled="allowEdit">- <template #trigger>- <label- class="flex items-center gap-x-2"- :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"- >- <NCheckbox- :disabled="!allowEdit"- :checked="disallowSignupEnabled"- @update:checked="handleDisallowSignupToggle"- />- <span class="font-medium">{{- $t("settings.general.workspace.disallow-signup.enable")- }}</span>- </label>- </template>- <span class="text-sm text-gray-400 -translate-y-2">+ <label+ class="flex items-center gap-x-2 tooltip-wrapper"+ :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"+ >+ <NCheckbox+ :disabled="!allowEdit"+ :checked="disallowSignupEnabled"+ @update:checked="handleDisallowSignupToggle"+ />+ <span class="font-medium">{{+ $t("settings.general.workspace.disallow-signup.enable")+ }}</span>++ <span+ v-if="!allowEdit"+ class="text-sm text-gray-400 -translate-y-2 tooltip"+ >{{ $t("settings.general.workspace.only-admin-can-edit") }}</span>- </NTooltip>+ </label><div class="mb-3 text-sm text-gray-400">{{ $t("settings.general.workspace.disallow-signup.description") }}</div></div>+ <div class="mb-7 mt-4 lg:mt-0">+ <label+ class="flex items-center gap-x-2 tooltip-wrapper"+ :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"+ >+ <NCheckbox+ :disabled="!allowEdit"+ :checked="require2FAEnabled"+ @update:checked="handleRequire2FAToggle"+ />+ <span class="font-medium">{{+ $t("settings.general.workspace.require-2fa.enable")+ }}</span>+ <span+ v-if="!allowEdit"+ class="text-sm text-gray-400 -translate-y-2 tooltip"+ >+ {{ $t("settings.general.workspace.only-admin-can-edit") }}+ </span>+ </label>+ <div class="mb-3 text-sm text-gray-400">+ {{ $t("settings.general.workspace.require-2fa.description") }}+ </div>+ </div><div class="mb-7 mt-4 lg:mt-0"><NTooltip placement="top-start" :disabled="allowEdit"><template #trigger>@@ -71,11 +95,13 @@><NCheckbox:disabled="!allowEdit"- :checked="require2FAEnabled"- @update:checked="handleRequire2FAToggle"+ :checked="restrictIssueCreationForSQLReview"+ @update:checked="handleRestrictIssueCreationForSQLReviewToggle"/><span class="font-medium">{{- $t("settings.general.workspace.require-2fa.enable")+ $t(+ "settings.general.workspace.restrict-issue-creation-for-sql-review.title"+ )}}</span></label></template>@@ -84,7 +110,11 @@</span></NTooltip><div class="mb-3 text-sm text-gray-400">- {{ $t("settings.general.workspace.require-2fa.description") }}+ {{+ $t(+ "settings.general.workspace.restrict-issue-creation-for-sql-review.description"+ )+ }}</div></div><SignInFrequencySetting />@@ -101,16 +131,21 @@<script lang="ts" setup>import { NCheckbox } from "naive-ui";import { storeToRefs } from "pinia";-import { computed, reactive } from "vue";+import { computed, onMounted, reactive } from "vue";import { useI18n } from "vue-i18n";import {featureToRef,pushNotification,useCurrentUserV1,useActuatorV1Store,+ usePolicyV1Store,} from "@/store";import { useSettingV1Store } from "@/store/modules/v1/setting";import { FeatureType } from "@/types";+import {+ PolicyResourceType,+ PolicyType,+} from "@/types/proto/v1/org_policy_service";import { hasWorkspacePermissionV1 } from "@/utils";import SignInFrequencySetting from "./SignInFrequencySetting.vue";@@ -122,6 +157,7 @@ const { t } = useI18n();const settingV1Store = useSettingV1Store();const currentUserV1 = useCurrentUserV1();const actuatorStore = useActuatorV1Store();+const policyV1Store = usePolicyV1Store();const { isSaaSMode } = storeToRefs(actuatorStore);const hasWatermarkFeature = featureToRef("bb.feature.branding");@@ -146,6 +182,23 @@ const disallowSignupEnabled = computed((): boolean => {const require2FAEnabled = computed((): boolean => {return settingV1Store.workspaceProfileSetting?.require2fa ?? false;});+const restrictIssueCreationForSQLReview = computed((): boolean => {+ return (+ policyV1Store.getPolicyByName(+ "policies/RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW"+ )?.restrictIssueCreationForSqlReviewPolicy?.disallow ?? false+ );+});++onMounted(async () => {+ await prepareOrgPolicy();+});++const prepareOrgPolicy = async () => {+ await policyV1Store.getOrFetchPolicyByName(+ "policies/RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW"+ );+};const handleDisallowSignupToggle = async (on: boolean) => {if (!hasDisallowSignupFeature.value && on) {@@ -196,4 +249,20 @@ const handleWatermarkToggle = async (on: boolean) => {title: t("settings.general.workspace.watermark.update-success"),});};++const handleRestrictIssueCreationForSQLReviewToggle = async (on: boolean) => {+ await policyV1Store.createPolicy("", {+ type: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,+ resourceType: PolicyResourceType.WORKSPACE,+ restrictIssueCreationForSqlReviewPolicy: {+ disallow: on,+ },+ });++ pushNotification({+ module: "bytebase",+ style: "SUCCESS",+ title: t("settings.general.workspace.config-updated"),+ });+};</script>diff --git a/frontend/src/components/SQLCheck/SQLCheckPanel.vue b/frontend/src/components/SQLCheck/SQLCheckPanel.vueindex 0bb796256c..77fd653bd7 100644--- a/frontend/src/components/SQLCheck/SQLCheckPanel.vue+++ b/frontend/src/components/SQLCheck/SQLCheckPanel.vue@@ -17,7 +17,11 @@<NButton @click="confirm.resolve(false)">{{ $t("issue.sql-check.back-to-edit") }}</NButton>- <NButton type="primary" @click="confirm.resolve(true)">+ <NButton+ v-if="!restrictIssueCreationForSQLReview"+ type="primary"+ @click="confirm.resolve(true)"+ >{{ $t("issue.sql-check.continue-anyway") }}</NButton></div>@@ -26,6 +30,8 @@<script setup lang="ts">import { NButton } from "naive-ui";+import { computed, onMounted } from "vue";+import { usePolicyV1Store } from "@/store";import { ComposedDatabase } from "@/types";import { Advice } from "@/types/proto/v1/sql_service";import { Defer } from "@/utils";@@ -41,4 +47,24 @@ defineProps<{defineEmits<{(event: "close"): void;}>();++const policyV1Store = usePolicyV1Store();++const restrictIssueCreationForSQLReview = computed((): boolean => {+ return (+ policyV1Store.getPolicyByName(+ "policies/RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW"+ )?.restrictIssueCreationForSqlReviewPolicy?.disallow ?? false+ );+});++onMounted(async () => {+ await prepareOrgPolicy();+});++const prepareOrgPolicy = async () => {+ await policyV1Store.getOrFetchPolicyByName(+ "policies/RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW"+ );+};</script>diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 101146ff7f..8d0773503e 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -665,7 +665,11 @@"self": "Link","placeholder": "Input announcement link"},- "confirm-delete-custom-logo": "Delete custom branding logo?"+ "confirm-delete-custom-logo": "Delete custom branding logo?",+ "restrict-issue-creation-for-sql-review": {+ "title": "Restrict issue creation for SQL review",+ "description": "Once enabled, users can only create issues after SQL review has passed."+ }}},"sensitive-data": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex a17583a19e..a8bb2a7f75 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -664,7 +664,11 @@"days": "Días","config-updated": "La configuración se ha actualizado. Necesita reiniciar Bytebase y volver a iniciar sesión para que surta efecto."},- "confirm-delete-custom-logo": "¿Eliminar el logotipo de marca personalizado?"+ "confirm-delete-custom-logo": "¿Eliminar el logotipo de marca personalizado?",+ "restrict-issue-creation-for-sql-review": {+ "title": "Restringir la creación de incidencias para la revisión de SQL",+ "description": "Cuando está habilitado, solo los usuarios con el rol de DBA pueden crear incidencias para la revisión de SQL."+ }}},"sensitive-data": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex f3c5727e39..d1172be802 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -663,7 +663,11 @@"self": "链接","placeholder": "输入公告链接"},- "confirm-delete-custom-logo": "删除自定义品牌 Logo?"+ "confirm-delete-custom-logo": "删除自定义品牌 Logo?",+ "restrict-issue-creation-for-sql-review": {+ "title": "通过 SQL 审核限制工单的创建",+ "description": "开启后,只有具有 SQL 审核通过时用户才能创建工单。"+ }}},"sensitive-data": {