Skip to content

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

feat: implement project issue related settings (#12513)

boojackf8e69bdc519c
diff --git a/backend/api/v1/plan_service.go b/backend/api/v1/plan_service.go
index 5dd5f1a7c9..4e61a35807 100644
--- a/backend/api/v1/plan_service.go
+++ b/backend/api/v1/plan_service.go
@@ -671,6 +671,11 @@ func (s *PlanService) UpdatePlan(ctx context.Context, request *v1pb.UpdatePlanRe
}
}
+ // Check project setting for modify statement.
+ if len(taskPatchList) > 0 && doUpdateSheet && !project.Setting.AllowModifyStatement {
+ return nil, status.Errorf(codes.FailedPrecondition, "modify statement is not allowed for project %s", project.Title)
+ }
+
for _, taskPatch := range taskPatchList {
task := tasksMap[taskPatch.ID]
if _, err := s.store.UpdateTaskV2(ctx, taskPatch); err != nil {
diff --git a/backend/api/v1/project_service.go b/backend/api/v1/project_service.go
index 2dae5a670d..4c5c4ccec0 100644
--- a/backend/api/v1/project_service.go
+++ b/backend/api/v1/project_service.go
@@ -213,6 +213,14 @@ func (s *ProjectService) UpdateProject(ctx context.Context, request *v1pb.Update
projectSettings := project.Setting
projectSettings.ForceIssueLabels = request.Project.ForceIssueLabels
patch.Setting = projectSettings
+ case "allow_modify_statement":
+ projectSettings := project.Setting
+ projectSettings.AllowModifyStatement = request.Project.AllowModifyStatement
+ patch.Setting = projectSettings
+ case "auto_resolve_issue":
+ projectSettings := project.Setting
+ projectSettings.AutoResolveIssue = request.Project.AutoResolveIssue
+ patch.Setting = projectSettings
default:
return nil, status.Errorf(codes.InvalidArgument, `unsupport update_mask "%s"`, path)
}
@@ -1500,6 +1508,8 @@ func convertToProject(projectMessage *store.ProjectMessage) *v1pb.Project {
DataClassificationConfigId: projectMessage.DataClassificationConfigID,
IssueLabels: issueLabels,
ForceIssueLabels: projectMessage.Setting.ForceIssueLabels,
+ AllowModifyStatement: projectMessage.Setting.AllowModifyStatement,
+ AutoResolveIssue: projectMessage.Setting.AutoResolveIssue,
}
}
diff --git a/backend/runner/taskrun/schedulerv2.go b/backend/runner/taskrun/schedulerv2.go
index d7e4b077a9..6e99b3688f 100644
--- a/backend/runner/taskrun/schedulerv2.go
+++ b/backend/runner/taskrun/schedulerv2.go
@@ -706,9 +706,8 @@ func (s *SchedulerV2) ListenTaskSkippedOrDone(ctx context.Context) {
slog.Error("failed to create rollout release notification activity", log.BBError(err))
}
- if pipelineDone {
- // Every task in the pipeline has finished.
- // Resolve the issue.
+ // After all tasks in the pipeline are done, we will resolve the issue if the issue is auto-resolvable.
+ if issue.Project.Setting.AutoResolveIssue && pipelineDone {
if err := func() error {
// For those database data export issues, we don't resolve them automatically.
if issue.Type == api.IssueDatabaseDataExport {
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
index 7a3dab50d6..d0484392b1 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
@@ -212,7 +212,6 @@ import { useElementSize } from "@vueuse/core";
import { cloneDeep, head, uniq } from "lodash-es";
import { ExpandIcon } from "lucide-vue-next";
import { NButton, NTooltip, useDialog } from "naive-ui";
-import { v1 as uuidv1 } from "uuid";
import { computed, h, reactive, ref, toRef, watch } from "vue";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
@@ -229,7 +228,6 @@ import {
isDeploymentConfigChangeTaskV1,
isGroupingChangeTaskV1,
databaseEngineForSpec,
- databaseForSpec,
} from "@/components/IssueV1/logic";
import { MonacoEditor } from "@/components/MonacoEditor";
import { extensionNameOfLanguage } from "@/components/MonacoEditor/utils";
@@ -282,8 +280,7 @@ const { t } = useI18n();
const route = useRoute();
const currentUser = useCurrentUserV1();
const context = useIssueContext();
-const { events, isCreating, issue, selectedTask, selectedSpec, formatOnSave } =
- context;
+const { events, isCreating, issue, selectedTask, formatOnSave } = context;
const project = computed(() => issue.value.projectEntity);
const dialog = useDialog();
const editorContainerElRef = ref<HTMLElement>();
@@ -298,19 +295,15 @@ const state = reactive<LocalState>({
isUploadingFile: false,
});
-const rolloutMode = computed(() => !!issue.value.rollout);
-
const database = computed(() => {
- return rolloutMode.value
- ? databaseForTask(issue.value, selectedTask.value)
- : databaseForSpec(issue.value, selectedSpec.value);
+ return databaseForTask(issue.value, selectedTask.value);
});
const language = useInstanceV1EditorLanguage(
computed(() => database.value.instanceEntity)
);
const filename = computed(() => {
- const name = (rolloutMode.value && selectedTask.value.name) || uuidv1();
+ const name = selectedTask.value.name;
const ext = extensionNameOfLanguage(language.value);
return `${name}.${ext}`;
});
@@ -351,13 +344,7 @@ const isEditorReadonly = computed(() => {
if (isCreating.value) {
return !allowEditStatementWhenCreating.value;
}
- return (
- !state.isEditing ||
- // !allowEditStatement.value || // TODO
- isSheetOversize.value ||
- // isGroupingChangeIssue(issue.value as Issue) || // TODO
- false // TODO
- );
+ return !state.isEditing || isSheetOversize.value || false;
});
const {
@@ -379,13 +366,11 @@ const isSheetOversize = computed(() => {
});
const denyEditStatementReasons = computed(() => {
- return rolloutMode.value
- ? allowUserToEditStatementForTask(
- issue.value,
- selectedTask.value,
- currentUser.value
- )
- : [];
+ return allowUserToEditStatementForTask(
+ issue.value,
+ selectedTask.value,
+ currentUser.value
+ );
});
const shouldShowEditButton = computed(() => {
@@ -656,36 +641,27 @@ const updateStatement = async (statement: string) => {
}
const specsIdList: string[] = [];
- if (rolloutMode.value) {
- // - find the task related plan/step/spec
- // - create a new sheet
- // - update sheet id in the spec
-
- // Find the target editing task(s)
- // default to selectedTask
- // also ask whether to apply the change to all tasks in the stage.
- const { target, tasks } = await chooseUpdateStatementTarget();
-
- if (target === "CANCELED" || tasks.length === 0) {
- cancelEdit();
- return;
- }
+ // - find the task related plan/step/spec
+ // - create a new sheet
+ // - update sheet id in the spec
- tasks.forEach((task) => {
- const spec = specForTask(planPatch, task);
- if (spec) {
- specsIdList.push(spec.id);
- }
- });
- } else {
- const spec = selectedSpec.value;
- if (!spec) {
- notifyNotEditableLegacyIssue();
- return;
- }
- specsIdList.push(spec.id);
+ // Find the target editing task(s)
+ // default to selectedTask
+ // also ask whether to apply the change to all tasks in the stage.
+ const { target, tasks } = await chooseUpdateStatementTarget();
+
+ if (target === "CANCELED" || tasks.length === 0) {
+ cancelEdit();
+ return;
}
+ tasks.forEach((task) => {
+ const spec = specForTask(planPatch, task);
+ if (spec) {
+ specsIdList.push(spec.id);
+ }
+ });
+
const distinctSpecsIds = new Set(
specsIdList.filter((id) => id && id !== String(EMPTY_ID))
);
diff --git a/frontend/src/components/IssueV1/logic/rollout.ts b/frontend/src/components/IssueV1/logic/rollout.ts
index e190dc3a7b..1d7b5a8e8e 100644
--- a/frontend/src/components/IssueV1/logic/rollout.ts
+++ b/frontend/src/components/IssueV1/logic/rollout.ts
@@ -65,6 +65,9 @@ export const allowUserToEditStatementForTask = (
if (issue.status !== IssueStatus.OPEN) {
denyReasons.push("The issue is not open");
}
+ if (!issue.projectEntity.allowModifyStatement) {
+ denyReasons.push("Cannot edit statement after issue created");
+ }
if (task.type === Task_Type.DATABASE_CREATE) {
// For standard mode projects, we are not allowed to edit the database
diff --git a/frontend/src/components/Project/ProjectIssueLabelsSettingPanel.vue b/frontend/src/components/Project/ProjectIssueLabelsSettingPanel.vue
deleted file mode 100644
index 623f608f5d..0000000000
--- a/frontend/src/components/Project/ProjectIssueLabelsSettingPanel.vue
+++ /dev/null
@@ -1,178 +0,0 @@
-<template>
- <div class="w-full flex flex-col justify-start items-start pt-6 space-y-4">
- <div>
- <h3 class="text-lg font-medium leading-7 text-main">
- {{ $t("project.settings.labels.issue-labels") }}
- </h3>
- <div class="flex space-x-2 items-center textinfolabel">
- {{ $t("project.settings.labels.force-issue-labels") }}
- <NSwitch
- class="ml-2"
- :size="'small'"
- :value="project.forceIssueLabels"
- :disabled="!allowEdit"
- @update:value="onSwitchUpdate"
- />
- </div>
- </div>
- <NDynamicTags
- :size="'large'"
- :disabled="!allowEdit"
- :value="labelValues"
- :render-tag="renderLabel"
- @update:value="onLabelsUpdate"
- />
- <div class="hidden">
- <NColorPicker
- :modes="['hex']"
- :show-alpha="false"
- :disabled="!allowEdit"
- :to="colorPickerLocator ?? false"
- :show="state.pendingEditColorIndex >= 0"
- :value="state.labels[state.pendingEditColorIndex]?.color"
- @update:value="onColorChange"
- />
- </div>
- <div v-if="valueChanged" class="w-full flex justify-end gap-x-3">
- <NButton :disabled="false" @click.prevent="revertChanges">
- {{ $t("common.revert") }}
- </NButton>
- <NButton type="primary" :disabled="!allowEdit" @click.prevent="onUpdate">
- {{ $t("common.update") }}
- </NButton>
- </div>
- </div>
-</template>
-
-<script setup lang="ts">
-import { onClickOutside } from "@vueuse/core";
-import { isEqual, cloneDeep } from "lodash-es";
-import { NDynamicTags, NTag, NColorPicker, NSwitch } from "naive-ui";
-import { h, computed, nextTick, reactive } from "vue";
-import { useI18n } from "vue-i18n";
-import { pushNotification, useProjectV1Store } from "@/store";
-import type { ComposedProject } from "@/types";
-import { Label } from "@/types/proto/v1/project_service";
-
-interface LocalState {
- labels: Label[];
- pendingEditColorIndex: number;
-}
-
-const defaultColor = "#4f46e5";
-
-const props = defineProps<{
- project: ComposedProject;
- allowEdit: boolean;
-}>();
-
-const state = reactive<LocalState>({
- labels: [...props.project.issueLabels],
- pendingEditColorIndex: -1,
-});
-
-const { t } = useI18n();
-const projectStore = useProjectV1Store();
-
-const colorPickerLocator = computed(() =>
- document.getElementById(`#color-${state.pendingEditColorIndex}`)
-);
-
-const labelValues = computed(() => state.labels.map((l) => l.value));
-
-const valueChanged = computed(
- () => !isEqual(state.labels, props.project.issueLabels)
-);
-
-const onUpdate = async () => {
- const projectPatch = cloneDeep(props.project);
- projectPatch.issueLabels = state.labels;
- await projectStore.updateProject(projectPatch, ["issue_labels"]);
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
-};
-
-const revertChanges = () => {
- state.labels = [...props.project.issueLabels];
-};
-
-const onLabelsUpdate = (values: string[]) => {
- if (state.labels.length + 1 !== values.length) {
- return;
- }
- const newValue = values[values.length - 1];
- if (new Set(labelValues.value).has(newValue)) {
- return;
- }
- state.labels.push({
- color: defaultColor,
- value: newValue,
- group: "",
- });
-};
-
-const renderLabel = (value: string, index: number) => {
- const label = state.labels.find((l) => l.value === value) ?? {
- value,
- color: defaultColor,
- };
-
- return h(
- NTag,
- {
- closable: true,
- size: "large",
- disabled: !props.allowEdit,
- onClose: () => {
- state.labels.splice(index, 1);
- },
- },
- {
- default: () =>
- h("div", { class: "flex items-center gap-x-2" }, [
- h("div", {
- class: "w-4 h-4 rounded cursor-pointer relative",
- id: `#color-${index}`,
- style: `background-color: ${label.color};`,
- onClick: () => {
- state.pendingEditColorIndex = index;
- nextTick(() => {
- onClickOutside(colorPickerLocator, () => {
- state.pendingEditColorIndex = -1;
- });
- });
- },
- }),
- label.value,
- ]),
- }
- );
-};
-
-const onColorChange = (color: string) => {
- if (state.pendingEditColorIndex < 0) {
- return;
- }
- state.labels[state.pendingEditColorIndex].color = color;
-};
-
-const onSwitchUpdate = async (on: boolean) => {
- const projectPatch = cloneDeep(props.project);
- projectPatch.forceIssueLabels = on;
- await projectStore.updateProject(projectPatch, ["force_issue_labels"]);
- pushNotification({
- module: "bytebase",
- style: "SUCCESS",
- title: t("common.updated"),
- });
-};
-</script>
-
-<style scoped lang="postcss">
-:deep(.v-binder-follower-content) {
- @apply !translate-x-4 !translate-y-4;
-}
-</style>
diff --git a/frontend/src/components/Project/ProjectBranchProtectionRulesSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectBranchProtectionRulesSettingPanel.vue
similarity index 96%
rename from frontend/src/components/Project/ProjectBranchProtectionRulesSettingPanel.vue
rename to frontend/src/components/Project/Settings/ProjectBranchProtectionRulesSettingPanel.vue
index b4ac47b057..57907a81bf 100644
--- a/frontend/src/components/Project/ProjectBranchProtectionRulesSettingPanel.vue
+++ b/frontend/src/components/Project/Settings/ProjectBranchProtectionRulesSettingPanel.vue
@@ -56,7 +56,7 @@ import { ref } from "vue";
import { useProjectBranchProtectionRules } from "@/store/modules/v1/projectProtectionRoles";
import type { ComposedProject } from "@/types";
import type { ProtectionRule } from "@/types/proto/v1/project_service";
-import CreateProjectBranchProtectionRulePanel from "./CreateProjectBranchProtectionRulePanel.vue";
+import CreateProjectBranchProtectionRulePanel from "../CreateProjectBranchProtectionRulePanel.vue";
const props = defineProps<{
project: ComposedProject;
diff --git a/frontend/src/components/Project/ProjectGeneralSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue
similarity index 100%
rename from frontend/src/components/Project/ProjectGeneralSettingPanel.vue
rename to frontend/src/components/Project/Settings/ProjectGeneralSettingPanel.vue
diff --git a/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue
new file mode 100644
index 0000000000..244960fa89
--- /dev/null
+++ b/frontend/src/components/Project/Settings/ProjectIssueRelatedSettingPanel.vue
@@ -0,0 +1,203 @@
+<template>
+ <div class="w-full flex flex-col justify-start items-start pt-6 space-y-4">
+ <h3 class="text-lg font-medium text-main">
+ {{ $t("project.settings.issue-related.self") }}
+ </h3>
+ <div class="w-full flex flex-col justify-start items-start gap-2">
+ <span class="textlabel">{{
+ $t("project.settings.issue-related.labels.self")
+ }}</span>
+ <NDynamicTags
+ :size="'large'"
+ :disabled="!allowEdit"
+ :value="labelValues"
+ :render-tag="renderLabel"
+ @update:value="onLabelsUpdate"
+ />
+ <div>
+ <NCheckbox
+ v-model:checked="state.forceIssueLabels"
+ size="large"
+ :disabled="!allowEdit || state.issueLabels.length === 0"
+ :label="
+ $t('project.settings.issue-related.labels.force-issue-labels.self')
+ "
+ />
+ <p class="text-sm text-gray-400 pl-6 ml-0.5">
+ {{
+ $t(
+ "project.settings.issue-related.labels.force-issue-labels.description"
+ )
+ }}
+ </p>
+ </div>
+ <div>
+ <NCheckbox
+ v-model:checked="state.allowModifyStatement"
+ size="large"
+ :disabled="!allowEdit"
+ :label="
+ $t('project.settings.issue-related.allow-modify-statement.self')
+ "
+ />
+ <p class="text-sm text-gray-400 pl-6 ml-0.5">
+ {{
+ $t(
+ "project.settings.issue-related.allow-modify-statement.description"
+ )
+ }}
+ </p>
+ </div>
+ <div>
+ <NCheckbox
+ v-model:checked="state.autoResolveIssue"
+ size="large"
+ :disabled="!allowEdit"
+ :label="$t('project.settings.issue-related.auto-resolve-issue.self')"
+ />
+ <p class="text-sm text-gray-400 pl-6 ml-0.5">
+ {{
+ $t("project.settings.issue-related.auto-resolve-issue.description")
+ }}
+ </p>
+ </div>
+ </div>
+ <div class="w-full flex justify-end gap-x-3">
+ <NButton
+ type="primary"
+ :disabled="!valueChanged || !allowEdit"
+ @click.prevent="doUpdate"
+ >
+ {{ $t("common.update") }}
+ </NButton>
+ </div>
+ </div>
+</template>
+
+<script setup lang="tsx">
+import { isEqual, cloneDeep } from "lodash-es";
+import { NButton, NDynamicTags, NTag, NColorPicker, NCheckbox } from "naive-ui";
+import { computed, reactive } from "vue";
+import { useI18n } from "vue-i18n";
+import { pushNotification, useProjectV1Store } from "@/store";
+import type { ComposedProject } from "@/types";
+import { Label } from "@/types/proto/v1/project_service";
+
+const getInitialLocalState = (): LocalState => {
+ const project = props.project;
+ return {
+ issueLabels: [...cloneDeep(project.issueLabels)],
+ forceIssueLabels: project.forceIssueLabels,
+ allowModifyStatement: project.allowModifyStatement,
+ autoResolveIssue: project.autoResolveIssue,
+ };
+};
+
+interface LocalState {
+ issueLabels: Label[];
+ forceIssueLabels: boolean;
+ allowModifyStatement: boolean;
+ autoResolveIssue: boolean;
+}
+
+const defaultColor = "#4f46e5";
+
+const props = defineProps<{
+ project: ComposedProject;
+ allowEdit: boolean;
+}>();
+
+const state = reactive<LocalState>(getInitialLocalState());
+
+const { t } = useI18n();
+const projectStore = useProjectV1Store();
+
+const labelValues = computed(() => state.issueLabels.map((l) => l.value));
+
+const valueChanged = computed(() => !isEqual(state, getInitialLocalState()));
+
+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({
+ 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">
+ <div class="w-4 h-4 relative">
+ <NColorPicker
+ class="!w-full !h-full"
+ modes={["hex"]}
+ showAlpha={false}
+ value={label.color}
+ renderLabel={() => (
+ <div
+ class="w-4 h-4 rounded cursor-pointer relative"
+ style={{ backgroundColor: label.color }}
+ ></div>
+ )}
+ onUpdateValue={(color: string) => (label.color = color)}
+ />
+ </div>
+ <span>{label.value}</span>
+ </div>
+ </NTag>
+ );
+};
+
+const doUpdate = async () => {
+ const projectPatch = {
+ ...cloneDeep(props.project),
+ ...state,
+ };
+ await projectStore.updateProject(projectPatch, getUpdateMask());
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+};
+
+const getUpdateMask = () => {
+ 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.allowModifyStatement !== props.project.allowModifyStatement) {
+ mask.push("allow_modify_statement");
+ }
+ if (state.autoResolveIssue !== props.project.autoResolveIssue) {
+ mask.push("auto_resolve_issue");
+ }
+ return mask;
+};
+</script>
diff --git a/frontend/src/components/Project/Settings/ProjectSecuritySettingPanel.vue b/frontend/src/components/Project/Settings/ProjectSecuritySettingPanel.vue
new file mode 100644
index 0000000000..a18655ed61
--- /dev/null
+++ b/frontend/src/components/Project/Settings/ProjectSecuritySettingPanel.vue
@@ -0,0 +1,91 @@
+<template>
+ <div class="w-full flex flex-col justify-start items-start pt-6 space-y-4">
+ <h3 class="text-lg font-medium leading-7 text-main">
+ {{ $t("settings.sidebar.security-and-policy") }}
+ </h3>
+ <SQLReviewForResource :resource="project.name" :allow-edit="allowEdit" />
+ <div class="mt-2">
+ <NTooltip placement="top-start" :disabled="allowEdit">
+ <template #trigger>
+ <label
+ class="flex items-center gap-x-2"
+ :class="[allowEdit ? 'cursor-pointer' : 'cursor-not-allowed']"
+ >
+ <NCheckbox
+ :disabled="!allowEdit"
+ :checked="restrictIssueCreationForSQLReview"
+ :label="
+ $t(
+ 'settings.general.workspace.restrict-issue-creation-for-sql-review.title'
+ )
+ "
+ @update:checked="handleRestrictIssueCreationForSQLReviewToggle"
+ />
+ </label>
+ </template>
+ <span class="text-sm text-gray-400 -translate-y-2">
+ {{ $t("settings.general.workspace.only-admin-can-edit") }}
+ </span>
+ </NTooltip>
+ <div class="mb-3 text-sm text-gray-400">
+ {{
+ $t(
+ "settings.general.workspace.restrict-issue-creation-for-sql-review.description"
+ )
+ }}
+ </div>
+ </div>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { NTooltip, NCheckbox } from "naive-ui";
+import { computed, watchEffect } from "vue";
+import { useI18n } from "vue-i18n";
+import { pushNotification, usePolicyV1Store } from "@/store";
+import type { ComposedProject } from "@/types";
+import {
+ PolicyResourceType,
+ PolicyType,
+} from "@/types/proto/v1/org_policy_service";
+
+const props = defineProps<{
+ project: ComposedProject;
+ allowEdit: boolean;
+}>();
+
+const { t } = useI18n();
+const policyV1Store = usePolicyV1Store();
+
+watchEffect(async () => {
+ await policyV1Store.getOrFetchPolicyByParentAndType({
+ parentPath: props.project.name,
+ policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,
+ });
+});
+
+const restrictIssueCreationForSQLReview = computed((): boolean => {
+ return (
+ policyV1Store.getPolicyByParentAndType({
+ parentPath: props.project.name,
+ policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,
+ })?.restrictIssueCreationForSqlReviewPolicy?.disallow ?? false
+ );
+});
+
+const handleRestrictIssueCreationForSQLReviewToggle = async (on: boolean) => {
+ await policyV1Store.createPolicy(props.project.name, {
+ type: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,
+ resourceType: PolicyResourceType.PROJECT,
+ restrictIssueCreationForSqlReviewPolicy: {
+ disallow: on,
+ },
+ });
+
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("settings.general.workspace.config-updated"),
+ });
+};
+</script>
diff --git a/frontend/src/components/Project/Settings/index.ts b/frontend/src/components/Project/Settings/index.ts
new file mode 100644
index 0000000000..b3c2d479ee
--- /dev/null
+++ b/frontend/src/components/Project/Settings/index.ts
@@ -0,0 +1,11 @@
+import ProjectBranchProtectionRulesSettingPanel from "./ProjectBranchProtectionRulesSettingPanel.vue";
+import ProjectGeneralSettingPanel from "./ProjectGeneralSettingPanel.vue";
+import ProjectIssueRelatedSettingPanel from "./ProjectIssueRelatedSettingPanel.vue";
+import ProjectSecuritySettingPanel from "./ProjectSecuritySettingPanel.vue";
+
+export {
+ ProjectBranchProtectionRulesSettingPanel,
+ ProjectGeneralSettingPanel,
+ ProjectSecuritySettingPanel,
+ ProjectIssueRelatedSettingPanel,
+};
diff --git a/frontend/src/components/ProjectSettingPanel.vue b/frontend/src/components/ProjectSettingPanel.vue
index 386087a7f5..f58aa73bdb 100644
--- a/frontend/src/components/ProjectSettingPanel.vue
+++ b/frontend/src/components/ProjectSettingPanel.vue
@@ -7,7 +7,7 @@
:project="project"
:allow-edit="allowEdit"
/>
- <ProjectIssueLabelsSettingPanel
+ <ProjectIssueRelatedSettingPanel
:project="project"
:allow-edit="allowEdit"
/>
@@ -21,8 +21,12 @@
<script lang="ts" setup>
import type { ComposedProject } from "@/types";
import ProjectArchiveRestoreButton from "./Project/ProjectArchiveRestoreButton.vue";
-import ProjectGeneralSettingPanel from "./Project/ProjectGeneralSettingPanel.vue";
-import ProjectSecuritySettingPanel from "./Project/ProjectSecuritySettingPanel.vue";
+import {
+ ProjectBranchProtectionRulesSettingPanel,
+ ProjectGeneralSettingPanel,
+ ProjectSecuritySettingPanel,
+ ProjectIssueRelatedSettingPanel,
+} from "./Project/Settings/";
defineProps<{
project: ComposedProject;
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index bc3ddaa9d9..bca5cbd575 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -1997,10 +1997,24 @@
"no-protection-rule-configured": "No protection rule configured.",
"only-apply-to-main-branches": "Only apply to main branches"
},
- "labels": {
- "issue-labels": "Issue Labels",
- "configure-labels": "Configure labels",
- "force-issue-labels": "Require labels for all issues"
+ "issue-related": {
+ "self": "Issue related",
+ "labels": {
+ "self": "Labels",
+ "configure-labels": "Configure labels",
+ "force-issue-labels": {
+ "self": "Require labels for all issues",
+ "description": "Require at least one label when creating issues."
+ }
+ },
+ "allow-modify-statement": {
+ "self": "Allow modify statement",
+ "description": "Allow users to modify the statement of the issue after creation."
+ },
+ "auto-resolve-issue": {
+ "self": "Auto resolve issue",
+ "description": "Automatically resolve the issue after all tasks are completed."
+ }
}
},
"members": {
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index fb90923a0e..16f56d79ff 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -1997,10 +1997,24 @@
"no-protection-rule-configured": "No hay regla de protección configurada",
"only-apply-to-main-branches": "Sólo aplica en sucursales principales"
},
- "labels": {
- "issue-labels": "Etiquetas de problemas",
- "configure-labels": "Configurar etiquetas",
- "force-issue-labels": "Requerir etiquetas para todos los incidencias"
+ "issue-related": {
+ "self": "Problema relacionado",
+ "labels": {
+ "self": "Etiquetas",
+ "configure-labels": "Configurar etiquetas",
+ "force-issue-labels": {
+ "self": "Requerir etiquetas para todos los problemas",
+ "description": "Exija al menos una etiqueta al crear problemas."
+ }
+ },
+ "allow-modify-statement": {
+ "self": "Permitir modificar declaración",
+ "description": "Permitir a los usuarios modificar la declaración del problema después de su creación."
+ },
+ "auto-resolve-issue": {
+ "self": "Problema de resolución automática",
+ "description": "Resuelva automáticamente el problema después de completar todas las tareas."
+ }
}
},
"members": {
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 2cc2b1b878..52685a4f06 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -1997,10 +1997,24 @@
"no-protection-rule-configured": "ブランチ保護ルールは構成されていません。",
"only-apply-to-main-branches": "メインブランチでのみ有効です"
},
- "labels": {
- "issue-labels": "作業指示タグ",
- "configure-labels": "タグを構成する",
- "force-issue-labels": "すべての作業命令にラベルを付けることを要求する"
+ "issue-related": {
+ "self": "問題関連",
+ "labels": {
+ "self": "ラベル",
+ "configure-labels": "ラベルを設定する",
+ "force-issue-labels": {
+ "self": "すべての問題にラベルが必要",
+ "description": "問題を作成するときは、少なくとも 1 つのラベルが必要です。"
+ }
+ },
+ "allow-modify-statement": {
+ "self": "ステートメントの変更を許可する",
+ "description": "ユーザーが作成後に問題の説明を変更できるようにします。"
+ },
+ "auto-resolve-issue": {
+ "self": "自動解決の問題",
+ "description": "すべてのタスクが完了すると、問題が自動的に解決されます。"
+ }
}
},
"members": {
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 73c70ffe99..daa9729ae5 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -1997,10 +1997,24 @@
"no-protection-rule-configured": "没有配置分支保护规则。",
"only-apply-to-main-branches": "只对主分支生效"
},
- "labels": {
- "issue-labels": "工单标签",
- "configure-labels": "配置标签",
- "force-issue-labels": "要求所有工单都必须有标签"
+ "issue-related": {
+ "self": "工单相关",
+ "labels": {
+ "self": "标签",
+ "configure-labels": "配置标签",
+ "force-issue-labels": {
+ "self": "要求所有工单都必须有标签",
+ "description": "创建工单时必须添加至少一个标签。"
+ }
+ },
+ "allow-modify-statement": {
+ "self": "允许工单创建后修改语句",
+ "description": "允许用户在创建工单后修改该变更语句。"
+ },
+ "auto-resolve-issue": {
+ "self": "自动解决工单",
+ "description": "所有任务完成后自动解决工单。"
+ }
}
},
"members": {
@@ -3564,4 +3578,4 @@
"self": "最后更新"
}
}
-}
\ No newline at end of file
+}