Skip to content

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

fix: improve plan and rollout table responsiveness on mobile (#19167)

boojackd590e627e29f
diff --git a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
index 42c8403154..070fca2792 100644
--- a/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
+++ b/frontend/src/components/Plan/components/PlanDataTable/PlanDataTable.vue
@@ -1,21 +1,25 @@
<template>
- <NDataTable
- key="plan-table"
- size="small"
- :columns="columnList"
- :data="planList"
- :striped="true"
- :bordered="true"
- :loading="loading"
- :row-key="(plan: Plan) => plan.name"
- :row-props="rowProps"
- />
+ <div ref="tableRef">
+ <NDataTable
+ key="plan-table"
+ size="small"
+ :columns="columnList"
+ :data="planList"
+ :striped="true"
+ :bordered="true"
+ :loading="loading"
+ :scroll-x="scrollX"
+ :row-key="(plan: Plan) => plan.name"
+ :row-props="rowProps"
+ />
+ </div>
</template>
<script lang="tsx" setup>
+import { useElementSize } from "@vueuse/core";
import type { DataTableColumn } from "naive-ui";
import { NDataTable, NPerformantEllipsis, NTag } from "naive-ui";
-import { computed } from "vue";
+import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import Timestamp from "@/components/misc/Timestamp.vue";
@@ -25,7 +29,11 @@ import { useUserStore } from "@/store";
import { unknownUser } from "@/types";
import { State } from "@/types/proto-es/v1/common_pb";
import type { Plan } from "@/types/proto-es/v1/plan_service_pb";
-import { extractPlanUID, extractProjectResourceName } from "@/utils";
+import {
+ extractPlanUID,
+ extractProjectResourceName,
+ TailwindBreakpoints,
+} from "@/utils";
import PlanCheckRunStatusIcon from "../PlanCheckRunStatusIcon.vue";
withDefaults(
@@ -39,12 +47,18 @@ withDefaults(
const { t } = useI18n();
const router = useRouter();
const userStore = useUserStore();
+const tableRef = ref<HTMLDivElement>();
+const { width: tableWidth } = useElementSize(tableRef);
+const showExtendedColumns = computed(
+ () => tableWidth.value > TailwindBreakpoints.md
+);
const columnList = computed((): DataTableColumn<Plan>[] => {
const columns: (DataTableColumn<Plan> & { hide?: boolean })[] = [
{
key: "title",
title: t("issue.table.name"),
+ minWidth: 200,
ellipsis: true,
resizable: true,
render: (plan) => {
@@ -89,13 +103,15 @@ const columnList = computed((): DataTableColumn<Plan>[] => {
{
key: "updateTime",
title: t("issue.table.updated"),
- width: 128,
+ minWidth: 128,
+ hide: !showExtendedColumns.value,
render: (plan) => <Timestamp timestamp={plan.updateTime} />,
},
{
key: "creator",
title: t("issue.table.creator"),
- width: 200,
+ minWidth: 200,
+ hide: !showExtendedColumns.value,
resizable: true,
ellipsis: true,
render: (plan) => {
@@ -118,6 +134,12 @@ const columnList = computed((): DataTableColumn<Plan>[] => {
return columns.filter((column) => !column.hide);
});
+const scrollX = computed(() => {
+ return columnList.value.reduce((sum, col) => {
+ return sum + ((col as { minWidth?: number }).minWidth ?? 100);
+ }, 0);
+});
+
const rowProps = (plan: Plan) => {
const isDeleted = plan.state === State.DELETED;
return {
diff --git a/frontend/src/components/Rollout/RolloutDataTable.vue b/frontend/src/components/Rollout/RolloutDataTable.vue
index fbcfba2987..3a3108b4ef 100644
--- a/frontend/src/components/Rollout/RolloutDataTable.vue
+++ b/frontend/src/components/Rollout/RolloutDataTable.vue
@@ -1,20 +1,24 @@
<template>
- <NDataTable
- size="small"
- :columns="columnList"
- :data="rolloutList"
- :striped="true"
- :bordered="bordered"
- :loading="loading"
- :row-key="(rollout) => rollout.name"
- :row-props="rowProps"
- />
+ <div ref="tableRef">
+ <NDataTable
+ size="small"
+ :columns="columnList"
+ :data="rolloutList"
+ :striped="true"
+ :bordered="bordered"
+ :loading="loading"
+ :scroll-x="scrollX"
+ :row-key="(rollout) => rollout.name"
+ :row-props="rowProps"
+ />
+ </div>
</template>
<script lang="tsx" setup>
+import { useElementSize } from "@vueuse/core";
import type { DataTableColumn } from "naive-ui";
import { NDataTable, NPerformantEllipsis, NTooltip } from "naive-ui";
-import { computed } from "vue";
+import { computed, ref } from "vue";
import { useI18n } from "vue-i18n";
import { useRouter } from "vue-router";
import Timestamp from "@/components/misc/Timestamp.vue";
@@ -33,6 +37,7 @@ import {
extractProjectResourceName,
getStageStatus,
stringifyTaskStatus,
+ TailwindBreakpoints,
} from "@/utils";
withDefaults(
@@ -52,6 +57,11 @@ withDefaults(
const { t } = useI18n();
const router = useRouter();
const environmentStore = useEnvironmentV1Store();
+const tableRef = ref<HTMLDivElement>();
+const { width: tableWidth } = useElementSize(tableRef);
+const showExtendedColumns = computed(
+ () => tableWidth.value > TailwindBreakpoints.md
+);
const getStageTaskCount = (stage: Stage, status: Task_Status) => {
return stage.tasks.filter((task) => task.status === status).length;
@@ -63,6 +73,7 @@ const columnList = computed(
{
key: "title",
title: t("issue.table.name"),
+ minWidth: 160,
resizable: true,
ellipsis: true,
render: (rollout) => {
@@ -92,8 +103,8 @@ const columnList = computed(
{
key: "stages",
title: t("rollout.stage.self", 2),
+ minWidth: 160,
resizable: true,
- ellipsis: true,
render: (rollout) => {
if (rollout.stages.length === 0) {
return (
@@ -114,17 +125,19 @@ const columnList = computed(
<NTooltip key={stage.name} placement="top">
{{
trigger: () => (
- <div class="flex items-center gap-1 cursor-pointer">
+ <div class="flex items-center gap-1 cursor-pointer shrink-0">
<TaskStatus
status={stageStatus}
size="small"
disabled
/>
- <EnvironmentV1Name
- environment={environment}
- link={false}
- nullEnvironmentPlaceholder="Null"
- />
+ {showExtendedColumns.value && (
+ <EnvironmentV1Name
+ environment={environment}
+ link={false}
+ nullEnvironmentPlaceholder="Null"
+ />
+ )}
</div>
),
default: () => {
@@ -178,7 +191,7 @@ const columnList = computed(
{
key: "updateTime",
title: t("common.updated-at"),
- width: 128,
+ minWidth: 128,
render: (rollout) => <Timestamp timestamp={rollout.updateTime} />,
},
];
@@ -186,6 +199,12 @@ const columnList = computed(
}
);
+const scrollX = computed(() => {
+ return columnList.value.reduce((sum, col) => {
+ return sum + ((col as { minWidth?: number }).minWidth ?? 100);
+ }, 0);
+});
+
const rowProps = (rollout: Rollout) => {
return {
style: "cursor: pointer;",