feat(web): 列表自适应布局并将分页固定页脚
数据源与查询列表整页不滚、仅表体内滚;名称筛选去掉「模糊」占位后缀。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
c1da6d7c3a
commit
be63e2fe5d
11 files changed
+314
-271
No files matched your search
@@ -313,14 +313,21 @@ test.describe("datasources console", () => {
|
||||
await expect(page.getByTestId("datasource-filter-search")).toBeVisible();
|
||||
await expect(page.getByTestId("datasource-filter-reset")).toBeVisible();
|
||||
|
||||
// 新建 sits above the table, right aligned.
|
||||
// 新建 sits above the table, right aligned; pagination is a page footer below the table.
|
||||
const create = await page.getByTestId("datasource-create").boundingBox();
|
||||
const table = await page.getByTestId("datasource-table").boundingBox();
|
||||
const pager = await page.getByTestId("datasource-pagination").boundingBox();
|
||||
const viewport = page.viewportSize();
|
||||
expect(create && table && viewport).toBeTruthy();
|
||||
expect(create && table && pager && viewport).toBeTruthy();
|
||||
expect(create!.y + create!.height).toBeLessThanOrEqual(table!.y);
|
||||
expect(create!.x + create!.width).toBeGreaterThan(table!.x + table!.width - 40);
|
||||
// No page footer on the list.
|
||||
expect(pager!.y).toBeGreaterThanOrEqual(table!.y + table!.height - 2);
|
||||
// The list page itself does not scroll; only the table body does.
|
||||
const listScrolls = await page
|
||||
.getByTestId("datasource-list")
|
||||
.evaluate((el) => el.scrollHeight > el.clientHeight + 1);
|
||||
expect(listScrolls).toBe(false);
|
||||
// Detail-style action footer is not used on the list.
|
||||
await expect(page.getByTestId("datasource-footer")).toHaveCount(0);
|
||||
|
||||
// Disabled row: visible, 测试 disabled, no 停用, no "停用后不能测试" copy.
|
||||
|
||||
@@ -516,8 +516,14 @@ test.describe("queries console", () => {
|
||||
|
||||
const create = (await page.getByTestId("query-create").boundingBox())!;
|
||||
const box = (await table.boundingBox())!;
|
||||
const pager = (await page.getByTestId("query-pagination").boundingBox())!;
|
||||
expect(create.y + create.height).toBeLessThanOrEqual(box.y);
|
||||
expect(create.x + create.width).toBeGreaterThan(box.x + box.width - 40);
|
||||
expect(pager.y).toBeGreaterThanOrEqual(box.y + box.height - 2);
|
||||
const listScrolls = await page
|
||||
.getByTestId("query-list")
|
||||
.evaluate((el) => el.scrollHeight > el.clientHeight + 1);
|
||||
expect(listScrolls).toBe(false);
|
||||
await expect(page.getByTestId("query-footer")).toHaveCount(0);
|
||||
|
||||
await expect(page.getByTestId("query-list-toolbar")).toBeVisible();
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"loadFailed": "Failed to load data sources",
|
||||
"empty": "No data sources yet",
|
||||
"emptyHint": "An administrator can create the first data source.",
|
||||
"filterName": "Name (contains)",
|
||||
"filterName": "Name",
|
||||
"filterEngine": "Engine",
|
||||
"filterStatus": "Status",
|
||||
"filterSearch": "Search",
|
||||
@@ -183,7 +183,7 @@
|
||||
"loadFailed": "Failed to load queries",
|
||||
"empty": "No queries yet",
|
||||
"emptyHint": "An administrator can create the first query: pick a data source, write a parameterized SQL template, and declare its parameters and output contract.",
|
||||
"filterName": "Name (contains)",
|
||||
"filterName": "Name",
|
||||
"filterDatasource": "Data source",
|
||||
"filterStatus": "Status",
|
||||
"filterSearch": "Search",
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"loadFailed": "โหลดแหล่งข้อมูลไม่สำเร็จ",
|
||||
"empty": "ยังไม่มีแหล่งข้อมูล",
|
||||
"emptyHint": "ผู้ดูแลสามารถสร้างแหล่งข้อมูลแรกได้",
|
||||
"filterName": "ชื่อ (ค้นหาบางส่วน)",
|
||||
"filterName": "ชื่อ",
|
||||
"filterEngine": "เอนจิน",
|
||||
"filterStatus": "สถานะ",
|
||||
"filterSearch": "ค้นหา",
|
||||
@@ -183,7 +183,7 @@
|
||||
"loadFailed": "โหลดคิวรีไม่สำเร็จ",
|
||||
"empty": "ยังไม่มีคิวรี",
|
||||
"emptyHint": "ผู้ดูแลสามารถสร้างคิวรีแรกได้ โดยเลือกแหล่งข้อมูล เขียนเทมเพลต SQL แบบมีพารามิเตอร์ และประกาศพารามิเตอร์กับสัญญาเอาต์พุต",
|
||||
"filterName": "ชื่อ (ค้นหาบางส่วน)",
|
||||
"filterName": "ชื่อ",
|
||||
"filterDatasource": "แหล่งข้อมูล",
|
||||
"filterStatus": "สถานะ",
|
||||
"filterSearch": "ค้นหา",
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
"loadFailed": "数据源加载失败",
|
||||
"empty": "还没有数据源",
|
||||
"emptyHint": "管理者可以新建第一个数据源。",
|
||||
"filterName": "名称(模糊)",
|
||||
"filterName": "名称",
|
||||
"filterEngine": "引擎",
|
||||
"filterStatus": "状态",
|
||||
"filterSearch": "查询",
|
||||
@@ -184,7 +184,7 @@
|
||||
"loadFailed": "查询加载失败",
|
||||
"empty": "还没有查询",
|
||||
"emptyHint": "管理者可以新建第一个查询定义:选择数据源,写参数化 SQL,声明参数与输出契约。",
|
||||
"filterName": "名称(模糊)",
|
||||
"filterName": "名称",
|
||||
"filterDatasource": "数据源",
|
||||
"filterStatus": "状态",
|
||||
"filterSearch": "查询",
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
"loadFailed": "資料來源載入失敗",
|
||||
"empty": "還沒有資料來源",
|
||||
"emptyHint": "管理者可以新增第一個資料來源。",
|
||||
"filterName": "名稱(模糊)",
|
||||
"filterName": "名稱",
|
||||
"filterEngine": "引擎",
|
||||
"filterStatus": "狀態",
|
||||
"filterSearch": "查詢",
|
||||
@@ -183,7 +183,7 @@
|
||||
"loadFailed": "查詢載入失敗",
|
||||
"empty": "還沒有查詢",
|
||||
"emptyHint": "管理者可以新建第一個查詢定義:選擇資料來源,撰寫參數化 SQL,宣告參數與輸出契約。",
|
||||
"filterName": "名稱(模糊)",
|
||||
"filterName": "名稱",
|
||||
"filterDatasource": "資料來源",
|
||||
"filterStatus": "狀態",
|
||||
"filterSearch": "查詢",
|
||||
|
||||
@@ -218,8 +218,12 @@ onMounted(load);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full overflow-auto p-5" data-testid="datasource-list">
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2" data-testid="datasource-list-toolbar">
|
||||
<!-- Page itself does not scroll: toolbar + table body + pagination footer. -->
|
||||
<div class="flex h-full min-h-0 flex-col overflow-hidden" data-testid="datasource-list">
|
||||
<div
|
||||
class="flex shrink-0 flex-wrap items-center gap-2 px-5 pb-3 pt-5"
|
||||
data-testid="datasource-list-toolbar"
|
||||
>
|
||||
<div class="w-[200px]" data-testid="datasource-filter-name">
|
||||
<ElInput v-model="draft.name" clearable :placeholder="t('datasource.list.filterName')" />
|
||||
</div>
|
||||
@@ -259,145 +263,157 @@ onMounted(load);
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
data-testid="datasource-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && !hasAppliedFilters"
|
||||
data-testid="datasource-empty"
|
||||
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.empty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("datasource.list.emptyHint") }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="datasource-filter-empty"
|
||||
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.filterEmpty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("datasource.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
<template v-else>
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="datasource-table"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
<div class="flex min-h-0 flex-1 flex-col px-5">
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
data-testid="datasource-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && !hasAppliedFilters"
|
||||
data-testid="datasource-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<ElTableColumn prop="name" :label="t('datasource.columns.name')" min-width="140" sortable="custom" />
|
||||
<ElTableColumn prop="engine" :label="t('datasource.columns.engine')" min-width="110" sortable="custom">
|
||||
<template #default="{ row }">{{ engineLabel(row.engine) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="host" :label="t('datasource.columns.host')" min-width="170" sortable="custom" />
|
||||
<ElTableColumn prop="port" :label="t('datasource.columns.port')" width="90" sortable="custom" />
|
||||
<ElTableColumn
|
||||
prop="database_name"
|
||||
:label="t('datasource.columns.database')"
|
||||
min-width="130"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="username"
|
||||
:label="t('datasource.columns.username')"
|
||||
min-width="130"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn prop="status" :label="t('datasource.columns.status')" min-width="150" sortable="custom">
|
||||
<template #default="{ row }">
|
||||
<span class="inline-flex items-center gap-1.5">
|
||||
<span
|
||||
class="h-[7px] w-[7px] rounded-full"
|
||||
:class="row.enabled ? 'bg-[#1a7f37]' : 'bg-[var(--text-muted)]'"
|
||||
/>
|
||||
{{ row.enabled ? t("datasource.status.enabled") : t("datasource.status.disabled") }}
|
||||
<span
|
||||
v-if="row.circuit_state === 'open'"
|
||||
class="text-xs text-[#cf222e]"
|
||||
data-testid="row-circuit-open"
|
||||
>
|
||||
{{ t("datasource.status.circuitOpen") }}
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="last_test_at"
|
||||
:label="t('datasource.columns.lastTest')"
|
||||
min-width="190"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span
|
||||
:class="
|
||||
row.last_test_category === 'success'
|
||||
? 'text-[#1a7f37]'
|
||||
: row.last_test_category
|
||||
? 'text-[#cf222e]'
|
||||
: 'text-[var(--text-muted)]'
|
||||
"
|
||||
>
|
||||
{{ lastTestText(row) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
:label="t('datasource.columns.actions')"
|
||||
:width="actionsWidth"
|
||||
align="right"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap" :data-testid="`datasource-row-${row.id}`">
|
||||
<ElButton link type="primary" data-testid="row-edit" @click="openDetail(row)">
|
||||
{{ t("datasource.actions.edit") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="row-test"
|
||||
:disabled="testBlocked(row)"
|
||||
:title="testTitle(row)"
|
||||
@click="openTest(row)"
|
||||
>
|
||||
{{ t("datasource.actions.test") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="row.enabled"
|
||||
link
|
||||
type="danger"
|
||||
data-testid="row-disable"
|
||||
@click="disable(row)"
|
||||
>
|
||||
{{ t("datasource.actions.disable") }}
|
||||
</ElButton>
|
||||
<ElButton v-else link type="success" data-testid="row-enable" @click="enable(row)">
|
||||
{{ t("datasource.actions.enable") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<div class="mt-3 flex justify-end" data-testid="datasource-pagination">
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.empty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("datasource.list.emptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="datasource-filter-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("datasource.list.filterEmpty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("datasource.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1" data-testid="datasource-table-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="datasource-table"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<ElTableColumn prop="name" :label="t('datasource.columns.name')" min-width="140" sortable="custom" />
|
||||
<ElTableColumn prop="engine" :label="t('datasource.columns.engine')" min-width="110" sortable="custom">
|
||||
<template #default="{ row }">{{ engineLabel(row.engine) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn prop="host" :label="t('datasource.columns.host')" min-width="170" sortable="custom" />
|
||||
<ElTableColumn prop="port" :label="t('datasource.columns.port')" width="90" sortable="custom" />
|
||||
<ElTableColumn
|
||||
prop="database_name"
|
||||
:label="t('datasource.columns.database')"
|
||||
min-width="130"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="username"
|
||||
:label="t('datasource.columns.username')"
|
||||
min-width="130"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn prop="status" :label="t('datasource.columns.status')" min-width="150" sortable="custom">
|
||||
<template #default="{ row }">
|
||||
<span class="inline-flex items-center gap-1.5">
|
||||
<span
|
||||
class="h-[7px] w-[7px] rounded-full"
|
||||
:class="row.enabled ? 'bg-[#1a7f37]' : 'bg-[var(--text-muted)]'"
|
||||
/>
|
||||
{{ row.enabled ? t("datasource.status.enabled") : t("datasource.status.disabled") }}
|
||||
<span
|
||||
v-if="row.circuit_state === 'open'"
|
||||
class="text-xs text-[#cf222e]"
|
||||
data-testid="row-circuit-open"
|
||||
>
|
||||
{{ t("datasource.status.circuitOpen") }}
|
||||
</span>
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="last_test_at"
|
||||
:label="t('datasource.columns.lastTest')"
|
||||
min-width="190"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span
|
||||
:class="
|
||||
row.last_test_category === 'success'
|
||||
? 'text-[#1a7f37]'
|
||||
: row.last_test_category
|
||||
? 'text-[#cf222e]'
|
||||
: 'text-[var(--text-muted)]'
|
||||
"
|
||||
>
|
||||
{{ lastTestText(row) }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
:label="t('datasource.columns.actions')"
|
||||
:width="actionsWidth"
|
||||
align="right"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap" :data-testid="`datasource-row-${row.id}`">
|
||||
<ElButton link type="primary" data-testid="row-edit" @click="openDetail(row)">
|
||||
{{ t("datasource.actions.edit") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="row-test"
|
||||
:disabled="testBlocked(row)"
|
||||
:title="testTitle(row)"
|
||||
@click="openTest(row)"
|
||||
>
|
||||
{{ t("datasource.actions.test") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
v-if="row.enabled"
|
||||
link
|
||||
type="danger"
|
||||
data-testid="row-disable"
|
||||
@click="disable(row)"
|
||||
>
|
||||
{{ t("datasource.actions.disable") }}
|
||||
</ElButton>
|
||||
<ElButton v-else link type="success" data-testid="row-enable" @click="enable(row)">
|
||||
{{ t("datasource.actions.enable") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
v-if="!loadError && (loading || total > 0)"
|
||||
data-testid="datasource-pagination"
|
||||
class="flex shrink-0 items-center justify-end border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
>
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</footer>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -202,8 +202,9 @@ onMounted(async () => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full overflow-auto p-5" data-testid="query-list">
|
||||
<div class="mb-3 flex flex-wrap items-center gap-2" data-testid="query-list-toolbar">
|
||||
<!-- Page itself does not scroll: toolbar + table body + pagination footer. -->
|
||||
<div class="flex h-full min-h-0 flex-col overflow-hidden" data-testid="query-list">
|
||||
<div class="flex shrink-0 flex-wrap items-center gap-2 px-5 pb-3 pt-5" data-testid="query-list-toolbar">
|
||||
<div class="w-[200px]" data-testid="query-filter-name">
|
||||
<ElInput v-model="draft.name" clearable :placeholder="t('query.list.filterName')" />
|
||||
</div>
|
||||
@@ -246,123 +247,135 @@ onMounted(async () => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
data-testid="query-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && !hasAppliedFilters"
|
||||
data-testid="query-empty"
|
||||
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.empty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("query.list.emptyHint") }}</p>
|
||||
</div>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="query-filter-empty"
|
||||
class="rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.filterEmpty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("query.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
<template v-else>
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="query-table"
|
||||
:default-sort="{ prop: 'updated_at', order: 'descending' }"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
<div class="flex min-h-0 flex-1 flex-col px-5">
|
||||
<ElAlert
|
||||
v-if="loadError"
|
||||
type="error"
|
||||
data-testid="query-load-error"
|
||||
:title="loadError"
|
||||
show-icon
|
||||
:closable="false"
|
||||
/>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && !hasAppliedFilters"
|
||||
data-testid="query-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<ElTableColumn
|
||||
prop="name"
|
||||
:label="t('query.columns.name')"
|
||||
min-width="180"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="datasource"
|
||||
:label="t('query.columns.datasource')"
|
||||
min-width="160"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ sourceName(row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="status"
|
||||
:label="t('query.columns.status')"
|
||||
min-width="110"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="row.enabled ? 'success' : 'info'" effect="light" data-testid="row-status">
|
||||
{{ row.enabled ? t("query.status.enabled") : t("query.status.disabled") }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="currentVersion"
|
||||
:label="t('query.columns.currentVersion')"
|
||||
min-width="120"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ currentVersion(row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="updated_at"
|
||||
:label="t('query.columns.updatedAt')"
|
||||
min-width="150"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ formatDateTime(row.updated_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
:label="t('query.columns.actions')"
|
||||
:width="actionsWidth"
|
||||
align="right"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap" :data-testid="`query-row-${row.id}`">
|
||||
<ElButton link type="primary" data-testid="row-open" @click="openDetail(row)">
|
||||
{{ t("query.actions.open") }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" data-testid="row-switch-version" @click="openSwitch(row)">
|
||||
{{ t("query.actions.switchVersion") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="row-preview"
|
||||
:disabled="!row.enabled"
|
||||
:title="row.enabled ? undefined : t('query.actions.previewDisabledWhy')"
|
||||
@click="openPreview(row)"
|
||||
>
|
||||
{{ t("query.actions.preview") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
<div class="mt-3 flex justify-end" data-testid="query-pagination">
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.empty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("query.list.emptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
v-else-if="!loading && total === 0 && hasAppliedFilters"
|
||||
data-testid="query-filter-empty"
|
||||
class="flex flex-1 items-center justify-center rounded-lg border border-dashed border-[var(--border-default)] bg-white px-5 py-14 text-center"
|
||||
>
|
||||
<div>
|
||||
<h3 class="mb-1.5 text-[15px] font-semibold">{{ t("query.list.filterEmpty") }}</h3>
|
||||
<p class="text-[var(--text-secondary)]">{{ t("query.list.filterEmptyHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="min-h-0 flex-1" data-testid="query-table-wrap">
|
||||
<ElTable
|
||||
v-loading="loading"
|
||||
height="100%"
|
||||
:data="items"
|
||||
row-key="id"
|
||||
data-testid="query-table"
|
||||
:default-sort="{ prop: 'updated_at', order: 'descending' }"
|
||||
:row-class-name="rowClass"
|
||||
@sort-change="onSortChange"
|
||||
>
|
||||
<ElTableColumn
|
||||
prop="name"
|
||||
:label="t('query.columns.name')"
|
||||
min-width="180"
|
||||
sortable="custom"
|
||||
/>
|
||||
<ElTableColumn
|
||||
prop="datasource"
|
||||
:label="t('query.columns.datasource')"
|
||||
min-width="160"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ sourceName(row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="status"
|
||||
:label="t('query.columns.status')"
|
||||
min-width="110"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<ElTag :type="row.enabled ? 'success' : 'info'" effect="light" data-testid="row-status">
|
||||
{{ row.enabled ? t("query.status.enabled") : t("query.status.disabled") }}
|
||||
</ElTag>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="currentVersion"
|
||||
:label="t('query.columns.currentVersion')"
|
||||
min-width="120"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ currentVersion(row) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
prop="updated_at"
|
||||
:label="t('query.columns.updatedAt')"
|
||||
min-width="150"
|
||||
sortable="custom"
|
||||
>
|
||||
<template #default="{ row }">{{ formatDateTime(row.updated_at) }}</template>
|
||||
</ElTableColumn>
|
||||
<ElTableColumn
|
||||
:label="t('query.columns.actions')"
|
||||
:width="actionsWidth"
|
||||
align="right"
|
||||
fixed="right"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div class="whitespace-nowrap" :data-testid="`query-row-${row.id}`">
|
||||
<ElButton link type="primary" data-testid="row-open" @click="openDetail(row)">
|
||||
{{ t("query.actions.open") }}
|
||||
</ElButton>
|
||||
<ElButton link type="primary" data-testid="row-switch-version" @click="openSwitch(row)">
|
||||
{{ t("query.actions.switchVersion") }}
|
||||
</ElButton>
|
||||
<ElButton
|
||||
link
|
||||
type="primary"
|
||||
data-testid="row-preview"
|
||||
:disabled="!row.enabled"
|
||||
:title="row.enabled ? undefined : t('query.actions.previewDisabledWhy')"
|
||||
@click="openPreview(row)"
|
||||
>
|
||||
{{ t("query.actions.preview") }}
|
||||
</ElButton>
|
||||
</div>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
</ElTable>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer
|
||||
v-if="!loadError && (loading || total > 0)"
|
||||
data-testid="query-pagination"
|
||||
class="flex shrink-0 items-center justify-end border-t border-[var(--border-subtle)] bg-white px-5 py-3"
|
||||
>
|
||||
<ElPagination
|
||||
background
|
||||
layout="total, sizes, prev, pager, next"
|
||||
:total="total"
|
||||
:page-size="pageSize"
|
||||
:page-sizes="[...LIST_PAGE_SIZES]"
|
||||
:current-page="page"
|
||||
@current-change="onPageChange"
|
||||
@size-change="onSizeChange"
|
||||
/>
|
||||
</footer>
|
||||
|
||||
<ElDialog
|
||||
v-model="switchOpen"
|
||||
|
||||
Reference in new issue
Block a user