Skip to content

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

chore(frontend): highlight advise online migration rule (#12648)

Liu Jicb6936ca61fb
diff --git a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue
index cc530578d7..42e7e4efe7 100644
--- a/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue
+++ b/frontend/src/components/IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue
@@ -1,9 +1,112 @@
<template>
- <div class="space-y-3 divide-y pb-4 px-2">
+ <div class="divide-y">
<div
- v-for="(row, i) in tableRows"
+ v-for="(row, i) in highlightTableRows"
:key="i"
- class="pt-3 first:pt-2 space-y-2"
+ class="py-3 px-2 first:pt-2 space-y-2"
+ :class="[
+ row.checkResult.status === PlanCheckRun_Result_Status.ERROR &&
+ 'border-error border rounded',
+ row.checkResult.status === PlanCheckRun_Result_Status.WARNING &&
+ 'border-warning border rounded',
+ ]"
+ >
+ <div class="flex items-center space-x-3">
+ <div
+ class="relative w-5 h-5 flex flex-shrink-0 items-center justify-center rounded-full select-none"
+ :class="statusIconClass(row.checkResult.status)"
+ >
+ <template
+ v-if="row.checkResult.status === PlanCheckRun_Result_Status.SUCCESS"
+ >
+ <heroicons-solid:check class="w-4 h-4" />
+ </template>
+ <template
+ v-if="row.checkResult.status === PlanCheckRun_Result_Status.WARNING"
+ >
+ <heroicons-outline:exclamation class="h-4 w-4" />
+ </template>
+ <template
+ v-else-if="
+ row.checkResult.status === PlanCheckRun_Result_Status.ERROR
+ "
+ >
+ <span class="text-white font-medium text-base" aria-hidden="true">
+ !
+ </span>
+ </template>
+ </div>
+ <div v-if="showCategoryColumn" class="shrink-0">
+ {{ row.category }}
+ </div>
+ <div class="font-semibold">{{ row.title }}</div>
+
+ <slot name="row-title-extra" :row="row" />
+ </div>
+ <div class="textinfolabel">
+ <span>{{ row.checkResult.content }}</span>
+ <template v-if="row.checkResult.sqlReviewReport?.detail">
+ <span
+ class="ml-1 normal-link"
+ @click="
+ state.activeResultDefinition =
+ row.checkResult.sqlReviewReport!.detail
+ "
+ >{{ $t("sql-review.view-definition") }}</span
+ >
+ <span class="border-r border-control-border ml-1"></span>
+ </template>
+ <template
+ v-if="
+ row.checkResult.sqlReviewReport &&
+ getActiveRule(row.checkResult.title)
+ "
+ >
+ <span
+ class="ml-1 normal-link"
+ @click="setActiveRule(row.checkResult.title)"
+ >{{ $t("sql-review.rule-detail") }}</span
+ >
+ <span class="border-r border-control-border ml-1"></span>
+ </template>
+ <template v-if="row.checkResult.sqlSummaryReport">
+ {{ row.checkResult.sqlSummaryReport.affectedRows }}
+ </template>
+
+ <HideInStandaloneMode>
+ <a
+ v-if="row.link"
+ class="ml-1 normal-link"
+ :href="row.link.url"
+ :target="row.link.target"
+ >
+ {{ row.link.title }}
+ </a>
+ </HideInStandaloneMode>
+
+ <!-- Only show the error line for latest plan check run -->
+ <template v-if="isLatest && row.checkResult.sqlReviewReport?.line">
+ <span class="border-r border-control-border ml-1"></span>
+ <span
+ class="ml-1 normal-link"
+ @click="
+ handleClickPlanCheckDetailLine(
+ row.checkResult.sqlReviewReport!.line
+ )
+ "
+ >
+ Line {{ row.checkResult.sqlReviewReport.line }}
+ </span>
+ </template>
+
+ <slot name="row-extra" :row="row" />
+ </div>
+ </div>
+
+ <div
+ v-for="(row, i) in standardTableRows"
+ :key="i"
+ class="py-3 px-2 first:pt-2 space-y-2"
>
<div class="flex items-center space-x-3">
<div
@@ -156,6 +259,7 @@ const props = defineProps<{
planCheckRun: PlanCheckRun;
isLatest?: boolean;
database?: ComposedDatabase;
+ highlightRowFilter?: (row: PlanCheckDetailTableRow) => boolean;
}>();
const { t } = useI18n();
@@ -302,6 +406,18 @@ const tableRows = computed(() => {
});
});
+const highlightTableRows = computed(() => {
+ const { highlightRowFilter } = props;
+ if (!highlightRowFilter) return [];
+ return tableRows.value.filter(highlightRowFilter);
+});
+
+const standardTableRows = computed(() => {
+ const { highlightRowFilter } = props;
+ if (!highlightRowFilter) return tableRows.value;
+ return tableRows.value.filter((row) => !highlightRowFilter(row));
+});
+
const showCategoryColumn = computed((): boolean =>
tableRows.value.some((row) => row.category !== "")
);
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/OnlineMigrationAdviceExtra.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/OnlineMigrationAdviceExtra.vue
index 53a9e56991..eb889b8c86 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/OnlineMigrationAdviceExtra.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/OnlineMigrationAdviceExtra.vue
@@ -1,12 +1,16 @@
<template>
- <div v-if="allowEnableGhost">
- <div class="normal-link inline-block" @click="enableGhost">
- {{ $t("task.online-migration.enable") }}
- </div>
- </div>
+ <NButton
+ v-if="allowEnableGhost"
+ size="small"
+ type="primary"
+ @click="enableGhost"
+ >
+ {{ $t("task.online-migration.enable") }}
+ </NButton>
</template>
<script setup lang="ts">
+import { NButton } from "naive-ui";
import { computed } from "vue";
import { isGroupingChangeTaskV1, useIssueContext } from "../../logic";
import { type PlanCheckDetailTableRow } from "../PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue";
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
index 4e80fe39d2..b933fd9cea 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckBadge.vue
@@ -27,9 +27,12 @@
v-if="showDetailPanel"
:database="database"
:advices="advices"
+ :highlight-row-filter="
+ (row) => row.checkResult.title === 'advice.online-migration'
+ "
@close="showDetailPanel = false"
>
- <template #row-extra="{ row }">
+ <template #row-title-extra="{ row }">
<OnlineMigrationAdviceExtra
v-if="row.checkResult.title === 'advice.online-migration'"
:row="row"
diff --git a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
index 5a88f18acb..68ca54e790 100644
--- a/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
+++ b/frontend/src/components/IssueV1/components/SQLCheckSection/SQLCheckSection.vue
@@ -13,6 +13,9 @@
:button-props="{
size: 'tiny',
}"
+ :highlight-row-filter="
+ (row) => row.checkResult.title === 'advice.online-migration'
+ "
button-style="--n-padding: 0 8px 0 6px; --n-icon-margin: 3px;"
class="justify-between flex-1"
@update:advices="$emit('update:advices', $event)"
@@ -26,7 +29,7 @@
<SQLCheckBadge v-else :is-running="isRunning" :advices="advices" />
</template>
- <template #row-extra="{ row, confirm }">
+ <template #row-title-extra="{ row, confirm }">
<OnlineMigrationAdviceExtra
v-if="row.checkResult.title === 'advice.online-migration'"
:row="row"
diff --git a/frontend/src/components/SQLCheck/SQLCheckButton.vue b/frontend/src/components/SQLCheck/SQLCheckButton.vue
index 404e3e0393..058137c55a 100644
--- a/frontend/src/components/SQLCheck/SQLCheckButton.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckButton.vue
@@ -60,11 +60,15 @@
:advices="advices"
:confirm="confirmDialog"
:override-title="$t('issue.sql-check.sql-review-violations')"
+ :highlight-row-filter="highlightRowFilter"
@close="onPanelClose"
>
<template #row-extra="{ row }">
<slot name="row-extra" :row="row" :confirm="confirmDialog" />
</template>
+ <template #row-title-extra="{ row }">
+ <slot name="row-title-extra" :row="row" :confirm="confirmDialog" />
+ </template>
</SQLCheckPanel>
</div>
</template>
@@ -85,6 +89,7 @@ import type { CheckRequest_ChangeType } from "@/types/proto/v1/sql_service";
import { Advice, Advice_Status } from "@/types/proto/v1/sql_service";
import type { Defer, VueStyle } from "@/utils";
import { defer, hasWorkspacePermissionV2 } from "@/utils";
+import type { PlanCheckDetailTableRow } from "../IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue";
import ErrorList from "../misc/ErrorList.vue";
import SQLCheckSummary from "./SQLCheckSummary.vue";
import { useSQLCheckContext } from "./context";
@@ -97,12 +102,14 @@ const props = withDefaults(
buttonProps?: ButtonProps;
buttonStyle?: VueStyle;
changeType?: CheckRequest_ChangeType;
+ highlightRowFilter?: (row: PlanCheckDetailTableRow) => boolean;
}>(),
{
databaseMetadata: undefined,
buttonProps: undefined,
buttonStyle: undefined,
changeType: undefined,
+ highlightRowFilter: undefined,
}
);
diff --git a/frontend/src/components/SQLCheck/SQLCheckPanel.vue b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
index a9c19800af..c2f03f02c5 100644
--- a/frontend/src/components/SQLCheck/SQLCheckPanel.vue
+++ b/frontend/src/components/SQLCheck/SQLCheckPanel.vue
@@ -12,16 +12,20 @@
:plan-check-run="planCheckRun"
:database="database"
:is-latest="false"
+ :highlight-row-filter="highlightRowFilter"
@close="$emit('close')"
>
<template #row-extra="{ row }">
<slot name="row-extra" :row="row" />
</template>
+ <template #row-title-extra="{ row }">
+ <slot name="row-title-extra" :row="row" />
+ </template>
</PlanCheckDetail>
<div
v-if="confirm"
- class="flex flex-row justify-end items-center gap-x-3 mt-4"
+ class="flex flex-row justify-end items-center gap-x-3 mt-3"
>
<NButton @click="confirm!.resolve(false)">
{{ $t("issue.sql-check.back-to-edit") }}
@@ -53,13 +57,16 @@ import {
import type { Advice } from "@/types/proto/v1/sql_service";
import { Advice_Status } from "@/types/proto/v1/sql_service";
import type { Defer } from "@/utils";
-import PlanCheckDetail from "../IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue";
+import PlanCheckDetail, {
+ type PlanCheckDetailTableRow,
+} from "../IssueV1/components/PlanCheckSection/PlanCheckBar/PlanCheckDetail.vue";
const { advices, database } = defineProps<{
database: ComposedDatabase;
advices: Advice[];
overrideTitle?: string;
confirm?: Defer<boolean>;
+ highlightRowFilter?: (row: PlanCheckDetailTableRow) => boolean;
}>();
defineEmits<{