Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,35 @@

export let store: ConnectorExplorerStore;
export let olapOnly: boolean = false;
/** Auto-expand this connector when the list first renders */
export let defaultExpanded: string = "";

const client = useRuntimeClient();

$: connectors = getAnalyzedConnectors(client, olapOnly);
$: ({ data, error } = $connectors);

// When defaultExpanded is set, pre-seed the store so only that connector
// starts expanded and others start collapsed.
let hasAutoExpanded = false;
$: if (defaultExpanded && data?.connectors && !hasAutoExpanded) {
for (const c of data.connectors) {
if (!c.name) continue;
// Pre-seed each connector before ConnectorEntry renders.
// This prevents getDefaultState from expanding all connectors.
store.store.update((state) => {
if (c.name! in state.expandedItems) return state;
return {
...state,
expandedItems: {
...state.expandedItems,
[c.name!]: c.name === defaultExpanded,
},
};
});
}
hasAutoExpanded = true;
}
</script>

<div class="wrapper">
Expand Down
19 changes: 14 additions & 5 deletions web-common/src/features/workspaces/VisualMetrics.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -287,13 +287,18 @@
tables.find(
(table) =>
table.name === modelOrSourceOrTableName &&
table.database === database &&
(table.databaseSchema === databaseSchema ||
(!databaseSchema && table.databaseSchema === "default")),
(!database || table.database === database) &&
(!databaseSchema || table.databaseSchema === databaseSchema),
);

$: tableMode = Boolean(hasValidOLAPTableSelected);

$: showConnectorExplorer =
!!yamlConnector ||
tableMode ||
!isModelingSupported ||
modelAndSourceOptions.length === 0;

function createDimensions(
rawDimensions: YAMLSeq<YAMLMap<string, string>>,
metricsViewDimensions: MetricsViewSpecDimension[],
Expand Down Expand Up @@ -543,7 +548,7 @@
<div class="wrapper">
<div class="main-area">
<div class="flex gap-x-4 border-b pb-4">
{#if tableMode || !isModelingSupported}
{#if showConnectorExplorer}
<div class="flex flex-col gap-y-1 w-full">
<InputLabel label="Table" id="table">
<svelte:fragment slot="mode-switch">
Expand Down Expand Up @@ -586,7 +591,11 @@
class="!min-w-64 overflow-hidden p-1"
>
<div class="size-full overflow-y-auto max-h-72">
<ConnectorExplorer {store} olapOnly />
<ConnectorExplorer
{store}
olapOnly
defaultExpanded={yamlConnector}
/>
</div>
</DropdownMenu.Content>
</DropdownMenu.Root>
Expand Down
Loading