Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
feat: implement direct issue creation from plan without drawer (#17244)
boojack648daf229a4b
diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vueindex e94d858b1a..e7fd566f31 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/Actions.vue@@ -11,10 +11,6 @@/><!-- Panels -->- <IssueCreationActionPanel- :show="pendingIssueCreationAction !== undefined"- @close="pendingIssueCreationAction = undefined"- /><template v-if="issue"><IssueReviewActionPanel@@ -30,35 +26,50 @@</template><script setup lang="ts">+import { create } from "@bufbuild/protobuf";import { head } from "lodash-es";import { useDialog } from "naive-ui";-import { computed, ref } from "vue";+import { computed, nextTick, ref, watchEffect } from "vue";import { useI18n } from "vue-i18n";+import { useRouter } from "vue-router";import { useSpecsValidation } from "@/components/Plan/components/common";-import { usePlanContext } from "@/components/Plan/logic";+import { usePlanContext, usePlanCheckStatus } from "@/components/Plan/logic";import { useIssueReviewContext } from "@/components/Plan/logic/issue-review";import { useResourcePoller } from "@/components/Plan/logic/poller";import { useEditorState } from "@/components/Plan/logic/useEditorState";+import {+ issueServiceClientConnect,+ rolloutServiceClientConnect,+} from "@/grpcweb";+import { PROJECT_V1_ROUTE_ISSUE_DETAIL_V1 } from "@/router/dashboard/projectV1";import {useCurrentUserV1,candidatesOfApprovalStepV1,extractUserId,useCurrentProjectV1,pushNotification,+ usePolicyV1Store,} from "@/store";import { usePlanStore } from "@/store/modules/v1/plan";import { State } from "@/types/proto-es/v1/common_pb";import {+ CreateIssueRequestSchema,+ IssueSchema,IssueStatus,Issue_Approver_Status,+ Issue_Type,} from "@/types/proto-es/v1/issue_service_pb";-import { isUserIncludedInList, hasProjectPermissionV2 } from "@/utils";-import { CreateButton } from "./create";+import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";+import { PlanCheckRun_Result_Status } from "@/types/proto-es/v1/plan_service_pb";+import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";import {- IssueReviewActionPanel,- IssueStatusActionPanel,- IssueCreationActionPanel,-} from "./panels";+ isUserIncludedInList,+ hasProjectPermissionV2,+ extractProjectResourceName,+ extractIssueUID,+} from "@/utils";+import { CreateButton } from "./create";+import { IssueReviewActionPanel, IssueStatusActionPanel } from "./panels";import {UnifiedActionGroup,type ActionConfig,@@ -69,20 +80,31 @@ import {} from "./unified";const { t } = useI18n();+const router = useRouter();const dialog = useDialog();const resourcePoller = useResourcePoller();-const { isCreating, plan, issue } = usePlanContext();+const { isCreating, plan, issue, events } = usePlanContext();const currentUser = useCurrentUserV1();const { project } = useCurrentProjectV1();const planStore = usePlanStore();+const policyV1Store = usePolicyV1Store();const editorState = useEditorState();// Use the validation hook for all specsconst { isSpecEmpty } = useSpecsValidation(plan.value.specs);+// Use plan check status for issue creation validation+const {+ getOverallStatus: planCheckSummaryStatus,+ hasRunning: hasRunningPlanChecks,+} = usePlanCheckStatus(plan);+// Provide issue review context when an issue existsconst reviewContext = useIssueReviewContext();+// Policy for restricting issue creation when plan checks fail+const restrictIssueCreationForSqlReviewPolicy = ref(false);+// Computed property for actions disabled state.const actionsDisabled = computed(() => {return editorState.isEditing.value;@@ -99,7 +121,40 @@ const disabledTooltip = computed(() => {// Panel visibility stateconst pendingReviewAction = ref<IssueReviewAction | undefined>(undefined);const pendingStatusAction = ref<IssueStatusAction | undefined>(undefined);-const pendingIssueCreationAction = ref<"CREATE" | undefined>(undefined);++// Watch for policy changes to determine if issue creation is restricted+watchEffect(async () => {+ const workspaceLevelPolicy =+ await policyV1Store.getOrFetchPolicyByParentAndType({+ parentPath: "",+ policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,+ });+ if (+ workspaceLevelPolicy?.policy?.case ===+ "restrictIssueCreationForSqlReviewPolicy" &&+ workspaceLevelPolicy.policy.value.disallow+ ) {+ restrictIssueCreationForSqlReviewPolicy.value = true;+ return;+ }++ const projectLevelPolicy =+ await policyV1Store.getOrFetchPolicyByParentAndType({+ parentPath: project.value.name,+ policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,+ });+ if (+ projectLevelPolicy?.policy?.case ===+ "restrictIssueCreationForSqlReviewPolicy" &&+ projectLevelPolicy.policy.value.disallow+ ) {+ restrictIssueCreationForSqlReviewPolicy.value = true;+ return;+ }++ // Fall back to default value.+ restrictIssueCreationForSqlReviewPolicy.value = false;+});// Compute available actions based on issue state and user permissionsconst availableActions = computed(() => {@@ -230,10 +285,45 @@ const primaryAction = computed((): ActionConfig | undefined => {if (actions.includes("ISSUE_CREATE")) {// Check if all specs have valid statements (not empty)const hasValidSpecs = !plan.value.specs.some((spec) => isSpecEmpty(spec));++ // Check permissions+ const hasPermission = hasProjectPermissionV2(+ project.value,+ "bb.issues.create"+ );++ // Check plan check status and policy restrictions+ const planChecksFailed =+ planCheckSummaryStatus.value === PlanCheckRun_Result_Status.ERROR;+ const isRestrictedByPolicy =+ planChecksFailed && restrictIssueCreationForSqlReviewPolicy.value;+ const hasRunningChecks = hasRunningPlanChecks.value;++ const errors: string[] = [];+ if (!hasValidSpecs) {+ errors.push("Missing statement");+ }+ if (!hasPermission) {+ errors.push(t("common.missing-required-permission"));+ }+ if (hasRunningChecks) {+ errors.push("Plan checks are running");+ }+ if (isRestrictedByPolicy) {+ errors.push(+ t(+ "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"+ )+ );+ }++ const isDisabled = errors.length > 0;+ const description = isDisabled ? errors.join(", ") : undefined;+return {action: "ISSUE_CREATE",- disabled: !hasValidSpecs,- description: hasValidSpecs ? undefined : "Missing statement",+ disabled: isDisabled,+ description,};}@@ -288,7 +378,7 @@ const handlePerformAction = async (action: UnifiedAction) => {pendingStatusAction.value = action as IssueStatusAction;break;case "ISSUE_CREATE":- pendingIssueCreationAction.value = "CREATE";+ await handleIssueCreate();break;case "PLAN_CLOSE":await handlePlanStateChange("PLAN_CLOSE");@@ -299,6 +389,59 @@ const handlePerformAction = async (action: UnifiedAction) => {}};+const handleIssueCreate = async () => {+ if (!plan?.value) return;++ try {+ await doCreateIssue();+ } catch (error) {+ console.error("Failed to create issue:", error);+ pushNotification({+ module: "bytebase",+ style: "CRITICAL",+ title: "Failed to create issue",+ description: String(error),+ });+ }+};++const doCreateIssue = async () => {+ const request = create(CreateIssueRequestSchema, {+ parent: project.value.name,+ issue: create(IssueSchema, {+ creator: `users/${currentUser.value.email}`,+ labels: [], // No labels for direct creation+ plan: plan.value.name,+ status: IssueStatus.OPEN,+ type: Issue_Type.DATABASE_CHANGE,+ rollout: "",+ }),+ });+ const createdIssue = await issueServiceClientConnect.createIssue(request);++ // Then create the rollout from the plan.+ const rolloutRequest = create(CreateRolloutRequestSchema, {+ parent: project.value.name,+ rollout: {+ plan: plan.value.name,+ },+ });+ await rolloutServiceClientConnect.createRollout(rolloutRequest);++ // Emit status changed to refresh the UI+ events.emit("status-changed", { eager: true });++ nextTick(() => {+ router.push({+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,+ params: {+ projectId: extractProjectResourceName(plan.value.name),+ issueId: extractIssueUID(createdIssue.name),+ },+ });+ });+};+const handlePlanStateChange = async (action: PlanAction) => {if (!plan?.value) return;diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vueindex 8db13967a2..24592a99ea 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/create/CreateButton.vue@@ -17,20 +17,11 @@<ErrorList :errors="planCreateErrorList" /></template></NTooltip>-- <!-- prevent clicking the page when creating in progress -->- <div- v-if="loading"- v-zindexable="{ enabled: true }"- class="fixed inset-0 pointer-events-auto flex flex-col items-center justify-center"- @click.stop.prevent- /></template><script setup lang="ts">import { create } from "@bufbuild/protobuf";import { NTooltip, NButton } from "naive-ui";-import { zindexable as vZindexable } from "vdirs";import { computed, nextTick, ref } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vuedeleted file mode 100644index 42805b3706..0000000000--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/IssueCreationActionPanel.vue+++ /dev/null@@ -1,282 +0,0 @@-<template>- <CommonDrawer- :show="props.show"- :title="title"- :loading="loading"- @close="$emit('close')"- >- <template #default>- <div class="flex flex-col gap-y-4 px-1">- <!-- Plan Check Status -->- <div v-if="planCheckStatus.total > 0" class="flex items-center gap-3">- <span class="text-control shrink-0">{{- $t("plan.navigator.checks")- }}</span>- <PlanCheckStatusCount :plan="plan" />- </div>-- <div class="flex flex-col gap-y-1">- <div class="text-control">- {{ $t("common.description") }}- </div>- <NInput- v-model:value="description"- type="textarea"- :placeholder="$t('issue.add-some-description')"- :autosize="{- minRows: 3,- maxRows: 10,- }"- />- </div>-- <div class="flex flex-col gap-y-1">- <div class="text-control">- {{ $t("common.labels") }}- <RequiredStar v-if="project.forceIssueLabels" />- </div>- <IssueLabelSelector- :disabled="false"- :selected="labels"- :project="project"- :size="'medium'"- @update:selected="labels = $event"- />- </div>-- <div v-if="tips.length > 0" class="flex flex-col gap-y-2 pl-2">- <ul class="list-disc list-inside space-y-1 text-sm text-gray-500">- <li v-for="(tip, index) in tips" :key="index">- {{ tip }}- </li>- </ul>- </div>- </div>- </template>- <template #footer>- <div class="w-full flex flex-row justify-end items-center gap-2">- <div class="flex justify-end gap-x-3">- <NButton @click="$emit('close')" quaternary>- {{ $t("common.close") }}- </NButton>-- <NTooltip :disabled="confirmErrors.length === 0" placement="top">- <template #trigger>- <NButton- type="primary"- :disabled="confirmErrors.length > 0"- @click="handleConfirm"- >- {{ $t("common.confirm") }}- </NButton>- </template>- <template #default>- <ErrorList :errors="confirmErrors" />- </template>- </NTooltip>- </div>- </div>- </template>- </CommonDrawer>-</template>--<script setup lang="ts">-import { create } from "@bufbuild/protobuf";-import { NButton, NInput, NTooltip } from "naive-ui";-import { computed, nextTick, ref, watchEffect } from "vue";-import { useI18n } from "vue-i18n";-import { useRouter } from "vue-router";-import IssueLabelSelector from "@/components/IssueV1/components/IssueLabelSelector.vue";-import CommonDrawer from "@/components/IssueV1/components/Panel/CommonDrawer.vue";-import PlanCheckStatusCount from "@/components/Plan/components/PlanCheckStatusCount.vue";-import { ErrorList } from "@/components/Plan/components/common";-import { usePlanContext, usePlanCheckStatus } from "@/components/Plan/logic";-import RequiredStar from "@/components/RequiredStar.vue";-import {- issueServiceClientConnect,- planServiceClientConnect,- rolloutServiceClientConnect,-} from "@/grpcweb";-import { PROJECT_V1_ROUTE_ISSUE_DETAIL_V1 } from "@/router/dashboard/projectV1";-import {- useCurrentProjectV1,- useCurrentUserV1,- usePolicyV1Store,-} from "@/store";-import {- CreateIssueRequestSchema,- IssueSchema,-} from "@/types/proto-es/v1/issue_service_pb";-import { IssueStatus, Issue_Type } from "@/types/proto-es/v1/issue_service_pb";-import { PolicyType } from "@/types/proto-es/v1/org_policy_service_pb";-import {- PlanCheckRun_Result_Status,- UpdatePlanRequestSchema,-} from "@/types/proto-es/v1/plan_service_pb";-import { CreateRolloutRequestSchema } from "@/types/proto-es/v1/rollout_service_pb";-import {- extractProjectResourceName,- hasProjectPermissionV2,- extractIssueUID,-} from "@/utils";--const props = defineProps<{- show: boolean;-}>();--const emit = defineEmits<{- (event: "close"): void;-}>();--const { t } = useI18n();-const router = useRouter();-const { project } = useCurrentProjectV1();-const currentUser = useCurrentUserV1();-const policyV1Store = usePolicyV1Store();-const { plan, events } = usePlanContext();-const loading = ref(false);-const description = ref(plan.value.description || "");-const labels = ref<string[]>([]);-const restrictIssueCreationForSqlReviewPolicy = ref(false);--const title = computed(() => {- return t("plan.ready-for-review");-});--const {- statusSummary: planCheckStatus,- getOverallStatus: planCheckSummaryStatus,-} = usePlanCheckStatus(plan);--const tips = computed(() => {- const tipsList: string[] = [];-- // Add tip about modifying statements- if (!project.value.allowModifyStatement) {- tipsList.push(t("issue.error.statement-cannot-be-modified"));- }-- return tipsList;-});--const confirmErrors = computed(() => {- const errors: string[] = [];-- if (!hasProjectPermissionV2(project.value, "bb.plans.create")) {- errors.push(t("common.missing-required-permission"));- }-- if (- planCheckSummaryStatus.value === PlanCheckRun_Result_Status.ERROR &&- restrictIssueCreationForSqlReviewPolicy.value- ) {- errors.push(- t(- "custom-approval.issue-review.disallow-approve-reason.some-task-checks-didnt-pass"- )- );- }-- if (project.value.forceIssueLabels && labels.value.length === 0) {- errors.push(- t("project.settings.issue-related.labels.force-issue-labels.warning")- );- }-- return errors;-});--watchEffect(async () => {- const workspaceLevelPolicy =- await policyV1Store.getOrFetchPolicyByParentAndType({- parentPath: "",- policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,- });- if (- workspaceLevelPolicy?.policy?.case ===- "restrictIssueCreationForSqlReviewPolicy" &&- workspaceLevelPolicy.policy.value.disallow- ) {- restrictIssueCreationForSqlReviewPolicy.value = true;- return;- }-- const projectLevelPolicy =- await policyV1Store.getOrFetchPolicyByParentAndType({- parentPath: project.value.name,- policyType: PolicyType.RESTRICT_ISSUE_CREATION_FOR_SQL_REVIEW,- });- if (- projectLevelPolicy?.policy?.case ===- "restrictIssueCreationForSqlReviewPolicy" &&- projectLevelPolicy.policy.value.disallow- ) {- restrictIssueCreationForSqlReviewPolicy.value = true;- return;- }-- // Fall back to default value.- restrictIssueCreationForSqlReviewPolicy.value = false;-});--const handleConfirm = async () => {- await doCreateIssue();-};--const doCreateIssue = async () => {- loading.value = true;-- try {- // Update the plan description if it has changed before creating the issue.- if (description.value !== plan.value.description) {- await planServiceClientConnect.updatePlan(- create(UpdatePlanRequestSchema, {- plan: {- name: plan.value.name,- description: description.value,- },- updateMask: { paths: ["description"] },- })- );- }-- const request = create(CreateIssueRequestSchema, {- parent: project.value.name,- issue: create(IssueSchema, {- creator: `users/${currentUser.value.email}`,- labels: labels.value,- plan: plan.value.name,- status: IssueStatus.OPEN,- type: Issue_Type.DATABASE_CHANGE,- rollout: "",- }),- });- const createdIssue = await issueServiceClientConnect.createIssue(request);-- // Then create the rollout from the plan.- const rolloutRequest = create(CreateRolloutRequestSchema, {- parent: project.value.name,- rollout: {- plan: plan.value.name,- },- });- await rolloutServiceClientConnect.createRollout(rolloutRequest);-- // Emit status changed to refresh the UI- events.emit("status-changed", { eager: true });-- nextTick(() => {- router.push({- name: PROJECT_V1_ROUTE_ISSUE_DETAIL_V1,- params: {- projectId: extractProjectResourceName(plan.value.name),- issueId: extractIssueUID(createdIssue.name),- },- });- });- } finally {- loading.value = false;- emit("close");- }-};-</script>diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.tsindex c37f772551..4f99fb32fd 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/panels/index.ts@@ -1,3 +1,2 @@export { default as IssueReviewActionPanel } from "./IssueReviewActionPanel.vue";export { default as IssueStatusActionPanel } from "./IssueStatusActionPanel.vue";-export { default as IssueCreationActionPanel } from "./IssueCreationActionPanel.vue";diff --git a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vueindex 0474caa3fb..713c54b44c 100644--- a/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue+++ b/frontend/src/components/Plan/components/HeaderSection/Actions/unified/UnifiedActionButton.vue@@ -1,5 +1,5 @@<template>- <NTooltip :disabled="!disabledTooltip" placement="top">+ <NTooltip :disabled="!disabledTooltip" placement="bottom-end"><template #trigger><NButtonsize="medium"diff --git a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vueindex 8a012ccd6d..140c9402b8 100644--- a/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue+++ b/frontend/src/components/Plan/components/SpecDetailView/SpecListSection.vue@@ -15,13 +15,12 @@>#{{ index + 1 }}</span>{{ getSpecTitle(spec) }}- <span- v-if="isSpecEmpty(spec)"- class="text-error"- :title="$t('plan.navigator.statement-empty')"- >- *- </span>+ <NTooltip v-if="isSpecEmpty(spec)">+ <template #trigger>+ <span class="text-error">*</span>+ </template>+ {{ $t("plan.navigator.statement-empty") }}+ </NTooltip><NButtonv-if="canModifySpecs && plan.specs.length > 1"quaternary@@ -63,7 +62,7 @@<script setup lang="ts">import { create } from "@bufbuild/protobuf";import { PlusIcon, XIcon } from "lucide-vue-next";-import { NTabs, NTab, NButton, useDialog } from "naive-ui";+import { NTabs, NTab, NButton, useDialog, NTooltip } from "naive-ui";import { ref, computed } from "vue";import { useI18n } from "vue-i18n";import { useRouter } from "vue-router";diff --git a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vueindex 8d91ff3414..5efaa0d363 100644--- a/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue+++ b/frontend/src/components/v2/Model/DatabaseV1Table/DatabaseV1Table.vue@@ -108,8 +108,8 @@ const columnList = computed((): DatabaseDataTableColumn[] => {<EnvironmentV1Nameenvironment={data.effectiveEnvironmentEntity}link={false}- tag="div"keyword={props.keyword}+ nullEnvironmentPlaceholder="Null"/>),};diff --git a/frontend/src/components/v2/Sidebar/CommonSidebar.vue b/frontend/src/components/v2/Sidebar/CommonSidebar.vueindex 16e2559878..d23ab9f1ce 100644--- a/frontend/src/components/v2/Sidebar/CommonSidebar.vue+++ b/frontend/src/components/v2/Sidebar/CommonSidebar.vue@@ -1,5 +1,7 @@<template>- <nav class="flex-1 flex flex-col overflow-y-hidden">+ <nav+ class="flex-1 flex flex-col overflow-y-hidden border-r border-block-border"+ ><BytebaseLogov-if="showLogo"class="w-full px-4 shrink-0"diff --git a/frontend/src/layouts/BodyLayout.vue b/frontend/src/layouts/BodyLayout.vueindex e6363ff50b..6f4890a63d 100644--- a/frontend/src/layouts/BodyLayout.vue+++ b/frontend/src/layouts/BodyLayout.vue@@ -72,7 +72,7 @@</template><div- class="flex flex-col min-w-0 flex-1 border-x border-block-border"+ class="flex flex-col min-w-0 flex-1"data-label="bb-main-body-wrapper"><nav