Skip to content

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

feat: implement review issue template (#12020)

boojackd66c93360a73
diff --git a/frontend/src/components/IssueV1/GrantRequestIssueDetailPage.vue b/frontend/src/components/IssueV1/GrantRequestIssueDetailPage.vue
index 16e8784280..8fca127930 100644
--- a/frontend/src/components/IssueV1/GrantRequestIssueDetailPage.vue
+++ b/frontend/src/components/IssueV1/GrantRequestIssueDetailPage.vue
@@ -8,14 +8,16 @@
<div class="flex-1 flex flex-row">
<div
- class="flex-1 flex flex-col hide-scrollbar divide-y overflow-x-hidden px-4 py-2"
+ class="flex-1 flex flex-col hide-scrollbar divide-y overflow-x-hidden py-2"
>
- <GrantRequestExporterForm
- v-if="requestRole === PresetRoleType.PROJECT_EXPORTER"
- />
- <GrantRequestQuerierForm
- v-if="requestRole === PresetRoleType.PROJECT_QUERIER"
- />
+ <div class="w-full px-4">
+ <GrantRequestExporterForm
+ v-if="requestRole === PresetRoleType.PROJECT_EXPORTER"
+ />
+ <GrantRequestQuerierForm
+ v-if="requestRole === PresetRoleType.PROJECT_QUERIER"
+ />
+ </div>
<DescriptionSection />
diff --git a/frontend/src/components/IssueV1/SQLReviewIssueDetailPage.vue b/frontend/src/components/IssueV1/SQLReviewIssueDetailPage.vue
new file mode 100644
index 0000000000..a60121fdfc
--- /dev/null
+++ b/frontend/src/components/IssueV1/SQLReviewIssueDetailPage.vue
@@ -0,0 +1,118 @@
+<template>
+ <div ref="containerRef" class="h-full flex flex-col">
+ <div class="border-b">
+ <div class="issue-debug">phase: {{ phase }}</div>
+ <BannerSection v-if="!isCreating" />
+
+ <HeaderSection />
+ </div>
+ <div class="flex-1 flex flex-row">
+ <div
+ class="flex-1 flex flex-col hide-scrollbar divide-y overflow-x-hidden"
+ >
+ <ReviewIssueSpecSection />
+ <SQLCheckSection v-if="isCreating" />
+ <PlanCheckSection v-if="!isCreating" />
+ <StatementSection />
+ <DescriptionSection />
+ <IssueCommentSection v-if="!isCreating" />
+ </div>
+
+ <div
+ v-if="sidebarMode == 'DESKTOP'"
+ class="hide-scrollbar border-l"
+ :style="{
+ width: `${desktopSidebarWidth}px`,
+ }"
+ >
+ <Sidebar />
+ </div>
+ </div>
+ </div>
+
+ <template v-if="sidebarMode === 'MOBILE'">
+ <!-- mobile sidebar -->
+ <Drawer :show="mobileSidebarOpen" @close="mobileSidebarOpen = false">
+ <div
+ style="
+ min-width: 240px;
+ width: 80vw;
+ max-width: 320px;
+ padding: 0.5rem 0;
+ "
+ >
+ <Sidebar v-if="sidebarMode === 'MOBILE'" />
+ </div>
+ </Drawer>
+ </template>
+
+ <IssueReviewActionPanel
+ :action="ongoingIssueReviewAction?.action"
+ @close="ongoingIssueReviewAction = undefined"
+ />
+ <IssueStatusActionPanel
+ :action="ongoingIssueStatusAction?.action"
+ @close="ongoingIssueStatusAction = undefined"
+ />
+
+ <div class="issue-debug">
+ <pre class="text-xs">{{ JSON.stringify(issue, null, " ") }}</pre>
+ </div>
+</template>
+
+<script setup lang="ts">
+import { ref } from "vue";
+import { provideSQLCheckContext } from "../SQLCheck";
+import { Drawer } from "../v2";
+import {
+ BannerSection,
+ HeaderSection,
+ PlanCheckSection,
+ StatementSection,
+ DescriptionSection,
+ IssueCommentSection,
+ Sidebar,
+ IssueReviewActionPanel,
+ IssueStatusActionPanel,
+ SQLCheckSection,
+ ReviewIssueSpecSection,
+} from "./components";
+import type { IssueReviewAction, IssueStatusAction } from "./logic";
+import {
+ provideIssueSidebarContext,
+ useIssueContext,
+ usePollIssue,
+} from "./logic";
+
+const containerRef = ref<HTMLElement>();
+const { isCreating, phase, issue, events } = useIssueContext();
+
+const ongoingIssueReviewAction = ref<{
+ action: IssueReviewAction;
+}>();
+const ongoingIssueStatusAction = ref<{
+ action: IssueStatusAction;
+}>();
+
+usePollIssue();
+
+events.on("perform-issue-review-action", ({ action }) => {
+ ongoingIssueReviewAction.value = {
+ action,
+ };
+});
+
+events.on("perform-issue-status-action", ({ action }) => {
+ ongoingIssueStatusAction.value = {
+ action,
+ };
+});
+
+provideSQLCheckContext();
+
+const {
+ mode: sidebarMode,
+ desktopSidebarWidth,
+ mobileSidebarOpen,
+} = provideIssueSidebarContext(containerRef);
+</script>
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueStatusActionButtonGroup/IssueStatusActionButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueStatusActionButtonGroup/IssueStatusActionButtonGroup.vue
index bac0f2bca4..6be24060b5 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueStatusActionButtonGroup/IssueStatusActionButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/common/IssueStatusActionButtonGroup/IssueStatusActionButtonGroup.vue
@@ -84,20 +84,7 @@ const issueStatusActionDropdownOptions = computed(() => {
});
const mergedDropdownActionList = computed(() => {
- if (issueStatusActionDropdownOptions.value.length > 0) {
- // When there are something to do with tasks, they will be shown as big
- // buttons.
- // Now we display issue-level actions as a dropdown together with "extra"
- // actions.
- return [
- ...issueStatusActionDropdownOptions.value,
- ...props.extraActionList,
- ];
- } else {
- // When we have nothing to do with tasks, show issue-level actions as big
- // buttons. And show only "extra" actions as a dropdown.
- return [...props.extraActionList];
- }
+ return [...issueStatusActionDropdownOptions.value, ...props.extraActionList];
});
const renderDropdownOption = ({
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
index 9e8d0bce48..32c9f60693 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/create/CreateButton.vue
@@ -32,13 +32,14 @@ import { NTooltip, NButton } from "naive-ui";
import { zindexable as vZindexable } from "vdirs";
import { computed, nextTick, ref, toRaw } from "vue";
import { useI18n } from "vue-i18n";
-import { useRouter } from "vue-router";
+import { useRoute, useRouter } from "vue-router";
import { getValidIssueLabels } from "@/components/IssueV1/components/IssueLabelSelector.vue";
import { ErrorList } from "@/components/IssueV1/components/common";
import {
databaseEngineForSpec,
databaseForTask,
getLocalSheetByName,
+ isValidSpec,
isValidStage,
specForTask,
useIssueContext,
@@ -46,7 +47,7 @@ import {
import formatSQL from "@/components/MonacoEditor/sqlFormatter";
import { useSQLCheckContext } from "@/components/SQLCheck";
import { issueServiceClient, rolloutServiceClient } from "@/grpcweb";
-import { emitWindowEvent } from "@/plugins";
+import { emitWindowEvent, type TemplateType } from "@/plugins";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
import { useCurrentUserV1, useDatabaseV1Store, useSheetV1Store } from "@/store";
import type { ComposedIssue } from "@/types";
@@ -70,6 +71,7 @@ import {
const MAX_FORMATTABLE_STATEMENT_SIZE = 10000; // 10K characters
const { t } = useI18n();
+const route = useRoute();
const router = useRouter();
const { issue, formatOnSave } = useIssueContext();
const { runSQLCheck } = useSQLCheckContext();
@@ -90,10 +92,22 @@ const issueCreateErrorList = computed(() => {
if (!issue.value.title.trim()) {
errorList.push("Missing issue title");
}
- if (
- !issue.value.rolloutEntity?.stages.every((stage) => isValidStage(stage))
- ) {
- errorList.push("Missing SQL statement in some stages");
+ if (issue.value.rollout) {
+ if (
+ !issue.value.rolloutEntity?.stages.every((stage) => isValidStage(stage))
+ ) {
+ errorList.push("Missing SQL statement in some stages");
+ }
+ } else {
+ if (issue.value.planEntity) {
+ if (
+ !issue.value.planEntity.steps.every((step) =>
+ step.specs.every((spec) => isValidSpec(spec))
+ )
+ ) {
+ errorList.push("Missing SQL statement in some specs");
+ }
+ }
}
if (
issue.value.projectEntity.forceIssueLabels &&
@@ -131,23 +145,25 @@ const doCreateIssue = async () => {
parent: issue.value.project,
issue: issueCreate,
});
-
- const createdRollout = await rolloutServiceClient.createRollout({
- parent: issue.value.project,
- rollout: {
- plan: createdPlan.name,
- },
- });
-
- createdIssue.rollout = createdRollout.name;
-
const composedIssue: ComposedIssue = {
...issue.value,
...createdIssue,
planEntity: createdPlan,
- rolloutEntity: createdRollout,
};
+ // Don't create rollout for review issue template.
+ if ((route.query.template as TemplateType) !== "bb.issue.sql-review") {
+ const createdRollout = await rolloutServiceClient.createRollout({
+ parent: issue.value.project,
+ rollout: {
+ plan: createdPlan.name,
+ },
+ });
+
+ composedIssue.rollout = createdRollout.name;
+ composedIssue.rolloutEntity = createdRollout;
+ }
+
await emitIssueCreateWindowEvent(composedIssue);
nextTick(() => {
router.push({
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
index 791d9a0e88..51dfe73384 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/review/IssueReviewButtonGroup.vue
@@ -97,7 +97,10 @@ const issueReviewActionList = computed(() => {
});
const issueStatusActionList = computed(() => {
- return getApplicableIssueStatusActionList(issue.value);
+ return getApplicableIssueStatusActionList(
+ issue.value,
+ reviewContext.status.value
+ );
});
const forceRolloutActionList = computed((): ExtraActionOption[] => {
// If it's not a database change related issue, no force rollout actions.
diff --git a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
index bfc9a14fdb..f4639afd13 100644
--- a/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
+++ b/frontend/src/components/IssueV1/components/HeaderSection/Actions/rollout/CombinedRolloutButtonGroup.vue
@@ -64,11 +64,20 @@ import type { RolloutAction } from "./common";
const { t } = useI18n();
const currentUser = useCurrentUserV1();
-const { issue, activeStage, activeTask, events, releaserCandidates } =
- useIssueContext();
+const {
+ issue,
+ activeStage,
+ activeTask,
+ events,
+ releaserCandidates,
+ reviewContext,
+} = useIssueContext();
const issueStatusActionList = computed(() => {
- return getApplicableIssueStatusActionList(issue.value);
+ return getApplicableIssueStatusActionList(
+ issue.value,
+ reviewContext.status.value
+ );
});
const taskRolloutActionList = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/Panel/IssueStatusActionPanel.vue b/frontend/src/components/IssueV1/components/Panel/IssueStatusActionPanel.vue
index 250ff9c94b..4149b705ae 100644
--- a/frontend/src/components/IssueV1/components/Panel/IssueStatusActionPanel.vue
+++ b/frontend/src/components/IssueV1/components/Panel/IssueStatusActionPanel.vue
@@ -66,7 +66,7 @@
<NButton
:disabled="confirmErrors.length > 0"
v-bind="confirmButtonProps"
- @click="handleConfirm(action, comment)"
+ @click="handleConfirm(action!, comment)"
>
{{ $t("common.confirm") }}
</NButton>
diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckBadge.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckBadge.vue
index a0329b94a1..741f87e910 100644
--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckBadge.vue
+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckBadge.vue
@@ -6,7 +6,7 @@
</div>
<button
- class="inline-flex items-center px-3 py-0.5 rounded-full text-sm border border-control-border"
+ class="inline-flex items-center px-3 leading-6 rounded-full text-sm border"
:class="buttonClasses"
@click="clickable && $emit('click')"
>
@@ -81,39 +81,32 @@ const resultStatus = computed(() => {
const buttonClasses = computed(() => {
let bgColor = "";
- let bgHoverColor = "";
let textColor = "";
switch (status.value) {
case PlanCheckRun_Status.RUNNING:
bgColor = "bg-blue-100";
- bgHoverColor = "bg-blue-300";
textColor = "text-blue-800";
break;
case PlanCheckRun_Status.FAILED:
bgColor = "bg-red-100";
- bgHoverColor = "bg-red-300";
textColor = "text-red-800";
break;
case PlanCheckRun_Status.CANCELED:
bgColor = "bg-yellow-100";
- bgHoverColor = "bg-yellow-300";
textColor = "text-yellow-800";
break;
case PlanCheckRun_Status.DONE:
switch (resultStatus.value) {
case PlanCheckRun_Result_Status.SUCCESS:
bgColor = "bg-gray-100";
- bgHoverColor = "bg-gray-300";
textColor = "text-gray-800";
break;
case PlanCheckRun_Result_Status.WARNING:
bgColor = "bg-yellow-100";
- bgHoverColor = "bg-yellow-300";
textColor = "text-yellow-800";
break;
case PlanCheckRun_Result_Status.ERROR:
bgColor = "bg-red-100";
- bgHoverColor = "bg-red-300";
textColor = "text-red-800";
break;
}
@@ -122,17 +115,17 @@ const buttonClasses = computed(() => {
const styleList: string[] = [textColor];
if (props.clickable) {
- styleList.push("cursor-pointer", `hover:${bgHoverColor}`);
+ styleList.push("cursor-pointer");
if (props.selected) {
- styleList.push(bgHoverColor);
+ styleList.push("shadow", "font-medium", "border-control-border");
} else {
- styleList.push(bgColor);
+ styleList.push(bgColor, "hover:opacity-80", "border-transparent");
}
} else {
styleList.push(bgColor);
styleList.push("cursor-default");
}
- styleList.push("cursor-pointer", `hover:${bgHoverColor}`);
+ styleList.push("cursor-pointer");
styleList.push(bgColor);
return styleList.join(" ");
diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckBar.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckBar.vue
index c70639df25..4c0d0a60b2 100644
--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckBar.vue
+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckBar.vue
@@ -89,7 +89,7 @@ withDefaults(
const { issue, events } = useIssueContext();
const state = reactive<LocalState>({
- showPlanCheckDetail: false,
+ showPlanCheckDetail: !issue.value.rollout, // Show plan check detail by default if there is no rollout.
});
const selectedType = ref<PlanCheckRun_Type>();
diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckPanel.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckPanel.vue
index 0de07b4c9f..7dc3232bb2 100644
--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckPanel.vue
+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckPanel.vue
@@ -29,7 +29,7 @@ import { useI18n } from "vue-i18n";
import { databaseForSpec, useIssueContext } from "@/components/IssueV1/logic";
import type { TabFilterItem } from "@/components/v2";
import { TabFilter } from "@/components/v2";
-import { UNKNOWN_ID } from "@/types";
+import { EMPTY_ID } from "@/types";
import {
PlanCheckRun_Result_Status,
PlanCheckRun_Type,
@@ -121,7 +121,7 @@ watch(selectedPlanCheckRunList, (list) => {
const environment = computed(() => {
const spec = selectedSpec.value;
- if (!spec || spec.id === String(UNKNOWN_ID)) {
+ if (!spec || spec.id === String(EMPTY_ID)) {
return;
}
const database = databaseForSpec(issue.value, spec);
diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
index e9bfa6c0f6..7c9c3c7a4e 100644
--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckSection.vue
@@ -28,7 +28,7 @@ import {
} from "@/components/IssueV1/logic";
import { rolloutServiceClient } from "@/grpcweb";
import { useCurrentUserV1 } from "@/store";
-import { UNKNOWN_ID } from "@/types";
+import { EMPTY_ID } from "@/types";
import { extractUserResourceName, hasProjectPermissionV2 } from "@/utils";
import PlanCheckBar from "./PlanCheckBar";
@@ -39,7 +39,7 @@ const show = computed(() => {
if (isCreating.value) {
return false;
}
- if (selectedSpec.value.id === String(UNKNOWN_ID)) {
+ if (selectedSpec.value.id === String(EMPTY_ID)) {
return false;
}
return planSpecHasPlanChecks(selectedSpec.value);
@@ -71,11 +71,11 @@ const allowRunChecks = computed(() => {
const planCheckRunList = computed(() => {
// If a task is selected, show plan checks for the task.
- if (selectedTask.value && selectedTask.value.uid !== String(UNKNOWN_ID)) {
+ if (selectedTask.value && selectedTask.value.uid !== String(EMPTY_ID)) {
return planCheckRunListForTask(issue.value, selectedTask.value);
}
// If a spec is selected, show plan checks for the spec.
- if (selectedSpec.value && selectedSpec.value.id !== String(UNKNOWN_ID)) {
+ if (selectedSpec.value && selectedSpec.value.id !== String(EMPTY_ID)) {
return planCheckRunListForSpec(issue.value, selectedSpec.value);
}
// Otherwise, show plan checks for the issue.
diff --git a/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewIssueSpecSection.vue b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewIssueSpecSection.vue
new file mode 100644
index 0000000000..ab66bc31b3
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewIssueSpecSection.vue
@@ -0,0 +1,48 @@
+<template>
+ <div class="w-full flex flex-col divide-y">
+ <template v-if="selectedSpec">
+ <div class="w-full flex flex-row items-center py-2 px-2 sm:px-4">
+ <span class="textlabel mr-4">{{ $t("common.database") }}</span>
+ <DatabaseInfo :database="database" />
+ </div>
+ <div class="w-full py-2 px-2 sm:px-4">
+ <ReviewOptionSection />
+ </div>
+ </template>
+ <template v-else>
+ <NoPermissionPlaceholder
+ v-if="placeholder === 'PERMISSION_DENIED'"
+ class="!border-0"
+ />
+ <NoDataPlaceholder v-else class="!border-0" />
+ </template>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { computed } from "vue";
+import DatabaseInfo from "@/components/DatabaseInfo.vue";
+import { databaseForSpec, useIssueContext } from "@/components/IssueV1/logic";
+import NoDataPlaceholder from "@/components/misc/NoDataPlaceholder.vue";
+import NoPermissionPlaceholder from "@/components/misc/NoPermissionPlaceholder.vue";
+import { useCurrentUserV1 } from "@/store";
+import { hasProjectPermissionV2 } from "@/utils";
+import ReviewOptionSection from "./ReviewOptionSection";
+
+const { isCreating, issue, selectedSpec } = useIssueContext();
+const me = useCurrentUserV1();
+
+const database = computed(() => {
+ return databaseForSpec(issue.value, selectedSpec.value);
+});
+
+const placeholder = computed(() => {
+ if (
+ isCreating.value &&
+ !hasProjectPermissionV2(issue.value.projectEntity, me.value, "bb.plans.get")
+ ) {
+ return "PERMISSION_DENIED";
+ }
+ return "NO_DATA";
+});
+</script>
diff --git a/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/ReviewOptionSection.vue b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/ReviewOptionSection.vue
new file mode 100644
index 0000000000..025f058723
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/ReviewOptionSection.vue
@@ -0,0 +1,164 @@
+<template>
+ <div class="w-full flex flex-col">
+ <div class="w-full flex flex-row justify-between items-center mb-1">
+ <span class="textlabel mr-4">{{ $t("issue.data-export.options") }}</span>
+ <div
+ v-if="!isCreating"
+ class="flex flex-row justify-end items-center gap-2"
+ >
+ <NTooltip
+ v-if="!state.isEditing"
+ :disabled="denyEditTaskReasons.length === 0"
+ >
+ <template #trigger>
+ <NButton
+ size="tiny"
+ tag="div"
+ :disabled="denyEditTaskReasons.length > 0"
+ @click="state.isEditing = true"
+ >
+ {{ $t("common.edit") }}
+ </NButton>
+ </template>
+ <template #default>
+ <ErrorList :errors="denyEditTaskReasons" />
+ </template>
+ </NTooltip>
+ <template v-else>
+ <NButton size="tiny" @click="handleSaveEdit">
+ {{ $t("common.save") }}
+ </NButton>
+ <NButton size="tiny" quaternary @click.prevent="handleCancelEdit">
+ {{ $t("common.cancel") }}
+ </NButton>
+ </template>
+ </div>
+ </div>
+ <div class="w-full h-8 flex flex-row justify-start items-center">
+ <span class="textinfolabel inline-block mr-2 !min-w-[64px]">{{
+ $t("issue.sql-review.statement-type")
+ }}</span>
+ <StatementTypeSelector
+ :key="refreshKey"
+ v-model:statement-type="state.statementType"
+ :editable="optionsEditable"
+ />
+ </div>
+ </div>
+</template>
+
+<script lang="ts" setup>
+import { cloneDeep } from "lodash-es";
+import { NButton, NTooltip } from "naive-ui";
+import { computed, watch, reactive, ref } from "vue";
+import { useI18n } from "vue-i18n";
+import {
+ notifyNotEditableLegacyIssue,
+ useIssueContext,
+} from "@/components/IssueV1/logic";
+import { rolloutServiceClient } from "@/grpcweb";
+import { pushNotification, useCurrentUserV1 } from "@/store";
+import { IssueStatus } from "@/types/proto/v1/issue_service";
+import {
+ Plan_ChangeDatabaseConfig_Type,
+ Plan_ChangeDatabaseConfig,
+} from "@/types/proto/v1/rollout_service";
+import { hasProjectPermissionV2 } from "@/utils";
+import StatementTypeSelector from "./StatementTypeSelector.vue";
+import type { StatementType } from "./types";
+
+interface LocalState {
+ statementType: StatementType;
+ isEditing: boolean;
+}
+
+const { t } = useI18n();
+const { issue, isCreating, selectedSpec, events } = useIssueContext();
+const currentUser = useCurrentUserV1();
+const refreshKey = ref(0);
+
+const state = reactive<LocalState>({
+ statementType:
+ (selectedSpec.value.changeDatabaseConfig?.type as StatementType) ||
+ Plan_ChangeDatabaseConfig_Type.MIGRATE,
+ isEditing: false,
+});
+
+const denyEditTaskReasons = computed(() => {
+ const reasons: string[] = [];
+ if (issue.value.status !== IssueStatus.OPEN) {
+ reasons.push("Issue is not open");
+ }
+ if (
+ !hasProjectPermissionV2(
+ issue.value.projectEntity,
+ currentUser.value,
+ "bb.plans.update"
+ )
+ ) {
+ reasons.push("Permission denied");
+ }
+ return reasons;
+});
+
+const optionsEditable = computed(() => {
+ return isCreating.value || state.isEditing;
+});
+
+const handleCancelEdit = () => {
+ state.isEditing = false;
+ state.statementType =
+ (selectedSpec.value.changeDatabaseConfig?.type as StatementType) ||
+ Plan_ChangeDatabaseConfig_Type.MIGRATE;
+ // Trigger a re-render of the child components.
+ refreshKey.value++;
+};
+
+const handleSaveEdit = async () => {
+ const planPatch = cloneDeep(issue.value.planEntity);
+ if (!planPatch) {
+ notifyNotEditableLegacyIssue();
+ return;
+ }
+
+ const distinctSpecIds = new Set([selectedSpec.value.id]);
+ const specsToPatch = planPatch.steps
+ .flatMap((step) => step.specs)
+ .filter((spec) => distinctSpecIds.has(spec.id));
+ for (let i = 0; i < specsToPatch.length; i++) {
+ const spec = specsToPatch[i];
+ const config = spec.changeDatabaseConfig;
+ if (!config) continue;
+ config.type = state.statementType;
+ }
+
+ const updatedPlan = await rolloutServiceClient.updatePlan({
+ plan: planPatch,
+ updateMask: ["steps"],
+ });
+ issue.value.planEntity = updatedPlan;
+
+ events.emit("status-changed", { eager: true });
+ pushNotification({
+ module: "bytebase",
+ style: "SUCCESS",
+ title: t("common.updated"),
+ });
+ handleCancelEdit();
+};
+
+watch(
+ () => state.statementType,
+ () => {
+ if (!isCreating.value) {
+ return;
+ }
+ selectedSpec.value.changeDatabaseConfig =
+ Plan_ChangeDatabaseConfig.fromPartial({
+ ...selectedSpec.value.changeDatabaseConfig,
+ type: state.statementType,
+ });
+ },
+ { deep: true }
+);
+</script>
diff --git a/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/StatementTypeSelector.vue b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/StatementTypeSelector.vue
new file mode 100644
index 0000000000..138c82adb4
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/StatementTypeSelector.vue
@@ -0,0 +1,59 @@
+<template>
+ <NRadioGroup
+ v-if="editable"
+ :value="statementType"
+ @update:value="handleUpdate"
+ >
+ <NRadio
+ v-for="item in availableStatementTypes"
+ :key="item"
+ :value="item"
+ :label="stringifyStatementType(item)"
+ />
+ </NRadioGroup>
+ <template v-else>
+ <span class="text-base">{{ stringifyStatementType(statementType) }}</span>
+ </template>
+</template>
+
+<script setup lang="ts">
+import { NRadioGroup, NRadio } from "naive-ui";
+import { computed } from "vue";
+import { onMounted } from "vue";
+import { Plan_ChangeDatabaseConfig_Type } from "@/types/proto/v1/rollout_service";
+import type { StatementType } from "./types";
+
+const props = defineProps<{
+ statementType: StatementType;
+ editable?: boolean;
+}>();
+
+const emit = defineEmits<{
+ (event: "update:statement-type", value: StatementType): void;
+}>();
+
+const availableStatementTypes = computed((): StatementType[] => [
+ Plan_ChangeDatabaseConfig_Type.MIGRATE,
+ Plan_ChangeDatabaseConfig_Type.DATA,
+]);
+
+const handleUpdate = (value: StatementType) => {
+ emit("update:statement-type", value);
+};
+
+const stringifyStatementType = (statementType: StatementType) => {
+ if (statementType === Plan_ChangeDatabaseConfig_Type.MIGRATE) {
+ return "DDL";
+ } else if (statementType === Plan_ChangeDatabaseConfig_Type.DATA) {
+ return "DML";
+ } else {
+ return "Unknown";
+ }
+};
+
+onMounted(() => {
+ if (!availableStatementTypes.value.includes(props.statementType)) {
+ handleUpdate(availableStatementTypes.value[0]);
+ }
+});
+</script>
diff --git a/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/index.ts b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/index.ts
new file mode 100644
index 0000000000..8fa34a60a1
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/index.ts
@@ -0,0 +1,3 @@
+import ReviewOptionSection from "./ReviewOptionSection.vue";
+
+export default ReviewOptionSection;
diff --git a/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/types.ts b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/types.ts
new file mode 100644
index 0000000000..8e1f40f964
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/ReviewOptionSection/types.ts
@@ -0,0 +1,5 @@
+import type { Plan_ChangeDatabaseConfig_Type } from "@/types/proto/v1/rollout_service";
+
+export type StatementType =
+ | Plan_ChangeDatabaseConfig_Type.MIGRATE
+ | Plan_ChangeDatabaseConfig_Type.DATA;
diff --git a/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/index.ts b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/index.ts
new file mode 100644
index 0000000000..f139491fd6
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/ReviewIssueSpecSection/index.ts
@@ -0,0 +1,3 @@
+import ReviewIssueSpecSection from "./ReviewIssueSpecSection.vue";
+
+export default ReviewIssueSpecSection;
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
index a7ecb1b8cb..4e80fe39d2 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
@@ -45,7 +45,7 @@ import { computed, ref } from "vue";
import { SQLCheckPanel } from "@/components/SQLCheck";
import type { Advice } from "@/types/proto/v1/sql_service";
import { Advice_Status } from "@/types/proto/v1/sql_service";
-import { databaseForTask, useIssueContext } from "../../logic";
+import { databaseForSpec, databaseForTask, useIssueContext } from "../../logic";
import OnlineMigrationAdviceExtra from "./OnlineMigrationAdviceExtra.vue";
const props = defineProps<{
@@ -57,11 +57,15 @@ defineEmits<{
(event: "click"): void;
}>();
-const { issue, selectedTask, events } = useIssueContext();
+const { issue, selectedTask, selectedSpec, events } = useIssueContext();
const showDetailPanel = ref(false);
+const rolloutMode = computed(() => !!issue.value.rollout);
+
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return rolloutMode.value
+ ? databaseForTask(issue.value, selectedTask.value)
+ : databaseForSpec(issue.value, selectedSpec.value);
});
const status = computed(() => {
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
index fccc570a5a..7f059c6ca2 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
@@ -38,30 +38,47 @@
<script lang="ts" setup>
import { computed } from "vue";
-import { useTaskSheet } from "@/components/IssueV1/components/StatementSection/useTaskSheet";
-import { useIssueContext, databaseForTask ,specForTask} from "@/components/IssueV1/logic";
+import { useRoute } from "vue-router";
+import {
+ useIssueContext,
+ databaseForTask,
+ specForTask,
+ databaseForSpec,
+} from "@/components/IssueV1/logic";
import { SQLCheckButton } from "@/components/SQLCheck";
+import type { TemplateType } from "@/plugins";
import { TaskTypeListWithStatement } from "@/types";
-import { Plan_ChangeDatabaseConfig_Type, Task_Type } from "@/types/proto/v1/rollout_service";
+import {
+ Plan_ChangeDatabaseConfig_Type,
+ Task_Type,
+} from "@/types/proto/v1/rollout_service";
import { CheckRequest_ChangeType } from "@/types/proto/v1/sql_service";
import type { Defer } from "@/utils/util";
+import { useEditSheet } from "../StatementSection/useEditSheet";
import OnlineMigrationAdviceExtra from "./OnlineMigrationAdviceExtra.vue";
import SQLCheckBadge from "./SQLCheckBadge.vue";
-const { issue, selectedTask, events } = useIssueContext();
-const { sheetStatement } = useTaskSheet();
+const route = useRoute();
+const { issue, selectedTask, selectedSpec, events } = useIssueContext();
+const { sheetStatement } = useEditSheet();
+
+const rolloutMode = computed(() => !!issue.value.rollout);
+
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return rolloutMode.value
+ ? databaseForTask(issue.value, selectedTask.value)
+ : databaseForSpec(issue.value, selectedSpec.value);
});
-const getStatement = async () => {
- return {
- statement: sheetStatement.value,
- errors: [],
- };
-};
+const issueTemplate = computed(() => {
+ return route.query.template as TemplateType;
+});
const show = computed(() => {
+ if (issueTemplate.value === "bb.issue.sql-review") {
+ return true;
+ }
+
const type = selectedTask.value.type;
if (type === Task_Type.DATABASE_SCHEMA_BASELINE) {
return false;
@@ -72,6 +89,13 @@ const show = computed(() => {
return false;
});
+const getStatement = async () => {
+ return {
+ statement: sheetStatement.value,
+ errors: [],
+ };
+};
+
const handleToggleOnlineMigration = (on: boolean, confirm: Defer<boolean>) => {
if (on) {
events.emit("toggle-online-migration", {
diff --git a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/ReviewSection.vue b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/ReviewSection.vue
index 652219e0ce..95fa5925fa 100644
--- a/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/ReviewSection.vue
+++ b/frontend/src/components/IssueV1/components/Sidebar/ReviewSection/ReviewSection.vue
@@ -1,7 +1,7 @@
<template>
<div v-if="!isCreating" class="flex flex-col gap-y-2">
<div class="w-full flex flex-row justify-between items-center gap-2">
- <NTooltip :disabled="!showApprovalTooltip" placement="bottom">
+ <NTooltip placement="bottom">
<template #trigger>
<div>
<div class="textlabel flex items-center gap-x-1">
@@ -20,7 +20,7 @@
<RiskLevelTag />
</div>
- <div class="flex-1" :class="showApprovalTooltip && 'min-w-[14rem]'">
+ <div class="flex-1 min-w-[14rem]">
<div
v-if="!ready"
class="flex items-center gap-x-2 text-sm text-control-placeholder"
@@ -108,14 +108,6 @@ const retryFindingApprovalFlow = async () => {
}
};
-const showApprovalTooltip = computed(() => {
- // Don't show the tooltip if the issue type is grant request.
- if (isGrantRequestIssue(issue.value)) {
- return false;
- }
- return true;
-});
-
defineExpose({
shown: computed(() => {
return true; // Always shown
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
index 8bf991ed84..e6fff91382 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/EditorView.vue
@@ -52,13 +52,13 @@
<template v-if="!state.isEditing">
<template v-if="shouldShowEditButton">
<!-- for small size sheets, show full featured UI editing button group -->
- <NTooltip :disabled="denyEditTaskReasons.length === 0">
+ <NTooltip :disabled="denyEditStatementReasons.length === 0">
<template #trigger>
<NButton
- v-if="!isTaskSheetOversize"
+ v-if="!isSheetOversize"
size="tiny"
tag="div"
- :disabled="denyEditTaskReasons.length > 0"
+ :disabled="denyEditStatementReasons.length > 0"
@click.prevent="beginEdit"
>
{{ $t("common.edit") }}
@@ -74,7 +74,7 @@
</SQLUploadButton>
</template>
<template #default>
- <ErrorList :errors="denyEditTaskReasons" />
+ <ErrorList :errors="denyEditStatementReasons" />
</template>
</NTooltip>
</template>
@@ -113,7 +113,7 @@
</div>
<BBAttention
- v-if="isTaskSheetOversize"
+ v-if="isSheetOversize"
type="warning"
:title="$t('issue.statement-from-sheet-warning')"
>
@@ -208,7 +208,7 @@
<div>sheetStatement.length: {{ sheetStatement.length }}</div>
<div>sheet.title: {{ sheet?.title }}</div>
<div>sheet.content.length: {{ sheet?.content?.length }}</div>
- <div>isTaskSheetOversize: {{ isTaskSheetOversize }}</div>
+ <div>isTaskSheetOversize: {{ isSheetOversize }}</div>
<div>isEditorReadonly: {{ isEditorReadonly }}</div>
<div>state.isEditing: {{ state.isEditing }}</div>
</div>
@@ -237,6 +237,7 @@ import {
isDeploymentConfigChangeTaskV1,
isGroupingChangeTaskV1,
databaseEngineForSpec,
+ databaseForSpec,
} from "@/components/IssueV1/logic";
import { MonacoEditor } from "@/components/MonacoEditor";
import { extensionNameOfLanguage } from "@/components/MonacoEditor/utils";
@@ -251,9 +252,14 @@ import {
useSheetV1Store,
} from "@/store";
import type { SQLDialect } from "@/types";
-import { TaskTypeListWithStatement, dialectOfEngineV1 } from "@/types";
+import {
+ EMPTY_ID,
+ TaskTypeListWithStatement,
+ dialectOfEngineV1,
+} from "@/types";
+import { IssueStatus } from "@/types/proto/v1/issue_service";
import { TenantMode } from "@/types/proto/v1/project_service";
-import type { Plan_Spec, Task } from "@/types/proto/v1/rollout_service";
+import type { Task } from "@/types/proto/v1/rollout_service";
import { Task_Type } from "@/types/proto/v1/rollout_service";
import { Sheet } from "@/types/proto/v1/sheet_service";
import {
@@ -264,8 +270,6 @@ import {
sheetNameOfTaskV1,
useInstanceV1EditorLanguage,
getStatementSize,
- isDatabaseChangeRelatedIssue,
- isDatabaseDataExportIssue,
} from "@/utils";
import { useSQLAdviceMarkers } from "../useSQLAdviceMarkers";
import FormatOnSaveCheckbox from "./FormatOnSaveCheckbox.vue";
@@ -281,7 +285,7 @@ type LocalState = EditState & {
const { t } = useI18n();
const route = useRoute();
const currentUser = useCurrentUserV1();
-const { events, isCreating, issue, selectedTask, formatOnSave } =
+const { events, isCreating, issue, selectedTask, selectedSpec, formatOnSave } =
useIssueContext();
const project = computed(() => issue.value.projectEntity);
const dialog = useDialog();
@@ -297,15 +301,19 @@ const state = reactive<LocalState>({
isUploadingFile: false,
});
+const rolloutMode = computed(() => !!issue.value.rollout);
+
const database = computed(() => {
- return databaseForTask(issue.value, selectedTask.value);
+ return rolloutMode.value
+ ? databaseForTask(issue.value, selectedTask.value)
+ : databaseForSpec(issue.value, selectedSpec.value);
});
const language = useInstanceV1EditorLanguage(
computed(() => database.value.instanceEntity)
);
const filename = computed(() => {
- const name = selectedTask.value.name || uuidv1();
+ const name = (rolloutMode.value && selectedTask.value.name) || uuidv1();
const ext = extensionNameOfLanguage(language.value);
return `${name}.${ext}`;
});
@@ -353,7 +361,7 @@ const isEditorReadonly = computed(() => {
return (
!state.isEditing ||
// !allowEditStatement.value || // TODO
- isTaskSheetOversize.value ||
+ isSheetOversize.value ||
// isGroupingChangeIssue(issue.value as Issue) || // TODO
false // TODO
);
@@ -367,7 +375,7 @@ const {
reset: resetTempEditState,
} = useTempEditState(state);
-const isTaskSheetOversize = computed(() => {
+const isSheetOversize = computed(() => {
if (isCreating.value) return false;
if (state.isEditing) return false;
if (!sheetReady.value) return false;
@@ -377,12 +385,14 @@ const isTaskSheetOversize = computed(() => {
);
});
-const denyEditTaskReasons = computed(() => {
- return allowUserToEditStatementForTask(
- issue.value,
- selectedTask.value,
- currentUser.value
- );
+const denyEditStatementReasons = computed(() => {
+ return rolloutMode.value
+ ? allowUserToEditStatementForTask(
+ issue.value,
+ selectedTask.value,
+ currentUser.value
+ )
+ : [];
});
const shouldShowEditButton = computed(() => {
@@ -390,12 +400,15 @@ const shouldShowEditButton = computed(() => {
if (isCreating.value) {
return false;
}
+ // If the issue is not open, don't show the edit button.
+ if (issue.value.status !== IssueStatus.OPEN) {
+ return false;
+ }
// Will show another button group as [Upload][Cancel][Save]
// while editing
if (state.isEditing) {
return false;
}
-
return true;
});
@@ -403,6 +416,9 @@ const allowApplyTaskStateToOthers = computed(() => {
if (!isCreating.value) {
return false;
}
+ if (!rolloutMode.value) {
+ return false;
+ }
if (project.value.tenantMode === TenantMode.TENANT_MODE_ENABLED) {
return !isDeploymentConfigChangeTaskV1(issue.value, selectedTask.value);
}
@@ -644,43 +660,54 @@ const applyTaskStateToOthers = async () => {
};
const updateStatement = async (statement: string) => {
- // - 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;
- }
-
const planPatch = cloneDeep(issue.value.planEntity);
if (!planPatch) {
notifyNotEditableLegacyIssue();
return;
}
- const specs: Plan_Spec[] = [];
- tasks.forEach((task) => {
- const spec = specForTask(planPatch, task);
- if (spec) {
- specs.push(spec);
+ 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;
}
- });
- const distinctSpecIds = new Set(specs.map((s) => s.id));
- if (distinctSpecIds.size === 0) {
+
+ 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);
+ }
+
+ const distinctSpecsIds = new Set(
+ specsIdList.filter((id) => id && id !== String(EMPTY_ID))
+ );
+ if (distinctSpecsIds.size === 0) {
notifyNotEditableLegacyIssue();
return;
}
const specsToPatch = planPatch.steps
.flatMap((step) => step.specs)
- .filter((spec) => distinctSpecIds.has(spec.id));
-
+ .filter((spec) => distinctSpecsIds.has(spec.id));
const sheet = Sheet.fromPartial({
...createEmptyLocalSheet(),
title: issue.value.title,
@@ -695,9 +722,9 @@ const updateStatement = async (statement: string) => {
for (let i = 0; i < specsToPatch.length; i++) {
const spec = specsToPatch[i];
let config = undefined;
- if (isDatabaseChangeRelatedIssue(issue.value)) {
+ if (spec.changeDatabaseConfig) {
config = spec.changeDatabaseConfig;
- } else if (isDatabaseDataExportIssue(issue.value)) {
+ } else if (spec.exportDataConfig) {
config = spec.exportDataConfig;
}
if (!config) continue;
diff --git a/frontend/src/components/IssueV1/components/StatementSection/EditorView/useTempEditState.ts b/frontend/src/components/IssueV1/components/StatementSection/EditorView/useTempEditState.ts
index fb477e3563..e95e9e54e2 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/EditorView/useTempEditState.ts
+++ b/frontend/src/components/IssueV1/components/StatementSection/EditorView/useTempEditState.ts
@@ -1,7 +1,7 @@
import { computed, nextTick, ref, watch } from "vue";
import { UNKNOWN_ID } from "@/types";
import { useIssueContext } from "../../../logic";
-import { useTaskSheet } from "../useTaskSheet";
+import { useEditSheet } from "../useEditSheet";
export type EditState = {
isEditing: boolean;
@@ -9,14 +9,20 @@ export type EditState = {
};
export const useTempEditState = (state: EditState) => {
- const { isCreating, selectedTask } = useIssueContext();
- const { sheet, sheetName, sheetReady, sheetStatement } = useTaskSheet();
+ const { isCreating, issue, selectedTask } = useIssueContext();
+ const { sheet, sheetName, sheetReady, sheetStatement } = useEditSheet();
+ const rolloutMode = computed(() => !!issue.value.rollout);
let stopWatching = () => {
// noop
};
const startWatching = () => {
+ // In non-rollout mode, we don't have the task sheet.
+ if (!rolloutMode.value) {
+ return () => {};
+ }
+
const tempEditStateMap = new Map<string, EditState>();
const isSwitchingTask = ref(false);
@@ -25,6 +31,7 @@ export const useTempEditState = (state: EditState) => {
// So we need to watch the id instead of the object ref.
const selectedTaskUID = computed((): string => {
if (isCreating.value) return String(UNKNOWN_ID);
+ if (!rolloutMode.value) return String(UNKNOWN_ID);
return selectedTask.value.uid;
});
diff --git a/frontend/src/components/IssueV1/components/StatementSection/StatementSection.vue b/frontend/src/components/IssueV1/components/StatementSection/StatementSection.vue
index 16b9288010..8aa81192bf 100644
--- a/frontend/src/components/IssueV1/components/StatementSection/StatementSection.vue
+++ b/frontend/src/components/IssueV1/components/StatementSection/StatementSection.vue
@@ -10,13 +10,13 @@ import { computed } from "vue";
import { ref } from "vue";
import { nextTick } from "vue";
import { useRouter } from "vue-router";
-import { TaskTypeListWithStatement } from "@/types";
+import { EMPTY_ID, TaskTypeListWithStatement } from "@/types";
import { Task_Type } from "@/types/proto/v1/rollout_service";
import { useIssueContext } from "../../logic";
import EditorView from "./EditorView";
import SDLView from "./SDLView";
-const { isCreating, selectedTask } = useIssueContext();
+const { isCreating, selectedTask, selectedSpec } = useIssueContext();
const editorViewRef = ref<InstanceType<typeof EditorView>>();
const router = useRouter();
@@ -24,15 +24,20 @@ const router = useRouter();
type ViewMode = "NONE" | "EDITOR" | "SDL";
const viewMode = computed((): ViewMode => {
- const task = selectedTask.value;
- const { type } = task;
- if (type === Task_Type.DATABASE_SCHEMA_UPDATE_SDL) {
- return "SDL";
+ if (selectedTask.value.uid !== String(EMPTY_ID)) {
+ const task = selectedTask.value;
+ const { type } = task;
+ if (type === Task_Type.DATABASE_SCHEMA_UPDATE_SDL) {
+ return "SDL";
+ }
+ if (type === Task_Type.DATABASE_SCHEMA_BASELINE) {
+ return isCreating.value ? "EDITOR" : "NONE";
+ }
+ if (TaskTypeListWithStatement.includes(type)) {
+ return "EDITOR";
+ }
}
- if (type === Task_Type.DATABASE_SCHEMA_BASELINE) {
- return isCreating.value ? "EDITOR" : "NONE";
- }
- if (TaskTypeListWithStatement.includes(type)) {
+ if (selectedSpec.value.id !== String(EMPTY_ID)) {
return "EDITOR";
}
diff --git a/frontend/src/components/IssueV1/components/StatementSection/useEditSheet.ts b/frontend/src/components/IssueV1/components/StatementSection/useEditSheet.ts
new file mode 100644
index 0000000000..56bf8528f1
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/StatementSection/useEditSheet.ts
@@ -0,0 +1,11 @@
+import { useIssueContext } from "../../logic";
+import { useSpecSheet } from "./useSpecSheet";
+import { useTaskSheet } from "./useTaskSheet";
+
+export const useEditSheet = () => {
+ const { issue } = useIssueContext();
+ const taskSheet = useTaskSheet();
+ const specSheet = useSpecSheet();
+
+ return issue.value.rollout ? taskSheet : specSheet;
+};
diff --git a/frontend/src/components/IssueV1/components/StatementSection/useSpecSheet.ts b/frontend/src/components/IssueV1/components/StatementSection/useSpecSheet.ts
new file mode 100644
index 0000000000..33a3031673
--- /dev/null
+++ b/frontend/src/components/IssueV1/components/StatementSection/useSpecSheet.ts
@@ -0,0 +1,55 @@
+import { computedAsync } from "@vueuse/core";
+import { computed, ref } from "vue";
+import { useSheetV1Store } from "@/store";
+import {
+ extractSheetUID,
+ getSheetStatement,
+ setSheetStatement,
+ sheetNameOfSpec,
+} from "@/utils";
+import { getLocalSheetByName, useIssueContext } from "../../logic";
+
+export const useSpecSheet = () => {
+ const sheetStore = useSheetV1Store();
+ const { selectedSpec } = useIssueContext();
+
+ const sheetName = computed(() => {
+ return sheetNameOfSpec(selectedSpec.value);
+ });
+ const isFetchingSheet = ref(false);
+ const sheetReady = computed(() => {
+ return !isFetchingSheet.value;
+ });
+ const sheet = computedAsync(
+ async () => {
+ const name = sheetName.value;
+ const uid = extractSheetUID(name);
+ if (uid.startsWith("-")) {
+ return getLocalSheetByName(name);
+ }
+
+ return sheetStore.getOrFetchSheetByName(name);
+ },
+ undefined,
+ {
+ evaluating: isFetchingSheet,
+ }
+ );
+ const sheetStatement = computed({
+ get() {
+ if (!sheetReady.value || !sheet.value) return "";
+ return getSheetStatement(sheet.value);
+ },
+ set(statement) {
+ if (!sheetReady.value || !sheet.value) return;
+ setSheetStatement(sheet.value, statement);
+ },
+ });
+
+ return {
+ sheet,
+ sheetName,
+ sheetReady,
+ sheetStatement,
+ };
+};
diff --git a/frontend/src/components/IssueV1/components/index.ts b/frontend/src/components/IssueV1/components/index.ts
index ad79525dc0..0ffa2b572b 100644
--- a/frontend/src/components/IssueV1/components/index.ts
+++ b/frontend/src/components/IssueV1/components/index.ts
@@ -5,6 +5,7 @@ import HeaderSection from "./HeaderSection";
import IssueCommentSection from "./IssueCommentSection";
import IssueSearch from "./IssueSearch";
import PlanCheckSection from "./PlanCheckSection";
+import ReviewIssueSpecSection from "./ReviewIssueSpecSection";
import SQLCheckSection from "./SQLCheckSection";
import Sidebar from "./Sidebar";
import StageSection from "./StageSection";
@@ -28,4 +29,5 @@ export {
SQLCheckSection,
DataExportSection,
IssueCommentSection,
+ ReviewIssueSpecSection,
};
diff --git a/frontend/src/components/IssueV1/logic/action/issue.ts b/frontend/src/components/IssueV1/logic/action/issue.ts
index 4ec0bd6971..a83e4878fd 100644
--- a/frontend/src/components/IssueV1/logic/action/issue.ts
+++ b/frontend/src/components/IssueV1/logic/action/issue.ts
@@ -2,7 +2,10 @@ import type { ButtonProps } from "naive-ui";
import { t } from "@/plugins/i18n";
import type { ComposedIssue } from "@/types";
import type { User } from "@/types/proto/v1/auth_service";
-import { IssueStatus } from "@/types/proto/v1/issue_service";
+import {
+ IssueStatus,
+ Issue_Approver_Status,
+} from "@/types/proto/v1/issue_service";
import {
extractUserResourceName,
flattenTaskV1List,
@@ -38,7 +41,8 @@ export const PossibleIssueStatusActionMap: Record<
};
export const getApplicableIssueStatusActionList = (
- issue: ComposedIssue
+ issue: ComposedIssue,
+ reviewStatus?: Issue_Approver_Status
): IssueStatusAction[] => {
const list = PossibleIssueStatusActionMap[issue.status];
return list.filter((action) => {
@@ -55,6 +59,15 @@ export const getApplicableIssueStatusActionList = (
return false;
}
}
+ // For SQL review issues, only allow RESOLVE when the review is approved.
+ if (!issue.rollout) {
+ if (
+ action === "RESOLVE" &&
+ reviewStatus !== Issue_Approver_Status.APPROVED
+ ) {
+ return false;
+ }
+ }
return true;
});
};
diff --git a/frontend/src/components/IssueV1/logic/base.ts b/frontend/src/components/IssueV1/logic/base.ts
index 4b22e38c74..a638ac919c 100644
--- a/frontend/src/components/IssueV1/logic/base.ts
+++ b/frontend/src/components/IssueV1/logic/base.ts
@@ -5,11 +5,16 @@ import { computed } from "vue";
import { useRoute, useRouter } from "vue-router";
import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
import { useUIStateStore } from "@/store";
-import { emptyStage, emptyTask, TaskTypeListWithStatement } from "@/types";
+import {
+ EMPTY_ID,
+ emptyStage,
+ emptyTask,
+ TaskTypeListWithStatement,
+} from "@/types";
import { TenantMode } from "@/types/proto/v1/project_service";
import type { Plan_Spec, Stage, Task } from "@/types/proto/v1/rollout_service";
import { Task_Type } from "@/types/proto/v1/rollout_service";
-import { unknownPlanSpec } from "@/types/v1/issue/plan";
+import { emptyPlanSpec } from "@/types/v1/issue/plan";
import {
activeStageInRollout,
activeTaskInRollout,
@@ -76,11 +81,11 @@ export const useBaseIssueContext = (
}
// Otherwise, fallback to selected task's spec.
- if (selectedTask.value) {
- return specForTask(plan.value, selectedTask.value) || unknownPlanSpec();
+ if (selectedTask.value && selectedTask.value.uid !== String(EMPTY_ID)) {
+ return specForTask(plan.value, selectedTask.value) || emptyPlanSpec();
}
// Fallback to first spec.
- return first(specs.value) || unknownPlanSpec();
+ return first(specs.value) || emptyPlanSpec();
});
const selectedStage = computed((): Stage => {
const stageSlug = route.query.stage as string;
diff --git a/frontend/src/components/IssueV1/logic/initialize/create.ts b/frontend/src/components/IssueV1/logic/initialize/create.ts
index 3fed07e809..d7f5c34a46 100644
--- a/frontend/src/components/IssueV1/logic/initialize/create.ts
+++ b/frontend/src/components/IssueV1/logic/initialize/create.ts
@@ -86,9 +86,16 @@ export const createIssueSkeleton = async (
issue.plan = plan.name;
issue.planEntity = plan;
- const rollout = await previewPlan(plan, params);
- issue.rollout = rollout.name;
- issue.rolloutEntity = rollout;
+ const issueTemplate = query.template as TemplateType | undefined;
+ // Don't initial rollout for SQL review issue.
+ if (issueTemplate === "bb.issue.sql-review") {
+ issue.rollout = "";
+ issue.rolloutEntity = undefined;
+ } else {
+ const rollout = await previewPlan(plan, params);
+ issue.rollout = rollout.name;
+ issue.rolloutEntity = rollout;
+ }
const description = query.description;
if (description) {
@@ -390,6 +397,15 @@ export const buildSpecForTarget = async (
sheet,
});
}
+ if (template === "bb.issue.sql-review") {
+ // SQL review issues is reusing the same plan config type as changing database.
+ spec.changeDatabaseConfig = Plan_ChangeDatabaseConfig.fromJSON({
+ target,
+ sheet,
+ // TODO(steven): let user choose type in UI.
+ type: Plan_ChangeDatabaseConfig_Type.DATA,
+ });
+ }
return spec;
};
@@ -600,6 +616,31 @@ export const isValidStage = (stage: Stage): boolean => {
return true;
};
+export const isValidSpec = (spec: Plan_Spec): boolean => {
+ if (spec.changeDatabaseConfig || spec.exportDataConfig) {
+ const sheetName = sheetNameForSpec(spec);
+ if (!sheetName) {
+ return false;
+ }
+ const uid = extractSheetUID(sheetName);
+ if (uid.startsWith("-")) {
+ const sheet = getLocalSheetByName(sheetName);
+ if (getSheetStatement(sheet).length === 0) {
+ return false;
+ }
+ } else {
+ const sheet = useSheetV1Store().getSheetByName(sheetName);
+ if (!sheet) {
+ return false;
+ }
+ if (getSheetStatement(sheet).length === 0) {
+ return false;
+ }
+ }
+ }
+ return true;
+};
+
const prepareDatabaseUIDList = async (
// databaseIdList is a list of database identifiers. Including UID and resource id.
// e.g. ["103", "205", "instances/mysql/databases/employee"]
diff --git a/frontend/src/components/Project/ProjectSidebarV1.vue b/frontend/src/components/Project/ProjectSidebarV1.vue
index ad562db73d..e24972dc4e 100644
--- a/frontend/src/components/Project/ProjectSidebarV1.vue
+++ b/frontend/src/components/Project/ProjectSidebarV1.vue
@@ -19,6 +19,7 @@ import {
Settings,
RefreshCcw,
PencilRuler,
+ SearchCodeIcon,
DownloadIcon,
} from "lucide-vue-next";
import { computed, h } from "vue";
@@ -44,6 +45,7 @@ import projectV1Routes, {
PROJECT_V1_ROUTE_DEPLOYMENT_CONFIG,
PROJECT_V1_ROUTE_EXPORT_CENTER,
PROJECT_V1_ROUTE_AUDIT_LOGS,
+ PROJECT_V1_ROUTE_REVIEW_CENTER,
} from "@/router/dashboard/projectV1";
import { useCurrentUserV1 } from "@/store";
import { getProjectName } from "@/store/modules/v1/common";
@@ -202,6 +204,13 @@ const projectSidebarItemList = computed((): ProjectSidebarItem[] => {
type: "div",
hide: isDefaultProject.value,
},
+ {
+ title: t("review-center.self"),
+ icon: h(SearchCodeIcon),
+ path: PROJECT_V1_ROUTE_REVIEW_CENTER,
+ type: "div",
+ hide: isDefaultProject.value,
+ },
{
title: t("export-center.self"),
icon: h(DownloadIcon),
diff --git a/frontend/src/components/ReviewIssuePrepForm/ReviewIssuePrepForm.vue b/frontend/src/components/ReviewIssuePrepForm/ReviewIssuePrepForm.vue
new file mode 100644
index 0000000000..60e7502cc2
--- /dev/null
+++ b/frontend/src/components/ReviewIssuePrepForm/ReviewIssuePrepForm.vue
@@ -0,0 +1,248 @@
+<template>
+ <DrawerContent>
+ <template #header>
+ <div class="flex flex-col gap-y-1">
+ <span>
+ {{ $t("review-center.review-sql") }}
+ </span>
+ </div>
+ </template>
+
+ <div
+ class="space-y-4 h-full w-[calc(100vw-8rem)] lg:w-[60rem] max-w-[calc(100vw-8rem)] overflow-x-auto"
+ >
+ <div v-if="ready">
+ <div class="space-y-3">
+ <div class="w-full flex items-center space-x-2">
+ <AdvancedSearch
+ v-model:params="state.params"
+ :placeholder="$t('database.filter-database')"
+ :scope-options="scopeOptions"
+ />
+ <DatabaseLabelFilter
+ v-model:selected="state.selectedLabels"
+ :database-list="rawDatabaseList"
+ :placement="'left-start'"
+ />
+ </div>
+ <DatabaseV1Table
+ mode="ALL_SHORT"
+ :database-list="filteredDatabaseList"
+ :show-sql-editor-button="false"
+ :single-selection="true"
+ @update:selected-databases="handleDatabasesSelectionChanged"
+ />
+ </div>
+ </div>
+ <div
+ v-if="!ready"
+ class="w-full h-[20rem] flex items-center justify-center"
+ >
+ <BBSpin />
+ </div>
+ </div>
+
+ <template #footer>
+ <div class="flex-1 flex items-center justify-between">
+ <div></div>
+
+ <div class="flex items-center justify-end gap-x-3">
+ <NButton @click.prevent="cancel">
+ {{ $t("common.cancel") }}
+ </NButton>
+ <NButton
+ type="primary"
+ :disabled="!state.selectedDatabaseUid"
+ @click="navigateToIssuePage"
+ >
+ {{ $t("common.next") }}
+ </NButton>
+ </div>
+ </div>
+ </template>
+ </DrawerContent>
+</template>
+
+<script lang="ts" setup>
+import { NButton } from "naive-ui";
+import { computed, reactive } from "vue";
+import { useRouter } from "vue-router";
+import AdvancedSearch from "@/components/AdvancedSearch";
+import DatabaseV1Table from "@/components/v2/Model/DatabaseV1Table";
+import type { TemplateType } from "@/plugins";
+import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
+import {
+ useCurrentUserV1,
+ useSearchDatabaseV1List,
+ useDatabaseV1Store,
+ useProjectV1Store,
+} from "@/store";
+import type { ComposedDatabase } from "@/types";
+import { UNKNOWN_ID, DEFAULT_PROJECT_V1_NAME } from "@/types";
+import { State } from "@/types/proto/v1/common";
+import type { SearchParams } from "@/utils";
+import {
+ filterDatabaseV1ByKeyword,
+ sortDatabaseV1List,
+ extractEnvironmentResourceName,
+ extractInstanceResourceName,
+ generateIssueName,
+ extractProjectResourceName,
+} from "@/utils";
+import { useCommonSearchScopeOptions } from "../AdvancedSearch/useCommonSearchScopeOptions";
+import { DatabaseLabelFilter, DrawerContent } from "../v2";
+
+type LocalState = {
+ label: string;
+ selectedDatabaseUid?: string;
+ selectedLabels: { key: string; value: string }[];
+ params: SearchParams;
+};
+
+const props = defineProps({
+ projectId: {
+ type: String,
+ default: undefined,
+ },
+});
+
+const emit = defineEmits(["dismiss"]);
+
+const router = useRouter();
+const currentUserV1 = useCurrentUserV1();
+const projectV1Store = useProjectV1Store();
+const databaseV1Store = useDatabaseV1Store();
+
+const state = reactive<LocalState>({
+ label: "environment",
+ selectedLabels: [],
+ params: {
+ query: "",
+ scopes: [],
+ },
+});
+
+const scopeOptions = useCommonSearchScopeOptions(
+ computed(() => state.params),
+ ["project", "instance", "environment"]
+);
+
+const selectedProject = computed(() => {
+ if (props.projectId) {
+ return projectV1Store.getProjectByUID(props.projectId);
+ }
+ const filter = state.params.scopes.find(
+ (scope) => scope.id === "project"
+ )?.value;
+ if (filter) {
+ return projectV1Store.getProjectByName(`projects/${filter}`);
+ }
+ return undefined;
+});
+
+const selectedInstance = computed(() => {
+ return (
+ state.params.scopes.find((scope) => scope.id === "instance")?.value ??
+ `${UNKNOWN_ID}`
+ );
+});
+
+const selectedEnvironment = computed(() => {
+ return (
+ state.params.scopes.find((scope) => scope.id === "environment")?.value ??
+ `${UNKNOWN_ID}`
+ );
+});
+
+const { ready } = useSearchDatabaseV1List({
+ filter: "instance = instances/-",
+});
+
+const rawDatabaseList = computed(() => {
+ let list: ComposedDatabase[] = [];
+ if (selectedProject.value) {
+ list = databaseV1Store.databaseListByProject(selectedProject.value.name);
+ } else {
+ list = databaseV1Store.databaseListByUser(currentUserV1.value);
+ }
+ list = list.filter(
+ (db) =>
+ db.syncState == State.ACTIVE && db.project !== DEFAULT_PROJECT_V1_NAME
+ );
+ return list;
+});
+
+const filteredDatabaseList = computed(() => {
+ let list = [...rawDatabaseList.value];
+
+ list = list.filter((db) => {
+ if (selectedEnvironment.value !== `${UNKNOWN_ID}`) {
+ return (
+ extractEnvironmentResourceName(db.effectiveEnvironment) ===
+ selectedEnvironment.value
+ );
+ }
+ if (selectedInstance.value !== `${UNKNOWN_ID}`) {
+ return (
+ extractInstanceResourceName(db.instance) === selectedInstance.value
+ );
+ }
+ return filterDatabaseV1ByKeyword(db, state.params.query.trim(), [
+ "name",
+ "environment",
+ "instance",
+ "project",
+ ]);
+ });
+
+ const labels = state.selectedLabels;
+ if (labels.length > 0) {
+ list = list.filter((db) => {
+ return labels.some((kv) => db.labels[kv.key] === kv.value);
+ });
+ }
+
+ return sortDatabaseV1List(list);
+});
+
+const handleDatabasesSelectionChanged = (
+ selectedDatabaseNameList: Set<string>
+): void => {
+ if (selectedDatabaseNameList.size !== 1) {
+ return;
+ }
+ state.selectedDatabaseUid = databaseV1Store.getDatabaseByName(
+ Array.from(selectedDatabaseNameList)[0]
+ )?.uid;
+};
+
+const navigateToIssuePage = async () => {
+ if (!state.selectedDatabaseUid) {
+ return;
+ }
+
+ const selectedDatabase = filteredDatabaseList.value.find(
+ (db) => db.uid === state.selectedDatabaseUid
+ ) as ComposedDatabase;
+
+ const project = selectedDatabase?.projectEntity;
+ const issueType: TemplateType = "bb.issue.sql-review";
+ const query: Record<string, any> = {
+ template: issueType,
+ name: generateIssueName(issueType, [selectedDatabase.databaseName]),
+ databaseList: selectedDatabase.name,
+ };
+ router.push({
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(project.name),
+ issueSlug: "create",
+ },
+ query,
+ });
+};
+
+const cancel = () => {
+ emit("dismiss");
+};
+</script>
diff --git a/frontend/src/components/ReviewIssuePrepForm/index.ts b/frontend/src/components/ReviewIssuePrepForm/index.ts
new file mode 100644
index 0000000000..d22af7d8f6
--- /dev/null
+++ b/frontend/src/components/ReviewIssuePrepForm/index.ts
@@ -0,0 +1,3 @@
+import ReviewIssuePrepForm from "./ReviewIssuePrepForm.vue";
+
+export default ReviewIssuePrepForm;
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index a21f537d2c..d036d8ae0d 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -274,7 +274,8 @@
"project-member": "Project member",
"leave-without-saving": "Leave without saving?",
"configure-now": "Configure now",
- "connection": "Connection"
+ "connection": "Connection",
+ "permission-denied": "Permission denied"
},
"error-page": {
"go-back-home": "Go back home"
@@ -1217,6 +1218,9 @@
},
"affected-rows-n": "Affected rows: {n}"
}
+ },
+ "sql-review": {
+ "statement-type": "Statement type"
}
},
"alter-schema": {
@@ -3310,6 +3314,10 @@
"self": "Export Center",
"permission-denied": "Permission denied"
},
+ "review-center": {
+ "self": "Review Center",
+ "review-sql": "Review SQL"
+ },
"schema-designer": {
"self": "Schema Designer",
"schema-design": "Schema Design",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index e733597465..bba852444a 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -274,7 +274,8 @@
"project-member": "Miembro del proyecto",
"leave-without-saving": "¿Salir sin ahorrar?",
"configure-now": "Configurar ahora",
- "connection": "Conexión"
+ "connection": "Conexión",
+ "permission-denied": "Permiso denegado"
},
"error-page": {
"go-back-home": "Volver al inicio"
@@ -1217,6 +1218,9 @@
},
"affected-rows-n": "Filas afectadas: {n}"
}
+ },
+ "sql-review": {
+ "statement-type": "Tipo de declaración"
}
},
"alter-schema": {
@@ -3310,6 +3314,10 @@
"self": "centro de exportacion",
"permission-denied": "Permiso denegado"
},
+ "review-center": {
+ "self": "Centro de revisión",
+ "review-sql": "Revisar SQL"
+ },
"schema-designer": {
"self": "Diseñador de esquemas",
"schema-design": "Esquema diseñar",
@@ -3515,4 +3523,4 @@
"self": "Última actualización"
}
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index 8a5b4885ba..886b2f8ce1 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -274,7 +274,8 @@
"project-member": "プロジェクトメンバー",
"leave-without-saving": "変更を保存していませんか?",
"configure-now": "今すぐ設定する",
- "connection": "接続する"
+ "connection": "接続する",
+ "permission-denied": "許可が拒否されました"
},
"error-page": {
"go-back-home": "ホームページに戻る"
@@ -1217,6 +1218,9 @@
},
"affected-rows-n": "影響を受ける行: {n}"
}
+ },
+ "sql-review": {
+ "statement-type": "ステートメントタイプ"
}
},
"alter-schema": {
@@ -3310,6 +3314,10 @@
"self": "輸出センター",
"permission-denied": "この操作を実行する権限がありません"
},
+ "review-center": {
+ "self": "レビューセンター",
+ "review-sql": "SQLを確認する"
+ },
"schema-designer": {
"self": "スキーマデザイナー",
"schema-design": "スキーマ設計",
@@ -3515,4 +3523,4 @@
"self": "最後の更新"
}
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/sql-review/es-ES.json b/frontend/src/locales/sql-review/es-ES.json
index f65370fbeb..46f5637e04 100644
--- a/frontend/src/locales/sql-review/es-ES.json
+++ b/frontend/src/locales/sql-review/es-ES.json
@@ -652,4 +652,4 @@
"warning": "Advertencia",
"disabled": "Deshabilitado"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/sql-review/ja-JP.json b/frontend/src/locales/sql-review/ja-JP.json
index b8a408ff92..210e6425b9 100644
--- a/frontend/src/locales/sql-review/ja-JP.json
+++ b/frontend/src/locales/sql-review/ja-JP.json
@@ -652,4 +652,4 @@
"warning": "警告",
"disabled": "無効化"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/sql-review/zh-CN.json b/frontend/src/locales/sql-review/zh-CN.json
index 450ba93b87..4c46a18bc4 100644
--- a/frontend/src/locales/sql-review/zh-CN.json
+++ b/frontend/src/locales/sql-review/zh-CN.json
@@ -652,4 +652,4 @@
"warning": "警告",
"disabled": "禁用"
}
-}
+}
\ No newline at end of file
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 2d3d8aacc7..a0dded1f75 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -274,7 +274,8 @@
"project-member": "项目成员",
"leave-without-saving": "不保存变动?",
"configure-now": "现在配置",
- "connection": "连接"
+ "connection": "连接",
+ "permission-denied": "没有权限"
},
"error-page": {
"go-back-home": "回到主页"
@@ -1217,6 +1218,9 @@
},
"affected-rows-n": "影响行数:{n}"
}
+ },
+ "sql-review": {
+ "statement-type": "语句类型"
}
},
"alter-schema": {
@@ -3310,6 +3314,10 @@
"self": "导出中心",
"permission-denied": "您没有权限执行此操作"
},
+ "review-center": {
+ "self": "SQL 审核中心",
+ "review-sql": "审核 SQL"
+ },
"schema-designer": {
"self": "Schema 设计器",
"schema-design": "Schema 设计",
diff --git a/frontend/src/router/dashboard/projectV1.ts b/frontend/src/router/dashboard/projectV1.ts
index d9921e7e68..32ce6fadc7 100644
--- a/frontend/src/router/dashboard/projectV1.ts
+++ b/frontend/src/router/dashboard/projectV1.ts
@@ -34,6 +34,7 @@ export const PROJECT_V1_ROUTE_WEBHOOK_DETAIL = `${PROJECT_V1_ROUTE_DASHBOARD}.we
export const PROJECT_V1_ROUTE_MEMBERS = `${PROJECT_V1_ROUTE_DASHBOARD}.members`;
export const PROJECT_V1_ROUTE_SETTINGS = `${PROJECT_V1_ROUTE_DASHBOARD}.settings`;
export const PROJECT_V1_ROUTE_EXPORT_CENTER = `${PROJECT_V1_ROUTE_DASHBOARD}.export-center`;
+export const PROJECT_V1_ROUTE_REVIEW_CENTER = `${PROJECT_V1_ROUTE_DASHBOARD}.review-center`;
const projectV1Routes: RouteRecordRaw[] = [
{
@@ -471,6 +472,19 @@ const projectV1Routes: RouteRecordRaw[] = [
component: () => import("@/views/ExportCenter/index.vue"),
props: true,
},
+ {
+ path: "review-center",
+ name: PROJECT_V1_ROUTE_REVIEW_CENTER,
+ meta: {
+ overrideTitle: true,
+ requiredProjectPermissionList: () => [
+ "bb.projects.get",
+ "bb.issues.list",
+ ],
+ },
+ component: () => import("@/views/ReviewCenter/index.vue"),
+ props: true,
+ },
],
},
];
diff --git a/frontend/src/router/dashboard/workspace.ts b/frontend/src/router/dashboard/workspace.ts
index 8009b608ac..882b76b6a2 100644
--- a/frontend/src/router/dashboard/workspace.ts
+++ b/frontend/src/router/dashboard/workspace.ts
@@ -27,6 +27,7 @@ import {
WORKSPACE_ROUTE_SSO_CREATE,
WORKSPACE_ROUTE_SSO_DETAIL,
WORKSPACE_ROUTE_MAIL_DELIVERY,
+ WORKSPACE_ROUTE_REVIEW_CENTER,
} from "./workspaceRoutes";
const workspaceRoutes: RouteRecordRaw[] = [
@@ -103,6 +104,21 @@ const workspaceRoutes: RouteRecordRaw[] = [
},
props: { content: true, leftSidebar: true },
},
+ {
+ path: "review-center",
+ name: WORKSPACE_ROUTE_REVIEW_CENTER,
+ meta: {
+ title: () => startCase(t("review-center.self")),
+ },
+ components: {
+ content: () => import("@/views/ReviewCenter/index.vue"),
+ leftSidebar: () => import("@/views/DashboardSidebar.vue"),
+ },
+ props: {
+ content: true,
+ leftSidebar: true,
+ },
+ },
{
path: "export-center",
name: WORKSPACE_ROUTE_EXPORT_CENTER,
diff --git a/frontend/src/router/dashboard/workspaceRoutes.ts b/frontend/src/router/dashboard/workspaceRoutes.ts
index 13a09865e5..59d5a6b1d8 100644
--- a/frontend/src/router/dashboard/workspaceRoutes.ts
+++ b/frontend/src/router/dashboard/workspaceRoutes.ts
@@ -1,5 +1,6 @@
export const WORKSPACE_HOME_MODULE = "workspace.home";
export const WORKSPACE_ROUTE_SLOW_QUERY = "workspace.slow-query";
+export const WORKSPACE_ROUTE_REVIEW_CENTER = "workspace.review-center";
export const WORKSPACE_ROUTE_EXPORT_CENTER = "workspace.export-center";
export const WORKSPACE_ROUTE_ANOMALY_CENTER = "workspace.anomaly-center";
export const WORKSPACE_ROUTE_USER_PROFILE = "workspace.user-profile";
diff --git a/frontend/src/types/issue.ts b/frontend/src/types/issue.ts
index 92dfde1c9e..62d535817c 100644
--- a/frontend/src/types/issue.ts
+++ b/frontend/src/types/issue.ts
@@ -20,11 +20,14 @@ type IssueTypeDatabase =
type IssueTypeGrantRequest = "bb.issue.grant.request";
+type IssueTypeSQLReview = "bb.issue.sql-review";
+
export type IssueType =
| IssueTypeGeneral
| IssueTypeDataSource
| IssueTypeDatabase
- | IssueTypeGrantRequest;
+ | IssueTypeGrantRequest
+ | IssueTypeSQLReview;
export type IssueStatus = "OPEN" | "DONE" | "CANCELED";
diff --git a/frontend/src/utils/iam/permission-utils.ts b/frontend/src/utils/iam/permission-utils.ts
index 8b8bc0ba13..5ff2551f7d 100644
--- a/frontend/src/utils/iam/permission-utils.ts
+++ b/frontend/src/utils/iam/permission-utils.ts
@@ -57,3 +57,22 @@ export const hasPermissionToCreateDataExportIssue = (
user
);
};
+
+export const hasPermissionToCreateReviewIssueInProject = (
+ project: ComposedProject,
+ user: User
+) => {
+ return (
+ hasProjectPermissionV2(project, user, "bb.issues.create") &&
+ hasProjectPermissionV2(project, user, "bb.plans.create")
+ );
+};
+export const hasPermissionToCreateReviewIssueIssue = (
+ database: ComposedDatabase,
+ user: User
+) => {
+ return hasPermissionToCreateReviewIssueInProject(
+ database.projectEntity,
+ user
+ );
+};
diff --git a/frontend/src/utils/issue/index.ts b/frontend/src/utils/issue/index.ts
index 2815807cae..8fbba0437a 100644
--- a/frontend/src/utils/issue/index.ts
+++ b/frontend/src/utils/issue/index.ts
@@ -4,7 +4,8 @@ export const generateIssueName = (
type:
| "bb.issue.database.schema.update"
| "bb.issue.database.data.update"
- | "bb.issue.database.data.export",
+ | "bb.issue.database.data.export"
+ | "bb.issue.sql-review",
databaseNameList: string[],
isOnlineMode = false
) => {
@@ -23,7 +24,9 @@ export const generateIssueName = (
? `Edit schema`
: type === "bb.issue.database.data.update"
? `Change data`
- : "Export data"
+ : type === "bb.issue.database.data.export"
+ ? "Export data"
+ : "Review SQL"
);
}
const datetime = dayjs().format("@MM-DD HH:mm");
diff --git a/frontend/src/utils/v1/issue/index.ts b/frontend/src/utils/v1/issue/index.ts
index d85c62674e..5fb1862b05 100644
--- a/frontend/src/utils/v1/issue/index.ts
+++ b/frontend/src/utils/v1/issue/index.ts
@@ -1,2 +1,3 @@
export * from "./issue";
export * from "./rollout";
+export * from "./plan";
diff --git a/frontend/src/utils/v1/issue/plan.ts b/frontend/src/utils/v1/issue/plan.ts
new file mode 100644
index 0000000000..8cffc642a2
--- /dev/null
+++ b/frontend/src/utils/v1/issue/plan.ts
@@ -0,0 +1,5 @@
+import type { Plan_Spec } from "@/types/proto/v1/rollout_service";
+
+export const sheetNameOfSpec = (spec: Plan_Spec): string => {
+ return spec.changeDatabaseConfig?.sheet ?? spec.exportDataConfig?.sheet ?? "";
+};
diff --git a/frontend/src/views/DashboardSidebar.vue b/frontend/src/views/DashboardSidebar.vue
index b8c9f48b50..b8b1b0bfbc 100644
--- a/frontend/src/views/DashboardSidebar.vue
+++ b/frontend/src/views/DashboardSidebar.vue
@@ -15,6 +15,7 @@ import {
HomeIcon,
DatabaseIcon,
DownloadIcon,
+ SearchCodeIcon,
ShieldAlertIcon,
GalleryHorizontalEndIcon,
LayersIcon,
@@ -47,6 +48,7 @@ import {
WORKSPACE_ROUTE_GITOPS,
WORKSPACE_ROUTE_SSO,
WORKSPACE_ROUTE_MAIL_DELIVERY,
+ WORKSPACE_ROUTE_REVIEW_CENTER,
} from "@/router/dashboard/workspaceRoutes";
import { useCurrentUserV1 } from "@/store";
import type { WorkspacePermission } from "@/types";
@@ -186,6 +188,19 @@ const dashboardSidebarItemList = computed((): DashboardSidebarItem[] => {
type: "divider",
name: "",
},
+ {
+ navigationId: "bb.navigation.review-center",
+ title: t("review-center.self"),
+ icon: h(SearchCodeIcon),
+ name: WORKSPACE_ROUTE_REVIEW_CENTER,
+ type: "route",
+ shortcuts: ["g", "r", "c"],
+ hide: !hasProjectPermissionV2(
+ undefined,
+ currentUserV1.value,
+ "bb.projects.getIamPolicy"
+ ),
+ },
{
navigationId: "bb.navigation.export-center",
title: t("export-center.self"),
diff --git a/frontend/src/views/ReviewCenter/SQLReviewIssueDataTable/SQLReviewIssueDataTable.vue b/frontend/src/views/ReviewCenter/SQLReviewIssueDataTable/SQLReviewIssueDataTable.vue
new file mode 100644
index 0000000000..2a1b456734
--- /dev/null
+++ b/frontend/src/views/ReviewCenter/SQLReviewIssueDataTable/SQLReviewIssueDataTable.vue
@@ -0,0 +1,234 @@
+<template>
+ <div ref="tableRef">
+ <NDataTable
+ :columns="columnList"
+ :data="issueList"
+ :striped="true"
+ :bordered="true"
+ :loading="loading"
+ :row-key="(issue: ComposedIssue) => issue.uid"
+ :row-props="rowProps"
+ class="review-issue-table"
+ />
+ </div>
+</template>
+
+<script lang="tsx" setup>
+import { useElementSize } from "@vueuse/core";
+import { head } from "lodash-es";
+import type { DataTableColumn } from "naive-ui";
+import { NPerformantEllipsis, NDataTable } from "naive-ui";
+import { computed, watch, ref } from "vue";
+import { useI18n } from "vue-i18n";
+import { useRouter } from "vue-router";
+import DatabaseInfo from "@/components/DatabaseInfo.vue";
+import { databaseForSpec } from "@/components/IssueV1";
+import IssueLabelSelector, {
+ getValidIssueLabels,
+} from "@/components/IssueV1/components/IssueLabelSelector.vue";
+import IssueStatusIconWithTaskSummary from "@/components/IssueV1/components/IssueStatusIconWithTaskSummary.vue";
+import { ProjectNameCell } from "@/components/v2/Model/DatabaseV1Table/cells";
+import { emitWindowEvent } from "@/plugins";
+import { PROJECT_V1_ROUTE_ISSUE_DETAIL } from "@/router/dashboard/projectV1";
+import { useSheetV1Store } from "@/store";
+import { type ComposedIssue } from "@/types";
+import {
+ issueSlug,
+ extractProjectResourceName,
+ humanizeTs,
+ flattenSpecList,
+} from "@/utils";
+
+const { t } = useI18n();
+
+const columnList = computed((): DataTableColumn<ComposedIssue>[] => {
+ const columns: (DataTableColumn<ComposedIssue> & { hide?: boolean })[] = [
+ {
+ key: "title",
+ title: t("issue.table.name"),
+ resizable: true,
+ render: (issue) => {
+ return (
+ <div class="flex items-center overflow-hidden space-x-2">
+ <IssueStatusIconWithTaskSummary issue={issue} />
+ <div class="whitespace-nowrap text-control">
+ {issue.projectEntity.key}-{issue.uid}
+ </div>
+ <NPerformantEllipsis class="flex-1 truncate">
+ {{
+ default: () => <span>{issue.title}</span>,
+ tooltip: () => (
+ <div class="whitespace-pre-wrap break-words break-all">
+ {issue.title}
+ </div>
+ ),
+ }}
+ </NPerformantEllipsis>
+ </div>
+ );
+ },
+ },
+ {
+ key: "project",
+ title: t("common.project"),
+ width: 144,
+ resizable: true,
+ hide: !props.showProject,
+ render: (issue) => (
+ <ProjectNameCell project={issue.projectEntity} mode={"ALL_SHORT"} />
+ ),
+ },
+ {
+ key: "labels",
+ title: t("common.labels"),
+ width: 144,
+ resizable: true,
+ render: (issue) => {
+ const labels = getValidIssueLabels(
+ issue.labels,
+ issue.projectEntity.issueLabels
+ );
+ if (labels.length === 0) {
+ return "-";
+ }
+ return (
+ <IssueLabelSelector
+ disabled={true}
+ selected={labels}
+ size="small"
+ maxTagCount="responsive"
+ project={issue.projectEntity}
+ />
+ );
+ },
+ },
+ {
+ key: "database",
+ title: t("common.database"),
+ width: 300,
+ resizable: true,
+ hide: !showExtendedColumns.value,
+ render: (issue) => {
+ const database = issueRelatedDatabase(issue);
+ if (!database) {
+ return "-";
+ }
+ return <DatabaseInfo database={database} />;
+ },
+ },
+ {
+ key: "statement",
+ title: t("common.statement"),
+ resizable: true,
+ ellipsis: true,
+ hide: !showExtendedColumns.value,
+ render: (issue) => {
+ const statement = issueRelatedStatement(issue);
+ return statement || "-";
+ },
+ },
+ {
+ key: "updateTime",
+ title: t("issue.table.updated"),
+ width: 150,
+ resizable: true,
+ hide: !showExtendedColumns.value,
+ render: (issue) => humanizeTs((issue.updateTime?.getTime() ?? 0) / 1000),
+ },
+ ];
+ return columns.filter((column) => !column.hide);
+});
+
+const props = withDefaults(
+ defineProps<{
+ issueList: ComposedIssue[];
+ loading?: boolean;
+ showProject: boolean;
+ }>(),
+ {
+ loading: true,
+ showProject: true,
+ }
+);
+
+const router = useRouter();
+const sheetStore = useSheetV1Store();
+
+const tableRef = ref<HTMLDivElement>();
+const { width: tableWidth } = useElementSize(tableRef);
+const showExtendedColumns = computed(() => {
+ return tableWidth.value > 800;
+});
+
+const rowProps = (issue: ComposedIssue) => {
+ return {
+ style: "cursor: pointer;",
+ onClick: (e: MouseEvent) => {
+ emitWindowEvent("bb.issue-detail", {
+ uid: issue.uid,
+ });
+ const route = router.resolve({
+ name: PROJECT_V1_ROUTE_ISSUE_DETAIL,
+ params: {
+ projectId: extractProjectResourceName(issue.project),
+ issueSlug: issueSlug(issue.title, issue.uid),
+ },
+ });
+ const url = route.fullPath;
+ if (e.ctrlKey || e.metaKey) {
+ window.open(url, "_blank");
+ } else {
+ router.push(url);
+ }
+ },
+ };
+};
+
+const issueRelatedDatabase = (issue: ComposedIssue) => {
+ const spec = head(flattenSpecList(issue.planEntity));
+ if (!spec) {
+ return;
+ }
+ return databaseForSpec(issue, spec);
+};
+
+const issueRelatedStatement = (issue: ComposedIssue) => {
+ const spec = head(flattenSpecList(issue.planEntity));
+ const sheetName = spec?.changeDatabaseConfig?.sheet;
+ if (!spec || !sheetName) {
+ return;
+ }
+ const sheet = sheetStore.getSheetByName(sheetName);
+ if (!sheet) {
+ return;
+ }
+ const statement = new TextDecoder().decode(sheet.content);
+ return statement;
+};
+
+watch(
+ () => props.issueList,
+ (list) => {
+ // Prepare the sheet for each issue.
+ for (const issue of list) {
+ const spec = head(flattenSpecList(issue.planEntity));
+ const sheetName = spec?.changeDatabaseConfig?.sheet;
+ if (!spec || !sheetName) {
+ continue;
+ }
+ sheetStore.getOrFetchSheetByName(sheetName);
+ }
+ }
+);
+</script>
+
+<style scoped lang="postcss">
+:deep(.n-base-selection-tags) {
+ @apply !bg-transparent !p-0;
+}
+:deep(.n-base-suffix),
+:deep(.n-base-selection__border),
+:deep(.n-base-selection__state-border) {
+ @apply !hidden;
+}
+</style>
diff --git a/frontend/src/views/ReviewCenter/SQLReviewIssueDataTable/index.ts b/frontend/src/views/ReviewCenter/SQLReviewIssueDataTable/index.ts
new file mode 100644
index 0000000000..05ec2c69fd
--- /dev/null
+++ b/frontend/src/views/ReviewCenter/SQLReviewIssueDataTable/index.ts
@@ -0,0 +1,3 @@
+import SQLReviewIssueDataTable from "./SQLReviewIssueDataTable.vue";
+
+export default SQLReviewIssueDataTable;
diff --git a/frontend/src/views/ReviewCenter/index.vue b/frontend/src/views/ReviewCenter/index.vue
new file mode 100644
index 0000000000..deef4bd47e
--- /dev/null
+++ b/frontend/src/views/ReviewCenter/index.vue
@@ -0,0 +1,183 @@
+<template>
+ <div class="w-full px-4">
+ <div
+ class="w-full flex flex-col lg:flex-row items-start lg:items-center justify-between gap-2"
+ >
+ <div class="flex flex-1 max-w-full items-center gap-x-2">
+ <IssueSearch
+ v-model:params="state.params"
+ class="flex-1"
+ :readonly-scopes="readonlyScopes"
+ :override-scope-id-list="overideSearchScopeIdList"
+ >
+ <template #searchbox-suffix>
+ <NTooltip :disabled="allowToCreateReviewIssue">
+ <template #trigger>
+ <NButton
+ type="primary"
+ :disabled="!allowToCreateReviewIssue"
+ @click="state.showSQLReviewPanel = true"
+ >
+ {{ $t("review-center.review-sql") }}
+ </NButton>
+ </template>
+ {{ $t("common.permission-denied") }}
+ </NTooltip>
+ </template>
+ </IssueSearch>
+ </div>
+ </div>
+
+ <div class="relative w-full mt-4 min-h-[20rem]">
+ <PagedIssueTableV1
+ v-model:loading="state.loading"
+ v-model:loading-more="state.loadingMore"
+ :session-key="'review-center'"
+ :issue-filter="mergedIssueFilter"
+ :page-size="50"
+ :compose-issue-config="{ withPlan: true }"
+ >
+ <template #table="{ issueList, loading }">
+ <SQLReviewIssueDataTable
+ :loading="loading"
+ :issue-list="issueList"
+ :highlight-text="state.params.query"
+ :show-project="!specificProject"
+ />
+ </template>
+ </PagedIssueTableV1>
+ </div>
+ </div>
+
+ <Drawer
+ :auto-focus="true"
+ :show="state.showSQLReviewPanel"
+ @close="state.showSQLReviewPanel = false"
+ >
+ <ReviewIssuePrepForm
+ :project-id="specificProject?.uid"
+ @dismiss="state.showSQLReviewPanel = false"
+ />
+ </Drawer>
+</template>
+
+<script lang="ts" setup>
+import { NButton, NTooltip } from "naive-ui";
+import { computed, reactive } from "vue";
+import IssueSearch from "@/components/IssueV1/components/IssueSearch/IssueSearch.vue";
+import PagedIssueTableV1 from "@/components/IssueV1/components/PagedIssueTableV1.vue";
+import ReviewIssuePrepForm from "@/components/ReviewIssuePrepForm";
+import { Drawer } from "@/components/v2";
+import { useCurrentUserV1, useProjectV1Store } from "@/store";
+import { projectNamePrefix } from "@/store/modules/v1/common";
+import { Issue_Type } from "@/types/proto/v1/issue_service";
+import {
+ buildIssueFilterBySearchParams,
+ extractProjectResourceName,
+ hasPermissionToCreateReviewIssueInProject,
+ type SearchParams,
+ type SearchScope,
+ type SearchScopeId,
+} from "@/utils";
+import SQLReviewIssueDataTable from "./SQLReviewIssueDataTable";
+
+const props = defineProps<{
+ projectId?: string;
+}>();
+
+interface LocalState {
+ showSQLReviewPanel: boolean;
+ params: SearchParams;
+ loading: boolean;
+ loadingMore: boolean;
+}
+
+const specificProject = computed(() => {
+ return props.projectId
+ ? projectV1Store.getProjectByName(`${projectNamePrefix}${props.projectId}`)
+ : undefined;
+});
+
+const readonlyScopes = computed((): SearchScope[] => {
+ if (!specificProject.value) {
+ return [];
+ }
+ return [
+ {
+ id: "project",
+ value: extractProjectResourceName(specificProject.value.name),
+ },
+ ];
+});
+
+const defaultSearchParams = () => {
+ const params: SearchParams = {
+ query: "",
+ scopes: [...readonlyScopes.value, { id: "status", value: "OPEN" }],
+ };
+ return params;
+};
+
+const currentUser = useCurrentUserV1();
+const projectV1Store = useProjectV1Store();
+const state = reactive<LocalState>({
+ showSQLReviewPanel: false,
+ params: defaultSearchParams(),
+ loading: false,
+ loadingMore: false,
+});
+
+const issueSearchParams = computed(() => {
+ // Default scopes with type and creator.
+ const defaultScopes = [
+ {
+ id: "creator",
+ value: currentUser.value.email,
+ },
+ ];
+ // If specific project is provided, add project scope.
+ if (specificProject.value) {
+ defaultScopes.push({
+ id: "project",
+ value: extractProjectResourceName(specificProject.value.name),
+ });
+ }
+ return {
+ query: state.params.query,
+ scopes: [...state.params.scopes, ...defaultScopes],
+ } as SearchParams;
+});
+
+const overideSearchScopeIdList = computed(() => {
+ const defaultScopeIdList: SearchScopeId[] = [
+ "status",
+ "instance",
+ "database",
+ "label",
+ ];
+ if (!specificProject.value) {
+ defaultScopeIdList.push("project");
+ }
+ return defaultScopeIdList;
+});
+
+const mergedIssueFilter = computed(() => {
+ return buildIssueFilterBySearchParams(issueSearchParams.value, {
+ type: Issue_Type.DATABASE_CHANGE,
+ hasPipeline: false,
+ });
+});
+
+const allowToCreateReviewIssue = computed(() => {
+ if (specificProject.value) {
+ return hasPermissionToCreateReviewIssueInProject(
+ specificProject.value,
+ currentUser.value
+ );
+ }
+
+ return projectV1Store.projectList.some((project) =>
+ hasPermissionToCreateReviewIssueInProject(project, currentUser.value)
+ );
+});
+</script>
diff --git a/frontend/src/views/project/ProjectIssueDetail.vue b/frontend/src/views/project/ProjectIssueDetail.vue
index 93b44d9ff2..fce741cd5b 100644
--- a/frontend/src/views/project/ProjectIssueDetail.vue
+++ b/frontend/src/views/project/ProjectIssueDetail.vue
@@ -3,7 +3,10 @@
<template v-if="ready">
<GrantRequestIssueDetailPage v-if="isGrantRequestIssue(issue)" />
<DataExportIssueDetailPage v-else-if="isDatabaseDataExportIssue(issue)" />
- <IssueDetailPage v-else />
+ <template v-else>
+ <IssueDetailPage v-if="!!issue.rollout" />
+ <SQLReviewIssueDetailPage v-else />
+ </template>
</template>
<div v-else class="w-full h-full flex flex-col items-center justify-center">
<NSpin />
@@ -29,6 +32,7 @@ import {
useBaseIssueContext,
useInitializeIssue,
} from "@/components/IssueV1";
+import SQLReviewIssueDetailPage from "@/components/IssueV1/SQLReviewIssueDetailPage.vue";
import { useBodyLayoutContext } from "@/layouts/common";
import { useUIStateStore } from "@/store";
import { UNKNOWN_ID } from "@/types";