The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Native editor sidebar for transforms (#63287)
Romeo Van Snick2ce5dc4e4643
diff --git a/e2e/test/scenarios/admin/transforms.cy.spec.ts b/e2e/test/scenarios/admin/transforms.cy.spec.tsindex 9d9e69e60e5..905a4871716 100644--- a/e2e/test/scenarios/admin/transforms.cy.spec.ts+++ b/e2e/test/scenarios/admin/transforms.cy.spec.ts@@ -124,6 +124,63 @@ H.describeWithSnowplowEE("scenarios > admin > transforms", () => {H.assertQueryBuilderRowCount(3);});+ it("should be able to use the data reference and snippets when writing a SQL transform", () => {+ H.createSnippet({+ name: "snippet1",+ content: "1",+ });++ visitTransformListPage();+ getTransformListPage().button("Create a transform").click();+ H.popover().findByText("SQL query").click();+ H.popover().findByText(DB_NAME).click();++ function testDataReference() {+ cy.log("open the data reference");+ cy.findByTestId("native-query-editor-action-buttons")+ .findByLabelText("Learn about your data")+ .click();++ editorSidebar()+ .should("be.visible")+ .within(() => {+ cy.log("The current database should be opened by default");+ cy.findByText("Data Reference").should("not.exist");+ cy.findByText("Writable Postgres12").should("be.visible");+ });++ cy.findByTestId("native-query-editor-action-buttons")+ .findByLabelText("Learn about your data")+ .click();++ editorSidebar().should("not.exist");+ }++ function testSnippets() {+ cy.findByTestId("native-query-editor-action-buttons")+ .findByLabelText("SQL Snippets")+ .click();++ editorSidebar()+ .should("be.visible")+ .within(() => {+ cy.findByText("snippet1").should("be.visible");+ cy.icon("snippet").click();+ });++ H.NativeEditor.value().should("eq", "{{snippet: snippet1}}");++ cy.findByTestId("native-query-editor-action-buttons")+ .findByLabelText("SQL Snippets")+ .click();++ editorSidebar().should("not.exist");+ }++ testDataReference();+ testSnippets();+ });+it("should be able to create and run a transform from a question or a model", () => {function testCardSource({type,@@ -2250,3 +2307,7 @@ function assertOptionSelected(name: string) {function assertOptionNotSelected(name: string) {getTagsInputContainer().findByText(name).should("not.exist");}++function editorSidebar() {+ return cy.findByTestId("editor-sidebar");+}diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.tsx b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.tsxindex 6723064255d..18c4d78d964 100644--- a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.tsx+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorBody/EditorBody.tsx@@ -4,29 +4,54 @@ import { ResizableBox, type ResizableBoxProps } from "react-resizable";import type { CollectionPickerItem } from "metabase/common/components/Pickers/CollectionPicker";import type { DataPickerItem } from "metabase/common/components/Pickers/DataPicker";import { useSetting } from "metabase/common/hooks";-import NativeQueryEditor from "metabase/query_builder/components/NativeQueryEditor";+import NativeQueryEditor, {+ type SelectionRange,+} from "metabase/query_builder/components/NativeQueryEditor";import { Notebook } from "metabase/querying/notebook/components/Notebook";import { Box } from "metabase/ui";import { doesDatabaseSupportTransforms } from "metabase-enterprise/transforms/utils";import type Question from "metabase-lib/v1/Question";import type Database from "metabase-lib/v1/metadata/Database";import type NativeQuery from "metabase-lib/v1/queries/NativeQuery";-import type { Database as ApiDatabase, RecentItem } from "metabase-types/api";+import type {+ Database as ApiDatabase,+ NativeQuerySnippet,+ RecentItem,+} from "metabase-types/api";import S from "./EditorBody.module.css";import { ResizableBoxHandle } from "./ResizableBoxHandle";const EDITOR_HEIGHT = 400;+const NATIVE_EDITOR_SIDEBAR_FEATURES = {+ dataReference: true,+ variables: false,+ snippets: true,+ promptInput: true,+ formatQuery: true,+ aiGeneration: true,+};+type EditorBodyProps = {question: Question;isNative: boolean;isRunnable: boolean;isRunning: boolean;isResultDirty: boolean;+ isShowingDataReference: boolean;+ isShowingSnippetSidebar: boolean;onChange: (newQuestion: Question) => void;onRunQuery: () => Promise<void>;+ onToggleDataReference: () => void;+ onToggleSnippetSidebar: () => void;onCancelQuery: () => void;++ modalSnippet?: NativeQuerySnippet | null;+ onChangeModalSnippet: (snippet: NativeQuerySnippet | null) => void;+ onChangeNativeEditorSelection: (range: SelectionRange[]) => void;+ nativeEditorSelectedText?: string | null;+databases: ApiDatabase[];};@@ -36,10 +61,18 @@ export function EditorBody({isRunnable,isRunning,isResultDirty,+ isShowingDataReference,+ isShowingSnippetSidebar,onChange,onRunQuery,onCancelQuery,+ onToggleDataReference,+ onToggleSnippetSidebar,databases,+ modalSnippet,+ onChangeModalSnippet,+ onChangeNativeEditorSelection,+ nativeEditorSelectedText,}: EditorBodyProps) {const [isResizing, setIsResizing] = useState(false);const reportTimezone = useSetting("report-timezone-long");@@ -80,20 +113,28 @@ export function EditorBody({isRunning={isRunning}isResultDirty={isResultDirty}isInitiallyOpen+ isShowingDataReference={isShowingDataReference}+ isShowingSnippetSidebar={isShowingSnippetSidebar}isNativeEditorOpenhasTopBarhasRunButtonreadOnly={false}- hasEditingSidebar={false}hasParametersList={false}handleResize={handleResize}runQuery={onRunQuery}cancelQuery={onCancelQuery}setDatasetQuery={handleNativeQueryChange}+ sidebarFeatures={NATIVE_EDITOR_SIDEBAR_FEATURES}+ toggleDataReference={onToggleDataReference}+ toggleSnippetSidebar={onToggleSnippetSidebar}+ modalSnippet={modalSnippet}+ closeSnippetModal={() => onChangeModalSnippet(null)}databaseIsDisabled={(db: Database) => {const database = databases.find((database) => database.id === db.id);return !doesDatabaseSupportTransforms(database);}}+ setNativeEditorSelectedRange={onChangeNativeEditorSelection}+ nativeEditorSelectedText={nativeEditorSelectedText}/>) : (<ResizableBoxdiff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorHeader/EditorHeader.tsx b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorHeader/EditorHeader.tsxindex b025aeca7ae..a817cb0690d 100644--- a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorHeader/EditorHeader.tsx+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorHeader/EditorHeader.tsx@@ -23,6 +23,7 @@ export function EditorHeader({title={getTitle(isNew)}adminbuttons={[+ <Button key="cancel" small onClick={onCancel}>{t`Cancel`}</Button>,<Buttonkey="save"onClick={onSave}@@ -32,7 +33,6 @@ export function EditorHeader({>{getSaveButtonLabel(isNew, isSaving)}</Button>,- <Button key="cancel" small onClick={onCancel}>{t`Cancel`}</Button>,]}/>);diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/EditorSidebar.module.css b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/EditorSidebar.module.cssnew file mode 100644index 00000000000..2785ac2ec97--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/EditorSidebar.module.css@@ -0,0 +1,3 @@+.sidebar {+ border-left: 1px solid var(--mb-color-border);+}diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/EditorSidebar.tsx b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/EditorSidebar.tsxnew file mode 100644index 00000000000..97b6ba8437e--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/EditorSidebar.tsx@@ -0,0 +1,104 @@+import { useState } from "react";+import { useMount } from "react-use";+import { match } from "ts-pattern";++import DataReference from "metabase/query_builder/components/dataref/DataReference";+import { SnippetSidebar } from "metabase/query_builder/components/template_tags/SnippetSidebar";+import { Box } from "metabase/ui";+import type Question from "metabase-lib/v1/Question";+import type { NativeQuerySnippet } from "metabase-types/api";++import S from "./EditorSidebar.module.css";++type EditorSidebarProps = {+ question: Question;+ isNative?: boolean;+ isSnippetSidebarOpen?: boolean;+ isDataReferenceOpen?: boolean;+ onToggleDataReference: () => void;+ onToggleSnippetSidebar: () => void;+ onChangeModalSnippet: (snippet: NativeQuerySnippet) => void;+ onInsertSnippet: (snippet: NativeQuerySnippet) => void;+};++export function EditorSidebar(props: EditorSidebarProps) {+ const { isNative } = props;+ if (!isNative) {+ return null;+ }+ return <NativeQueryEditorSidebar {...props} />;+}++function NativeQueryEditorSidebar({+ isSnippetSidebarOpen,+ isDataReferenceOpen,+ ...props+}: EditorSidebarProps) {+ if (!isSnippetSidebarOpen && !isDataReferenceOpen) {+ return null;+ }++ return (+ <Box className={S.sidebar} h="100%" w="40%" data-testid="editor-sidebar">+ {match({ isSnippetSidebarOpen, isDataReferenceOpen })+ .with({ isSnippetSidebarOpen: true }, () => (+ <EditorSnippetSidebar {...props} />+ ))+ .with({ isDataReferenceOpen: true }, () => (+ <EditorDataReferenceSidebar {...props} />+ ))+ .otherwise(() => null)}+ </Box>+ );+}++function EditorDataReferenceSidebar({+ question,+ onToggleDataReference,+}: EditorSidebarProps) {+ const [dataReferenceStack, setDataReferenceStack] = useState<any[]>([]);++ useMount(() => {+ const databaseId = question.databaseId();+ if (dataReferenceStack.length === 0 && databaseId !== null) {+ pushDataReferenceStack({ type: "database", item: { id: databaseId } });+ }+ });++ const pushDataReferenceStack = (ref: any) => {+ setDataReferenceStack([...dataReferenceStack, ref]);+ };++ const popDataReferenceStack = () => {+ setDataReferenceStack(dataReferenceStack.slice(0, -1));+ };++ const toggleDataReference = () => {+ onToggleDataReference();+ };++ return (+ <DataReference+ dataReferenceStack={dataReferenceStack}+ popDataReferenceStack={popDataReferenceStack}+ pushDataReferenceStack={pushDataReferenceStack}+ onClose={toggleDataReference}+ />+ );+}++function EditorSnippetSidebar({+ onToggleSnippetSidebar,+ onChangeModalSnippet,+ onInsertSnippet,+}: EditorSidebarProps) {+ return (+ <SnippetSidebar+ onClose={onToggleSnippetSidebar}+ setModalSnippet={onChangeModalSnippet}+ openSnippetModalWithSelectedText={onChangeModalSnippet}+ snippetCollectionId={null}+ insertSnippet={onInsertSnippet}+ />+ );+}diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/index.ts b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/index.tsnew file mode 100644index 00000000000..406f6c4ed29--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/EditorSidebar/index.ts@@ -0,0 +1 @@+export * from "./EditorSidebar";diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/QueryEditor.tsx b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/QueryEditor.tsxindex 6c2ae8f1ea0..7274d91de50 100644--- a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/QueryEditor.tsx+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/QueryEditor.tsx@@ -1,10 +1,12 @@-import { useHotkeys } from "@mantine/hooks";+import { useDisclosure, useHotkeys } from "@mantine/hooks";+import { useState } from "react";import { useListDatabasesQuery } from "metabase/api";-import { Center, Flex, Loader } from "metabase/ui";+import type { SelectionRange } from "metabase/query_builder/components/NativeQueryEditor/types";+import { Center, Flex, Loader, Stack } from "metabase/ui";import * as Lib from "metabase-lib";import type Question from "metabase-lib/v1/Question";-import type { DatasetQuery } from "metabase-types/api";+import type { DatasetQuery, NativeQuerySnippet } from "metabase-types/api";import { useQueryMetadata } from "../../hooks/use-query-metadata";import { useQueryResults } from "../../hooks/use-query-results";@@ -12,8 +14,10 @@ import { useQueryState } from "../../hooks/use-query-state";import { EditorBody } from "./EditorBody";import { EditorHeader } from "./EditorHeader";+import { EditorSidebar } from "./EditorSidebar";import { EditorVisualization } from "./EditorVisualization";import S from "./QueryEditor.module.css";+import { useInsertSnippetHandler, useSelectedText } from "./util";type QueryEditorProps = {initialQuery: DatasetQuery;@@ -60,8 +64,39 @@ export function QueryEditor({}};+ const [+ isDataReferenceOpen,+ { toggle: toggleDataReference, close: closeDataReference },+ ] = useDisclosure();+ const [+ isSnippetSidebarOpen,+ { toggle: toggleSnippetSidebar, close: closeSnippetSidebar },+ ] = useDisclosure();+useHotkeys([["mod+Enter", handleCmdEnter]], []);+ const handleToggleDataReference = () => {+ closeSnippetSidebar();+ toggleDataReference();+ };++ const handleToggleSnippetSidebar = () => {+ closeDataReference();+ toggleSnippetSidebar();+ };++ const [selectionRange, setSelectionRange] = useState<SelectionRange[]>([]);+ const selectedText = useSelectedText(question, selectionRange);+ const handleInsertSnippet = useInsertSnippetHandler({+ question,+ selectionRange,+ onChange: handleChange,+ });++ const [modalSnippet, setModalSnippet] = useState<NativeQuerySnippet | null>(+ null,+ );+const { data: databases, isLoading } = useListDatabasesQuery({include_analytics: true,});@@ -75,13 +110,13 @@ export function QueryEditor({}return (- <Flex+ <StackclassName={S.root}w="100%"h="100%"- direction="column"bg="bg-white"data-testid="transform-query-editor"+ gap={0}><EditorHeaderisNew={isNew}@@ -90,28 +125,50 @@ export function QueryEditor({onSave={handleSave}onCancel={onCancel}/>- <EditorBody- question={question}- isNative={isNative}- isRunnable={isRunnable}- isRunning={isRunning}- isResultDirty={isResultDirty}- onChange={handleChange}- onRunQuery={runQuery}- onCancelQuery={cancelQuery}- databases={databases?.data ?? []}- />- <EditorVisualization- question={question}- result={result}- rawSeries={rawSeries}- isNative={isNative}- isRunnable={isRunnable}- isRunning={isRunning}- isResultDirty={isResultDirty}- onRunQuery={runQuery}- onCancelQuery={() => undefined}- />- </Flex>+ <Flex h="100%" w="100%">+ <Stack flex="2 1 100%">+ <EditorBody+ question={question}+ isNative={isNative}+ isRunnable={isRunnable}+ isRunning={isRunning}+ isResultDirty={isResultDirty}+ isShowingDataReference={isDataReferenceOpen}+ isShowingSnippetSidebar={isSnippetSidebarOpen}+ onChange={handleChange}+ onRunQuery={runQuery}+ onCancelQuery={cancelQuery}+ databases={databases?.data ?? []}+ onToggleDataReference={handleToggleDataReference}+ onToggleSnippetSidebar={handleToggleSnippetSidebar}+ modalSnippet={modalSnippet}+ onChangeModalSnippet={setModalSnippet}+ onChangeNativeEditorSelection={setSelectionRange}+ nativeEditorSelectedText={selectedText}+ />+ <EditorVisualization+ question={question}+ result={result}+ rawSeries={rawSeries}+ isNative={isNative}+ isRunnable={isRunnable}+ isRunning={isRunning}+ isResultDirty={isResultDirty}+ onRunQuery={runQuery}+ onCancelQuery={() => undefined}+ />+ </Stack>+ <EditorSidebar+ question={question}+ isNative={isNative}+ isDataReferenceOpen={isDataReferenceOpen}+ isSnippetSidebarOpen={isSnippetSidebarOpen}+ onToggleDataReference={toggleDataReference}+ onToggleSnippetSidebar={toggleSnippetSidebar}+ onChangeModalSnippet={setModalSnippet}+ onInsertSnippet={handleInsertSnippet}+ />+ </Flex>+ </Stack>);}diff --git a/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/util.ts b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/util.tsnew file mode 100644index 00000000000..522f102a77b--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/transforms/components/QueryEditor/util.ts@@ -0,0 +1,70 @@+import { useMemo } from "react";++import type {+ Location,+ SelectionRange,+} from "metabase/query_builder/components/NativeQueryEditor/types";+import * as Lib from "metabase-lib";+import type Question from "metabase-lib/v1/Question";+import type { NativeQuerySnippet } from "metabase-types/api";++const EMPTY_SELECTION_RANGE: SelectionRange = {+ start: { row: 0, column: 0 },+ end: { row: 0, column: 0 },+};++function locationToPosition(text: string, location: Location): number {+ const lines = text.split("\n");+ return lines.reduce((acc, line, index) => {+ if (index < location.row) {+ return acc + line.length + 1;+ }+ return acc;+ }, location.column);+}++function getSelectionPositions(text: string, selectionRange: SelectionRange[]) {+ const range = selectionRange[0] ?? EMPTY_SELECTION_RANGE;++ return {+ start: locationToPosition(text, range.start),+ end: locationToPosition(text, range.end),+ };+}++export function useSelectedText(+ question: Question,+ selectionRange: SelectionRange[],+) {+ return useMemo(() => {+ const query = question.query();+ const text = Lib.rawNativeQuery(query) ?? "";+ const { start, end } = getSelectionPositions(text, selectionRange);+ return text.slice(start, end);+ }, [question, selectionRange]);+}++export function useInsertSnippetHandler({+ selectionRange,+ question,+ onChange,+}: {+ selectionRange: SelectionRange[];+ question: Question;+ onChange: (question: Question) => void;+}) {+ return function handleInsertSnippet(snippet: NativeQuerySnippet) {+ const query = question.query();+ const text = Lib.rawNativeQuery(query) ?? "";++ const { start, end } = getSelectionPositions(text, selectionRange);++ const pre = text.slice(0, start);+ const post = text.slice(end);++ const newText = `${pre}{{snippet: ${snippet.name}}}${post}`;+ const newQuery = Lib.withNativeQuery(query, newText);++ onChange(question.setQuery(newQuery));+ };+}diff --git a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.tsx b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.tsxindex 3918c12e131..1f5b9b8a761 100644--- a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.tsx+++ b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditor.tsx@@ -297,6 +297,7 @@ class NativeQueryEditor extends Component<Props, NativeQueryEditorState> {isNativeEditorOpen={this.props.isNativeEditorOpen}toggleEditor={this.props.toggleEditor}toggleDataReference={this.props.toggleDataReference}+ toggleSnippetSidebar={this.props.toggleSnippetSidebar}setParameterValue={this.props.setParameterValue}setDatasetQuery={this.props.setDatasetQuery}onFormatQuery={canFormatQuery ? this.handleFormatQuery : undefined}diff --git a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditorActionButtons/NativeQueryEditorActionButtons.tsx b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditorActionButtons/NativeQueryEditorActionButtons.tsxindex c5766f73772..70a8ddf79a0 100644--- a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditorActionButtons/NativeQueryEditorActionButtons.tsx+++ b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditorActionButtons/NativeQueryEditorActionButtons.tsx@@ -32,6 +32,7 @@ interface NativeQueryEditorActionButtonsProps {runQuery?: () => void;cancelQuery?: () => void;toggleDataReference?: () => void;+ toggleSnippetSidebar?: () => void;onOpenModal?: (modalType: QueryModalType) => void;onFormatQuery?: () => void;onGenerateQuery: (queryText: string) => void;diff --git a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditorTopBar/NativeQueryEditorTopBar.tsx b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditorTopBar/NativeQueryEditorTopBar.tsxindex fe70cf7f73b..fbae612187f 100644--- a/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditorTopBar/NativeQueryEditorTopBar.tsx+++ b/frontend/src/metabase/query_builder/components/NativeQueryEditor/NativeQueryEditorTopBar/NativeQueryEditorTopBar.tsx@@ -43,6 +43,7 @@ interface NativeQueryEditorTopBarProps {toggleEditor?: () => void;toggleDataReference?: () => void;+ toggleSnippetSidebar?: () => void;setIsNativeEditorOpen?: (isOpen: boolean) => void;onFormatQuery?: () => void;onSetDatabaseId?: (id: DatabaseId) => void;@@ -81,6 +82,7 @@ const NativeQueryEditorTopBar = (props: NativeQueryEditorTopBarProps) => {setIsNativeEditorOpen,toggleEditor,toggleDataReference,+ toggleSnippetSidebar,onSetDatabaseId,hasParametersList = true,setDatasetQuery,@@ -162,6 +164,7 @@ const NativeQueryEditorTopBar = (props: NativeQueryEditorTopBarProps) => {isShowingTemplateTagsEditor={isShowingTemplateTagsEditor}isShowingSnippetSidebar={isShowingSnippetSidebar}toggleDataReference={toggleDataReference}+ toggleSnippetSidebar={toggleSnippetSidebar}onOpenModal={onOpenModal}/>)}diff --git a/frontend/src/metabase/query_builder/components/NativeQueryEditor/index.ts b/frontend/src/metabase/query_builder/components/NativeQueryEditor/index.tsindex fb05c5a05e1..5f1c2c2a7b9 100644--- a/frontend/src/metabase/query_builder/components/NativeQueryEditor/index.ts+++ b/frontend/src/metabase/query_builder/components/NativeQueryEditor/index.ts@@ -1,2 +1,3 @@// eslint-disable-next-line import/no-default-export -- deprecated usageexport { default } from "./NativeQueryEditor";+export { type SelectionRange } from "./types";diff --git a/frontend/src/metabase/query_builder/components/view/DataReferenceButton/DataReferenceButton.tsx b/frontend/src/metabase/query_builder/components/view/DataReferenceButton/DataReferenceButton.tsxindex edab4316f34..a01a4859ab1 100644--- a/frontend/src/metabase/query_builder/components/view/DataReferenceButton/DataReferenceButton.tsx+++ b/frontend/src/metabase/query_builder/components/view/DataReferenceButton/DataReferenceButton.tsx@@ -33,6 +33,7 @@ export const DataReferenceButton = ({return (<Tooltip label={t`Learn about your data`}><Box+ aria-label={t`Learn about your data`}component="a"h={size}className={cx(className, DataReferenceButtonS.ButtonRoot, {diff --git a/frontend/src/metabase/query_builder/components/view/SnippetSidebarButton/SnippetSidebarButton.tsx b/frontend/src/metabase/query_builder/components/view/SnippetSidebarButton/SnippetSidebarButton.tsxindex c8c8aca8025..ad7bf740b94 100644--- a/frontend/src/metabase/query_builder/components/view/SnippetSidebarButton/SnippetSidebarButton.tsx+++ b/frontend/src/metabase/query_builder/components/view/SnippetSidebarButton/SnippetSidebarButton.tsx@@ -1,8 +1,6 @@import cx from "classnames";import { t } from "ttag";-import { useDispatch } from "metabase/lib/redux";-import { toggleSnippetSidebar } from "metabase/query_builder/actions/native";import { Box, Icon, Tooltip } from "metabase/ui";import SnippetSidebarButtonS from "./SnippetSidebarButton.module.css";@@ -10,32 +8,27 @@ import SnippetSidebarButtonS from "./SnippetSidebarButton.module.css";interface SnippetSidebarButtonProps {className?: string;isShowingSnippetSidebar: boolean;+ toggleSnippetSidebar?: () => void;size: number;}export const SnippetSidebarButton = ({className,isShowingSnippetSidebar,+ toggleSnippetSidebar,size,}: SnippetSidebarButtonProps) => {- const dispatch = useDispatch();-return (<Tooltip label={t`SQL Snippets`}><Box+ aria-label={t`SQL Snippets`}component="a"h={size}className={cx(className, SnippetSidebarButtonS.ButtonRoot, {[SnippetSidebarButtonS.isSelected]: isShowingSnippetSidebar,})}>- <Icon- name="snippet"- size={size}- onClick={() => {- dispatch(toggleSnippetSidebar());- }}- />+ <Icon name="snippet" size={size} onClick={toggleSnippetSidebar} /></Box></Tooltip>);