Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
chore: update ux for query result limit (#17122)
ecmadao909a623a2c77
diff --git a/frontend/src/components/GrantRequestPanel/MaxRowCountSelect.vue b/frontend/src/components/GrantRequestPanel/MaxRowCountSelect.vueindex 29d98c3cd3..e4c7feb1ea 100644--- a/frontend/src/components/GrantRequestPanel/MaxRowCountSelect.vue+++ b/frontend/src/components/GrantRequestPanel/MaxRowCountSelect.vue@@ -20,7 +20,7 @@:value="value":show-button="false":min="0"- :max="100000"+ :max="rowCountOptions[rowCountOptions.length - 1]"style="width: 5rem"@update:value="handleInput"/>@@ -35,6 +35,7 @@ import { first, last } from "lodash-es";import { NButton, NInputNumber, NPopselect, type SelectOption } from "naive-ui";import { computed } from "vue";import { useI18n } from "vue-i18n";+import { useSettingV1Store } from "@/store";import { minmax } from "@/utils";defineProps<{@@ -46,10 +47,23 @@ const emit = defineEmits<{}>();const { t } = useI18n();-const rowCountOptions = [1, 100, 500, 1000, 5000, 10000, 100000];+const settingV1Store = useSettingV1Store();++const rowCountOptions = computed(() => {+ const list = [1, 100, 500, 1000, 5000, 10000, 100000].filter(+ (num) => num <= settingV1Store.maximumResultRows+ );+ if (+ settingV1Store.maximumResultRows !== Number.MAX_VALUE &&+ !list.includes(settingV1Store.maximumResultRows)+ ) {+ list.push(settingV1Store.maximumResultRows);+ }+ return list;+});const options = computed((): SelectOption[] => {- return rowCountOptions.map((n) => ({+ return rowCountOptions.value.map((n) => ({label: t("common.rows.n-rows", { n }),value: n,}));@@ -58,8 +72,8 @@ const options = computed((): SelectOption[] => {const handleInput = (value: number | null) => {const normalizedValue = minmax(value ?? 0,- first(rowCountOptions)!,- last(rowCountOptions)!+ first(rowCountOptions.value)!,+ last(rowCountOptions.value)!);emit("update:value", normalizedValue);};diff --git a/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue b/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vueindex cb4f20cc81..d8a757ad50 100644--- a/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue+++ b/frontend/src/components/IssueV1/components/DataExportSection/DataExportSection.vue@@ -4,6 +4,18 @@<StageSection /><TaskListSection /><div class="w-full py-2 px-2 sm:px-4">+ <BBAttention+ v-if="settingV1Store.maximumResultRows !== Number.MAX_VALUE"+ class="w-full mb-2"+ :type="'warning'"+ >+ {{+ $t(+ "settings.general.workspace.maximum-sql-result.rows.limit-warning",+ { count: settingV1Store.maximumResultRows }+ )+ }}+ </BBAttention><ExportOptionSection /></div></template>@@ -20,15 +32,17 @@<script lang="ts" setup>import { NEmpty } from "naive-ui";import { computed } from "vue";+import { BBAttention } from "@/bbkit";import { useIssueContext } from "@/components/IssueV1/logic";import NoPermissionPlaceholder from "@/components/misc/NoPermissionPlaceholder.vue";-import { useCurrentProjectV1 } from "@/store";+import { useCurrentProjectV1, useSettingV1Store } from "@/store";import { hasProjectPermissionV2 } from "@/utils";import { StageSection, TaskListSection } from "../../components";import ExportOptionSection from "./ExportOptionSection";const { isCreating, issue } = useIssueContext();const { project } = useCurrentProjectV1();+const settingV1Store = useSettingV1Store();// For database data export issue, the stageList should always be only 1 stage.const stageList = computed(() => {diff --git a/frontend/src/locales/en-US.json b/frontend/src/locales/en-US.jsonindex 6895d94a48..6613eaea9a 100644--- a/frontend/src/locales/en-US.json+++ b/frontend/src/locales/en-US.json@@ -605,7 +605,8 @@"rows": {"self": "Maximum SQL result rows","rows": "Rows",- "description": "Limit the output rows in SQL query result, the value <= 0 means no limit."+ "description": "Limit the output rows in SQL query result, the value <= 0 means no limit.",+ "limit-warning": "Maximum export {count} rows due to the query restriction"}},"query-data-policy": {diff --git a/frontend/src/locales/es-ES.json b/frontend/src/locales/es-ES.jsonindex 9c8c3f498f..a3f49d4e04 100644--- a/frontend/src/locales/es-ES.json+++ b/frontend/src/locales/es-ES.json@@ -605,7 +605,8 @@"rows": {"self": "Máximo de filas de resultados de SQL","rows": "Filas",- "description": "Limite las filas de salida en el resultado de la consulta SQL, el valor <= 0 significa que no hay límite."+ "description": "Limite las filas de salida en el resultado de la consulta SQL, el valor <= 0 significa que no hay límite.",+ "limit-warning": "Exportación máxima de {count} filas debido a la restricción de la consulta"}},"query-data-policy": {diff --git a/frontend/src/locales/ja-JP.json b/frontend/src/locales/ja-JP.jsonindex 4def0ddd46..93cb3b6eff 100644--- a/frontend/src/locales/ja-JP.json+++ b/frontend/src/locales/ja-JP.json@@ -605,7 +605,8 @@"rows": {"self": "最大SQL結果行数","rows": "行",- "description": "SQL クエリ結果の出力行を制限します。値 <= 0 は制限がないことを意味します。"+ "description": "SQL クエリ結果の出力行を制限します。値 <= 0 は制限がないことを意味します。",+ "limit-warning": "クエリ制限により、最大エクスポート行数は {count} 行です"}},"query-data-policy": {diff --git a/frontend/src/locales/vi-VN.json b/frontend/src/locales/vi-VN.jsonindex 8fc476c093..455b1d0f28 100644--- a/frontend/src/locales/vi-VN.json+++ b/frontend/src/locales/vi-VN.json@@ -605,7 +605,8 @@"rows": {"self": "Số lượng hàng kết quả SQL tối đa","rows": "Hàng",- "description": "Giới hạn số hàng đầu ra trong kết quả truy vấn SQL, giá trị <= 0 nghĩa là không giới hạn."+ "description": "Giới hạn số hàng đầu ra trong kết quả truy vấn SQL, giá trị <= 0 nghĩa là không giới hạn.",+ "limit-warning": "Xuất tối đa {count} hàng do hạn chế truy vấn"}},"query-data-policy": {diff --git a/frontend/src/locales/zh-CN.json b/frontend/src/locales/zh-CN.jsonindex f995583254..88cc3ffa73 100644--- a/frontend/src/locales/zh-CN.json+++ b/frontend/src/locales/zh-CN.json@@ -605,7 +605,8 @@"rows": {"self": "SQL结果行数上限","rows": "行",- "description": "限制SQL查询结果的输出行数,值 <=0 表示不限制。"+ "description": "限制SQL查询结果的输出行数,值 <=0 表示不限制。",+ "limit-warning": "由于查询限制,最多可导出 {count} 行"}},"query-data-policy": {diff --git a/frontend/src/store/modules/v1/setting.ts b/frontend/src/store/modules/v1/setting.tsindex 47596cf454..1e9abee617 100644--- a/frontend/src/store/modules/v1/setting.ts+++ b/frontend/src/store/modules/v1/setting.ts@@ -32,6 +32,19 @@ export const useSettingV1Store = defineStore("setting_v1", {settingMapByName: new Map(),}),getters: {+ maximumResultRows(state): number {+ const setting = state.settingMapByName.get(+ `${settingNamePrefix}${Setting_SettingName[Setting_SettingName.SQL_RESULT_SIZE_LIMIT]}`+ );+ if (setting?.value?.value?.case === "sqlQueryRestrictionSetting") {+ const limit = setting.value.value.value.maximumResultRows ?? -1;+ if (limit <= 0) {+ return Number.MAX_VALUE;+ }+ return limit;+ }+ return Number.MAX_VALUE;+ },workspaceProfileSetting(state): WorkspaceProfileSetting | undefined {const setting = state.settingMapByName.get(`${settingNamePrefix}${Setting_SettingName[Setting_SettingName.WORKSPACE_PROFILE]}`diff --git a/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue b/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vueindex 0b946d76bd..53bc6ada52 100644--- a/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue+++ b/frontend/src/views/sql-editor/EditorCommon/QueryContextSettingPopover.vue@@ -139,7 +139,6 @@ import {DataSourceQueryPolicy_Restriction,PolicyType,} from "@/types/proto-es/v1/org_policy_service_pb";-import { Setting_SettingName } from "@/types/proto-es/v1/setting_service_pb";import { QueryOption_RedisRunCommandsOn } from "@/types/proto-es/v1/sql_service_pb";import { getValidDataSourceByPolicy, readableDataSourceType } from "@/utils";import { getAdminDataSourceRestrictionOfDatabase } from "@/utils";@@ -273,17 +272,7 @@ watch();const maximumResultRows = computed(() => {- const setting = settingV1Store.getSettingByName(- Setting_SettingName.SQL_RESULT_SIZE_LIMIT- );- if (setting?.value?.value?.case === "sqlQueryRestrictionSetting") {- const limit = setting.value.value.value.maximumResultRows ?? -1;- if (limit <= 0) {- return Number.MAX_VALUE;- }- return limit;- }- return Number.MAX_VALUE;+ return settingV1Store.maximumResultRows;});watchEffect(() => {diff --git a/frontend/src/views/sql-editor/EditorCommon/ResultLimitSelect.vue b/frontend/src/views/sql-editor/EditorCommon/ResultLimitSelect.vueindex 379df7c32e..adc3b73c93 100644--- a/frontend/src/views/sql-editor/EditorCommon/ResultLimitSelect.vue+++ b/frontend/src/views/sql-editor/EditorCommon/ResultLimitSelect.vue@@ -17,7 +17,7 @@v-model:value="resultRowsLimit":show-button="false":min="0"- :max="Math.min(maximum, 100000)"+ :max="rowCountOptions[rowCountOptions.length - 1]"style="width: 5rem"size="small"/>@@ -41,15 +41,18 @@ const props = defineProps<{const { t } = useI18n();const { resultRowsLimit } = storeToRefs(useSQLEditorStore());-const options = computed((): SelectOption[] => {+const rowCountOptions = computed(() => {const list = [100, 500, 1000, 5000, 10000, 100000].filter((num) => num <= props.maximum);if (props.maximum !== Number.MAX_VALUE && !list.includes(props.maximum)) {list.push(props.maximum);}+ return list;+});- return list.map((n) => ({+const options = computed((): SelectOption[] => {+ return rowCountOptions.value.map((n) => ({label: t("sql-editor.result-limit.n-rows", { n }),value: n,}));