Skip to content

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

chore: support search by row number (#18375)

ecmadao87b0f13d335b
diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.json
index d34707c9a8..79ea3332b4 100644
--- a/frontend/src/locales/en-US.json
+++ b/frontend/src/locales/en-US.json
@@ -2177,7 +2177,11 @@
"column-display-format": "Column Display Format",
"next-row": "Next Row",
"previous-row": "Previous Row",
- "search-scope-column-description": "The column with {type} type. Input the value then press Enter to relocate to the matched row."
+ "search-scope-column-description": "Column with {type} type. Enter a value and press Enter to jump to the matching row.",
+ "search-scope-row-number-title": "Row number",
+ "search-scope-row-number-description": "Enter a row number to jump to that row.",
+ "scroll-to-top": "Scroll to the top",
+ "scroll-to-bottom": "Scroll to the bottom"
},
"schema-editor": {
"self": "Schema Editor",
diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.json
index 69155072fd..a324984b2a 100644
--- a/frontend/src/locales/es-ES.json
+++ b/frontend/src/locales/es-ES.json
@@ -2177,7 +2177,11 @@
"column-display-format": "Formato de visualización de columna",
"next-row": "siguiente fila",
"previous-row": "Fila anterior",
- "search-scope-column-description": "La columna con tipo {type}. Ingrese el valor y presione Enter para ir a la fila coincidente."
+ "search-scope-column-description": "Columna de tipo {type}. Ingrese un valor y presione Enter para saltar a la fila coincidente.",
+ "search-scope-row-number-title": "Número de fila",
+ "search-scope-row-number-description": "Ingrese un número de fila para saltar a esa fila.",
+ "scroll-to-top": "Desplazarse hacia arriba",
+ "scroll-to-bottom": "Desplazarse hacia abajo"
},
"schema-editor": {
"self": "Editor de esquema",
diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.json
index f958873d96..1a84516c04 100644
--- a/frontend/src/locales/ja-JP.json
+++ b/frontend/src/locales/ja-JP.json
@@ -2177,7 +2177,11 @@
"column-display-format": "列表示形式",
"next-row": "次の行",
"previous-row": "前の行",
- "search-scope-column-description": "{type}型の列。値を入力してEnterキーを押すと、一致する行に移動します。"
+ "search-scope-column-description": "{type}型の列。値を入力してEnterを押すと一致する行にジャンプします。",
+ "search-scope-row-number-title": "行番号",
+ "search-scope-row-number-description": "行番号を入力してその行にジャンプします。",
+ "scroll-to-top": "先頭へスクロール",
+ "scroll-to-bottom": "末尾へスクロール"
},
"schema-editor": {
"self": "スキーマエディタ",
diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.json
index 3ef24cb0b8..0203a834d2 100644
--- a/frontend/src/locales/vi-VN.json
+++ b/frontend/src/locales/vi-VN.json
@@ -2177,7 +2177,11 @@
"column-display-format": "Định dạng hiển thị cột",
"next-row": "Dòng tiếp theo",
"previous-row": "Dòng trước",
- "search-scope-column-description": "Cột có kiểu {type}. Nhập giá trị và nhấn Enter để chuyển đến dòng phù hợp."
+ "search-scope-column-description": "Cột kiểu {type}. Nhập giá trị và nhấn Enter để chuyển đến dòng khớp.",
+ "search-scope-row-number-title": "Số dòng",
+ "search-scope-row-number-description": "Nhập số dòng để chuyển đến dòng đó.",
+ "scroll-to-top": "Cuộn lên đầu",
+ "scroll-to-bottom": "Cuộn xuống cuối"
},
"schema-editor": {
"self": "Trình soạn thảo lược đồ",
diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.json
index 7fc1269f58..8326a8df01 100644
--- a/frontend/src/locales/zh-CN.json
+++ b/frontend/src/locales/zh-CN.json
@@ -2177,7 +2177,11 @@
"column-display-format": "列显示格式",
"next-row": "下一行",
"previous-row": "上一行",
- "search-scope-column-description": "{type} 类型的列。输入值后按回车键跳转到匹配的行。"
+ "search-scope-column-description": "{type} 类型的列。输入值并按回车跳转到匹配行。",
+ "search-scope-row-number-title": "行号",
+ "search-scope-row-number-description": "输入行号跳转到指定行。",
+ "scroll-to-top": "滚动到顶部",
+ "scroll-to-bottom": "滚动到底部"
},
"schema-editor": {
"self": "Schema 编辑器",
diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
index 0f8e67fe19..5fb45945f6 100644
--- a/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
+++ b/frontend/src/views/sql-editor/EditorCommon/ResultView/SingleResultViewV1.vue
@@ -125,34 +125,69 @@
</template>
</NEmpty>
- <div v-if="state.searchCandidateRowIndexs.length > 0" class="flex flex-row gap-x-2 absolute bottom-2 right-2 border shadow rounded bg-white py-1 px-2">
- <NButton
- quaternary
- size="small"
- :disabled="state.searchCandidateActiveIndex <= 0"
- @click="scrollToPreviousCandidate"
- >
- <template #icon>
- <ArrowUpIcon class="x-4" />
- </template>
- {{ $t("sql-editor.previous-row") }}
- </NButton>
- <NButton
- quaternary
- size="small"
- :disabled="state.searchCandidateActiveIndex >= (state.searchCandidateRowIndexs.length - 1)"
- @click="scrollToNextCandidate"
- >
- <template #icon>
- <ArrowDownIcon class="x-4" />
- </template>
- {{ $t("sql-editor.next-row") }}
- </NButton>
- <NButton quaternary size="small" style="--n-padding: 2px" @click="clearSearchCandidate">
- <template #icon>
- <XIcon class="x-4" />
- </template>
- </NButton>
+ <div class="absolute bottom-2 right-2 flex items-end gap-x-2">
+ <div v-if="state.searchCandidateRowIndexs.length > 0" class="flex flex-row gap-x-2 border shadow rounded bg-white py-1 px-2">
+ <NButton
+ quaternary
+ size="small"
+ :disabled="state.searchCandidateActiveIndex <= 0"
+ @click="scrollToPreviousCandidate"
+ >
+ <template #icon>
+ <ArrowUpIcon class="x-4" />
+ </template>
+ {{ $t("sql-editor.previous-row") }}
+ </NButton>
+ <NButton
+ quaternary
+ size="small"
+ :disabled="state.searchCandidateActiveIndex >= (state.searchCandidateRowIndexs.length - 1)"
+ @click="scrollToNextCandidate"
+ >
+ <template #icon>
+ <ArrowDownIcon class="x-4" />
+ </template>
+ {{ $t("sql-editor.next-row") }}
+ </NButton>
+ <NButton quaternary size="small" style="--n-padding: 2px" @click="clearSearchCandidate">
+ <template #icon>
+ <XIcon class="x-4" />
+ </template>
+ </NButton>
+ </div>
+
+ <div class="flex flex-col gap-y-2">
+ <NTooltip>
+ <template #trigger>
+ <NButton
+ circle
+ size="medium"
+ class="shadow"
+ @click="() => scrollToRow(0)"
+ >
+ <template #icon>
+ <ArrowUpIcon class="x-4" />
+ </template>
+ </NButton>
+ </template>
+ {{ $t("sql-editor.scroll-to-top") }}
+ </NTooltip>
+ <NTooltip>
+ <template #trigger>
+ <NButton
+ circle
+ size="medium"
+ class="shadow"
+ @click="() => scrollToRow(rows.length - 1)"
+ >
+ <template #icon>
+ <ArrowDownIcon class="x-4" />
+ </template>
+ </NButton>
+ </template>
+ {{ $t("sql-editor.scroll-to-bottom") }}
+ </NTooltip>
+ </div>
</div>
</div>
@@ -357,15 +392,24 @@ const columns = computed((): ResultTableColumn[] => {
});
const searchScopeOptions = computed((): ScopeOption[] => {
- return columns.value.map((column) => {
- return {
+ const options: ScopeOption[] = [
+ {
+ id: "row-number",
+ title: t("sql-editor.search-scope-row-number-title"),
+ description: t("sql-editor.search-scope-row-number-description"),
+ },
+ ];
+
+ for (const column of columns.value) {
+ options.push({
id: column.id,
title: column.name,
description: t("sql-editor.search-scope-column-description", {
type: column.columnType,
}),
- };
- });
+ });
+ }
+ return options;
});
const activeRowIndex = computed(() => {
@@ -405,6 +449,12 @@ watch(
);
const scrollToNextCandidate = () => {
+ if (
+ state.searchCandidateActiveIndex >=
+ state.searchCandidateRowIndexs.length - 1
+ ) {
+ return;
+ }
state.searchCandidateActiveIndex++;
// Append next candidate if reaches the last
if (
@@ -424,14 +474,17 @@ const scrollToNextCandidate = () => {
};
const scrollToPreviousCandidate = () => {
+ if (state.searchCandidateActiveIndex <= 0) {
+ return;
+ }
state.searchCandidateActiveIndex--;
};
const scrollToCurrentCandidate = () => {
- scrollToSearchCandidate(activeRowIndex.value);
+ scrollToRow(activeRowIndex.value);
};
-const scrollToSearchCandidate = (index: number | undefined) => {
+const scrollToRow = (index: number | undefined) => {
if (index === undefined || index < 0) {
return;
}
@@ -469,6 +522,9 @@ const getNextCandidateRowIndex = (from: number, params: SearchParams) => {
if (!scope.value) {
return false;
}
+ if (scope.id === "row-number") {
+ return i + 1 === Number.parseInt(scope.value, 10);
+ }
const columnIndex = columns.value.findIndex(
(column) => column.name === scope.id
);