feat(sidebar): auto-load all tables per connection when expanded
Closes #9834
This commit is contained in:
1 parent
725b1ee252
commit
5ba0d435f0
44 files changed
+332
-20
No files matched your search
@@ -148,7 +148,7 @@ import {
|
||||
} from "@lucide/vue";
|
||||
import { buildDraftVisibleDatabasesConnectionId, connectionCanChooseVisibleDatabases, initialVisibleDatabaseSelection, visibleObjectFiltersNeedReset } from "@/lib/connection/connectionVisibleDatabases";
|
||||
import { canSaveVisibleDatabaseSelection, connectionUsesVisibleSchemaFilter, filterDatabaseNamesForVisiblePicker, filterSchemaNamesForVisiblePicker, normalizeVisibleDatabaseSelection, buildDraftVisibleSchemasConnectionId, normalizeVisibleSchemaSelection } from "@/lib/database/visibleDatabases";
|
||||
import { isSchemaAware, isSingleDatabase } from "@/lib/database/databaseFeatureSupport";
|
||||
import { isSchemaAware, isSingleDatabase, supportsDataDictionary } from "@/lib/database/databaseFeatureSupport";
|
||||
import { normalizeConnectionScope, normalizeConnectionTimeouts } from "@/lib/connection/connectionSubmitNormalization";
|
||||
import { databaseConnectionFormKind } from "@/lib/database/databaseDriverManifest";
|
||||
import VisibleSchemasDialog from "@/components/sidebar/VisibleSchemasDialog.vue";
|
||||
@@ -231,6 +231,7 @@ const DREMIO_ARROW_FLIGHT_SQL_JDBC_DRIVER_CLASS = "org.apache.arrow.driver.jdbc.
|
||||
const DREMIO_LEGACY_JDBC_URL = "jdbc:dremio:direct=127.0.0.1:31010";
|
||||
const DREMIO_LEGACY_JDBC_DRIVER_CLASS = "com.dremio.jdbc.Driver";
|
||||
const DEFAULT_SSH_USER = "root";
|
||||
const DIRECT_SIDEBAR_OBJECT_TYPES = new Set<DatabaseType>(["redis", "etcd", "zookeeper", "consul", "mongodb", "dynamodb", "elasticsearch", "easysearch", "meilisearch", "solr", "milvus", "qdrant", "weaviate", "chromadb", "mq", "mqtt", "nacos", "plugin"]);
|
||||
const ETCD_GRPC_MAX_INBOUND_DEFAULT_MIB = 32;
|
||||
const ETCD_GRPC_MAX_INBOUND_MIN_MIB = 1;
|
||||
const ETCD_GRPC_MAX_INBOUND_MAX_MIB = 256;
|
||||
@@ -441,6 +442,7 @@ const defaultForm = (): ConnectionForm => ({
|
||||
docs_notes_path: undefined,
|
||||
read_only: false,
|
||||
show_system_schemas: false,
|
||||
sidebar_auto_load_all_tables: false,
|
||||
is_production: false,
|
||||
production_databases: [],
|
||||
visible_databases: undefined,
|
||||
@@ -632,6 +634,7 @@ function sshLayersForConfig(config: LegacyConnectionConfig): SshTunnelConfig[] {
|
||||
}
|
||||
|
||||
const form = ref(defaultForm());
|
||||
const supportsAutomaticTableLoading = computed(() => supportsDataDictionary(form.value.db_type) && !DIRECT_SIDEBAR_OBJECT_TYPES.has(form.value.db_type));
|
||||
const redisKeyTemplatesText = ref("");
|
||||
const noteTextareaRef = ref<HTMLTextAreaElement | null>(null);
|
||||
const showGaussdbConnectionMode = computed(() => form.value.db_type === "gaussdb");
|
||||
@@ -3110,6 +3113,7 @@ watch(
|
||||
docs_notes_path: config.docs_notes_path,
|
||||
read_only: config.read_only || false,
|
||||
show_system_schemas: config.show_system_schemas || false,
|
||||
sidebar_auto_load_all_tables: config.sidebar_auto_load_all_tables === true,
|
||||
is_production: config.is_production || false,
|
||||
production_databases: config.production_databases || [],
|
||||
visible_databases: config.visible_databases,
|
||||
@@ -5141,6 +5145,7 @@ function connectionConfigForSubmit(id: string, generatedName = "", validatePlugi
|
||||
config.visible_databases = Array.isArray(config.visible_databases) && config.visible_databases.length > 0 ? config.visible_databases : undefined;
|
||||
}
|
||||
if (!config.show_system_schemas) config.show_system_schemas = undefined;
|
||||
if (!config.sidebar_auto_load_all_tables) config.sidebar_auto_load_all_tables = undefined;
|
||||
if (config.visible_schemas && Object.keys(config.visible_schemas).length === 0) config.visible_schemas = undefined;
|
||||
if (config.agent_java_options && config.agent_java_options.length === 0) config.agent_java_options = undefined;
|
||||
// Pasted credentials may carry invisible characters that trim() keeps (#9043).
|
||||
@@ -9878,6 +9883,16 @@ function openExternalUrl(url: string) {
|
||||
<span class="text-xs text-muted-foreground">{{ t("connection.showSystemSchemasHint") }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div v-if="supportsAutomaticTableLoading" class="grid grid-cols-4 items-start gap-4">
|
||||
<Label :class="connectionLabelSmallPaddedClass">{{ t("connection.tableLoading") }}</Label>
|
||||
<div class="col-span-3 grid gap-1.5">
|
||||
<label class="flex cursor-pointer items-center gap-2">
|
||||
<Switch v-model="form.sidebar_auto_load_all_tables" />
|
||||
<span class="text-sm font-medium">{{ t("connection.autoLoadAllTables") }}</span>
|
||||
</label>
|
||||
<p class="text-xs leading-5 text-muted-foreground">{{ t("connection.autoLoadAllTablesHint") }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Documentation notes are a relational-only feature, so this
|
||||
follows the same isSchemaAware gate as the row above. -->
|
||||
<div v-if="isSchemaAware(form.db_type)" class="grid grid-cols-4 items-start gap-4">
|
||||
|
||||
+2
-1
@@ -234,7 +234,7 @@ describe("ConnectionDialog deep-link edit confirmation", () => {
|
||||
});
|
||||
|
||||
it("updates the existing ID only after Save and preserves omitted fields", async () => {
|
||||
await mountDialog(savedConnection(), "dbx://connection/new?id=saved-production&password=new-password");
|
||||
await mountDialog(savedConnection({ sidebar_auto_load_all_tables: true }), "dbx://connection/new?id=saved-production&password=new-password");
|
||||
const save = [...document.querySelectorAll("button")].find((button) => button.textContent?.trim() === "Save");
|
||||
expect(save).toBeTruthy();
|
||||
save!.click();
|
||||
@@ -255,6 +255,7 @@ describe("ConnectionDialog deep-link edit confirmation", () => {
|
||||
is_production: true,
|
||||
production_databases: ["orders"],
|
||||
visible_databases: ["orders"],
|
||||
sidebar_auto_load_all_tables: true,
|
||||
url_params: "connectTimeout=25",
|
||||
}),
|
||||
);
|
||||
|
||||
@@ -87,7 +87,18 @@ import { canTreeNodePin, canTreeNodeShowExpander } from "@/lib/sidebar/sidebarTr
|
||||
import { sidebarConnectionVisibleFilterMenu } from "@/lib/sidebar/sidebarVisibleFilterMenu";
|
||||
import { supportsSidebarObjectNameFilter } from "@/lib/sidebar/sidebarObjectNameFilter";
|
||||
import { connectionGroupDestinationRows } from "@/lib/sidebar/sidebarLayout";
|
||||
import { hasTableVGroupEntries, isTableVGroupContainerNode, isTableVGroupGroupableRowType, resolveTableVGroupScopeFromNode, selectedTableVGroupMoveTargets, tableVGroupDestinationRows, tableVGroupPathForTable, tableVGroupScopeKey, tableVGroupsEnabled } from "@/lib/table/tableVGroup";
|
||||
import {
|
||||
hasTableTreeLoadMore,
|
||||
hasTableVGroupEntries,
|
||||
isTableVGroupContainerNode,
|
||||
isTableVGroupGroupableRowType,
|
||||
resolveTableVGroupScopeFromNode,
|
||||
selectedTableVGroupMoveTargets,
|
||||
tableVGroupDestinationRows,
|
||||
tableVGroupPathForTable,
|
||||
tableVGroupScopeKey,
|
||||
tableVGroupsEnabled,
|
||||
} from "@/lib/table/tableVGroup";
|
||||
import { objectTypesForGroupNode } from "@/lib/table/tableTree";
|
||||
import { loadSidebarObjectGroup } from "@/lib/sidebar/sidebarObjectGroupRouting";
|
||||
import { requestObjectBrowserSearchFocus } from "@/lib/tabs/objectBrowserSearchFocus";
|
||||
@@ -883,7 +894,8 @@ async function toggle(requestId = beginNavigationRequest()) {
|
||||
// particular, schema-level trigger/type groups have no tableName, so they
|
||||
// must use the generic object loader rather than the table-trigger loader.
|
||||
const databaseObjectGroup = !!objectTypesForGroupNode(node.type);
|
||||
if (databaseObjectGroup && connectionStore.canUseLoadedTreeNodeToggle(node)) {
|
||||
const needsConfiguredTablePageDrain = node.type === "group-tables" && connectionStore.getConfig(node.connectionId || "")?.sidebar_auto_load_all_tables === true && hasTableTreeLoadMore(node.children ?? []);
|
||||
if (databaseObjectGroup && connectionStore.canUseLoadedTreeNodeToggle(node) && !needsConfiguredTablePageDrain) {
|
||||
node.isExpanded = !node.isExpanded;
|
||||
if (wasExpanded && shouldReleaseCollapsedTreeNodeChildren()) connectionStore.releaseCollapsedTreeNodeChildren(node.id);
|
||||
emitNodeToggled(node, wasExpanded);
|
||||
|
||||
+36
@@ -259,6 +259,42 @@ describe("SidebarTreeRuntimeHost expansion", () => {
|
||||
expect(connectionStore.loadObjectGroupChildren).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("routes an opted-in partial table group back through the loader", async () => {
|
||||
const group: TreeNode = {
|
||||
id: "mysql:basic:__tables",
|
||||
label: "tree.tables",
|
||||
type: "group-tables",
|
||||
connectionId: "mysql",
|
||||
database: "basic",
|
||||
isExpanded: false,
|
||||
children: [
|
||||
{ id: "mysql:basic:orders", label: "orders", type: "table", connectionId: "mysql", database: "basic" },
|
||||
{
|
||||
id: "mysql:basic:__tables:__load_more:1000",
|
||||
label: "tree.loadMore",
|
||||
type: "load-more",
|
||||
connectionId: "mysql",
|
||||
database: "basic",
|
||||
loadMore: { parentId: "mysql:basic:__tables", offset: 1000, pageSize: 1000 },
|
||||
},
|
||||
],
|
||||
};
|
||||
connectionStore.getConfig.mockReturnValue({ db_type: "mysql", name: "connection", sidebar_auto_load_all_tables: true });
|
||||
|
||||
const host = ref<InstanceType<typeof SidebarTreeRuntimeHost> | null>(null);
|
||||
const app = createApp(defineComponent({ setup: () => () => h(SidebarTreeRuntimeHost, { ref: host, node: group, depth: 0 }) }));
|
||||
mountedApps.push(app);
|
||||
const container = document.createElement("div");
|
||||
document.body.append(container);
|
||||
app.use(i18n);
|
||||
app.mount(container);
|
||||
|
||||
host.value?.toggleNode(group);
|
||||
|
||||
await vi.waitFor(() => expect(connectionStore.loadObjectGroupChildren).toHaveBeenCalledWith(group, undefined));
|
||||
expect(group.isExpanded).toBe(true);
|
||||
});
|
||||
|
||||
it("publishes a rendered group collapse and synchronizes the live tree", async () => {
|
||||
const liveGroup: TreeNode = {
|
||||
id: "connection:database:__tables",
|
||||
|
||||
Reference in new issue
Block a user