Skip to content

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

fix: sql review page in mobile screen (#9560)

ecmadao4c5216fcfb6d
diff --git a/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue b/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue
index e54a9683aa..dbc0861133 100644
--- a/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue
+++ b/frontend/src/components/SQLReview/SQLReviewPolicyTable.vue
@@ -1,71 +1,144 @@
<template>
- <BBGrid
- :column-list="columnList"
- :data-source="combinedList"
- :row-clickable="false"
- class="border"
- >
- <template
- #item="{
- item: { environment, review },
- }: {
- item: EnvironmentReviewPolicy,
- }"
+ <div>
+ <BBGrid
+ :column-list="columnList"
+ :data-source="combinedList"
+ :row-clickable="false"
+ class="border hidden md:grid"
>
- <div class="bb-grid-cell">
- <EnvironmentV1Name
- :environment="environment"
- :link="true"
- :plain="true"
- />
- </div>
- <div class="bb-grid-cell">
- <template v-if="review">
- {{ review.name }}
- </template>
- </div>
- <div class="bb-grid-cell justify-center">
- <BBCheckbox
- :disabled="!review || !hasPermission"
- :value="review?.enforce"
- @toggle="toggleReviewEnabled(review!, $event)"
- />
- </div>
- <div class="bb-grid-cell gap-x-2 !pr-[3rem]">
- <template v-if="!review">
- <button
- type="button"
- class="btn-normal flex justify-center !py-1 !px-3 w-full"
- :disabled="!hasPermission"
- @click.prevent="handleClickCreate(environment)"
- >
- {{ $t("sql-review.configure-policy") }}
- </button>
- </template>
- <template v-else>
- <button
- type="button"
- class="btn-normal flex justify-center !py-1 !px-3"
- @click.prevent="handleClickEdit(review)"
- >
- {{ hasPermission ? $t("common.edit") : $t("common.view") }}
- </button>
+ <template
+ #item="{
+ item: { environment, review },
+ }: {
+ item: EnvironmentReviewPolicy,
+ }"
+ >
+ <div class="bb-grid-cell">
+ <EnvironmentV1Name
+ :environment="environment"
+ :link="true"
+ :plain="true"
+ />
+ </div>
+ <div class="bb-grid-cell">
+ <template v-if="review">
+ {{ review.name }}
+ </template>
+ <span v-else class="italic textinfo text-gray-400">
+ {{ $t("sql-review.no-policy-set") }}
+ </span>
+ </div>
+ <div class="bb-grid-cell justify-center">
+ <BBCheckbox
+ :disabled="!review || !hasPermission"
+ :value="review?.enforce"
+ @toggle="toggleReviewEnabled(review!, $event)"
+ />
+ </div>
+ <div class="bb-grid-cell gap-x-2 !pr-[3rem]">
+ <template v-if="!review">
+ <button
+ type="button"
+ class="btn-normal flex justify-center !py-1 !px-3"
+ :disabled="!hasPermission"
+ @click.prevent="handleClickCreate(environment)"
+ >
+ {{ $t("sql-review.configure-policy") }}
+ </button>
+ </template>
+ <template v-else>
+ <button
+ type="button"
+ class="btn-normal flex justify-center !py-1 !px-3"
+ @click.prevent="handleClickEdit(review)"
+ >
+ {{ hasPermission ? $t("common.edit") : $t("common.view") }}
+ </button>
- <BBButtonConfirm
- class="btn-normal flex justify-center !py-1 !px-3"
- :disabled="!hasPermission"
- :style="'DELETE'"
- :hide-icon="true"
- :button-text="$t('common.delete')"
- :ok-text="$t('common.delete')"
- :confirm-title="$t('common.delete') + ` '${review.name}'?`"
- :require-confirm="true"
- @confirm="handleClickDelete(review)"
+ <BBButtonConfirm
+ class="btn-normal flex justify-center !py-1 !px-3"
+ :disabled="!hasPermission"
+ :style="'DELETE'"
+ :hide-icon="true"
+ :button-text="$t('common.delete')"
+ :ok-text="$t('common.delete')"
+ :confirm-title="$t('common.delete') + ` '${review.name}'?`"
+ :require-confirm="true"
+ @confirm="handleClickDelete(review)"
+ />
+ </template>
+ </div>
+ </template>
+ </BBGrid>
+ <div
+ class="flex flex-col md:hidden border px-2 pb-4 divide-y space-y-4 divide-block-border"
+ >
+ <div
+ v-for="policy in combinedList"
+ :key="policy.review?.id"
+ class="pt-4 space-y-3"
+ >
+ <div class="flex items-center gap-x-2">
+ <BBBadge
+ v-if="policy.environment"
+ :can-remove="false"
+ :link="`/environment/${policy.environment.uid}`"
+ >
+ <EnvironmentV1Name
+ :environment="policy.environment"
+ :link="false"
+ />
+ </BBBadge>
+ <BBBadge
+ v-if="policy.review && !policy.review.enforce"
+ :text="$t('sql-review.disabled')"
+ :can-remove="false"
+ :badge-style="'DISABLED'"
+ ::badge-style="'DISABLED'"
/>
- </template>
+ <span v-if="policy.review" class="text-md">
+ {{ policy.review?.name }}
+ </span>
+ <span v-else class="italic textinfo text-gray-400">
+ {{ $t("sql-review.no-policy-set") }}
+ </span>
+ </div>
+ <div class="flex items-center gap-x-2">
+ <template v-if="!policy.review">
+ <button
+ type="button"
+ class="btn-normal flex justify-center !py-1 !px-3"
+ :disabled="!hasPermission"
+ @click.prevent="handleClickCreate(policy.environment)"
+ >
+ {{ $t("sql-review.configure-policy") }}
+ </button>
+ </template>
+ <template v-else>
+ <button
+ type="button"
+ class="btn-normal flex justify-center !py-1 !px-3"
+ @click.prevent="handleClickEdit(policy.review)"
+ >
+ {{ hasPermission ? $t("common.edit") : $t("common.view") }}
+ </button>
+
+ <BBButtonConfirm
+ class="btn-normal flex justify-center !py-1 !px-3"
+ :disabled="!hasPermission"
+ :style="'DELETE'"
+ :hide-icon="true"
+ :button-text="$t('common.delete')"
+ :ok-text="$t('common.delete')"
+ :confirm-title="$t('common.delete') + ` '${policy.review.name}'?`"
+ :require-confirm="true"
+ @confirm="handleClickDelete(policy.review)"
+ />
+ </template>
+ </div>
</div>
- </template>
- </BBGrid>
+ </div>
+ </div>
</template>
<script lang="ts" setup>
@@ -102,22 +175,22 @@ const columnList = computed((): BBGridColumn[] => {
return [
{
title: t("common.environment"),
- width: "minmax(auto, 1fr)",
+ width: "minmax(min-content, auto)",
class: "capitalize",
},
{
title: t("common.name"),
- width: "minmax(auto, 2fr)",
+ width: "minmax(min-content, auto)",
class: "capitalize",
},
{
title: t("common.enabled"),
- width: "10rem",
+ width: "minmax(min-content, auto)",
class: "capitalize justify-center",
},
{
title: t("common.operations"),
- width: "auto",
+ width: "minmax(min-content, auto)",
class: "capitalize",
},
];
diff --git a/frontend/src/components/SQLReview/components/SQLReviewCategorySummaryFilter.vue b/frontend/src/components/SQLReview/components/SQLReviewCategorySummaryFilter.vue
index a3cda04c06..26464553b9 100644
--- a/frontend/src/components/SQLReview/components/SQLReviewCategorySummaryFilter.vue
+++ b/frontend/src/components/SQLReview/components/SQLReviewCategorySummaryFilter.vue
@@ -1,6 +1,6 @@
<template>
<div
- class="flex flex-col items-start xl:flex-row xl:items-center gap-y-5 gap-x-5"
+ class="flex flex-col items-start 2xl:flex-row 2xl:items-center gap-y-5 gap-x-5"
>
<div class="flex items-center gap-x-5">
<label
@@ -27,7 +27,7 @@
</span>
</label>
</div>
- <div class="hidden xl:block h-[1.5rem] border-l border-control-border" />
+ <div class="hidden 2xl:block h-[1.5rem] border-l border-control-border" />
<div class="flex items-center gap-x-5">
<label
v-for="stats in errorLevelList"
diff --git a/frontend/src/components/SQLReview/components/SQLRuleFilter.vue b/frontend/src/components/SQLReview/components/SQLRuleFilter.vue
index 91f62728d1..994a8a9109 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleFilter.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleFilter.vue
@@ -9,7 +9,7 @@
@toggle-checked-level="$emit('toggle-checked-level', $event)"
/>
<div
- class="flex flex-col lg:flex-row items-start justify-between gap-y-3 lg:items-center border-t border-control-border pt-4"
+ class="flex flex-row sm:flex-col lg:flex-row items-center sm:items-start lg:items-center justify-between gap-y-2 gap-x-2 border-t border-control-border pt-4"
>
<SQLReviewCategoryTabFilter
:value="params.selectedCategory"
@@ -19,7 +19,6 @@
<SearchBox
ref="searchField"
:value="params.searchText"
- class="w-full lg:w-auto"
:placeholder="$t('common.filter-by-name')"
@update:value="$emit('change-search-text', $event)"
/>
diff --git a/frontend/src/components/SQLReview/components/SQLRuleLevelBadge.vue b/frontend/src/components/SQLReview/components/SQLRuleLevelBadge.vue
index 667fcc2a07..39fdeb0992 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleLevelBadge.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleLevelBadge.vue
@@ -1,5 +1,10 @@
<template>
- <BBBadge :text="text" :can-remove="false" :badge-style="style" />
+ <BBBadge
+ :text="text"
+ :can-remove="false"
+ :badge-style="style"
+ :size="'small'"
+ />
</template>
<script lang="ts" setup>
diff --git a/frontend/src/components/SQLReview/components/SQLRuleTable.vue b/frontend/src/components/SQLReview/components/SQLRuleTable.vue
index 38b1e047cb..e0aab8ba50 100644
--- a/frontend/src/components/SQLReview/components/SQLRuleTable.vue
+++ b/frontend/src/components/SQLReview/components/SQLRuleTable.vue
@@ -13,7 +13,7 @@
:column-list="columnList"
:data-source="category.ruleList"
:row-clickable="false"
- class="border"
+ class="border hidden lg:grid"
>
<template #item="{ item: rule }: { item: RuleTemplate }">
<div class="bb-grid-cell justify-center">
@@ -89,6 +89,81 @@
</div>
</template>
</BBGrid>
+ <div
+ class="flex flex-col lg:hidden border px-2 pb-4 divide-y space-y-4 divide-block-border"
+ >
+ <div
+ v-for="rule in category.ruleList"
+ :key="rule.type"
+ class="pt-4 space-y-3"
+ >
+ <div class="flex justify-between items-center gap-x-2">
+ <div class="flex items-center gap-x-1">
+ <NTooltip
+ v-if="!isRuleAvailable(rule)"
+ trigger="hover"
+ :show-arrow="false"
+ >
+ <template #trigger>
+ <div class="flex justify-center">
+ <heroicons-outline:exclamation
+ class="h-5 w-5 text-yellow-600"
+ />
+ </div>
+ </template>
+ <span class="whitespace-nowrap">
+ {{
+ $t("sql-review.not-available-for-free", {
+ plan: $t(
+ `subscription.plan.${planTypeToString(
+ currentPlan
+ )}.title`
+ ),
+ })
+ }}
+ </span>
+ </NTooltip>
+ <span>
+ {{ getRuleLocalization(rule.type).title }}
+ <a
+ :href="`https://www.bytebase.com/docs/sql-review/review-rules#${rule.type}`"
+ target="_blank"
+ class="inline-block"
+ >
+ <ExternalLinkIcon class="w-4 h-4" />
+ </a>
+ </span>
+ </div>
+ <div class="flex items-center space-x-2">
+ <PencilIcon
+ v-if="editable"
+ class="w-4 h-4"
+ @click="setActiveRule(rule)"
+ />
+ <BBSwitch
+ :class="[!editable && 'pointer-events-none']"
+ :disabled="!isRuleAvailable(rule)"
+ :value="rule.level !== SQLReviewRuleLevel.DISABLED"
+ size="small"
+ @toggle="toggleActivity(rule, $event)"
+ />
+ </div>
+ </div>
+ <div class="flex gap-x-2 items-center">
+ <RuleEngineIcons :rule="rule" />
+ </div>
+ <RuleLevelSwitch
+ class="text-xs"
+ :level="rule.level"
+ :disabled="!isRuleAvailable(rule)"
+ :editable="editable"
+ @level-change="$emit('level-change', rule, $event)"
+ />
+ <p class="textinfolabel">
+ {{ getRuleLocalization(rule.type).description }}
+ </p>
+ </div>
+ </div>
</template>
<SQLRuleEditDialog
@@ -105,6 +180,7 @@
</template>
<script lang="ts" setup>
+import { ExternalLinkIcon, PencilIcon } from "lucide-vue-next";
import { computed, reactive } from "vue";
import { useI18n } from "vue-i18n";
import { BBSwitch, BBGrid, type BBGridColumn } from "@/bbkit";
diff --git a/frontend/src/views/SettingSidebar.vue b/frontend/src/views/SettingSidebar.vue
index 473e9b0d5f..8cd3bed312 100644
--- a/frontend/src/views/SettingSidebar.vue
+++ b/frontend/src/views/SettingSidebar.vue
@@ -40,6 +40,12 @@ const getItemClass = (path: string | undefined) => {
list.push("router-link-active", "bg-link-hover");
}
break;
+ case "setting.workspace.sql-review.create":
+ case "setting.workspace.sql-review.detail":
+ if (path === "/setting/sql-review") {
+ list.push("router-link-active", "bg-link-hover");
+ }
+ break;
}
return list;
};
diff --git a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
index 665b39f140..ffac0fb7d3 100644
--- a/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
+++ b/frontend/src/views/SettingWorkspaceSQLReviewDetail.vue
@@ -11,7 +11,7 @@
/>
<div v-else>
<div
- class="flex flex-col items-center space-x-2 justify-center md:flex-row"
+ class="flex flex-col gap-y-2 items-start md:items-center gap-x-2 justify-center md:flex-row"
>
<div class="flex-1 flex space-x-2 items-center justify-start">
<BBBadge
@@ -28,11 +28,12 @@
<BBBadge
:text="$t('sql-review.disabled')"
:can-remove="false"
+ :badge-style="'DISABLED'"
::badge-style="'DISABLED'"
/>
</div>
<BBTextField
- class="flex-1 text-3xl py-0.5 px-0.5 font-bold truncate"
+ class="flex-1 text-xl md:text-3xl py-0.5 px-0.5 font-bold truncate"
:disabled="!hasPermission"
:required="true"
:focus-on-mount="false"
@@ -42,7 +43,7 @@
@end-editing="changeName"
/>
</div>
- <div v-if="hasPermission" class="flex space-x-2">
+ <div v-if="hasPermission" class="flex gap-x-2">
<NButton
v-if="reviewPolicy.enforce"
@click.prevent="state.showDisableModal = true"