Skip to content

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

refactor(frontend): migrate project settings page to React (#19853)

Danny Xud02188fd5888
diff --git a/frontend/src/components/Project/Settings/ApprovalFlowIndicator.vue b/frontend/src/components/Project/Settings/ApprovalFlowIndicator.vue
deleted file mode 100644
index 0d9f779faf..0000000000
--- a/frontend/src/components/Project/Settings/ApprovalFlowIndicator.vue
+++ /dev/null
@@ -1,73 +0,0 @@
-<template>
- <NTooltip v-if="ready">
- <template #trigger>
- <ShieldCheckIcon v-if="configured" class="w-4 h-4 text-success" />
- <TriangleAlertIcon v-else class="w-4 h-4 text-warning" />
- </template>
- <div class="flex flex-col gap-y-1">
- <span>{{ tooltipText }}</span>
- <router-link
- class="normal-link"
- :to="{ name: WORKSPACE_ROUTE_CUSTOM_APPROVAL }"
- >
- {{
- $t("project.settings.issue-related.view-approval-flow")
- }}
- </router-link>
- </div>
- </NTooltip>
-</template>
-
-<script setup lang="ts">
-import { ShieldCheckIcon, TriangleAlertIcon } from "lucide-vue-next";
-import { NTooltip } from "naive-ui";
-import { computed, ref, watchEffect } from "vue";
-import { useI18n } from "vue-i18n";
-import { WORKSPACE_ROUTE_CUSTOM_APPROVAL } from "@/router/dashboard/workspaceRoutes";
-import { useWorkspaceApprovalSettingStore } from "@/store";
-import { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";
-import { hasWorkspacePermissionV2 } from "@/utils";
-
-const props = defineProps<{
- source: WorkspaceApprovalSetting_Rule_Source;
-}>();
-
-const { t } = useI18n();
-const approvalSettingStore = useWorkspaceApprovalSettingStore();
-const ready = ref(false);
-
-watchEffect(async () => {
- if (!hasWorkspacePermissionV2("bb.settings.get")) {
- return;
- }
- await approvalSettingStore.fetchConfig();
- ready.value = true;
-});
-
-const status = computed((): "source" | "fallback" | "none" => {
- if (approvalSettingStore.getRulesBySource(props.source).length > 0) {
- return "source";
- }
- if (
- approvalSettingStore.getRulesBySource(
- WorkspaceApprovalSetting_Rule_Source.SOURCE_UNSPECIFIED
- ).length > 0
- ) {
- return "fallback";
- }
- return "none";
-});
-
-const configured = computed(() => status.value !== "none");
-
-const tooltipText = computed(() => {
- switch (status.value) {
- case "source":
- return t("project.settings.issue-related.approval-flow-configured");
- case "fallback":
- return t("project.settings.issue-related.approval-flow-fallback");
- default:
- return t("project.settings.issue-related.approval-flow-not-configured");
- }
-});
-</script>
diff --git a/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue
deleted file mode 100644
index 2ea03db35d..0000000000
--- a/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue
+++ /dev/null
@@ -1,152 +0,0 @@
-<template>
- <form class="w-full flex flex-col gap-y-4">
- <div>
- <div class="font-medium">
- {{ $t("common.name") }}
- <RequiredStar />
- </div>
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.projects.update'
- ]"
- >
- <NInput
- id="projectName"
- class="mt-1"
- v-model:value="state.title"
- :disabled="slotProps.disabled"
- required
- />
- </PermissionGuardWrapper>
- <div class="mt-1">
- <ResourceIdField
- resource-type="project"
- :value="extractProjectResourceName(project.name)"
- :readonly="true"
- />
- </div>
- </div>
-
- <!-- Project Labels Section -->
- <div>
- <div class="font-medium">
- {{ $t("project.settings.project-labels.self") }}
- </div>
- <div class="text-sm text-gray-500 mb-3">
- {{ $t("project.settings.project-labels.description") }}
- </div>
-
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.projects.update'
- ]"
- >
- <LabelListEditor
- ref="labelListEditorRef"
- v-model:kv-list="labelKVList"
- :readonly="slotProps.disabled"
- :show-errors="true"
- />
- </PermissionGuardWrapper>
- </div>
- </form>
-</template>
-
-<script lang="ts" setup>
-import { cloneDeep, isEmpty, isEqual } from "lodash-es";
-import { NInput } from "naive-ui";
-import { computed, reactive, ref, watch } from "vue";
-import { LabelListEditor } from "@/components/Label";
-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import RequiredStar from "@/components/RequiredStar.vue";
-import ResourceIdField from "@/components/v2/Form/ResourceIdField.vue";
-import { useProjectV1Store } from "@/store";
-import { isDefaultProject } from "@/types";
-import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import {
- convertKVListToLabels,
- convertLabelsToKVList,
- extractProjectResourceName,
-} from "@/utils";
-
-interface LocalState {
- title: string;
-}
-
-const props = defineProps<{
- project: Project;
-}>();
-
-const projectV1Store = useProjectV1Store();
-const labelListEditorRef = ref<InstanceType<typeof LabelListEditor>>();
-
-const state = reactive<LocalState>({
- title: props.project.title,
-});
-
-// Convert labels to KVList format for LabelListEditor
-const labelKVList = ref(
- convertLabelsToKVList(props.project.labels, true /* sort */)
-);
-
-// Watch for external changes to project labels
-watch(
- () => props.project.labels,
- (newLabels) => {
- labelKVList.value = convertLabelsToKVList(newLabels, true /* sort */);
- }
-);
-
-const allowSave = computed((): boolean => {
- const titleChanged =
- !isDefaultProject(props.project.name) &&
- !isEmpty(state.title) &&
- state.title !== props.project.title;
-
- const labelsChanged = !isEqual(
- convertKVListToLabels(labelKVList.value, false),
- props.project.labels
- );
-
- // Check if there are validation errors
- const hasErrors = (labelListEditorRef.value?.flattenErrors ?? []).length > 0;
-
- return (titleChanged || labelsChanged) && !hasErrors;
-});
-
-const onUpdate = async () => {
- const projectPatch = cloneDeep(props.project);
- const updateMask: string[] = [];
-
- if (state.title !== props.project.title) {
- projectPatch.title = state.title;
- updateMask.push("title");
- }
-
- const currentLabels = convertKVListToLabels(labelKVList.value, false);
- if (!isEqual(currentLabels, props.project.labels)) {
- projectPatch.labels = currentLabels;
- updateMask.push("labels");
- }
-
- if (updateMask.length > 0) {
- await projectV1Store.updateProject(projectPatch, updateMask);
- }
-};
-
-defineExpose({
- isDirty: allowSave,
- update: onUpdate,
- revert: () => {
- state.title = props.project.title;
- labelKVList.value = convertLabelsToKVList(
- props.project.labels,
- true /* sort */
- );
- },
-});
-</script>
diff --git a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue
deleted file mode 100644
index 87442cb077..0000000000
--- a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue
+++ /dev/null
@@ -1,514 +0,0 @@
-<template>
- <div class="w-full flex flex-col justify-start items-start gap-y-6">
- <div class="flex flex-col gap-y-2">
- <div class="font-medium">
- {{ $t("project.settings.issue-related.labels.self") }}
- <div class="textinfolabel">
- {{ $t("project.settings.issue-related.labels.description") }}
- </div>
- </div>
- <NDynamicTags
- :size="'large'"
- :disabled="!allowEdit || loading"
- :value="labelValues"
- :render-tag="renderLabel"
- :input-props="{
- placeholder: $t('project.settings.issue-related.labels.placeholder'),
- clearable: true,
- }"
- :input-style="'min-width: 12rem;'"
- @update:value="onLabelsUpdate"
- />
- </div>
- <div>
- <div class="flex items-center gap-x-2">
- <Switch
- v-model:value="state.forceIssueLabels"
- :text="true"
- :disabled="
- !allowUpdateIssueProjectSetting ||
- state.issueLabels.length === 0 ||
- loading
- "
- />
- <div class="textlabel flex items-center gap-x-2">
- {{
- $t(
- "project.settings.issue-related.labels.force-issue-labels.self"
- )
- }}
- <NTooltip v-if="allowEdit && state.issueLabels.length === 0">
- <template #trigger>
- <TriangleAlertIcon class="w-4 text-warning" />
- </template>
- {{
- $t(
- "project.settings.issue-related.labels.force-issue-labels.warning"
- )
- }}
- </NTooltip>
- </div>
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t(
- "project.settings.issue-related.labels.force-issue-labels.description"
- )
- }}
- </div>
- </div>
- <div>
- <div class="flex items-center gap-x-2">
- <Switch
- v-model:value="state.enforceIssueTitle"
- :text="true"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- />
- <span class="textlabel">
- {{ $t("project.settings.issue-related.enforce-issue-title.self") }}
- </span>
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t("project.settings.issue-related.enforce-issue-title.description")
- }}
- </div>
- </div>
- <div>
- <div class="flex items-center gap-x-2">
- <Switch
- v-model:value="state.enforceSqlReview"
- :text="true"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- />
- <span class="textlabel">
- {{ $t("project.settings.issue-related.enforce-sql-review.self") }}
- </span>
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t("project.settings.issue-related.enforce-sql-review.description")
- }}
- </div>
- </div>
- <div>
- <div class="flex items-center gap-x-2">
- <Switch
- v-model:value="state.allowSelfApproval"
- :text="true"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- />
- <span class="textlabel">
- {{ $t("project.settings.issue-related.allow-self-approval.self") }}
- </span>
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t("project.settings.issue-related.allow-self-approval.description")
- }}
- </div>
- </div>
- <div>
- <div class="flex items-center gap-x-2">
- <Switch
- v-model:value="state.requireIssueApproval"
- :text="true"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- />
- <span class="textlabel">
- {{
- $t("project.settings.issue-related.require-issue-approval.self")
- }}
- </span>
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t(
- "project.settings.issue-related.require-issue-approval.description"
- )
- }}
- </div>
- </div>
- <div>
- <div class="flex items-center gap-x-2">
- <Switch
- v-model:value="state.requirePlanCheckNoError"
- :text="true"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- />
- <span class="textlabel">
- {{
- $t(
- "project.settings.issue-related.require-plan-check-no-error.self"
- )
- }}
- </span>
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t(
- "project.settings.issue-related.require-plan-check-no-error.description"
- )
- }}
- </div>
- </div>
- <div>
- <div class="flex items-center gap-x-2">
- <Switch
- v-model:value="state.postgresDatabaseTenantMode"
- :text="true"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- />
- <span class="textlabel">
- {{
- $t(
- "project.settings.issue-related.postgres-database-tenant-mode.self"
- )
- }}
- </span>
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t(
- "project.settings.issue-related.postgres-database-tenant-mode.description"
- )
- }}
- </div>
- </div>
- <div>
- <p class="">
- <span class="textlabel">
- {{ $t("project.settings.issue-related.max-retries.self") }}
- </span>
- </p>
- <p class="mb-3 text-sm text-gray-400">
- {{ $t("project.settings.issue-related.max-retries.description") }}
- </p>
- <div class="mt-3 w-full flex flex-row justify-start items-center gap-4">
- <NInputNumber
- :value="state.executionRetryPolicy?.maximumRetries ?? 0"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- class="w-60"
- :min="0"
- :precision="0"
- @update:value="handleInput"
- >
- <template #suffix> Times </template>
- </NInputNumber>
- </div>
- </div>
- <div>
- <p class="">
- <span class="textlabel">
- {{ $t("project.settings.issue-related.ci-sampling-size.self") }}
- </span>
- </p>
- <p class="mb-3 text-sm text-gray-400">
- {{
- $t("project.settings.issue-related.ci-sampling-size.description")
- }}
- </p>
- <div class="mt-3 w-full flex flex-row justify-start items-center gap-4">
- <NInputNumber
- :value="state.ciSamplingSize"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- class="w-60"
- :min="0"
- :precision="0"
- @update:value="handleCiSamplingSizeInput"
- >
- </NInputNumber>
- </div>
- </div>
- <div>
- <p class="">
- <span class="textlabel">
- {{
- $t(
- "project.settings.issue-related.parallel_tasks_per_rollout.self"
- )
- }}
- </span>
- </p>
- <p class="mb-3 text-sm text-gray-400">
- {{
- $t(
- "project.settings.issue-related.parallel_tasks_per_rollout.description"
- )
- }}
- </p>
- <div class="mt-3 w-full flex flex-row justify-start items-center gap-4">
- <NInputNumber
- :value="state.parallelTasksPerRollout"
- :disabled="!allowUpdateIssueProjectSetting || loading"
- class="w-60"
- :min="0"
- :precision="0"
- @update:value="handleParallelTasksPerRolloutInput"
- >
- </NInputNumber>
- </div>
- </div>
- </div>
-</template>
-
-<script setup lang="tsx">
-import { create as createProto } from "@bufbuild/protobuf";
-import { cloneDeep, isEqual } from "lodash-es";
-import { TriangleAlertIcon } from "lucide-vue-next";
-import {
- NColorPicker,
- NDynamicTags,
- NInputNumber,
- NTag,
- NTooltip,
-} from "naive-ui";
-import { type ComponentPublicInstance, computed, reactive, ref } from "vue";
-import { Switch } from "@/components/v2";
-import { useProjectV1Store } from "@/store";
-import type {
- Label,
- Project,
- Project_ExecutionRetryPolicy,
-} from "@/types/proto-es/v1/project_service_pb";
-import {
- LabelSchema,
- Project_ExecutionRetryPolicySchema,
-} from "@/types/proto-es/v1/project_service_pb";
-
-interface LocalState {
- issueLabels: Label[];
- enforceSqlReview: boolean;
- forceIssueLabels: boolean;
- enforceIssueTitle: boolean;
- allowSelfApproval: boolean;
- postgresDatabaseTenantMode: boolean;
- executionRetryPolicy: Project_ExecutionRetryPolicy | undefined;
- ciSamplingSize: number;
- parallelTasksPerRollout: number;
- requireIssueApproval: boolean;
- requirePlanCheckNoError: boolean;
-}
-
-const getInitialLocalState = (): LocalState => {
- if (!props.project) {
- return {
- issueLabels: [],
- forceIssueLabels: false,
- enforceIssueTitle: false,
- enforceSqlReview: false,
- postgresDatabaseTenantMode: false,
- allowSelfApproval: false,
- executionRetryPolicy: createProto(Project_ExecutionRetryPolicySchema, {
- maximumRetries: 0,
- }),
- ciSamplingSize: 0,
- parallelTasksPerRollout: 1,
- requireIssueApproval: false,
- requirePlanCheckNoError: false,
- };
- }
- return {
- issueLabels: cloneDeep(props.project.issueLabels),
- forceIssueLabels: props.project.forceIssueLabels,
- enforceIssueTitle: props.project.enforceIssueTitle,
- enforceSqlReview: props.project.enforceSqlReview,
- postgresDatabaseTenantMode: props.project.postgresDatabaseTenantMode,
- allowSelfApproval: props.project.allowSelfApproval,
- executionRetryPolicy: props.project.executionRetryPolicy
- ? createProto(Project_ExecutionRetryPolicySchema, {
- maximumRetries: props.project.executionRetryPolicy.maximumRetries,
- })
- : createProto(Project_ExecutionRetryPolicySchema, {
- maximumRetries: 0,
- }),
- ciSamplingSize: props.project.ciSamplingSize,
- parallelTasksPerRollout: props.project.parallelTasksPerRollout,
- requireIssueApproval: props.project.requireIssueApproval,
- requirePlanCheckNoError: props.project.requirePlanCheckNoError,
- };
-};
-
-const defaultColor = "#4f46e5";
-
-const props = defineProps<{
- project: Project;
- allowEdit: boolean;
-}>();
-
-const projectStore = useProjectV1Store();
-const state = reactive<LocalState>(getInitialLocalState());
-const loading = ref<boolean>(false);
-
-const labelValues = computed(() => state.issueLabels.map((l) => l.value));
-
-const valueChanged = computed(() => !isEqual(state, getInitialLocalState()));
-
-const allowUpdateIssueProjectSetting = computed(() => {
- return props.allowEdit;
-});
-
-const onLabelsUpdate = (values: string[]) => {
- if (state.issueLabels.length + 1 !== values.length) {
- return;
- }
- const newValue = values[values.length - 1];
- if (new Set(labelValues.value).has(newValue)) {
- return;
- }
- state.issueLabels.push(
- createProto(LabelSchema, {
- color: defaultColor,
- value: newValue,
- group: "",
- })
- );
-};
-
-const renderLabel = (value: string, index: number) => {
- const label = state.issueLabels.find((l) => l.value === value) ?? {
- value,
- color: defaultColor,
- };
-
- return (
- <NTag
- size="large"
- closable
- disabled={!props.allowEdit}
- onClose={() => {
- state.issueLabels.splice(index, 1);
- if (state.issueLabels.length === 0) {
- state.forceIssueLabels = false;
- }
- }}
- >
- <div class="flex flex-row items-start justify-center gap-x-2">
- <NColorPicker
- modes={["hex"]}
- showAlpha={false}
- value={label.color}
- onUpdateValue={(color: string) => (label.color = color)}
- v-slots={{
- trigger: ({
- value,
- onClick,
- ref: triggerRef,
- }: {
- value: string | null;
- onClick: () => void;
- ref: (el: Element | ComponentPublicInstance | null) => void;
- }) => (
- <div
- ref={triggerRef}
- class="w-4 h-4 rounded-sm cursor-pointer"
- style={{ backgroundColor: value || label.color }}
- onClick={onClick}
- />
- ),
- }}
- />
- <span>{label.value}</span>
- </div>
- </NTag>
- );
-};
-
-const doUpdate = async () => {
- if (loading.value) {
- return;
- }
- if (updateMask.value.length === 0) {
- return;
- }
- loading.value = true;
- const projectPatch = {
- ...cloneDeep(props.project),
- ...state,
- };
- try {
- await projectStore.updateProject(projectPatch, updateMask.value);
- } finally {
- loading.value = false;
- }
-};
-
-const updateMask = computed(() => {
- const mask: string[] = [];
- if (!isEqual(state.issueLabels, props.project.issueLabels)) {
- mask.push("issue_labels");
- }
- if (state.forceIssueLabels !== props.project.forceIssueLabels) {
- mask.push("force_issue_labels");
- }
- if (state.enforceSqlReview !== props.project.enforceSqlReview) {
- mask.push("enforce_sql_review");
- }
- if (state.enforceIssueTitle !== props.project.enforceIssueTitle) {
- mask.push("enforce_issue_title");
- }
- if (state.allowSelfApproval !== props.project.allowSelfApproval) {
- mask.push("allow_self_approval");
- }
- if (
- !isEqual(
- state.postgresDatabaseTenantMode,
- props.project.postgresDatabaseTenantMode
- )
- ) {
- mask.push("postgres_database_tenant_mode");
- }
- if (
- !isEqual(
- state.executionRetryPolicy?.maximumRetries ?? 0,
- props.project.executionRetryPolicy?.maximumRetries ?? 0
- )
- ) {
- mask.push("execution_retry_policy");
- }
- if (!isEqual(state.ciSamplingSize, props.project.ciSamplingSize || 0)) {
- mask.push("ci_sampling_size");
- }
- if (
- !isEqual(
- state.parallelTasksPerRollout,
- props.project.parallelTasksPerRollout || 0
- )
- ) {
- mask.push("parallel_tasks_per_rollout");
- }
- if (state.requireIssueApproval !== props.project.requireIssueApproval) {
- mask.push("require_issue_approval");
- }
- if (state.requirePlanCheckNoError !== props.project.requirePlanCheckNoError) {
- mask.push("require_plan_check_no_error");
- }
- return mask;
-});
-
-const handleInput = (value: number | null) => {
- if (value === null) return;
- if (value === undefined) return;
- state.executionRetryPolicy = createProto(Project_ExecutionRetryPolicySchema, {
- maximumRetries: value,
- });
-};
-
-const handleCiSamplingSizeInput = (value: number | null) => {
- if (value === null || value === undefined) return;
- state.ciSamplingSize = value;
-};
-
-const handleParallelTasksPerRolloutInput = (value: number | null) => {
- if (value === null || value === undefined) return;
- state.parallelTasksPerRollout = value;
-};
-
-defineExpose({
- isDirty: valueChanged,
- update: doUpdate,
- revert: () => {
- Object.assign(state, getInitialLocalState());
- },
-});
-</script>
diff --git a/frontend/src/components/Project/Settings/ProjectSecuritySettingPanel.vue b/frontend/src/components/Project/Settings/ProjectSecuritySettingPanel.vue
deleted file mode 100644
index cb177edf91..0000000000
--- a/frontend/src/components/Project/Settings/ProjectSecuritySettingPanel.vue
+++ /dev/null
@@ -1,288 +0,0 @@
-<template>
- <div class="w-full flex flex-col justify-start items-start gap-y-6">
- <ComponentPermissionGuard
- :project="project"
- :permissions="['bb.policies.get']"
- >
- <div class="w-full flex flex-col justify-start items-start gap-y-6">
- <SQLReviewForResource
- ref="sqlReviewForResourceRef"
- :resource="project.name"
- />
-
- <!-- Maximum SQL Result Rows (project-level) -->
- <div>
- <p class="font-medium flex flex-row justify-start items-center">
- <span class="mr-2">
- {{ $t("settings.general.workspace.maximum-sql-result.rows.self") }}
- </span>
- <FeatureBadge :feature="PlanFeature.FEATURE_QUERY_POLICY" />
- </p>
- <p class="text-sm text-gray-400 mt-1">
- {{
- $t("settings.general.workspace.maximum-sql-result.rows.description")
- }}
- <span class="font-semibold! textinfolabel">
- {{ $t("settings.general.workspace.no-limit") }}
- </span>
- </p>
- <div class="mt-3 w-full flex flex-row justify-start items-center gap-4">
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.policies.update'
- ]"
- >
- <NInputNumber
- :value="maximumResultRows"
- :disabled="!hasQueryPolicyFeature || slotProps.disabled"
- class="w-60"
- :min="0"
- :precision="0"
- @update:value="handleMaxRowsInput"
- >
- <template #suffix>{{
- $t("settings.general.workspace.maximum-sql-result.rows.rows")
- }}</template>
- </NInputNumber>
- </PermissionGuardWrapper>
- </div>
- </div>
- </div>
- </ComponentPermissionGuard>
-
- <div>
- <div class="flex items-center gap-x-2">
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.projects.update'
- ]"
- >
- <Switch
- v-model:value="allowRequestRole"
- :text="true"
- :disabled="
- slotProps.disabled ||
- loading
- "
- />
- </PermissionGuardWrapper>
- <div class="textlabel flex items-center gap-x-2">
- {{
- $t(
- "project.settings.issue-related.allow-request-role.self"
- )
- }}
- </div>
- <ApprovalFlowIndicator
- :source="WorkspaceApprovalSetting_Rule_Source.REQUEST_ROLE"
- />
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t(
- "project.settings.issue-related.allow-request-role.description"
- )
- }}
- </div>
- </div>
-
- <div>
- <div class="flex items-center gap-x-2">
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.projects.update'
- ]"
- >
- <Switch
- v-model:value="allowJustInTimeAccess"
- :text="true"
- :disabled="
- slotProps.disabled ||
- loading
- "
- />
- </PermissionGuardWrapper>
- <div class="textlabel flex items-center gap-x-2">
- {{
- $t(
- "project.settings.issue-related.allow-jit.self"
- )
- }}
- </div>
- <ApprovalFlowIndicator
- :source="WorkspaceApprovalSetting_Rule_Source.REQUEST_ACCESS"
- />
- </div>
- <div class="mt-1 text-sm text-gray-400">
- {{
- $t(
- "project.settings.issue-related.allow-jit.description"
- )
- }}
- </div>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { create } from "@bufbuild/protobuf";
-import { cloneDeep } from "lodash-es";
-import { NInputNumber } from "naive-ui";
-import { computed, ref, watch } from "vue";
-import { FeatureBadge } from "@/components/FeatureGuard";
-import ComponentPermissionGuard from "@/components/Permission/ComponentPermissionGuard.vue";
-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import { SQLReviewForResource } from "@/components/SQLReview";
-import { Switch } from "@/components/v2";
-import {
- featureToRef,
- usePolicyByParentAndType,
- usePolicyV1Store,
- useProjectV1Store,
-} from "@/store";
-import {
- PolicyResourceType,
- PolicyType,
- QueryDataPolicySchema,
-} from "@/types/proto-es/v1/org_policy_service_pb";
-import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";
-import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
-import ApprovalFlowIndicator from "./ApprovalFlowIndicator.vue";
-
-const props = defineProps<{
- project: Project;
-}>();
-
-const projectStore = useProjectV1Store();
-const policyV1Store = usePolicyV1Store();
-const hasQueryPolicyFeature = featureToRef(PlanFeature.FEATURE_QUERY_POLICY);
-
-const allowRequestRole = ref<boolean>(props.project.allowRequestRole);
-const allowJustInTimeAccess = ref<boolean>(props.project.allowJustInTimeAccess);
-const loading = ref<boolean>(false);
-
-const sqlReviewForResourceRef =
- ref<InstanceType<typeof SQLReviewForResource>>();
-
-const { ready } = usePolicyByParentAndType(
- computed(() => ({
- parentPath: props.project.name,
- policyType: PolicyType.DATA_QUERY,
- }))
-);
-
-const policyPayload = computed(() => {
- return policyV1Store.getQueryDataPolicyByParent(props.project.name);
-});
-
-// Maximum result rows (project-level)
-const getInitialMaxRows = () => {
- const rows = Number(policyPayload.value.maximumResultRows);
- return rows < 0 ? 0 : rows;
-};
-const maximumResultRows = ref<number>(getInitialMaxRows());
-
-watch(
- () => ready.value,
- (ready) => {
- if (ready) {
- maximumResultRows.value = getInitialMaxRows();
- }
- }
-);
-
-const handleMaxRowsInput = (value: number | null) => {
- if (value === null || value === undefined) return;
- maximumResultRows.value = value;
-};
-
-const maxRowsDirty = computed(
- () => maximumResultRows.value !== getInitialMaxRows()
-);
-
-const isDirty = computed(
- () =>
- sqlReviewForResourceRef.value?.isDirty ||
- maxRowsDirty.value ||
- allowRequestRole.value !== props.project.allowRequestRole ||
- allowJustInTimeAccess.value !== props.project.allowJustInTimeAccess
-);
-
-const updateMask = computed(() => {
- const mask: string[] = [];
- if (allowRequestRole.value !== props.project.allowRequestRole) {
- mask.push("allow_request_role");
- }
- if (allowJustInTimeAccess.value !== props.project.allowJustInTimeAccess) {
- mask.push("allow_just_in_time_access");
- }
- return mask;
-});
-
-const doUpdateProject = async () => {
- if (loading.value) {
- return;
- }
- if (updateMask.value.length === 0) {
- return;
- }
- loading.value = true;
- const projectPatch = {
- ...cloneDeep(props.project),
- allowRequestRole: allowRequestRole.value,
- allowJustInTimeAccess: allowJustInTimeAccess.value,
- };
- try {
- await projectStore.updateProject(projectPatch, updateMask.value);
- } finally {
- loading.value = false;
- }
-};
-
-const updateMaxRows = async () => {
- await policyV1Store.upsertPolicy({
- parentPath: props.project.name,
- policy: {
- type: PolicyType.DATA_QUERY,
- resourceType: PolicyResourceType.PROJECT,
- policy: {
- case: "queryDataPolicy",
- value: create(QueryDataPolicySchema, {
- ...policyPayload.value,
- maximumResultRows: maximumResultRows.value,
- }),
- },
- },
- });
-};
-
-const onUpdate = async () => {
- if (sqlReviewForResourceRef.value?.isDirty) {
- await sqlReviewForResourceRef.value.update();
- }
- if (maxRowsDirty.value) {
- await updateMaxRows();
- }
- await doUpdateProject();
-};
-
-const resetState = () => {
- sqlReviewForResourceRef.value?.revert();
- maximumResultRows.value = getInitialMaxRows();
- allowRequestRole.value = props.project.allowRequestRole;
- allowJustInTimeAccess.value = props.project.allowJustInTimeAccess;
-};
-
-defineExpose({
- isDirty,
- update: onUpdate,
- revert: resetState,
-});
-</script>
diff --git a/frontend/src/components/Project/Settings/index.ts b/frontend/src/components/Project/Settings/index.ts
deleted file mode 100644
index e19dccafae..0000000000
--- a/frontend/src/components/Project/Settings/index.ts
+++ /dev/null
@@ -1,9 +0,0 @@
-import ProjectGeneralSettingPanel from "./ProjectGeneralSettingPanel.vue";
-import ProjectIssueRelatedSettingPanel from "./ProjectIssueRelatedSettingPanel.vue";
-import ProjectSecuritySettingPanel from "./ProjectSecuritySettingPanel.vue";
-
-export {
- ProjectGeneralSettingPanel,
- ProjectSecuritySettingPanel,
- ProjectIssueRelatedSettingPanel,
-};
diff --git a/frontend/src/components/ProjectSettingPanel.vue b/frontend/src/components/ProjectSettingPanel.vue
deleted file mode 100644
index 36a6ffbca5..0000000000
--- a/frontend/src/components/ProjectSettingPanel.vue
+++ /dev/null
@@ -1,321 +0,0 @@
-<template>
- <div class="w-full flex flex-col gap-y-0 pt-4 px-4">
- <div class="divide-y divide-block-border">
- <!-- General Settings Section -->
- <div class="pb-6 lg:flex">
- <div class="text-left lg:w-1/4">
- <h1 class="text-2xl font-bold">
- {{ $t("common.general") }}
- </h1>
- </div>
- <div class="flex-1 mt-4 lg:px-4 lg:mt-0">
- <ProjectGeneralSettingPanel
- ref="projectGeneralSettingPanelRef"
- :project="project"
- />
- </div>
- </div>
-
- <!-- Security Settings Section -->
- <div class="py-6 lg:flex">
- <div class="text-left lg:w-1/4">
- <h1 class="text-2xl font-bold">
- {{ $t("settings.sidebar.security-and-policy") }}
- </h1>
- </div>
- <div class="flex-1 mt-4 lg:px-4 lg:mt-0">
- <ProjectSecuritySettingPanel
- ref="projectSecuritySettingPanelRef"
- :project="project"
- />
- </div>
- </div>
-
- <div id="issue-related" class="py-6 lg:flex">
- <div class="text-left lg:w-1/4">
- <h1 class="text-2xl font-bold">
- {{ $t("project.settings.issue-related.self") }}
- </h1>
- </div>
- <div class="flex-1 mt-4 lg:px-4 lg:mt-0">
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.projects.update'
- ]"
- >
- <ProjectIssueRelatedSettingPanel
- ref="projectIssueRelatedSettingPanelRef"
- :project="project"
- :allow-edit="!slotProps.disabled"
- />
- </PermissionGuardWrapper>
- </div>
- </div>
-
- <div class="py-6 lg:flex">
- <div class="text-left lg:w-1/4">
- <div class="flex items-center gap-x-2">
- <h1 class="text-2xl font-bold">
- {{ $t("common.danger-zone") }}
- </h1>
- </div>
- </div>
- <div class="flex-1 mt-4 lg:px-4 lg:mt-0">
- <div class="border border-error-alpha bg-error-alpha rounded-lg divide-y divide-error-alpha">
- <!-- Archive/Restore Section -->
- <div class="p-6 flex items-start justify-between gap-x-6">
- <template v-if="project.state === State.ACTIVE">
- <div class="flex-1">
- <h4 class="font-medium text-main">
- {{ $t('common.archive-resource', { type: $t('common.project') }) }}
- </h4>
- <p class="text-sm text-control-light mt-1">
- {{ $t('common.archive-description', { name: project.title || project.name }) }}
- </p>
- </div>
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.projects.delete'
- ]"
- >
- <div>
- <BBButtonConfirm
- type="ARCHIVE"
- :button-text="$t('common.archive')"
- :confirm-title="$t('common.confirm-archive')"
- :confirm-description="
- $t('project.settings.confirm-archive-project', { name: project.title || project.name })
- "
- :require-confirm="true"
- :disabled="dangerZoneState.isExecuting || slotProps.disabled"
- @confirm="handleArchive"
- />
- </div>
- </PermissionGuardWrapper>
- </template>
- <template v-else-if="project.state === State.DELETED">
- <div class="flex-1">
- <h4 class="font-medium text-main">
- {{ $t('project.settings.restore.title') }}
- </h4>
- <p class="text-sm text-control-light mt-1">
- {{ $t('project.settings.restore.btn-text') }}
- </p>
- </div>
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.projects.undelete'
- ]"
- >
- <div>
- <BBButtonConfirm
- type="RESTORE"
- :button-text="$t('common.restore')"
- :confirm-title="$t('project.settings.restore.title')"
- :confirm-description="
- $t('project.settings.restore.title') + ` '${project.title || project.name}'?`
- "
- :require-confirm="true"
- :disabled="dangerZoneState.isExecuting || slotProps.disabled"
- @confirm="handleRestore"
- />
- </div>
- </PermissionGuardWrapper>
- </template>
- </div>
-
- <!-- Delete Section -->
- <div class="p-6 flex items-start justify-between gap-x-6">
- <div class="flex-1">
- <h4 class="font-medium text-error">
- {{ $t('common.delete-resource', { type: $t('common.project') }) }}
- </h4>
- <p class="text-sm text-control-light mt-1">
- {{ $t('common.delete-resource-description', { name: project.title || project.name }) }}
- </p>
- </div>
- <PermissionGuardWrapper
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.projects.delete'
- ]"
- >
- <div>
- <BBButtonConfirm
- type="DELETE"
- :button-text="$t('common.delete')"
- :confirm-title="$t('common.confirm-delete')"
- :confirm-description="
- $t('project.settings.confirm-delete-project', { name: project.title || project.name })
- "
- :require-confirm="true"
- :disabled="dangerZoneState.isExecuting || slotProps.disabled"
- @confirm="handleDelete"
- />
- </div>
- </PermissionGuardWrapper>
- </div>
- </div>
- </div>
- </div>
-
- <!-- Save/Cancel buttons -->
- <div v-if="allowEdit && isDirty" class="sticky bottom-0 z-10">
- <div
- class="flex justify-between w-full py-4 border-t border-block-border bg-white"
- >
- <NButton @click.prevent="onRevert">
- {{ $t("common.cancel") }}
- </NButton>
- <NButton type="primary" @click.prevent="onUpdate">
- {{ $t("common.confirm-and-update") }}
- </NButton>
- </div>
- </div>
- </div>
- </div>
-</template>
-
-<script lang="ts" setup>
-import { NButton } from "naive-ui";
-import { computed, reactive, ref } from "vue";
-import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
-import { BBButtonConfirm } from "@/bbkit";
-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import { useRouteChangeGuard } from "@/composables/useRouteChangeGuard";
-import { PROJECT_V1_ROUTE_DASHBOARD } from "@/router/dashboard/workspaceRoutes";
-import {
- pushNotification,
- useGracefulRequest,
- useProjectV1Store,
-} from "@/store";
-import { State } from "@/types/proto-es/v1/common_pb";
-import type { Project } from "@/types/proto-es/v1/project_service_pb";
-import {
- ProjectGeneralSettingPanel,
- ProjectIssueRelatedSettingPanel,
- ProjectSecuritySettingPanel,
-} from "./Project/Settings/";
-
-const props = defineProps<{
- project: Project;
- allowEdit: boolean;
-}>();
-
-const { t } = useI18n();
-const router = useRouter();
-const projectStore = useProjectV1Store();
-
-const projectSecuritySettingPanelRef =
- ref<InstanceType<typeof ProjectSecuritySettingPanel>>();
-const projectGeneralSettingPanelRef =
- ref<InstanceType<typeof ProjectGeneralSettingPanel>>();
-const projectIssueRelatedSettingPanelRef =
- ref<InstanceType<typeof ProjectIssueRelatedSettingPanel>>();
-
-const settingRefList = computed(() => {
- return [
- projectGeneralSettingPanelRef,
- projectSecuritySettingPanelRef,
- projectIssueRelatedSettingPanelRef,
- ];
-});
-
-const isDirty = computed(() => {
- return settingRefList.value.some((settingRef) => settingRef.value?.isDirty);
-});
-
-useRouteChangeGuard(isDirty);
-
-const onUpdate = async () => {
- for (const settingRef of settingRefList.value) {
- if (!settingRef.value?.isDirty) {
- continue;
- }
- try {
- await settingRef.value.update();
- } catch {
- pushNotification({
- module: "bytebase",
- style: "CRITICAL",
- title: t("project.settings.update-failed"),
- });
- return;
- }
- }
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("project.settings.success-updated"),
- });
-};
-
-const onRevert = () => {
- for (const settingRef of settingRefList.value) {
- settingRef.value?.revert();
- }
-};
-
-const dangerZoneState = reactive({
- isExecuting: false,
-});
-
-const handleArchive = () => {
- dangerZoneState.isExecuting = true;
- useGracefulRequest(async () => {
- try {
- await projectStore.archiveProject(props.project);
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: `${props.project.title || props.project.name} ${t("common.archived")}`,
- });
- router.push({ name: PROJECT_V1_ROUTE_DASHBOARD });
- } finally {
- dangerZoneState.isExecuting = false;
- }
- });
-};
-
-const handleRestore = () => {
- dangerZoneState.isExecuting = true;
- useGracefulRequest(async () => {
- try {
- await projectStore.restoreProject(props.project);
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: `${props.project.title || props.project.name} ${t("common.restored")}`,
- });
- router.push({ name: PROJECT_V1_ROUTE_DASHBOARD });
- } finally {
- dangerZoneState.isExecuting = false;
- }
- });
-};
-
-const handleDelete = () => {
- dangerZoneState.isExecuting = true;
- useGracefulRequest(async () => {
- try {
- await projectStore.deleteProject(props.project.name);
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: `${props.project.title || props.project.name} ${t("common.deleted")}`,
- });
- router.push({ name: PROJECT_V1_ROUTE_DASHBOARD });
- } finally {
- dangerZoneState.isExecuting = false;
- }
- });
-};
-</script>
diff --git a/frontend/src/components/SQLReview/components/SQLReviewForResource.vue b/frontend/src/components/SQLReview/components/SQLReviewForResource.vue
deleted file mode 100644
index 50bfc7de71..0000000000
--- a/frontend/src/components/SQLReview/components/SQLReviewForResource.vue
+++ /dev/null
@@ -1,240 +0,0 @@
-<template>
- <div v-if="allowGetSQLReviewPolicy" class="flex flex-col gap-y-2">
- <div class="flex items-center gap-x-2">
- <label class="font-medium">
- {{ $t("sql-review.title") }}
- </label>
- <NTooltip v-if="tooltip">
- <template #trigger>
- <CircleQuestionMarkIcon class="w-4 textinfolabel" />
- </template>
- <span>
- {{ tooltip }}
- </span>
- </NTooltip>
- </div>
- <div>
- <div
- v-if="pendingSelectReviewPolicy"
- class="inline-flex items-center gap-x-2"
- >
- <PermissionGuardWrapper
- v-slot="slotProps"
- :permissions="[
- 'bb.reviewConfigs.update',
- ]"
- >
- <Switch
- v-model:value="enforceSQLReviewPolicy"
- :text="true"
- :disabled="slotProps.disabled"
- />
- </PermissionGuardWrapper>
- <div
- class="flex items-center space-x-1"
- >
- <span class="textlabel normal-link text-accent!" @click="onSQLReviewPolicyClick">
- {{ pendingSelectReviewPolicy.name }}
- </span>
- <NButton
- v-if="hasUpdatePolicyPermission"
- quaternary
- size="tiny"
- @click.stop="onReviewPolicyRemove"
- >
- <template #icon>
- <XIcon class="w-4 h-auto" />
- </template>
- </NButton>
- </div>
- </div>
- <PermissionGuardWrapper
- v-else
- v-slot="slotProps"
- :project="project"
- :permissions="[
- 'bb.policies.update',
- 'bb.reviewConfigs.list'
- ]"
- >
- <NButton
- :disabled="slotProps.disabled"
- @click.prevent="showReviewSelectPanel = true"
- >
- {{ $t("sql-review.configure-policy") }}
- </NButton>
- </PermissionGuardWrapper>
- </div>
- </div>
-
- <SQLReviewPolicySelectPanel
- :resource="resource"
- :show="showReviewSelectPanel"
- @close="showReviewSelectPanel = false"
- @select="onReviewPolicySelect"
- />
-</template>
-
-<script setup lang="ts">
-import { isEqual } from "lodash-es";
-import { CircleQuestionMarkIcon, XIcon } from "lucide-vue-next";
-import { NButton, NTooltip } from "naive-ui";
-import { computed, ref, watchEffect } from "vue";
-import { useRouter } from "vue-router";
-import PermissionGuardWrapper from "@/components/Permission/PermissionGuardWrapper.vue";
-import { Switch } from "@/components/v2";
-import { t } from "@/plugins/i18n";
-import { WORKSPACE_ROUTE_SQL_REVIEW_DETAIL } from "@/router/dashboard/workspaceRoutes";
-import {
- useProjectV1Store,
- useReviewPolicyByResource,
- useSQLReviewStore,
-} from "@/store";
-import { projectNamePrefix } from "@/store/modules/v1/common";
-import type { SQLReviewPolicy } from "@/types";
-import { isValidProjectName } from "@/types";
-import {
- hasProjectPermissionV2,
- hasWorkspacePermissionV2,
- sqlReviewPolicySlug,
-} from "@/utils";
-import SQLReviewPolicySelectPanel from "./SQLReviewPolicySelectPanel.vue";
-
-const props = defineProps<{
- resource: string;
-}>();
-
-const router = useRouter();
-const reviewStore = useSQLReviewStore();
-const showReviewSelectPanel = ref<boolean>(false);
-const pendingSelectReviewPolicy = ref<SQLReviewPolicy | undefined>(undefined);
-const projectStore = useProjectV1Store();
-
-const project = computed(() => {
- if (props.resource.startsWith(projectNamePrefix)) {
- const proj = projectStore.getProjectByName(props.resource);
- if (!isValidProjectName(proj.name)) {
- return undefined;
- }
- return proj;
- }
- return undefined;
-});
-
-const hasGetPolicyPermission = computed(() => {
- if (project.value) {
- return hasProjectPermissionV2(project.value, "bb.policies.get");
- }
- return hasWorkspacePermissionV2("bb.policies.get");
-});
-
-const hasUpdatePolicyPermission = computed(() => {
- if (project.value) {
- return hasProjectPermissionV2(project.value, "bb.policies.update");
- }
- return hasWorkspacePermissionV2("bb.policies.update");
-});
-
-const tooltip = computed(() => {
- if (project.value) {
- return t("sql-review.tooltip-for-resource", {
- scope: t(
- "settings.general.workspace.query-data-policy.environment-scope"
- ),
- });
- }
- return t("sql-review.tooltip-for-resource", {
- scope: t("settings.general.workspace.query-data-policy.project-scope"),
- });
-});
-
-const sqlReviewPolicy = useReviewPolicyByResource(
- computed(() => props.resource)
-);
-const enforceSQLReviewPolicy = ref<boolean>(false);
-
-const resetState = () => {
- pendingSelectReviewPolicy.value = sqlReviewPolicy.value;
- enforceSQLReviewPolicy.value = sqlReviewPolicy.value?.enforce ?? false;
-};
-
-watchEffect(resetState);
-
-const allowGetSQLReviewPolicy = computed(() => {
- return (
- hasWorkspacePermissionV2("bb.reviewConfigs.get") &&
- hasGetPolicyPermission.value
- );
-});
-
-const onReviewPolicySelect = (review: SQLReviewPolicy) => {
- pendingSelectReviewPolicy.value = review;
- enforceSQLReviewPolicy.value = true;
- showReviewSelectPanel.value = false;
-};
-
-const onReviewPolicyRemove = () => {
- pendingSelectReviewPolicy.value = undefined;
- enforceSQLReviewPolicy.value = false;
-};
-
-const toggleSQLReviewPolicy = async () => {
- if (!isEqual(sqlReviewPolicy.value, pendingSelectReviewPolicy.value)) {
- if (sqlReviewPolicy.value) {
- // remove resource from old review policy
- await reviewStore.upsertReviewConfigTag({
- oldResources: [...sqlReviewPolicy.value.resources],
- newResources: sqlReviewPolicy.value.resources.filter(
- (resource) => resource !== props.resource
- ),
- review: sqlReviewPolicy.value.id,
- });
- }
- if (pendingSelectReviewPolicy.value) {
- // attach resource to new selected review policy.
- await reviewStore.upsertReviewConfigTag({
- oldResources: [...pendingSelectReviewPolicy.value.resources],
- newResources: [
- ...pendingSelectReviewPolicy.value.resources,
- props.resource,
- ],
- review: pendingSelectReviewPolicy.value.id,
- });
- }
- }
-
- if (
- pendingSelectReviewPolicy.value &&
- pendingSelectReviewPolicy.value.enforce !== enforceSQLReviewPolicy.value
- ) {
- await reviewStore.upsertReviewPolicy({
- id: pendingSelectReviewPolicy.value.id,
- enforce: enforceSQLReviewPolicy.value,
- });
- }
-};
-
-const onSQLReviewPolicyClick = () => {
- if (pendingSelectReviewPolicy.value) {
- router.push({
- name: WORKSPACE_ROUTE_SQL_REVIEW_DETAIL,
- params: {
- sqlReviewPolicySlug: sqlReviewPolicySlug(
- pendingSelectReviewPolicy.value
- ),
- },
- });
- }
-};
-
-defineExpose({
- isDirty: computed(
- () =>
- enforceSQLReviewPolicy.value !==
- (pendingSelectReviewPolicy.value?.enforce ?? false) ||
- !isEqual(pendingSelectReviewPolicy.value, sqlReviewPolicy.value)
- ),
- update: toggleSQLReviewPolicy,
- revert: resetState,
-});
-</script>
diff --git a/frontend/src/components/SQLReview/components/SQLReviewPolicySelectPanel.vue b/frontend/src/components/SQLReview/components/SQLReviewPolicySelectPanel.vue
deleted file mode 100644
index d085eb1b2a..0000000000
--- a/frontend/src/components/SQLReview/components/SQLReviewPolicySelectPanel.vue
+++ /dev/null
@@ -1,86 +0,0 @@
-<template>
- <Drawer :show="show" @close="$emit('close')">
- <DrawerContent
- :title="$t('sql-review.select-review')"
- class="w-240 max-w-[100vw] relative"
- >
- <template #default>
- <div class="flex flex-col gap-y-4">
- <i18n-t
- keypath="sql-review.select-review-label"
- tag="p"
- class="textinfolabel"
- >
- <template #create>
- <NButton
- text
- type="primary"
- class="normal-link lowercase"
- @click="createPolicy"
- @disabled="!allowCreateSQLReviewPolicy"
- >
- {{ $t("sql-review.create-policy") }}
- </NButton>
- </template>
- </i18n-t>
- <SQLReviewPolicyDataTable
- :size="'small'"
- :review-list="sqlReviewStore.reviewPolicyList"
- :allow-edit="false"
- :custom-click="true"
- @row-click="emit('select', $event)"
- />
- </div>
- </template>
- <template #footer>
- <div class="flex items-center justify-end gap-x-3">
- <NButton @click="$emit('close')">
- {{ $t("common.cancel") }}
- </NButton>
- </div>
- </template>
- </DrawerContent>
- </Drawer>
-</template>
-
-<script setup lang="ts">
-import { NButton } from "naive-ui";
-import { computed, watchEffect } from "vue";
-import { useRouter } from "vue-router";
-import { Drawer, DrawerContent } from "@/components/v2";
-import { WORKSPACE_ROUTE_SQL_REVIEW_CREATE } from "@/router/dashboard/workspaceRoutes";
-import { useSQLReviewStore } from "@/store";
-import type { SQLReviewPolicy } from "@/types";
-import { hasWorkspacePermissionV2 } from "@/utils";
-import SQLReviewPolicyDataTable from "./SQLReviewPolicyDataTable.vue";
-
-const props = defineProps<{
- show: boolean;
- resource: string;
-}>();
-
-const emit = defineEmits<{
- (event: "close"): void;
- (event: "select", review: SQLReviewPolicy): void;
-}>();
-
-const sqlReviewStore = useSQLReviewStore();
-const router = useRouter();
-
-watchEffect(() => {
- sqlReviewStore.fetchReviewPolicyList();
-});
-
-const allowCreateSQLReviewPolicy = computed(() => {
- return hasWorkspacePermissionV2("bb.reviewConfigs.create");
-});
-
-const createPolicy = () => {
- router.push({
- name: WORKSPACE_ROUTE_SQL_REVIEW_CREATE,
- query: {
- attachedResource: props.resource,
- },
- });
-};
-</script>
diff --git a/frontend/src/components/SQLReview/components/index.ts b/frontend/src/components/SQLReview/components/index.ts
index 9f685194e1..2750499f8c 100644
--- a/frontend/src/components/SQLReview/components/index.ts
+++ b/frontend/src/components/SQLReview/components/index.ts
@@ -1,5 +1,4 @@
-import SQLReviewForResource from "./SQLReviewForResource.vue";
import SQLRuleEditDialog from "./SQLRuleEditDialog.vue";
-export { SQLRuleEditDialog, SQLReviewForResource };
+export { SQLRuleEditDialog };
export * from "./utils";
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index f113656422..eea18ed9cb 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -775,9 +775,7 @@
"self": "Maximum query time",
"description": "The maximum time allowed for a query to run."
},
- "seconds": "Seconds",
- "project-scope": "project",
- "environment-scope": "environment"
+ "seconds": "Seconds"
},
"domain-restriction": {
"self": "Workspace Domain",
@@ -2488,10 +2486,8 @@
"description": "SQL review policy can define different set of SQL lint rules for the respective environments. It helps teams to adopt SQL best practice and enforce schema consistency across different databases. Whenever you attempt a DDL/DML change or use SQL Editor to query data, the query will be checked against the configured SQL review policy.",
"disabled": "SQL review is disabled",
"create-policy": "Create SQL review",
- "select-review": "Select SQL review",
"select-review-rules": "Select SQL review rules",
"select-all": "Select all",
- "select-review-label": "You can attach an existed SQL review policy to the resource, or {create}.",
"configure-policy": "Configure policy",
"policy-removed": "Successfully removed the review policy.",
"policy-created": "Successfully created the review policy.",
@@ -2539,8 +2535,7 @@
"name": "Level",
"error": "Error",
"warning": "Warning"
- },
- "tooltip-for-resource": "It's also configurable at the {scope} level. Bytebase will prioritize the environment-level configuration."
+ }
},
"audit-log": {
"export-finished": "Export finished",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 71f60ca248..c218c4462d 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -775,9 +775,7 @@
"self": "Tiempo máximo de consulta",
"description": "El tiempo máximo permitido para la ejecución de una consulta."
},
- "seconds": "Segundos",
- "project-scope": "proyecto",
- "environment-scope": "ambiente"
+ "seconds": "Segundos"
},
"domain-restriction": {
"self": "Dominio de espacio de trabajo",
@@ -2488,10 +2486,8 @@
"description": "La política de revisión de SQL puede definir diferentes conjuntos de reglas de lint SQL para los entornos respectivos. Ayuda a los equipos a adoptar las mejores prácticas de SQL y a hacer cumplir la consistencia del esquema en diferentes bases de datos. Cada vez que intente realizar un cambio DDL/DML o use el Editor SQL para consultar datos, la consulta se verificará en función de la política de revisión de SQL configurada.",
"disabled": "La revisión de SQL está deshabilitada",
"create-policy": "Crear política",
- "select-review": "Seleccione revisión SQL",
"select-review-rules": "Seleccionar reglas de revisión de SQL",
"select-all": "Seleccionar todo",
- "select-review-label": "Puede adjuntar una política de revisión de SQL existente al recurso o {create}.",
"configure-policy": "Configurar política",
"policy-removed": "La política de revisión se eliminó correctamente.",
"policy-created": "La política de revisión se creó correctamente.",
@@ -2539,8 +2535,7 @@
"name": "Nivel",
"error": "Error",
"warning": "Advertencia"
- },
- "tooltip-for-resource": "También es configurable a nivel {scope}. Bytebase dará prioridad a la configuración a nivel de entorno."
+ }
},
"agent": {
"assistant-title": "Asistente de Bytebase",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index caff9d6cc0..63388313fe 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -775,9 +775,7 @@
"self": "最大クエリ時間",
"description": "クエリの実行に許容される最大時間。"
},
- "seconds": "秒",
- "project-scope": "プロジェクト",
- "environment-scope": "環境"
+ "seconds": "秒"
},
"domain-restriction": {
"self": "ワークスペースドメイン",
@@ -2488,10 +2486,8 @@
"description": "SQL レビューポリシーは、さまざまな環境に対してさまざまな SQL lint ルールのセットを定義でき、チームが SQL のベスト プラクティスを採用し、さまざまなデータベースでスキーマの一貫性を制約するのに役立ちます。 DDL/DML を変更しようとしたり、SQL エディターを使用してデータをクエリしようとしたりすると、設定された SQL レビュールールによって対応する実行ステートメントがチェックされます。",
"disabled": "SQL レビューポリシーが無効になっています",
"create-policy": "SQL レビューポリシーを作成する",
- "select-review": "SQL レビューを選択",
"select-review-rules": "SQL レビュールールを選択",
"select-all": "すべて選択",
- "select-review-label": "既存の SQL レビューポリシーをリソースまたは {create} に添付できます。",
"configure-policy": "SQL レビューポリシーを設定する",
"policy-removed": "SQL レビューポリシーが削除されました",
"policy-created": "SQL レビューポリシーが作成されました",
@@ -2539,8 +2535,7 @@
"name": "レベル",
"error": "エラー",
"warning": "警告"
- },
- "tooltip-for-resource": "{scope} レベルでも設定可能です。Bytebase は環境レベルの設定を優先します。"
+ }
},
"agent": {
"assistant-title": "Bytebase アシスタント",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 634083b0f6..5045711959 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -775,9 +775,7 @@
"self": "Thời gian truy vấn tối đa",
"description": "Thời gian tối đa cho phép để thực hiện một truy vấn."
},
- "seconds": "Giây",
- "project-scope": "dự án",
- "environment-scope": "môi trường"
+ "seconds": "Giây"
},
"domain-restriction": {
"self": "Tên miền không gian làm việc",
@@ -2488,10 +2486,8 @@
"description": "Chính sách đánh giá SQL có thể xác định các bộ quy tắc lint SQL khác nhau cho các môi trường tương ứng. Nó giúp các nhóm áp dụng thực tiễn tốt nhất về SQL và thực thi tính nhất quán của lược đồ trên các cơ sở dữ liệu khác nhau. Bất cứ khi nào bạn cố gắng thay đổi DDL/DML hoặc sử dụng Trình soạn thảo SQL để truy vấn dữ liệu, truy vấn sẽ được kiểm tra theo chính sách đánh giá SQL đã định cấu hình.",
"disabled": "Đánh giá SQL bị vô hiệu hóa",
"create-policy": "Tạo chính sách đánh giá SQL",
- "select-review": "Chọn đánh giá SQL",
"select-review-rules": "Chọn quy tắc đánh giá SQL",
"select-all": "Chọn tất cả",
- "select-review-label": "Bạn có thể đính kèm chính sách đánh giá SQL hiện có vào tài nguyên hoặc {create}.",
"configure-policy": "Định cấu hình chính sách",
"policy-removed": "Đã xóa thành công chính sách đánh giá.",
"policy-created": "Đã tạo thành công chính sách đánh giá.",
@@ -2539,8 +2535,7 @@
"name": "Cấp độ",
"error": "Lỗi",
"warning": "Cảnh báo"
- },
- "tooltip-for-resource": "Bạn cũng có thể cấu hình ở cấp độ {scope}. Bytebase sẽ ưu tiên cấu hình ở cấp độ môi trường."
+ }
},
"agent": {
"assistant-title": "Trợ lý Bytebase",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index cc77e155d8..00bd09a61f 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -775,9 +775,7 @@
"self": "最大查询时间",
"description": "允许运行查询的最长时间。"
},
- "seconds": "秒",
- "project-scope": "项目",
- "environment-scope": "环境"
+ "seconds": "秒"
},
"domain-restriction": {
"self": "工作空间域名",
@@ -2488,10 +2486,8 @@
"description": "SQL 审核策略可以为不同的环境定义不同的 SQL lint 规则集. 它可以帮助团队采用 SQL 最佳使用实践,并在不同的数据库上约束 schema 的一致性。每当您尝试做一个 DDL/DML 变更或者使用 SQL 编辑器来查询数据时, 配置的 SQL 审核规则就会检查相应的执行语句。",
"disabled": "SQL 审核策略已禁用",
"create-policy": "创建审核策略",
- "select-review": "选择 SQL 审核",
"select-review-rules": "选择 SQL 审核规则",
"select-all": "选择全部",
- "select-review-label": "您可以将现有的 SQL 审核策略附加到资源,或者 {create}。",
"configure-policy": "配置审核策略",
"policy-removed": "审核策略已删除",
"policy-created": "审核策略已创建",
@@ -2539,8 +2535,7 @@
"name": "级别",
"error": "错误",
"warning": "警告"
- },
- "tooltip-for-resource": "也可在 {scope} 级别进行配置。Bytebase 将优先考虑环境级别的配置。"
+ }
},
"audit-log": {
"export-finished": "导出完成",
diff --git a/frontend/src/react/locales/en-US.json b/frontend/src/react/locales/en-US.json
index 8acd85835b..3fbbed6aac 100644
--- a/frontend/src/react/locales/en-US.json
+++ b/frontend/src/react/locales/en-US.json
@@ -160,7 +160,13 @@
"warning": "Warning",
"you": "you",
"database-group": "Database Group",
- "databases": "Databases"
+ "databases": "Databases",
+ "danger-zone": "Danger Zone",
+ "archive-resource": "Archive {{type}}",
+ "archive-description": "Mark \"{{name}}\" as archived and read-only.",
+ "confirm-archive": "Archive Resource?",
+ "delete-resource-description": "Once you delete \"{{name}}\", there is no going back. Please be certain.",
+ "confirm-delete": "Delete Resource?"
},
"create-db": {
"cluster": "Cluster",
@@ -317,6 +323,13 @@
"issue": {
"labels": "Issue Labels"
},
+ "label": {
+ "error": {
+ "key-necessary": "Key is required",
+ "key-duplicated": "Duplicated keys",
+ "max-value-length-exceeded": "Value's length cannot exceed {{length}} characters"
+ }
+ },
"landing": {
"changelog-for-version": "Changelog for {{version}}",
"last-visit": "Last visit",
@@ -370,6 +383,81 @@
"filter-projects": "Filter projects",
"table": {
"name": "Name"
+ },
+ "settings": {
+ "success-updated": "Project settings updated successfully.",
+ "update-failed": "Failed to update the project setting.",
+ "confirm-archive-project": "Archiving \"{{name}}\" will make it read-only and hide it from active project lists. All issues, databases, and settings will be preserved. You can restore it later from the archived projects list.",
+ "confirm-delete-project": "Deleting \"{{name}}\" will permanently remove the project and all associated data including issues, configurations, and history. All databases in this project will be moved to the default project. This action cannot be undone.",
+ "restore": {
+ "title": "Restore project",
+ "btn-text": "Restore this project"
+ },
+ "project-labels": {
+ "self": "Project Labels",
+ "description": "Organize projects with key-value labels (max 64)"
+ },
+ "issue-related": {
+ "self": "Issue Related",
+ "labels": {
+ "self": "Issue Labels",
+ "description": "Labels can be attached in the issues for management",
+ "placeholder": "Press Enter to add tag",
+ "force-issue-labels": {
+ "self": "Require labels for all issues",
+ "description": "Require at least one label when creating issues.",
+ "warning": "Require at least configured one label"
+ }
+ },
+ "enforce-issue-title": {
+ "self": "Require manual title",
+ "description": "Require titles for issues and plans to be created by user instead of auto-generated."
+ },
+ "enforce-sql-review": {
+ "self": "Enforce SQL review",
+ "description": "Require SQL review checks to pass without errors before allowing issue creation."
+ },
+ "allow-self-approval": {
+ "self": "Allow self approval",
+ "description": "Allow the issue creator to approve the issue."
+ },
+ "allow-request-role": {
+ "self": "Allow request role",
+ "description": "Allow project members to request roles."
+ },
+ "allow-jit": {
+ "self": "Just-In-Time access",
+ "description": "Allow project members to request just-in-time (JIT) access."
+ },
+ "postgres-database-tenant-mode": {
+ "self": "Postgres database tenant mode",
+ "description": "The tenant mode for Postgres database. If enable, the issue will be run by the database OWNER. Otherwise, the issue will be run by the instance connection user."
+ },
+ "max-retries": {
+ "self": "Maximum retries count for lock timeout",
+ "description": "The maximum retries count for lock timeout when running the task. The default value is 0. Only applicable to Postgres."
+ },
+ "ci-sampling-size": {
+ "self": "CI Data Sampling Size",
+ "description": "The maximum number of databases to sample during CI data validation. When disabled (zero), full validation will be performed."
+ },
+ "parallel_tasks_per_rollout": {
+ "self": "Parallel tasks per rollout",
+ "description": "Control the number of parallel tasks per rollout. Setting this to zero disables any throttling."
+ },
+ "require-issue-approval": {
+ "self": "Require issue approval before creating rollout",
+ "description": "Issue must be approved before creating rollout."
+ },
+ "require-plan-check-no-error": {
+ "self": "Require plan checks to pass before creating rollout",
+ "description": "Plan checks must pass without error before creating rollout."
+ },
+ "approval-flow-configured": "Approval flow configured",
+ "approval-flow-fallback": "Using fallback approval flow",
+ "approval-flow-not-configured": "No approval flow configured",
+ "view-approval-flow": "View approval flow"
+ }
}
},
"quick-action": {
@@ -833,7 +921,8 @@
"members-and-groups": "Members & Groups",
"sso": "SSO",
"subscription": "Subscription",
- "users-and-groups": "Users & Groups"
+ "users-and-groups": "Users & Groups",
+ "security-and-policy": "Security & Policy"
},
"sso": {
"create": "Create SSO",
diff --git a/frontend/src/react/locales/es-ES.json b/frontend/src/react/locales/es-ES.json
index 31a15a53d3..c549d535fe 100644
--- a/frontend/src/react/locales/es-ES.json
+++ b/frontend/src/react/locales/es-ES.json
@@ -160,7 +160,13 @@
"warning": "Advertencia",
"you": "tu",
"database-group": "Grupo de bases de datos",
- "databases": "Bases de datos"
+ "databases": "Bases de datos",
+ "danger-zone": "Danger Zone",
+ "archive-resource": "Archive {{type}}",
+ "archive-description": "Mark \"{{name}}\" as archived and read-only.",
+ "confirm-archive": "Archive Resource?",
+ "delete-resource-description": "Once you delete \"{{name}}\", there is no going back. Please be certain.",
+ "confirm-delete": "Delete Resource?"
},
"create-db": {
"cluster": "Clúster",
@@ -317,6 +323,13 @@
"issue": {
"labels": "Etiquetas de problema"
},
+ "label": {
+ "error": {
+ "key-necessary": "Se requiere una clave",
+ "key-duplicated": "Claves duplicadas",
+ "max-value-length-exceeded": "La longitud del valor no puede exceder {{length}} caracteres"
+ }
+ },
"landing": {
"changelog-for-version": "Registro de cambios para {{version}}",
"last-visit": "Última visita",
@@ -370,6 +383,81 @@
"filter-projects": "Filtrar proyectos",
"table": {
"name": "Nombre"
+ },
+ "settings": {
+ "success-updated": "La configuración del proyecto se actualizó correctamente.",
+ "update-failed": "No se pudo actualizar la configuración del proyecto.",
+ "confirm-archive-project": "Archiving \"{{name}}\" will make it read-only and hide it from active project lists. All issues, databases, and settings will be preserved. You can restore it later from the archived projects list.",
+ "confirm-delete-project": "Deleting \"{{name}}\" will permanently remove the project and all associated data including issues, configurations, and history. All databases in this project will be moved to the default project. This action cannot be undone.",
+ "restore": {
+ "title": "Restaurar proyecto",
+ "btn-text": "Restaurar este @.lower:{'common.project'}"
+ },
+ "project-labels": {
+ "self": "Etiquetas de proyecto",
+ "description": "Organizar proyectos con etiquetas clave-valor (máximo 64)"
+ },
+ "issue-related": {
+ "self": "Problema Relacionado",
+ "labels": {
+ "self": "Etiquetas de problema",
+ "description": "Se pueden colocar etiquetas en los problemas para su gestión.",
+ "placeholder": "Presione Enter para agregar etiqueta",
+ "force-issue-labels": {
+ "self": "Requerir etiquetas para todos los problemas",
+ "description": "Exija al menos una etiqueta al crear problemas.",
+ "warning": "Requiere al menos una etiqueta configurada"
+ }
+ },
+ "enforce-issue-title": {
+ "self": "Requerir título manual",
+ "description": "Requerir que los títulos de problemas y planes sean creados por el usuario en lugar de generarse automáticamente."
+ },
+ "enforce-sql-review": {
+ "self": "Aplicar revisión SQL",
+ "description": "Requiere que las comprobaciones de revisión SQL pasen sin errores antes de permitir la creación de issues."
+ },
+ "allow-self-approval": {
+ "self": "Permitir la autoaprobación",
+ "description": "Permitir que el creador del problema apruebe el problema."
+ },
+ "allow-request-role": {
+ "self": "Permitir solicitar rol",
+ "description": "Los usuarios que no son propietarios del proyecto pueden solicitar roles a nivel de proyecto por sí mismos"
+ },
+ "allow-jit": {
+ "self": "Permitir acceso justo a tiempo",
+ "description": "Una vez habilitado, los usuarios pueden solicitar y usar el acceso justo a tiempo en el Editor SQL."
+ },
+ "postgres-database-tenant-mode": {
+ "self": "Modo inquilino de base de datos Postgres",
+ "description": "Modo de base de datos de inquilino de Postgres. Si se habilita, el problema será ejecutado por el OWNER de la base de datos. De lo contrario, la tarea será ejecutada por el usuario de conexión de la instancia."
+ },
+ "max-retries": {
+ "self": "Los reintentos máximos cuentan para el tiempo de espera de bloqueo",
+ "description": "Las reintentos máximas cuentan para el tiempo de espera de bloqueo al ejecutar la tarea. \nEl valor predeterminado es 0. Solo aplicable a Postgres."
+ },
+ "ci-sampling-size": {
+ "self": "Tamaño de muestreo de datos de CI",
+ "description": "El número máximo de bases de datos para probar durante la validación de datos de CI. \nCuando está deshabilitado (cero), se realizará la validación completa."
+ },
+ "parallel_tasks_per_rollout": {
+ "self": "Tareas paralelas por despliegue",
+ "description": "Controle el número de tareas paralelas por despliegue. \nEstablecer esto en cero deshabilita cualquier estrangulamiento."
+ },
+ "require-issue-approval": {
+ "self": "Requiere aprobación de issue antes de crear el despliegue",
+ "description": "El issue debe ser aprobado antes de crear un despliegue."
+ },
+ "require-plan-check-no-error": {
+ "self": "Requiere que las verificaciones del plan pasen antes de crear el despliegue",
+ "description": "Todas las verificaciones del plan deben pasar sin errores antes de crear un despliegue."
+ },
+ "approval-flow-configured": "Flujo de aprobación configurado",
+ "approval-flow-fallback": "Usando regla de aprobación predeterminada",
+ "approval-flow-not-configured": "Flujo de aprobación no configurado",
+ "view-approval-flow": "Ver flujo de aprobación"
+ }
}
},
"quick-action": {
@@ -833,7 +921,8 @@
"members-and-groups": "Miembros y grupos",
"sso": "SSO",
"subscription": "Suscripción",
- "users-and-groups": "Usuarios y grupos"
+ "users-and-groups": "Usuarios y grupos",
+ "security-and-policy": "Seguridad y Política"
},
"sso": {
"create": "Crear SSO",
diff --git a/frontend/src/react/locales/ja-JP.json b/frontend/src/react/locales/ja-JP.json
index c0e58d0ea3..cc7d8a96da 100644
--- a/frontend/src/react/locales/ja-JP.json
+++ b/frontend/src/react/locales/ja-JP.json
@@ -160,7 +160,13 @@
"warning": "警告する",
"you": "あなた",
"database-group": "データベースグループ",
- "databases": "データベース"
+ "databases": "データベース",
+ "danger-zone": "Danger Zone",
+ "archive-resource": "Archive {{type}}",
+ "archive-description": "Mark \"{{name}}\" as archived and read-only.",
+ "confirm-archive": "Archive Resource?",
+ "delete-resource-description": "Once you delete \"{{name}}\", there is no going back. Please be certain.",
+ "confirm-delete": "Delete Resource?"
},
"create-db": {
"cluster": "集まる",
@@ -317,6 +323,13 @@
"issue": {
"labels": "イシューラベル"
},
+ "label": {
+ "error": {
+ "key-necessary": "キーを指定する必要があります",
+ "key-duplicated": "キーが繰り返されました",
+ "max-value-length-exceeded": "値は {{length}} 文字を超えることはできません"
+ }
+ },
"landing": {
"changelog-for-version": "{{version}} の変更履歴",
"last-visit": "最終訪問",
@@ -370,6 +383,81 @@
"filter-projects": "プロジェクトをフィルタリング",
"table": {
"name": "名前"
+ },
+ "settings": {
+ "success-updated": "プロジェクト設定が正常に更新されました",
+ "update-failed": "プロジェクト設定の更新に失敗しました。",
+ "confirm-archive-project": "Archiving \"{{name}}\" will make it read-only and hide it from active project lists. All issues, databases, and settings will be preserved. You can restore it later from the archived projects list.",
+ "confirm-delete-project": "Deleting \"{{name}}\" will permanently remove the project and all associated data including issues, configurations, and history. All databases in this project will be moved to the default project. This action cannot be undone.",
+ "restore": {
+ "title": "アイテムを復元する",
+ "btn-text": "この @:common.project を復元します"
+ },
+ "project-labels": {
+ "self": "プロジェクトラベル",
+ "description": "キーバリューラベルでプロジェクトを整理(最大64個)"
+ },
+ "issue-related": {
+ "self": "イシュー関連",
+ "labels": {
+ "self": "イシューラベル",
+ "description": "イシューにラベルを貼って管理できる",
+ "placeholder": "Enterキーを押してタグを追加してください",
+ "force-issue-labels": {
+ "self": "すべてのイシューにラベルが必要",
+ "description": "イシューを作成するときは、少なくとも 1 つのラベルが必要です。",
+ "warning": "少なくとも 1 つのラベルを設定する必要があります"
+ }
+ },
+ "enforce-issue-title": {
+ "self": "手動タイトルを要求する",
+ "description": "イシューとプランのタイトルを自動生成ではなくユーザーが作成することを要求します。"
+ },
+ "enforce-sql-review": {
+ "self": "SQL レビューを強制",
+ "description": "課題作成を許可する前に、SQL レビューチェックがエラーなしで合格することを要求します。"
+ },
+ "allow-self-approval": {
+ "self": "自己承認を許可する",
+ "description": "イシューの作成者がイシューを承認できるようにします。"
+ },
+ "allow-request-role": {
+ "self": "ロールリクエストを許可",
+ "description": "プロジェクト所有者以外のユーザーがプロジェクトレベルのロールを自分でリクエストできます"
+ },
+ "allow-jit": {
+ "self": "ジャストインタイムアクセスを許可",
+ "description": "有効にすると、ユーザーは SQL エディタでジャストインタイムアクセスをリクエストして使用できます。"
+ },
+ "postgres-database-tenant-mode": {
+ "self": "Postgres データベーステナントモード",
+ "description": "Postgres データベーステナントモード。有効にすると、イシューはデータベースのOWNERによって実行されます。無効にすると、イシューはインスタンス接続ユーザーによって実行されます。"
+ },
+ "max-retries": {
+ "self": "ロックタイムアウトの最大レトリカウント",
+ "description": "タスクを実行するときのロックタイムアウトの最大再試行カウント。\nデフォルト値は0です。ポストグレスにのみ適用できます。"
+ },
+ "ci-sampling-size": {
+ "self": "CIデータサンプリングサイズ",
+ "description": "CIデータ検証中にサンプリングするデータベースの最大数。\n無効(ゼロ)の場合、完全な検証が実行されます。"
+ },
+ "parallel_tasks_per_rollout": {
+ "self": "ロールアウトごとの並列タスク",
+ "description": "ロールアウトあたりの並列タスクの数を制御します。\nこれをゼロに設定すると、スロットリングが無効になります。"
+ },
+ "require-issue-approval": {
+ "self": "ロールアウト作成前にイシュー承認が必要",
+ "description": "ロールアウトを作成する前にイシューの承認が必要です。"
+ },
+ "require-plan-check-no-error": {
+ "self": "ロールアウト作成前にプランチェック合格が必要",
+ "description": "ロールアウトを作成する前にすべてのプランチェックがエラーなしで合格する必要があります。"
+ },
+ "approval-flow-configured": "承認フローが設定済み",
+ "approval-flow-fallback": "フォールバック承認ルールを使用中",
+ "approval-flow-not-configured": "承認フローが未設定",
+ "view-approval-flow": "承認フローを表示"
+ }
}
},
"quick-action": {
@@ -833,7 +921,8 @@
"members-and-groups": "メンバーとグループ",
"sso": "SSO",
"subscription": "サブスクリプション",
- "users-and-groups": "ユーザーとグループ"
+ "users-and-groups": "ユーザーとグループ",
+ "security-and-policy": "セキュリティポリシー"
},
"sso": {
"create": "SSOの作成",
diff --git a/frontend/src/react/locales/vi-VN.json b/frontend/src/react/locales/vi-VN.json
index b54e7b350d..59003dda8b 100644
--- a/frontend/src/react/locales/vi-VN.json
+++ b/frontend/src/react/locales/vi-VN.json
@@ -160,7 +160,13 @@
"warning": "Cảnh báo",
"you": "bạn",
"database-group": "Nhóm cơ sở dữ liệu",
- "databases": "Cơ sở dữ liệu"
+ "databases": "Cơ sở dữ liệu",
+ "danger-zone": "Danger Zone",
+ "archive-resource": "Archive {{type}}",
+ "archive-description": "Mark \"{{name}}\" as archived and read-only.",
+ "confirm-archive": "Archive Resource?",
+ "delete-resource-description": "Once you delete \"{{name}}\", there is no going back. Please be certain.",
+ "confirm-delete": "Delete Resource?"
},
"create-db": {
"cluster": "Cụm",
@@ -317,6 +323,13 @@
"issue": {
"labels": "Nhãn vấn đề"
},
+ "label": {
+ "error": {
+ "key-necessary": "Khóa là bắt buộc",
+ "key-duplicated": "Khóa trùng lặp",
+ "max-value-length-exceeded": "Độ dài giá trị không được vượt quá {{length}} ký tự"
+ }
+ },
"landing": {
"changelog-for-version": "Nhật ký thay đổi cho phiên bản {{version}}",
"last-visit": "Lần truy cập cuối",
@@ -370,6 +383,81 @@
"filter-projects": "Lọc dự án",
"table": {
"name": "Tên"
+ },
+ "settings": {
+ "success-updated": "Đã cập nhật thành công cài đặt dự án.",
+ "update-failed": "Không cập nhật được cài đặt dự án.",
+ "confirm-archive-project": "Archiving \"{{name}}\" will make it read-only and hide it from active project lists. All issues, databases, and settings will be preserved. You can restore it later from the archived projects list.",
+ "confirm-delete-project": "Deleting \"{{name}}\" will permanently remove the project and all associated data including issues, configurations, and history. All databases in this project will be moved to the default project. This action cannot be undone.",
+ "restore": {
+ "title": "Khôi phục dự án",
+ "btn-text": "Khôi phục @.lower:{'common.project'} này"
+ },
+ "project-labels": {
+ "self": "Nhãn dự án",
+ "description": "Tổ chức dự án với nhãn khóa-giá trị (tối đa 64)"
+ },
+ "issue-related": {
+ "self": "Liên quan đến vấn đề",
+ "labels": {
+ "self": "Nhãn vấn đề",
+ "description": "Có thể gắn nhãn vào các vấn đề để quản lý",
+ "placeholder": "Nhấn Enter để thêm thẻ",
+ "force-issue-labels": {
+ "self": "Yêu cầu nhãn cho tất cả các vấn đề",
+ "description": "Yêu cầu ít nhất một nhãn khi tạo vấn đề.",
+ "warning": "Yêu cầu ít nhất một nhãn được cấu hình"
+ }
+ },
+ "enforce-issue-title": {
+ "self": "Yêu cầu tiêu đề thủ công",
+ "description": "Yêu cầu tiêu đề cho vấn đề và kế hoạch được tạo bởi người dùng thay vì tự động tạo."
+ },
+ "enforce-sql-review": {
+ "self": "Bắt buộc đánh giá SQL",
+ "description": "Yêu cầu kiểm tra đánh giá SQL phải vượt qua mà không có lỗi trước khi cho phép tạo vấn đề。"
+ },
+ "allow-self-approval": {
+ "self": "Cho phép tự phê duyệt",
+ "description": "Cho phép người tạo vấn đề phê duyệt vấn đề."
+ },
+ "allow-request-role": {
+ "self": "Cho phép yêu cầu vai trò",
+ "description": "Người dùng không phải chủ sở hữu dự án có thể tự yêu cầu vai trò cấp dự án"
+ },
+ "allow-jit": {
+ "self": "Cho phép truy cập tức thời",
+ "description": "Khi được bật, người dùng có thể yêu cầu và sử dụng quyền truy cập tức thời trong Trình soạn thảo SQL."
+ },
+ "postgres-database-tenant-mode": {
+ "self": "Chế độ đối tượng thuê cơ sở dữ liệu Postgres",
+ "description": "Chế độ đối tượng thuê cho cơ sở dữ liệu Postgres. Nếu bật, vấn đề sẽ được chạy bởi CHỦ SỞ HỮU cơ sở dữ liệu. Nếu không, vấn đề sẽ được chạy bởi người dùng kết nối phiên bản."
+ },
+ "max-retries": {
+ "self": "Số lần thử lại tối đa cho thời gian chờ khóa",
+ "description": "Tối đa nhớ lại số lượng thời gian chờ khóa khi chạy tác vụ. \nGiá trị mặc định là 0. Chỉ áp dụng cho Postgres."
+ },
+ "ci-sampling-size": {
+ "self": "Kích thước lấy mẫu dữ liệu CI",
+ "description": "Số lượng cơ sở dữ liệu tối đa để lấy mẫu trong quá trình xác thực dữ liệu CI. \nKhi bị vô hiệu hóa (không), xác thực đầy đủ sẽ được thực hiện."
+ },
+ "parallel_tasks_per_rollout": {
+ "self": "Nhiệm vụ song song cho mỗi lần triển khai",
+ "description": "Kiểm soát số lượng các tác vụ song song cho mỗi lần triển khai. \nĐặt điều này thành 0 vô hiệu hóa bất kỳ điều chỉnh."
+ },
+ "require-issue-approval": {
+ "self": "Yêu cầu phê duyệt issue trước khi tạo triển khai",
+ "description": "Issue phải được phê duyệt trước khi tạo triển khai."
+ },
+ "require-plan-check-no-error": {
+ "self": "Yêu cầu kiểm tra kế hoạch phải đạt trước khi tạo triển khai",
+ "description": "Tất cả kiểm tra kế hoạch phải đạt không có lỗi trước khi tạo triển khai."
+ },
+ "approval-flow-configured": "Quy trình phê duyệt đã được cấu hình",
+ "approval-flow-fallback": "Đang sử dụng quy tắc phê duyệt mặc định",
+ "approval-flow-not-configured": "Chưa cấu hình quy trình phê duyệt",
+ "view-approval-flow": "Xem quy trình phê duyệt"
+ }
}
},
"quick-action": {
@@ -833,7 +921,8 @@
"members-and-groups": "Thành viên & Nhóm",
"sso": "SSO",
"subscription": "Gói đăng ký",
- "users-and-groups": "Người dùng & Nhóm"
+ "users-and-groups": "Người dùng & Nhóm",
+ "security-and-policy": "Bảo mật & Chính sách"
},
"sso": {
"create": "Tạo SSO",
diff --git a/frontend/src/react/locales/zh-CN.json b/frontend/src/react/locales/zh-CN.json
index 5499c5bd01..b8df754e9e 100644
--- a/frontend/src/react/locales/zh-CN.json
+++ b/frontend/src/react/locales/zh-CN.json
@@ -160,7 +160,13 @@
"warning": "警告",
"you": "您",
"database-group": "数据库分组",
- "databases": "数据库"
+ "databases": "数据库",
+ "danger-zone": "危险区域",
+ "archive-resource": "归档{{type}}",
+ "archive-description": "将「{{name}}」标记为已归档且只读。",
+ "confirm-archive": "确定归档资源?",
+ "delete-resource-description": "删除「{{name}}」后将无法恢复,请确认。",
+ "confirm-delete": "确定删除资源?"
},
"create-db": {
"cluster": "集群",
@@ -317,6 +323,13 @@
"issue": {
"labels": "工单标签"
},
+ "label": {
+ "error": {
+ "key-necessary": "需要指定 Key",
+ "key-duplicated": "Key 重复了",
+ "max-value-length-exceeded": "值的长度不能超过 {{length}} 字符"
+ }
+ },
"landing": {
"changelog-for-version": "{{version}} 的更新日志",
"last-visit": "上次访问",
@@ -370,6 +383,81 @@
"filter-projects": "过滤项目",
"table": {
"name": "名称"
+ },
+ "settings": {
+ "success-updated": "项目设置更新成功",
+ "update-failed": "无法更新项目设置。",
+ "confirm-archive-project": "归档「{{name}}」将使其变为只读并从活跃项目列表中隐藏。所有工单、数据库和设置将被保留。您可以稍后从已归档项目列表中恢复。",
+ "confirm-delete-project": "删除「{{name}}」将永久移除该项目及所有关联数据,包括工单、配置和历史记录。该项目中的所有数据库将被移至默认项目。此操作无法撤销。",
+ "restore": {
+ "title": "恢复项目",
+ "btn-text": "恢复这个@:common.project"
+ },
+ "project-labels": {
+ "self": "项目标签",
+ "description": "用键值标签组织项目(最多64个)"
+ },
+ "issue-related": {
+ "self": "工单相关",
+ "labels": {
+ "self": "工单标签",
+ "description": "可以在工单中附加标签以便管理",
+ "placeholder": "按 Enter 键添加标签",
+ "force-issue-labels": {
+ "self": "要求所有工单都必须有标签",
+ "description": "创建工单时必须添加至少一个标签。",
+ "warning": "至少需要配置一个标签"
+ }
+ },
+ "enforce-issue-title": {
+ "self": "要求手动输入标题",
+ "description": "工单和计划的标题必须由用户输入,而不是自动生成。"
+ },
+ "enforce-sql-review": {
+ "self": "强制 SQL 审核",
+ "description": "在允许创建工单之前,要求 SQL 审核检查通过且无错误。"
+ },
+ "allow-self-approval": {
+ "self": "允许创建者审批",
+ "description": "允许创建者审批自己创建的工单。"
+ },
+ "allow-request-role": {
+ "self": "允许申请角色",
+ "description": "非项目所有者可以自行申请项目级角色"
+ },
+ "allow-jit": {
+ "self": "允许即时访问",
+ "description": "启用后,用户可以在 SQL 编辑器中请求并使用即时数据访问权限。"
+ },
+ "postgres-database-tenant-mode": {
+ "self": "Postgres 数据库租户模式",
+ "description": "Postgres 数据库租户模式。如果启用,该工单将由数据库 OWNER 运行。否则,该工单将由实例连接用户运行。"
+ },
+ "max-retries": {
+ "self": "锁超时的最大重试数",
+ "description": "运行任务时锁超时的最大重试数。默认值为0。只对 PostgreSQL 有效。"
+ },
+ "ci-sampling-size": {
+ "self": "CI 数据采样大小",
+ "description": "在CI数据验证期间,要采样的数据库数量的最大数量。\n禁用(零)时,将执行完整验证。"
+ },
+ "parallel_tasks_per_rollout": {
+ "self": "每个发布的并行任务数",
+ "description": "控制每个发布的并行任务数量。\n将其设置为零,可以禁用任何节流。"
+ },
+ "require-issue-approval": {
+ "self": "创建发布前需要工单审批",
+ "description": "工单必须在创建发布前获得批准。"
+ },
+ "require-plan-check-no-error": {
+ "self": "创建发布前要求变更检查通过",
+ "description": "所有变更检查必须无错误才能创建发布。"
+ },
+ "approval-flow-configured": "审批流程已配置",
+ "approval-flow-fallback": "使用默认审批规则",
+ "approval-flow-not-configured": "未配置审批流程",
+ "view-approval-flow": "查看审批流程"
+ }
}
},
"quick-action": {
@@ -833,7 +921,8 @@
"members-and-groups": "成员和群组",
"sso": "SSO",
"subscription": "订阅",
- "users-and-groups": "用户和群组"
+ "users-and-groups": "用户和群组",
+ "security-and-policy": "安全 & 策略"
},
"sso": {
"create": "创建 SSO",
diff --git a/frontend/src/react/pages/project/ProjectSettingsPage.tsx b/frontend/src/react/pages/project/ProjectSettingsPage.tsx
new file mode 100644
index 0000000000..a702374e4f
--- /dev/null
+++ b/frontend/src/react/pages/project/ProjectSettingsPage.tsx
@@ -0,0 +1,1409 @@
+import { create } from "@bufbuild/protobuf";
+import { cloneDeep, isEqual } from "lodash-es";
+import { ShieldCheck, TriangleAlert, X } from "lucide-react";
+import { useCallback, useEffect, useMemo, useRef, useState } from "react";
+import { useTranslation } from "react-i18next";
+import { FeatureBadge } from "@/react/components/FeatureBadge";
+import { Button } from "@/react/components/ui/button";
+import {
+ Dialog,
+ DialogContent,
+ DialogTitle,
+} from "@/react/components/ui/dialog";
+import { Input } from "@/react/components/ui/input";
+import { Switch } from "@/react/components/ui/switch";
+import { Tooltip } from "@/react/components/ui/tooltip";
+import { useVueState } from "@/react/hooks/useVueState";
+import { router } from "@/router";
+import {
+ PROJECT_V1_ROUTE_DASHBOARD,
+ WORKSPACE_ROUTE_CUSTOM_APPROVAL,
+ WORKSPACE_ROUTE_SQL_REVIEW_CREATE,
+ WORKSPACE_ROUTE_SQL_REVIEW_DETAIL,
+} from "@/router/dashboard/workspaceRoutes";
+import {
+ pushNotification,
+ usePolicyV1Store,
+ useProjectV1Store,
+ useSQLReviewStore,
+ useSubscriptionV1Store,
+ useWorkspaceApprovalSettingStore,
+} from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import type { Permission, SQLReviewPolicy } from "@/types";
+import { isDefaultProject } from "@/types";
+import { State } from "@/types/proto-es/v1/common_pb";
+import {
+ PolicyResourceType,
+ PolicyType,
+ QueryDataPolicySchema,
+} from "@/types/proto-es/v1/org_policy_service_pb";
+import type { Label } from "@/types/proto-es/v1/project_service_pb";
+import {
+ LabelSchema,
+ Project_ExecutionRetryPolicySchema,
+} from "@/types/proto-es/v1/project_service_pb";
+import { WorkspaceApprovalSetting_Rule_Source } from "@/types/proto-es/v1/setting_service_pb";
+import { PlanFeature } from "@/types/proto-es/v1/subscription_service_pb";
+import {
+ convertKVListToLabels,
+ convertLabelsToKVList,
+ extractProjectResourceName,
+ hasProjectPermissionV2,
+ hasWorkspacePermissionV2,
+ sqlReviewPolicySlug,
+} from "@/utils";
+
+// ---------------------------------------------------------------------------
+// ApprovalFlowIndicator
+// ---------------------------------------------------------------------------
+function ApprovalFlowIndicator({
+ source,
+}: {
+ source: WorkspaceApprovalSetting_Rule_Source;
+}) {
+ const { t } = useTranslation();
+ const approvalStore = useWorkspaceApprovalSettingStore();
+ const [ready, setReady] = useState(false);
+
+ useEffect(() => {
+ if (!hasWorkspacePermissionV2("bb.settings.get")) return;
+ approvalStore.fetchConfig().then(() => setReady(true));
+ }, [approvalStore]);
+
+ const status = useMemo((): "source" | "fallback" | "none" => {
+ if (!ready) return "none";
+ if (approvalStore.getRulesBySource(source).length > 0) return "source";
+ if (
+ approvalStore.getRulesBySource(
+ WorkspaceApprovalSetting_Rule_Source.SOURCE_UNSPECIFIED
+ ).length > 0
+ )
+ return "fallback";
+ return "none";
+ }, [ready, approvalStore, source]);
+
+ if (!ready) return null;
+
+ const configured = status !== "none";
+ const tooltipText =
+ status === "source"
+ ? t("project.settings.issue-related.approval-flow-configured")
+ : status === "fallback"
+ ? t("project.settings.issue-related.approval-flow-fallback")
+ : t("project.settings.issue-related.approval-flow-not-configured");
+
+ return (
+ <Tooltip
+ content={
+ <div className="flex flex-col gap-y-1">
+ <span>{tooltipText}</span>
+ <button
+ type="button"
+ className="text-accent underline text-left"
+ onClick={() =>
+ router.push({ name: WORKSPACE_ROUTE_CUSTOM_APPROVAL })
+ }
+ >
+ {t("project.settings.issue-related.view-approval-flow")}
+ </button>
+ </div>
+ }
+ >
+ {configured ? (
+ <ShieldCheck className="w-4 h-4 text-success" />
+ ) : (
+ <TriangleAlert className="w-4 h-4 text-warning" />
+ )}
+ </Tooltip>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Main Page
+// ---------------------------------------------------------------------------
+export function ProjectSettingsPage() {
+ const { t } = useTranslation();
+ const projectStore = useProjectV1Store();
+ const policyStore = usePolicyV1Store();
+ const reviewStore = useSQLReviewStore();
+ const subscriptionStore = useSubscriptionV1Store();
+
+ const projectId = useVueState(
+ () => router.currentRoute.value.params.projectId as string
+ );
+ const projectName = `${projectNamePrefix}${projectId}`;
+ const project = useVueState(() => projectStore.getProjectByName(projectName));
+ const isDefault = isDefaultProject(projectName);
+
+ const hasPermission = useCallback(
+ (permission: Permission) =>
+ project ? hasProjectPermissionV2(project, permission) : false,
+ [project]
+ );
+
+ const allowEdit = useMemo(
+ () =>
+ hasPermission("bb.projects.update") && project?.state === State.ACTIVE,
+ [hasPermission, project]
+ );
+
+ // -----------------------------------------------------------------------
+ // General state
+ // -----------------------------------------------------------------------
+ const [title, setTitle] = useState(project?.title ?? "");
+ const [labelKVList, setLabelKVList] = useState<
+ { key: string; value: string }[]
+ >(() => convertLabelsToKVList(project?.labels ?? {}, true));
+
+ // Sync label state when project labels change externally
+ const projectLabels = project?.labels;
+ useEffect(() => {
+ setLabelKVList(convertLabelsToKVList(projectLabels ?? {}, true));
+ }, [projectLabels]);
+
+ // -----------------------------------------------------------------------
+ // Security state
+ // -----------------------------------------------------------------------
+ const reviewPolicyList = useVueState(
+ () => reviewStore.reviewPolicyList ?? []
+ );
+ const currentReviewPolicy = useVueState(() =>
+ reviewStore.getReviewPolicyByResouce(projectName)
+ );
+ const [pendingReviewPolicy, setPendingReviewPolicy] = useState<
+ SQLReviewPolicy | undefined
+ >(undefined);
+ const [enforceReview, setEnforceReview] = useState(false);
+ const [showReviewDialog, setShowReviewDialog] = useState(false);
+
+ const queryDataPolicy = useVueState(() =>
+ policyStore.getQueryDataPolicyByParent(projectName)
+ );
+ const getInitialMaxRows = useCallback(() => {
+ const rows = Number(queryDataPolicy?.maximumResultRows ?? 0);
+ return rows < 0 ? 0 : rows;
+ }, [queryDataPolicy]);
+ const [maxRows, setMaxRows] = useState(() => getInitialMaxRows());
+
+ const [allowRequestRole, setAllowRequestRole] = useState(
+ project?.allowRequestRole ?? false
+ );
+ const [allowJustInTimeAccess, setAllowJustInTimeAccess] = useState(
+ project?.allowJustInTimeAccess ?? false
+ );
+
+ const hasQueryPolicyFeature = useVueState(() =>
+ subscriptionStore.hasInstanceFeature(PlanFeature.FEATURE_QUERY_POLICY)
+ );
+
+ // -----------------------------------------------------------------------
+ // Issue-related state
+ // -----------------------------------------------------------------------
+ const [issueLabels, setIssueLabels] = useState<Label[]>(() =>
+ cloneDeep(project?.issueLabels ?? [])
+ );
+ const [forceIssueLabels, setForceIssueLabels] = useState(
+ project?.forceIssueLabels ?? false
+ );
+ const [enforceIssueTitle, setEnforceIssueTitle] = useState(
+ project?.enforceIssueTitle ?? false
+ );
+ const [enforceSqlReview, setEnforceSqlReview] = useState(
+ project?.enforceSqlReview ?? false
+ );
+ const [allowSelfApproval, setAllowSelfApproval] = useState(
+ project?.allowSelfApproval ?? false
+ );
+ const [requireIssueApproval, setRequireIssueApproval] = useState(
+ project?.requireIssueApproval ?? false
+ );
+ const [requirePlanCheckNoError, setRequirePlanCheckNoError] = useState(
+ project?.requirePlanCheckNoError ?? false
+ );
+ const [postgresDatabaseTenantMode, setPostgresDatabaseTenantMode] = useState(
+ project?.postgresDatabaseTenantMode ?? false
+ );
+ const [maxRetries, setMaxRetries] = useState(
+ project?.executionRetryPolicy?.maximumRetries ?? 0
+ );
+ const [ciSamplingSize, setCiSamplingSize] = useState(
+ project?.ciSamplingSize ?? 0
+ );
+ const [parallelTasksPerRollout, setParallelTasksPerRollout] = useState(
+ project?.parallelTasksPerRollout ?? 1
+ );
+
+ // New issue label input
+ const [newLabelValue, setNewLabelValue] = useState("");
+
+ // -----------------------------------------------------------------------
+ // Danger zone
+ // -----------------------------------------------------------------------
+ const [dangerAction, setDangerAction] = useState<
+ "archive" | "restore" | "delete" | null
+ >(null);
+ const [executing, setExecuting] = useState(false);
+
+ // -----------------------------------------------------------------------
+ // Fetch on mount and when projectName changes
+ // -----------------------------------------------------------------------
+ const lastFetchedProject = useRef("");
+ useEffect(() => {
+ if (lastFetchedProject.current === projectName) return;
+ lastFetchedProject.current = projectName;
+ reviewStore.fetchReviewPolicyList();
+ policyStore.getOrFetchPolicyByParentAndType({
+ parentPath: projectName,
+ policyType: PolicyType.DATA_QUERY,
+ });
+ }, [reviewStore, policyStore, projectName]);
+
+ // Sync review policy state when it loads or changes externally
+ useEffect(() => {
+ setPendingReviewPolicy(currentReviewPolicy);
+ setEnforceReview(currentReviewPolicy?.enforce ?? false);
+ }, [currentReviewPolicy]);
+
+ // Sync max rows when policy loads
+ useEffect(() => {
+ setMaxRows(getInitialMaxRows());
+ }, [getInitialMaxRows]);
+
+ // Saving state
+ const [saving, setSaving] = useState(false);
+
+ // -----------------------------------------------------------------------
+ // Dirty tracking
+ // -----------------------------------------------------------------------
+ const isDirty = useMemo(() => {
+ if (!project) return false;
+ if (title !== project.title) return true;
+ if (!isEqual(convertKVListToLabels(labelKVList, false), project.labels))
+ return true;
+ // SQL review
+ if (!isEqual(pendingReviewPolicy, currentReviewPolicy)) return true;
+ if (
+ enforceReview !== (pendingReviewPolicy?.enforce ?? false) &&
+ pendingReviewPolicy
+ )
+ return true;
+ // Max rows
+ if (maxRows !== getInitialMaxRows()) return true;
+ // Project toggles
+ if (allowRequestRole !== project.allowRequestRole) return true;
+ if (allowJustInTimeAccess !== project.allowJustInTimeAccess) return true;
+ // Issue-related
+ if (!isEqual(issueLabels, project.issueLabels)) return true;
+ if (forceIssueLabels !== project.forceIssueLabels) return true;
+ if (enforceIssueTitle !== project.enforceIssueTitle) return true;
+ if (enforceSqlReview !== project.enforceSqlReview) return true;
+ if (allowSelfApproval !== project.allowSelfApproval) return true;
+ if (requireIssueApproval !== project.requireIssueApproval) return true;
+ if (requirePlanCheckNoError !== project.requirePlanCheckNoError)
+ return true;
+ if (postgresDatabaseTenantMode !== project.postgresDatabaseTenantMode)
+ return true;
+ if (maxRetries !== (project.executionRetryPolicy?.maximumRetries ?? 0))
+ return true;
+ if (ciSamplingSize !== (project.ciSamplingSize ?? 0)) return true;
+ if (parallelTasksPerRollout !== (project.parallelTasksPerRollout ?? 0))
+ return true;
+ return false;
+ }, [
+ project,
+ title,
+ labelKVList,
+ pendingReviewPolicy,
+ currentReviewPolicy,
+ enforceReview,
+ maxRows,
+ getInitialMaxRows,
+ allowRequestRole,
+ allowJustInTimeAccess,
+ issueLabels,
+ forceIssueLabels,
+ enforceIssueTitle,
+ enforceSqlReview,
+ allowSelfApproval,
+ requireIssueApproval,
+ requirePlanCheckNoError,
+ postgresDatabaseTenantMode,
+ maxRetries,
+ ciSamplingSize,
+ parallelTasksPerRollout,
+ ]);
+
+ // Unsaved-changes protection: browser close + in-app navigation
+ useEffect(() => {
+ if (!isDirty) return;
+ const onBeforeUnload = (e: BeforeUnloadEvent) => {
+ e.returnValue = t("common.leave-without-saving");
+ e.preventDefault();
+ };
+ window.addEventListener("beforeunload", onBeforeUnload);
+ const removeGuard = router.beforeEach((_to, _from, next) => {
+ if (window.confirm(t("common.leave-without-saving"))) {
+ next();
+ } else {
+ next(false);
+ }
+ });
+ return () => {
+ window.removeEventListener("beforeunload", onBeforeUnload);
+ removeGuard();
+ };
+ }, [isDirty, t]);
+
+ // -----------------------------------------------------------------------
+ // Revert
+ // -----------------------------------------------------------------------
+ const revert = useCallback(() => {
+ if (!project) return;
+ setTitle(project.title);
+ setLabelKVList(convertLabelsToKVList(project.labels, true));
+ setPendingReviewPolicy(currentReviewPolicy);
+ setEnforceReview(currentReviewPolicy?.enforce ?? false);
+ setMaxRows(getInitialMaxRows());
+ setAllowRequestRole(project.allowRequestRole);
+ setAllowJustInTimeAccess(project.allowJustInTimeAccess);
+ setIssueLabels(cloneDeep(project.issueLabels));
+ setForceIssueLabels(project.forceIssueLabels);
+ setEnforceIssueTitle(project.enforceIssueTitle);
+ setEnforceSqlReview(project.enforceSqlReview);
+ setAllowSelfApproval(project.allowSelfApproval);
+ setRequireIssueApproval(project.requireIssueApproval);
+ setRequirePlanCheckNoError(project.requirePlanCheckNoError);
+ setPostgresDatabaseTenantMode(project.postgresDatabaseTenantMode);
+ setMaxRetries(project.executionRetryPolicy?.maximumRetries ?? 0);
+ setCiSamplingSize(project.ciSamplingSize);
+ setParallelTasksPerRollout(project.parallelTasksPerRollout);
+ }, [project, currentReviewPolicy, getInitialMaxRows]);
+
+ // -----------------------------------------------------------------------
+ // Save
+ // -----------------------------------------------------------------------
+ const handleSave = useCallback(async () => {
+ if (!project) return;
+ setSaving(true);
+ try {
+ // 1. SQL review policy (separate API, not part of project update)
+ if (!isEqual(pendingReviewPolicy, currentReviewPolicy)) {
+ if (currentReviewPolicy) {
+ await reviewStore.upsertReviewConfigTag({
+ oldResources: [...currentReviewPolicy.resources],
+ newResources: currentReviewPolicy.resources.filter(
+ (r) => r !== projectName
+ ),
+ review: currentReviewPolicy.id,
+ });
+ }
+ if (pendingReviewPolicy) {
+ await reviewStore.upsertReviewConfigTag({
+ oldResources: [...pendingReviewPolicy.resources],
+ newResources: [...pendingReviewPolicy.resources, projectName],
+ review: pendingReviewPolicy.id,
+ });
+ }
+ }
+ if (
+ pendingReviewPolicy &&
+ pendingReviewPolicy.enforce !== enforceReview
+ ) {
+ await reviewStore.upsertReviewPolicy({
+ id: pendingReviewPolicy.id,
+ enforce: enforceReview,
+ });
+ }
+
+ // 2. Max rows policy (separate API)
+ if (maxRows !== getInitialMaxRows()) {
+ await policyStore.upsertPolicy({
+ parentPath: projectName,
+ policy: {
+ type: PolicyType.DATA_QUERY,
+ resourceType: PolicyResourceType.PROJECT,
+ policy: {
+ case: "queryDataPolicy",
+ value: create(QueryDataPolicySchema, {
+ ...queryDataPolicy,
+ maximumResultRows: maxRows,
+ }),
+ },
+ },
+ });
+ }
+
+ // 3. All project fields in a single updateProject call
+ const updateMask: string[] = [];
+ const projectPatch = cloneDeep(project);
+ if (title !== project.title && title.trim()) {
+ projectPatch.title = title.trim();
+ updateMask.push("title");
+ }
+ const currentLabels = convertKVListToLabels(labelKVList, false);
+ if (!isEqual(currentLabels, project.labels)) {
+ projectPatch.labels = currentLabels;
+ updateMask.push("labels");
+ }
+ if (allowRequestRole !== project.allowRequestRole) {
+ projectPatch.allowRequestRole = allowRequestRole;
+ updateMask.push("allow_request_role");
+ }
+ if (allowJustInTimeAccess !== project.allowJustInTimeAccess) {
+ projectPatch.allowJustInTimeAccess = allowJustInTimeAccess;
+ updateMask.push("allow_just_in_time_access");
+ }
+ if (!isEqual(issueLabels, project.issueLabels)) {
+ projectPatch.issueLabels = issueLabels;
+ updateMask.push("issue_labels");
+ }
+ if (forceIssueLabels !== project.forceIssueLabels) {
+ projectPatch.forceIssueLabels = forceIssueLabels;
+ updateMask.push("force_issue_labels");
+ }
+ if (enforceIssueTitle !== project.enforceIssueTitle) {
+ projectPatch.enforceIssueTitle = enforceIssueTitle;
+ updateMask.push("enforce_issue_title");
+ }
+ if (enforceSqlReview !== project.enforceSqlReview) {
+ projectPatch.enforceSqlReview = enforceSqlReview;
+ updateMask.push("enforce_sql_review");
+ }
+ if (allowSelfApproval !== project.allowSelfApproval) {
+ projectPatch.allowSelfApproval = allowSelfApproval;
+ updateMask.push("allow_self_approval");
+ }
+ if (requireIssueApproval !== project.requireIssueApproval) {
+ projectPatch.requireIssueApproval = requireIssueApproval;
+ updateMask.push("require_issue_approval");
+ }
+ if (requirePlanCheckNoError !== project.requirePlanCheckNoError) {
+ projectPatch.requirePlanCheckNoError = requirePlanCheckNoError;
+ updateMask.push("require_plan_check_no_error");
+ }
+ if (postgresDatabaseTenantMode !== project.postgresDatabaseTenantMode) {
+ projectPatch.postgresDatabaseTenantMode = postgresDatabaseTenantMode;
+ updateMask.push("postgres_database_tenant_mode");
+ }
+ if (maxRetries !== (project.executionRetryPolicy?.maximumRetries ?? 0)) {
+ projectPatch.executionRetryPolicy = create(
+ Project_ExecutionRetryPolicySchema,
+ { maximumRetries: maxRetries }
+ );
+ updateMask.push("execution_retry_policy");
+ }
+ if (ciSamplingSize !== (project.ciSamplingSize ?? 0)) {
+ projectPatch.ciSamplingSize = ciSamplingSize;
+ updateMask.push("ci_sampling_size");
+ }
+ if (parallelTasksPerRollout !== (project.parallelTasksPerRollout ?? 0)) {
+ projectPatch.parallelTasksPerRollout = parallelTasksPerRollout;
+ updateMask.push("parallel_tasks_per_rollout");
+ }
+ if (updateMask.length > 0) {
+ await projectStore.updateProject(projectPatch, updateMask);
+ }
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("project.settings.success-updated"),
+ });
+ } catch {
+ pushNotification({
+ module: "bytebase",
+ style: "CRITICAL",
+ title: t("project.settings.update-failed"),
+ });
+ } finally {
+ setSaving(false);
+ }
+ }, [
+ project,
+ projectStore,
+ reviewStore,
+ policyStore,
+ projectName,
+ title,
+ labelKVList,
+ pendingReviewPolicy,
+ currentReviewPolicy,
+ enforceReview,
+ maxRows,
+ getInitialMaxRows,
+ queryDataPolicy,
+ allowRequestRole,
+ allowJustInTimeAccess,
+ issueLabels,
+ forceIssueLabels,
+ enforceIssueTitle,
+ enforceSqlReview,
+ allowSelfApproval,
+ requireIssueApproval,
+ requirePlanCheckNoError,
+ postgresDatabaseTenantMode,
+ maxRetries,
+ ciSamplingSize,
+ parallelTasksPerRollout,
+ t,
+ ]);
+
+ // -----------------------------------------------------------------------
+ // Danger zone handlers
+ // -----------------------------------------------------------------------
+ const handleDangerConfirm = useCallback(async () => {
+ if (!project || !dangerAction) return;
+ setExecuting(true);
+ try {
+ if (dangerAction === "archive") {
+ await projectStore.archiveProject(project);
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: `${project.title || project.name} ${t("common.archived")}`,
+ });
+ } else if (dangerAction === "restore") {
+ await projectStore.restoreProject(project);
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: `${project.title || project.name} ${t("common.restored")}`,
+ });
+ } else if (dangerAction === "delete") {
+ await projectStore.deleteProject(project.name);
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: `${project.title || project.name} ${t("common.deleted")}`,
+ });
+ }
+ router.push({ name: PROJECT_V1_ROUTE_DASHBOARD });
+ } finally {
+ setExecuting(false);
+ setDangerAction(null);
+ }
+ }, [project, dangerAction, projectStore, t]);
+
+ // -----------------------------------------------------------------------
+ // Label helpers
+ // -----------------------------------------------------------------------
+ const addKVLabel = useCallback(() => {
+ setLabelKVList((prev) => [...prev, { key: "", value: "" }]);
+ }, []);
+
+ const updateKVLabel = useCallback(
+ (index: number, field: "key" | "value", val: string) => {
+ setLabelKVList((prev) => {
+ const next = [...prev];
+ next[index] = { ...next[index], [field]: val };
+ return next;
+ });
+ },
+ []
+ );
+
+ const removeKVLabel = useCallback((index: number) => {
+ setLabelKVList((prev) => prev.filter((_, i) => i !== index));
+ }, []);
+
+ // Label validation
+ const labelErrors = useMemo(() => {
+ const errors: string[] = [];
+ const keys = new Set<string>();
+ for (const kv of labelKVList) {
+ if (!kv.key) {
+ errors.push(t("label.error.key-necessary"));
+ }
+ if (keys.has(kv.key) && kv.key) {
+ errors.push(t("label.error.key-duplicated"));
+ }
+ keys.add(kv.key);
+ if (kv.value.length > 63) {
+ errors.push(t("label.error.max-value-length-exceeded", { length: 63 }));
+ }
+ }
+ return errors;
+ }, [labelKVList, t]);
+
+ // -----------------------------------------------------------------------
+ // Issue label helpers
+ // -----------------------------------------------------------------------
+ const addIssueLabel = useCallback(() => {
+ const trimmed = newLabelValue.trim();
+ if (!trimmed) return;
+ if (issueLabels.some((l) => l.value === trimmed)) return;
+ setIssueLabels((prev) => [
+ ...prev,
+ create(LabelSchema, { value: trimmed, color: "#4f46e5", group: "" }),
+ ]);
+ setNewLabelValue("");
+ }, [newLabelValue, issueLabels]);
+
+ const removeIssueLabel = useCallback((index: number) => {
+ setIssueLabels((prev) => {
+ const next = prev.filter((_, i) => i !== index);
+ if (next.length === 0) {
+ setForceIssueLabels(false);
+ }
+ return next;
+ });
+ }, []);
+
+ const updateIssueLabelColor = useCallback((index: number, color: string) => {
+ setIssueLabels((prev) => {
+ const next = [...prev];
+ next[index] = { ...next[index], color };
+ return next;
+ });
+ }, []);
+
+ if (!project) return null;
+
+ const canUpdateProject = hasPermission("bb.projects.update");
+ const canGetPolicies = hasPermission("bb.policies.get");
+ const canUpdatePolicies = hasPermission("bb.policies.update");
+ const canDelete = hasPermission("bb.projects.delete");
+ const canUndelete = hasPermission("bb.projects.undelete");
+
+ // -----------------------------------------------------------------------
+ // Render
+ // -----------------------------------------------------------------------
+ return (
+ <div className="w-full flex flex-col gap-y-0 pt-4 px-4">
+ <div className="divide-y divide-block-border">
+ {/* ============================================================= */}
+ {/* Section 1: General */}
+ {/* ============================================================= */}
+ <div className="pb-6 lg:flex">
+ <div className="text-left lg:w-1/4">
+ <h1 className="text-2xl font-bold">{t("common.general")}</h1>
+ </div>
+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <form className="w-full flex flex-col gap-y-4">
+ <div>
+ <div className="font-medium">
+ {t("common.name")} <span className="text-error">*</span>
+ </div>
+ <Input
+ className="mt-1"
+ value={title}
+ onChange={(e) => setTitle(e.target.value)}
+ disabled={
+ !canUpdateProject ||
+ isDefault ||
+ project.state !== State.ACTIVE
+ }
+ required
+ />
+ <div className="mt-1 text-sm text-control-light">
+ {t("common.id")}: {extractProjectResourceName(project.name)}
+ </div>
+ </div>
+
+ {/* Project Labels */}
+ <div>
+ <div className="font-medium">
+ {t("project.settings.project-labels.self")}
+ </div>
+ <div className="text-sm text-gray-500 mb-3">
+ {t("project.settings.project-labels.description")}
+ </div>
+ <div className="flex flex-col gap-y-2">
+ {labelKVList.map((kv, index) => (
+ <div key={index} className="flex items-center gap-x-2">
+ <Input
+ className="flex-1"
+ placeholder={t("common.key")}
+ value={kv.key}
+ onChange={(e) =>
+ updateKVLabel(index, "key", e.target.value)
+ }
+ disabled={!canUpdateProject}
+ />
+ <Input
+ className="flex-1"
+ placeholder={t("common.value")}
+ value={kv.value}
+ onChange={(e) =>
+ updateKVLabel(index, "value", e.target.value)
+ }
+ disabled={!canUpdateProject}
+ />
+ <Button
+ variant="ghost"
+ size="icon"
+ disabled={!canUpdateProject}
+ onClick={() => removeKVLabel(index)}
+ >
+ <X className="w-4 h-4" />
+ </Button>
+ </div>
+ ))}
+ {labelErrors.length > 0 && (
+ <div className="text-sm text-error">
+ {labelErrors.map((e, i) => (
+ <div key={i}>{e}</div>
+ ))}
+ </div>
+ )}
+ {canUpdateProject && (
+ <Button variant="outline" size="sm" onClick={addKVLabel}>
+ {t("common.add")}
+ </Button>
+ )}
+ </div>
+ </div>
+ </form>
+ </div>
+ </div>
+
+ {/* ============================================================= */}
+ {/* Section 2: Security & Policy */}
+ {/* ============================================================= */}
+ <div className="py-6 lg:flex">
+ <div className="text-left lg:w-1/4">
+ <h1 className="text-2xl font-bold">
+ {t("settings.sidebar.security-and-policy")}
+ </h1>
+ </div>
+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <div className="w-full flex flex-col justify-start items-start gap-y-6">
+ {/* SQL Review + Max Rows: gated on bb.policies.get */}
+ {canGetPolicies && (
+ <>
+ {/* SQL Review */}
+ {hasWorkspacePermissionV2("bb.reviewConfigs.get") && (
+ <div className="flex flex-col gap-y-2">
+ <label className="font-medium">
+ {t("sql-review.title")}
+ </label>
+ <div>
+ {pendingReviewPolicy ? (
+ <div className="inline-flex items-center gap-x-2">
+ <Switch
+ checked={enforceReview}
+ onCheckedChange={setEnforceReview}
+ disabled={
+ !hasWorkspacePermissionV2(
+ "bb.reviewConfigs.update"
+ )
+ }
+ />
+ <span
+ className="text-sm font-medium text-accent cursor-pointer hover:underline"
+ onClick={() =>
+ router.push({
+ name: WORKSPACE_ROUTE_SQL_REVIEW_DETAIL,
+ params: {
+ sqlReviewPolicySlug:
+ sqlReviewPolicySlug(pendingReviewPolicy),
+ },
+ })
+ }
+ >
+ {pendingReviewPolicy.name}
+ </span>
+ {canUpdatePolicies && (
+ <Button
+ variant="ghost"
+ size="icon"
+ onClick={() => {
+ setPendingReviewPolicy(undefined);
+ setEnforceReview(false);
+ }}
+ >
+ <X className="w-4 h-4" />
+ </Button>
+ )}
+ </div>
+ ) : (
+ <Button
+ variant="outline"
+ disabled={
+ !canUpdatePolicies ||
+ !hasWorkspacePermissionV2("bb.reviewConfigs.list")
+ }
+ onClick={() => setShowReviewDialog(true)}
+ >
+ {t("sql-review.configure-policy")}
+ </Button>
+ )}
+ </div>
+ </div>
+ )}
+
+ {/* Maximum SQL Result Rows */}
+ <div>
+ <p className="font-medium flex flex-row justify-start items-center">
+ <span className="mr-2">
+ {t(
+ "settings.general.workspace.maximum-sql-result.rows.self"
+ )}
+ </span>
+ <FeatureBadge
+ feature={PlanFeature.FEATURE_QUERY_POLICY}
+ />
+ </p>
+ <p className="text-sm text-gray-400 mt-1">
+ {t(
+ "settings.general.workspace.maximum-sql-result.rows.description"
+ )}{" "}
+ <span className="font-semibold">
+ {t("settings.general.workspace.no-limit")}
+ </span>
+ </p>
+ <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">
+ <Input
+ type="number"
+ className="w-60"
+ min={0}
+ value={String(maxRows)}
+ onChange={(e) => {
+ const v = parseInt(e.target.value, 10);
+ if (!Number.isNaN(v) && v >= 0) setMaxRows(v);
+ }}
+ disabled={!hasQueryPolicyFeature || !canUpdatePolicies}
+ />
+ <span className="text-sm text-control-light">
+ {t(
+ "settings.general.workspace.maximum-sql-result.rows.rows"
+ )}
+ </span>
+ </div>
+ </div>
+ </>
+ )}
+
+ {/* Allow Request Role */}
+ <div>
+ <div className="flex items-center gap-x-2">
+ <Switch
+ checked={allowRequestRole}
+ onCheckedChange={setAllowRequestRole}
+ disabled={!canUpdateProject}
+ />
+ <span className="text-sm font-medium">
+ {t(
+ "project.settings.issue-related.allow-request-role.self"
+ )}
+ </span>
+ <ApprovalFlowIndicator
+ source={WorkspaceApprovalSetting_Rule_Source.REQUEST_ROLE}
+ />
+ </div>
+ <div className="mt-1 text-sm text-gray-400">
+ {t(
+ "project.settings.issue-related.allow-request-role.description"
+ )}
+ </div>
+ </div>
+
+ {/* Allow JIT Access */}
+ <div>
+ <div className="flex items-center gap-x-2">
+ <Switch
+ checked={allowJustInTimeAccess}
+ onCheckedChange={setAllowJustInTimeAccess}
+ disabled={!canUpdateProject}
+ />
+ <span className="text-sm font-medium">
+ {t("project.settings.issue-related.allow-jit.self")}
+ </span>
+ <ApprovalFlowIndicator
+ source={WorkspaceApprovalSetting_Rule_Source.REQUEST_ACCESS}
+ />
+ </div>
+ <div className="mt-1 text-sm text-gray-400">
+ {t("project.settings.issue-related.allow-jit.description")}
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ {/* ============================================================= */}
+ {/* Section 3: Issue-Related */}
+ {/* ============================================================= */}
+ <div id="issue-related" className="py-6 lg:flex">
+ <div className="text-left lg:w-1/4">
+ <h1 className="text-2xl font-bold">
+ {t("project.settings.issue-related.self")}
+ </h1>
+ </div>
+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <div className="w-full flex flex-col justify-start items-start gap-y-6">
+ {/* Issue Labels */}
+ <div className="flex flex-col gap-y-2">
+ <div className="font-medium">
+ {t("project.settings.issue-related.labels.self")}
+ <div className="text-sm text-gray-500 font-normal">
+ {t("project.settings.issue-related.labels.description")}
+ </div>
+ </div>
+ <div className="flex flex-wrap items-center gap-2">
+ {issueLabels.map((label, index) => (
+ <span
+ key={index}
+ className="inline-flex items-center gap-x-2 border border-control-border rounded-sm px-2 py-1"
+ >
+ <input
+ type="color"
+ value={label.color || "#4f46e5"}
+ onChange={(e) =>
+ updateIssueLabelColor(index, e.target.value)
+ }
+ disabled={!canUpdateProject}
+ className="w-4 h-4 rounded-sm cursor-pointer border-0 p-0"
+ />
+ <span className="text-sm">{label.value}</span>
+ {canUpdateProject && (
+ <button
+ type="button"
+ className="text-control-light hover:text-main"
+ onClick={() => removeIssueLabel(index)}
+ >
+ <X className="w-3 h-3" />
+ </button>
+ )}
+ </span>
+ ))}
+ {canUpdateProject && (
+ <div className="inline-flex items-center gap-x-1">
+ <Input
+ className="w-48"
+ placeholder={t(
+ "project.settings.issue-related.labels.placeholder"
+ )}
+ value={newLabelValue}
+ onChange={(e) => setNewLabelValue(e.target.value)}
+ onKeyDown={(e) => {
+ if (e.key === "Enter") {
+ e.preventDefault();
+ addIssueLabel();
+ }
+ }}
+ />
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={addIssueLabel}
+ disabled={!newLabelValue.trim()}
+ >
+ {t("common.add")}
+ </Button>
+ </div>
+ )}
+ </div>
+ </div>
+
+ {/* Boolean toggles */}
+ <ToggleRow
+ checked={forceIssueLabels}
+ onCheckedChange={setForceIssueLabels}
+ disabled={!canUpdateProject || issueLabels.length === 0}
+ label={t(
+ "project.settings.issue-related.labels.force-issue-labels.self"
+ )}
+ description={t(
+ "project.settings.issue-related.labels.force-issue-labels.description"
+ )}
+ warning={
+ canUpdateProject && issueLabels.length === 0
+ ? t(
+ "project.settings.issue-related.labels.force-issue-labels.warning"
+ )
+ : undefined
+ }
+ />
+ <ToggleRow
+ checked={enforceIssueTitle}
+ onCheckedChange={setEnforceIssueTitle}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.enforce-issue-title.self"
+ )}
+ description={t(
+ "project.settings.issue-related.enforce-issue-title.description"
+ )}
+ />
+ <ToggleRow
+ checked={enforceSqlReview}
+ onCheckedChange={setEnforceSqlReview}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.enforce-sql-review.self"
+ )}
+ description={t(
+ "project.settings.issue-related.enforce-sql-review.description"
+ )}
+ />
+ <ToggleRow
+ checked={allowSelfApproval}
+ onCheckedChange={setAllowSelfApproval}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.allow-self-approval.self"
+ )}
+ description={t(
+ "project.settings.issue-related.allow-self-approval.description"
+ )}
+ />
+ <ToggleRow
+ checked={requireIssueApproval}
+ onCheckedChange={setRequireIssueApproval}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.require-issue-approval.self"
+ )}
+ description={t(
+ "project.settings.issue-related.require-issue-approval.description"
+ )}
+ />
+ <ToggleRow
+ checked={requirePlanCheckNoError}
+ onCheckedChange={setRequirePlanCheckNoError}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.require-plan-check-no-error.self"
+ )}
+ description={t(
+ "project.settings.issue-related.require-plan-check-no-error.description"
+ )}
+ />
+ <ToggleRow
+ checked={postgresDatabaseTenantMode}
+ onCheckedChange={setPostgresDatabaseTenantMode}
+ disabled={!canUpdateProject}
+ label={t(
+ "project.settings.issue-related.postgres-database-tenant-mode.self"
+ )}
+ description={t(
+ "project.settings.issue-related.postgres-database-tenant-mode.description"
+ )}
+ />
+
+ {/* Numeric inputs */}
+ <NumericRow
+ label={t("project.settings.issue-related.max-retries.self")}
+ description={t(
+ "project.settings.issue-related.max-retries.description"
+ )}
+ value={maxRetries}
+ onChange={setMaxRetries}
+ disabled={!canUpdateProject}
+ suffix="Times"
+ />
+ <NumericRow
+ label={t(
+ "project.settings.issue-related.ci-sampling-size.self"
+ )}
+ description={t(
+ "project.settings.issue-related.ci-sampling-size.description"
+ )}
+ value={ciSamplingSize}
+ onChange={setCiSamplingSize}
+ disabled={!canUpdateProject}
+ />
+ <NumericRow
+ label={t(
+ "project.settings.issue-related.parallel_tasks_per_rollout.self"
+ )}
+ description={t(
+ "project.settings.issue-related.parallel_tasks_per_rollout.description"
+ )}
+ value={parallelTasksPerRollout}
+ onChange={setParallelTasksPerRollout}
+ disabled={!canUpdateProject}
+ />
+ </div>
+ </div>
+ </div>
+
+ {/* ============================================================= */}
+ {/* Section 4: Danger Zone */}
+ {/* ============================================================= */}
+ <div className="py-6 lg:flex">
+ <div className="text-left lg:w-1/4">
+ <h1 className="text-2xl font-bold">{t("common.danger-zone")}</h1>
+ </div>
+ <div className="flex-1 mt-4 lg:px-4 lg:mt-0">
+ <div className="border border-error-alpha bg-error-alpha rounded-lg divide-y divide-error-alpha">
+ {/* Archive / Restore */}
+ <div className="p-6 flex items-start justify-between gap-x-6">
+ {project.state === State.ACTIVE ? (
+ <>
+ <div className="flex-1">
+ <h4 className="font-medium text-main">
+ {t("common.archive-resource", {
+ type: t("common.project"),
+ })}
+ </h4>
+ <p className="text-sm text-control-light mt-1">
+ {t("common.archive-description", {
+ name: project.title || project.name,
+ })}
+ </p>
+ </div>
+ <Button
+ variant="outline"
+ disabled={!canDelete || executing}
+ onClick={() => setDangerAction("archive")}
+ >
+ {t("common.archive")}
+ </Button>
+ </>
+ ) : project.state === State.DELETED ? (
+ <>
+ <div className="flex-1">
+ <h4 className="font-medium text-main">
+ {t("project.settings.restore.title")}
+ </h4>
+ <p className="text-sm text-control-light mt-1">
+ {t("project.settings.restore.btn-text")}
+ </p>
+ </div>
+ <Button
+ variant="outline"
+ disabled={!canUndelete || executing}
+ onClick={() => setDangerAction("restore")}
+ >
+ {t("common.restore")}
+ </Button>
+ </>
+ ) : null}
+ </div>
+
+ {/* Delete */}
+ <div className="p-6 flex items-start justify-between gap-x-6">
+ <div className="flex-1">
+ <h4 className="font-medium text-error">
+ {t("common.delete-resource", {
+ type: t("common.project"),
+ })}
+ </h4>
+ <p className="text-sm text-control-light mt-1">
+ {t("common.delete-resource-description", {
+ name: project.title || project.name,
+ })}
+ </p>
+ </div>
+ <Button
+ variant="destructive"
+ disabled={!canDelete || executing}
+ onClick={() => setDangerAction("delete")}
+ >
+ {t("common.delete")}
+ </Button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ {/* ============================================================= */}
+ {/* Save / Cancel Bar */}
+ {/* ============================================================= */}
+ {allowEdit && isDirty && (
+ <div className="sticky bottom-0 z-10">
+ <div className="flex justify-between w-full py-4 border-t border-block-border bg-white">
+ <Button variant="outline" onClick={revert}>
+ {t("common.cancel")}
+ </Button>
+ <Button
+ onClick={handleSave}
+ disabled={labelErrors.length > 0 || saving || !title.trim()}
+ >
+ {t("common.confirm-and-update")}
+ </Button>
+ </div>
+ </div>
+ )}
+ </div>
+
+ {/* ============================================================= */}
+ {/* Dialogs */}
+ {/* ============================================================= */}
+
+ {/* SQL Review Policy Select Dialog */}
+ <Dialog open={showReviewDialog} onOpenChange={setShowReviewDialog}>
+ <DialogContent className="p-6">
+ <DialogTitle>{t("sql-review.configure-policy")}</DialogTitle>
+ <div className="mt-4 flex flex-col gap-y-2 max-h-96 overflow-y-auto">
+ {reviewPolicyList.length === 0 ? (
+ <div className="flex flex-col items-center gap-y-3 py-4">
+ <p className="text-sm text-control-light">
+ {t("common.no-data")}
+ </p>
+ {hasWorkspacePermissionV2("bb.reviewConfigs.create") && (
+ <Button
+ variant="outline"
+ onClick={() => {
+ setShowReviewDialog(false);
+ router.push({
+ name: WORKSPACE_ROUTE_SQL_REVIEW_CREATE,
+ query: { attachedResource: projectName },
+ });
+ }}
+ >
+ {t("sql-review.create-policy")}
+ </Button>
+ )}
+ </div>
+ ) : (
+ reviewPolicyList.map((policy) => (
+ <button
+ key={policy.id}
+ type="button"
+ className="w-full text-left px-4 py-3 border border-control-border rounded-sm hover:bg-control-bg transition-colors"
+ onClick={() => {
+ setPendingReviewPolicy(policy);
+ setEnforceReview(true);
+ setShowReviewDialog(false);
+ }}
+ >
+ <div className="font-medium">{policy.name}</div>
+ {policy.resources.length > 0 && (
+ <div className="text-xs text-control-light mt-1">
+ {policy.resources.length}{" "}
+ {t("common.resource", {
+ count: policy.resources.length,
+ })}
+ </div>
+ )}
+ </button>
+ ))
+ )}
+ </div>
+ <div className="mt-4 flex justify-end">
+ <Button
+ variant="outline"
+ onClick={() => setShowReviewDialog(false)}
+ >
+ {t("common.cancel")}
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+
+ {/* Danger Zone Confirmation Dialog */}
+ <Dialog
+ open={dangerAction !== null}
+ onOpenChange={(open) => {
+ if (!open) setDangerAction(null);
+ }}
+ >
+ <DialogContent className="p-6 max-w-md">
+ <DialogTitle>
+ {dangerAction === "archive" && t("common.confirm-archive")}
+ {dangerAction === "restore" && t("project.settings.restore.title")}
+ {dangerAction === "delete" && t("common.confirm-delete")}
+ </DialogTitle>
+ <p className="text-sm text-control-light mt-2">
+ {dangerAction === "archive" &&
+ t("project.settings.confirm-archive-project", {
+ name: project.title || project.name,
+ })}
+ {dangerAction === "restore" &&
+ `${t("project.settings.restore.title")} '${project.title || project.name}'?`}
+ {dangerAction === "delete" &&
+ t("project.settings.confirm-delete-project", {
+ name: project.title || project.name,
+ })}
+ </p>
+ <div className="mt-6 flex justify-end items-center gap-x-2">
+ <Button
+ variant="outline"
+ onClick={() => setDangerAction(null)}
+ disabled={executing}
+ >
+ {t("common.cancel")}
+ </Button>
+ <Button
+ variant={dangerAction === "delete" ? "destructive" : "default"}
+ onClick={handleDangerConfirm}
+ disabled={executing}
+ >
+ {t("common.confirm")}
+ </Button>
+ </div>
+ </DialogContent>
+ </Dialog>
+ </div>
+ );
+}
+
+// ---------------------------------------------------------------------------
+// Helper components
+// ---------------------------------------------------------------------------
+
+function ToggleRow({
+ checked,
+ onCheckedChange,
+ disabled,
+ label,
+ description,
+ warning,
+}: {
+ checked: boolean;
+ onCheckedChange: (v: boolean) => void;
+ disabled: boolean;
+ label: string;
+ description: string;
+ warning?: string;
+}) {
+ return (
+ <div>
+ <div className="flex items-center gap-x-2">
+ <Switch
+ checked={checked}
+ onCheckedChange={onCheckedChange}
+ disabled={disabled}
+ />
+ <span className="text-sm font-medium">{label}</span>
+ {warning && (
+ <Tooltip content={warning}>
+ <TriangleAlert className="w-4 h-4 text-warning" />
+ </Tooltip>
+ )}
+ </div>
+ <div className="mt-1 text-sm text-gray-400">{description}</div>
+ </div>
+ );
+}
+
+function NumericRow({
+ label,
+ description,
+ value,
+ onChange,
+ disabled,
+ suffix,
+}: {
+ label: string;
+ description: string;
+ value: number;
+ onChange: (v: number) => void;
+ disabled: boolean;
+ suffix?: string;
+}) {
+ return (
+ <div>
+ <p className="text-sm font-medium">{label}</p>
+ <p className="mb-3 text-sm text-gray-400">{description}</p>
+ <div className="mt-3 w-full flex flex-row justify-start items-center gap-4">
+ <Input
+ type="number"
+ className="w-60"
+ min={0}
+ value={String(value)}
+ onChange={(e) => {
+ const v = parseInt(e.target.value, 10);
+ if (!Number.isNaN(v) && v >= 0) onChange(v);
+ }}
+ disabled={disabled}
+ />
+ {suffix && <span className="text-sm text-control-light">{suffix}</span>}
+ </div>
+ </div>
+ );
+}
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index 171b137c43..cdf38aaa01 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -369,8 +369,8 @@ const projectV1Routes: RouteRecordRaw[] = [
meta: {
title: () => t("common.settings"),
},
- component: () => import("@/views/project/ProjectSettingPanel.vue"),
- props: true,
+ component: () => import("@/react/ReactPageMount.vue"),
+ props: () => ({ page: "ProjectSettingsPage" }),
},
{
path: "instances/:instanceId/databases/:databaseName",
diff --git a/frontend/src/views/project/ProjectSettingPanel.vue b/frontend/src/views/project/ProjectSettingPanel.vue
deleted file mode 100644
index a216a736a1..0000000000
--- a/frontend/src/views/project/ProjectSettingPanel.vue
+++ /dev/null
@@ -1,19 +0,0 @@
-<template>
- <ProjectSettingPanel :project="project" :allow-edit="allowEdit" />
-</template>
-
-<script setup lang="ts">
-import { computed } from "vue";
-import ProjectSettingPanel from "@/components/ProjectSettingPanel.vue";
-import { useProjectByName } from "@/store";
-import { projectNamePrefix } from "@/store/modules/v1/common";
-
-const props = defineProps<{
- projectId: string;
- allowEdit: boolean;
-}>();
-
-const { project } = useProjectByName(
- computed(() => `${projectNamePrefix}${props.projectId}`)
-);
-</script>