Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Data Studio UX improvements & QoL fixes (#68320)

Gabriel Moreno3856fd989e39
diff --git a/e2e/support/helpers/e2e-data-studio-helpers.ts b/e2e/support/helpers/e2e-data-studio-helpers.ts
index fbc0a716d91..881ddec0b87 100644
--- a/e2e/support/helpers/e2e-data-studio-helpers.ts
+++ b/e2e/support/helpers/e2e-data-studio-helpers.ts
@@ -42,7 +42,7 @@ export const DataStudio = {
Snippets: {
newPage: newSnippetPage,
editPage: editSnippetPage,
- nameInput: () => newSnippetPage().findByPlaceholderText("New SQL snippet"),
+ nameInput: () => newSnippetPage().findByDisplayValue("New SQL snippet"),
descriptionInput: () => cy.findByPlaceholderText("No description"),
saveButton: () => cy.findByRole("button", { name: "Save" }),
cancelButton: () => cy.findByRole("button", { name: "Cancel" }),
diff --git a/e2e/test/scenarios/data-studio/snippets.cy.spec.ts b/e2e/test/scenarios/data-studio/snippets.cy.spec.ts
index 63fd4e9f007..192ea3e12ff 100644
--- a/e2e/test/scenarios/data-studio/snippets.cy.spec.ts
+++ b/e2e/test/scenarios/data-studio/snippets.cy.spec.ts
@@ -25,9 +25,9 @@ describe("scenarios > data studio > snippets", () => {
H.DataStudio.Snippets.saveButton().should("be.disabled");
H.DataStudio.Snippets.editor.type("SELECT * FROM orders");
- H.DataStudio.Snippets.saveButton().should("be.disabled");
+ H.DataStudio.Snippets.saveButton().should("be.enabled");
- H.DataStudio.Snippets.nameInput().type("Test snippet");
+ H.DataStudio.Snippets.nameInput().clear().type("Test snippet");
H.DataStudio.Snippets.saveButton().should("be.enabled");
H.DataStudio.Snippets.descriptionInput().type(
@@ -196,7 +196,7 @@ describe("scenarios > data studio > snippets", () => {
H.DataStudio.Library.newButton().click();
H.popover().findByText("New snippet").click();
- H.DataStudio.Snippets.nameInput().type("Folder snippet");
+ H.DataStudio.Snippets.nameInput().clear().type("Folder snippet");
H.DataStudio.Snippets.editor.type("SELECT 1");
H.DataStudio.Snippets.saveButton().click();
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/app/pages/LibrarySectionLayout/LibrarySectionLayout.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/app/pages/LibrarySectionLayout/LibrarySectionLayout.tsx
index 87293853499..7de8b8c82c6 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/app/pages/LibrarySectionLayout/LibrarySectionLayout.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/app/pages/LibrarySectionLayout/LibrarySectionLayout.tsx
@@ -1,5 +1,5 @@
import { useCallback, useMemo, useState } from "react";
-import { goBack, push } from "react-router-redux";
+import { goBack } from "react-router-redux";
import { t } from "ttag";
import _ from "underscore";
@@ -152,22 +152,22 @@ export function LibrarySectionLayout() {
[libraryCollection, isInstanceRemoteSyncEnabled],
);
- const handleItemSelect = useCallback(
- (item: TreeItem) => {
- if (item.model === "empty-state" || isEmptyStateData(item.data)) {
- return;
- }
- const entityId = item.data.id as number;
- if (item.model === "metric") {
- dispatch(push(Urls.dataStudioMetric(entityId)));
- } else if (item.model === "snippet") {
- dispatch(push(Urls.dataStudioSnippet(entityId)));
- } else if (item.model === "table") {
- dispatch(push(Urls.dataStudioTable(entityId)));
- }
- },
- [dispatch],
- );
+ const getItemHref = useCallback((item: TreeItem): string | null => {
+ if (item.model === "empty-state" || isEmptyStateData(item.data)) {
+ return null;
+ }
+ const entityId = item.data.id as number;
+ if (item.model === "metric") {
+ return Urls.dataStudioMetric(entityId);
+ }
+ if (item.model === "snippet") {
+ return Urls.dataStudioSnippet(entityId);
+ }
+ if (item.model === "table") {
+ return Urls.dataStudioTable(entityId);
+ }
+ return null;
+ }, []);
const {
tree: tablesTree,
isLoading: loadingTables,
@@ -322,11 +322,9 @@ export function LibrarySectionLayout() {
[setIsPublishTableModalOpen],
);
- const handleRowActivate = useCallback(
- (row: { original: TreeItem }) => {
- handleItemSelect(row.original);
- },
- [handleItemSelect],
+ const getRowHref = useCallback(
+ (row: { original: TreeItem }) => getItemHref(row.original),
+ [getItemHref],
);
const treeTableInstance = useTreeTableInstance({
@@ -339,7 +337,6 @@ export function LibrarySectionLayout() {
isFilterable: (node) =>
node.model !== "collection" && node.model !== "empty-state",
defaultExpanded: effectiveExpandedState,
- onRowActivate: handleRowActivate,
});
let emptyMessage = null;
@@ -395,10 +392,10 @@ export function LibrarySectionLayout() {
}
if (row.getCanExpand()) {
row.toggleExpanded();
- } else {
- handleRowActivate(row);
}
+ // Navigation for leaf nodes is handled by the link
}}
+ getRowHref={getRowHref}
/>
)}
</Card>
diff --git a/enterprise/frontend/src/metabase-enterprise/data-studio/snippets/pages/NewSnippetPage/NewSnippetPage.tsx b/enterprise/frontend/src/metabase-enterprise/data-studio/snippets/pages/NewSnippetPage/NewSnippetPage.tsx
index 21768ba460b..b49130bbb44 100644
--- a/enterprise/frontend/src/metabase-enterprise/data-studio/snippets/pages/NewSnippetPage/NewSnippetPage.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/data-studio/snippets/pages/NewSnippetPage/NewSnippetPage.tsx
@@ -36,7 +36,7 @@ type NewSnippetPageProps = {
export function NewSnippetPage({ route }: NewSnippetPageProps) {
const dispatch = useDispatch();
const [sendToast] = useToast();
- const [name, setName] = useState("");
+ const [name, setName] = useState(t`New SQL snippet`);
const [description, setDescription] = useState("");
const [content, setContent] = useState("");
const [isCollectionPickerOpen, setIsCollectionPickerOpen] = useState(false);
diff --git a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/GraphEntryInput/GraphEntryInput.tsx b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/GraphEntryInput/GraphEntryInput.tsx
index a4ed0bd9ade..756fb3f9df8 100644
--- a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/GraphEntryInput/GraphEntryInput.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/GraphEntryInput/GraphEntryInput.tsx
@@ -43,7 +43,7 @@ export function GraphEntryInput({
return (
<>
- <Card p={0} bdrs={0}>
+ <Card p={0} bdrs={0} bg="transparent">
{node != null ? (
<EntryButton
node={node}
diff --git a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/GraphSelectionInput/GraphSelectionInput.tsx b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/GraphSelectionInput/GraphSelectionInput.tsx
index 357794d3ed0..2e569cd95e4 100644
--- a/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/GraphSelectionInput/GraphSelectionInput.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/dependencies/components/DependencyGraph/GraphSelectionInput/GraphSelectionInput.tsx
@@ -26,7 +26,7 @@ export function GraphSelectInput({ nodes }: GraphSelectInputProps) {
};
return (
- <Card p={0} bdrs={0}>
+ <Card p={0} bdrs={0} bg="transparent">
{isOpened ? (
<Select
value={null}
diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/pages/TransformListPage/TransformListPage.tsx b/enterprise/frontend/src/metabase-enterprise/transforms/pages/TransformListPage/TransformListPage.tsx
index 9ca23b5ba6f..0ff8ab68f7f 100644
--- a/enterprise/frontend/src/metabase-enterprise/transforms/pages/TransformListPage/TransformListPage.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/transforms/pages/TransformListPage/TransformListPage.tsx
@@ -1,7 +1,6 @@
import type { Row } from "@tanstack/react-table";
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
import type { WithRouterProps } from "react-router";
-import { push } from "react-router-redux";
import { t } from "ttag";
import {
@@ -14,7 +13,6 @@ import { Ellipsified } from "metabase/common/components/Ellipsified";
import { LoadingAndErrorWrapper } from "metabase/common/components/LoadingAndErrorWrapper";
import CS from "metabase/css/core/index.css";
import type { ColorName } from "metabase/lib/colors/types";
-import { useDispatch } from "metabase/lib/redux";
import * as Urls from "metabase/lib/urls";
import { PLUGIN_TRANSFORMS_PYTHON } from "metabase/plugins";
import type { TreeTableColumnDef } from "metabase/ui";
@@ -80,7 +78,6 @@ const globalFilterFn = (
};
export const TransformListPage = ({ location }: WithRouterProps) => {
- const dispatch = useDispatch();
const targetCollectionId =
Urls.extractEntityId(location.query?.collectionId) ?? null;
const hasScrolledRef = useRef(false);
@@ -191,23 +188,15 @@ export const TransformListPage = ({ location }: WithRouterProps) => {
[],
);
- const navigateToTransform = useCallback(
- (transformId: number) => {
- dispatch(push(Urls.transform(transformId)));
- },
- [dispatch],
- );
-
- const handleRowActivate = useCallback(
- (row: Row<TreeNode>) => {
- if (row.original.nodeType === "transform" && row.original.transformId) {
- navigateToTransform(row.original.transformId);
- } else if (row.original.nodeType === "library" && row.original.url) {
- dispatch(push(row.original.url));
- }
- },
- [navigateToTransform, dispatch],
- );
+ const getRowHref = useCallback((row: Row<TreeNode>) => {
+ if (row.original.nodeType === "transform" && row.original.transformId) {
+ return Urls.transform(row.original.transformId);
+ }
+ if (row.original.nodeType === "library" && row.original.url) {
+ return row.original.url;
+ }
+ return null;
+ }, []);
const treeTableInstance = useTreeTableInstance({
data: treeData,
@@ -220,24 +209,14 @@ export const TransformListPage = ({ location }: WithRouterProps) => {
onGlobalFilterChange: setSearchQuery,
globalFilterFn,
isFilterable,
- onRowActivate: handleRowActivate,
});
- const handleRowClick = useCallback(
- (row: Row<TreeNode>) => {
- if (row.getCanExpand()) {
- row.toggleExpanded();
- } else if (
- row.original.nodeType === "transform" &&
- row.original.transformId
- ) {
- navigateToTransform(row.original.transformId);
- } else if (row.original.nodeType === "library" && row.original.url) {
- dispatch(push(row.original.url));
- }
- },
- [navigateToTransform, dispatch],
- );
+ const handleRowClick = useCallback((row: Row<TreeNode>) => {
+ // Navigation for leaf nodes (transforms, library) is handled by the link
+ if (row.getCanExpand()) {
+ row.toggleExpanded();
+ }
+ }, []);
useEffect(() => {
if (targetCollectionId && !hasScrolledRef.current && !isLoading) {
@@ -292,6 +271,7 @@ export const TransformListPage = ({ location }: WithRouterProps) => {
emptyMessage ? <ListEmptyState label={emptyMessage} /> : null
}
onRowClick={handleRowClick}
+ getRowHref={getRowHref}
/>
)}
</Card>
diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/pages/TransformQueryPage/TransformQueryPage.tsx b/enterprise/frontend/src/metabase-enterprise/transforms/pages/TransformQueryPage/TransformQueryPage.tsx
index 01a8f723b1a..b84fbfc7151 100644
--- a/enterprise/frontend/src/metabase-enterprise/transforms/pages/TransformQueryPage/TransformQueryPage.tsx
+++ b/enterprise/frontend/src/metabase-enterprise/transforms/pages/TransformQueryPage/TransformQueryPage.tsx
@@ -157,8 +157,6 @@ function TransformQueryPageBody({
};
const handleCancel = () => {
- setSourceAndRejectProposed(transform.source);
-
if (isEditMode) {
dispatch(push(Urls.transform(transform.id)));
}
diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTable.tsx b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTable.tsx
index c8c4099f6a5..e10fd069f8d 100644
--- a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTable.tsx
+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTable.tsx
@@ -30,6 +30,7 @@ export function TreeTable<TData extends TreeNodeData>({
isChildrenLoading,
isRowDisabled,
getRowProps,
+ getRowHref,
classNames,
styles,
ariaLabel,
@@ -191,6 +192,7 @@ export function TreeTable<TData extends TreeNodeData>({
classNames={classNames}
styles={styles}
getRowProps={getRowProps}
+ href={getRowHref?.(row)}
/>
);
})}
diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableRow/TreeTableRow.module.css b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableRow/TreeTableRow.module.css
index 0aba23603a4..2efca6f1c93 100644
--- a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableRow/TreeTableRow.module.css
+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableRow/TreeTableRow.module.css
@@ -54,3 +54,9 @@
text-overflow: ellipsis;
white-space: nowrap;
}
+
+.link {
+ display: block;
+ text-decoration: none;
+ color: inherit;
+}
diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableRow/TreeTableRow.tsx b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableRow/TreeTableRow.tsx
index 3a0f4472e32..e4ac7a2a874 100644
--- a/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableRow/TreeTableRow.tsx
+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/TreeTableRow/TreeTableRow.tsx
@@ -3,6 +3,7 @@ import { flexRender } from "@tanstack/react-table";
import cx from "classnames";
import type { MouseEvent } from "react";
import { memo, useMemo } from "react";
+import { Link } from "react-router";
import { Flex } from "metabase/ui";
@@ -218,9 +219,35 @@ export function TreeTableRow<TData extends TreeNodeData>({
classNames,
styles,
getRowProps,
+ href,
}: TreeTableRowProps<TData>) {
const rowProps = useMemo(() => getRowProps?.(row), [getRowProps, row]);
+ const content = (
+ <TreeTableRowContent
+ row={row}
+ rowIndex={rowIndex}
+ table={table}
+ columnWidths={columnWidths}
+ showCheckboxes={showCheckboxes}
+ showExpandButtons={showExpandButtons}
+ indentWidth={indentWidth}
+ activeRowId={activeRowId ?? null}
+ selectedRowId={selectedRowId ?? null}
+ isDisabled={isDisabled}
+ isChildrenLoading={isChildrenLoading}
+ isExpanded={isExpanded}
+ canExpand={canExpand}
+ getSelectionState={getSelectionState}
+ onCheckboxClick={onCheckboxClick}
+ onRowClick={onRowClick}
+ onRowDoubleClick={onRowDoubleClick}
+ classNames={classNames}
+ styles={styles}
+ rowProps={rowProps}
+ />
+ );
+
return (
<div
ref={measureElement}
@@ -228,28 +255,13 @@ export function TreeTableRow<TData extends TreeNodeData>({
className={S.root}
style={{ transform: `translateY(${virtualItem.start}px)` }}
>
- <TreeTableRowContent
- row={row}
- rowIndex={rowIndex}
- table={table}
- columnWidths={columnWidths}
- showCheckboxes={showCheckboxes}
- showExpandButtons={showExpandButtons}
- indentWidth={indentWidth}
- activeRowId={activeRowId ?? null}
- selectedRowId={selectedRowId ?? null}
- isDisabled={isDisabled}
- isChildrenLoading={isChildrenLoading}
- isExpanded={isExpanded}
- canExpand={canExpand}
- getSelectionState={getSelectionState}
- onCheckboxClick={onCheckboxClick}
- onRowClick={onRowClick}
- onRowDoubleClick={onRowDoubleClick}
- classNames={classNames}
- styles={styles}
- rowProps={rowProps}
- />
+ {href ? (
+ <Link to={href} className={S.link}>
+ {content}
+ </Link>
+ ) : (
+ content
+ )}
</div>
);
}
diff --git a/frontend/src/metabase/ui/components/data-display/TreeTable/types.ts b/frontend/src/metabase/ui/components/data-display/TreeTable/types.ts
index 6e1deb9531d..1c7a56976e1 100644
--- a/frontend/src/metabase/ui/components/data-display/TreeTable/types.ts
+++ b/frontend/src/metabase/ui/components/data-display/TreeTable/types.ts
@@ -236,6 +236,13 @@ export interface TreeTableProps<TData extends TreeNodeData>
*/
getRowProps?: (row: Row<TData>) => Record<string, unknown>;
+ /**
+ * Callback to get the href for a row. When provided and returns a non-null value,
+ * the row will be rendered as a link, enabling Cmd+Click to open in new tab.
+ * Return null for rows that shouldn't be links (e.g., expandable parent nodes).
+ */
+ getRowHref?: (row: Row<TData>) => string | null;
+
ariaLabel?: string;
ariaLabelledBy?: string;
}
@@ -265,6 +272,8 @@ export interface TreeTableRowProps<TData extends TreeNodeData>
getSelectionState?: (row: Row<TData>) => SelectionState;
onCheckboxClick?: (row: Row<TData>, index: number, event: MouseEvent) => void;
getRowProps?: (row: Row<TData>) => Record<string, unknown>;
+ /** When provided, renders the row as a link for Cmd+Click support */
+ href?: string | null;
}
/**