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
GDGT-3076 Toast notifications are truncated for unavailable visualizations (#79766)
Kamil Mielnik22e69fce8be3
diff --git a/e2e/test/scenarios/visualizations-charts/custom-viz.cy.spec.ts b/e2e/test/scenarios/visualizations-charts/custom-viz.cy.spec.tsindex 631f5cafeb5..e3e6f1fe1a5 100644--- a/e2e/test/scenarios/visualizations-charts/custom-viz.cy.spec.ts+++ b/e2e/test/scenarios/visualizations-charts/custom-viz.cy.spec.ts@@ -689,6 +689,39 @@ describe("admin > custom visualizations", () => {.should("be.visible");});+ it("shows a single combined toast when multiple plugin bundles fail to load (metabase#GDGT-3076)", () => {+ H.addCustomVizPlugin(H.CUSTOM_VIZ_FIXTURE_TGZ_2);+ H.addCustomVizPlugin(H.CUSTOM_VIZ_FIXTURE_TGZ_3_SECURITY);+ H.addCustomVizPlugin(H.CUSTOM_VIZ_FIXTURE_TGZ_4_SECURITY_COMPONENT);++ cy.intercept("GET", "/api/ee/custom-viz-plugin/*/bundle*", {+ statusCode: 500,+ body: "boom",+ }).as("failedBundle");++ H.visitQuestion("@questionId");+ cy.findByTestId("viz-type-button").click();+ cy.wait([+ "@failedBundle",+ "@failedBundle",+ "@failedBundle",+ "@failedBundle",+ ]);++ H.undoToastList()+ .should("have.length", 1)+ .findByText(+ '4 visualizations are currently unavailable: "demo-viz", "demo-viz-2", "demo-viz-security", "demo-viz-security-component".',+ )+ .should("be.visible")+ // The message must wrap instead of truncating, i.e. be taller than one line+ .invoke("outerHeight")+ .should("be.gt", 30);++ // The message must not collapse to min-content+ H.undoToastList().invoke("outerWidth").should("be.within", 300, 700);+ });+it("falls back to the default viz when the bundle endpoint fails, then recovers on revisit", () => {const bundleMatcher = {method: "GET",diff --git a/enterprise/frontend/src/embedding-sdk-ee/custom-viz/initialize.ts b/enterprise/frontend/src/embedding-sdk-ee/custom-viz/initialize.tsindex e84d76df3a3..b5fb7082c60 100644--- a/enterprise/frontend/src/embedding-sdk-ee/custom-viz/initialize.ts+++ b/enterprise/frontend/src/embedding-sdk-ee/custom-viz/initialize.ts@@ -1,5 +1,6 @@import { useCallback, useEffect, useMemo, useState } from "react";+import { logUnavailableCustomVizMessage } from "embedding-sdk-bundle/lib/log-unavailable-custom-viz";import { useMetabaseProviderPropsStore } from "embedding-sdk-shared/hooks/use-metabase-provider-props-store";import { ensureMetabaseProviderPropsStore } from "embedding-sdk-shared/lib/ensure-metabase-provider-props-store";import { api } from "metabase/api/client";@@ -173,6 +174,7 @@ export function initializeSdkCustomVizPlugin() {}return await eeLoadCustomVizPlugin(plugin, {sandboxMode: getSdkSandboxMode(),+ onMessage: logUnavailableCustomVizMessage,});} catch {return null;@@ -195,6 +197,7 @@ export function initializeSdkCustomVizPlugin() {return eeUseAutoLoadCustomVizPlugin(allowed ? display : undefined, {sandboxMode: getSdkSandboxMode(),+ onMessage: logUnavailableCustomVizMessage,});},diff --git a/enterprise/frontend/src/metabase-enterprise/custom_viz/custom-viz-plugins.tsx b/enterprise/frontend/src/metabase-enterprise/custom_viz/custom-viz-plugins.tsxindex 2eda293d114..6f035415e54 100644--- a/enterprise/frontend/src/metabase-enterprise/custom_viz/custom-viz-plugins.tsx+++ b/enterprise/frontend/src/metabase-enterprise/custom_viz/custom-viz-plugins.tsx@@ -11,7 +11,7 @@ import { t } from "ttag";import { api } from "metabase/api/client";import { ExplicitSize } from "metabase/common/components/ExplicitSize";-import { useToast } from "metabase/common/hooks";+import { type ToastArgs, useToast } from "metabase/common/hooks";import type { IconData } from "metabase/common/utils/icon";import { useEmbeddingEntityContext } from "metabase/embedding/context";import { PLUGIN_CUSTOM_VIZ } from "metabase/plugins";@@ -38,6 +38,7 @@ import { applyDefaultVisualizationProps } from "./custom-viz-common";import { ensureVizApi } from "./custom-viz-globals";import type { SandboxMode } from "./sandbox";import { usePluginMount } from "./use-plugin-mount";+import { reportUnavailableCustomVizPlugin } from "./utils/unavailable-toast";// Track which plugins have already been loaded to avoid re-execution.// Maps plugin id → { identifier, hash } so we can detect when a re-uploaded@@ -105,7 +106,7 @@ function useCustomVizDevReload(display: string | undefined,plugins: CustomVizPluginRuntime[] | undefined,setLoading: (loading: boolean) => void,- onInfo: (message: string) => void,+ onMessage: (toast: ToastArgs) => void,sandboxMode: SandboxMode = "hosted",) {useEffect(() => {@@ -134,7 +135,7 @@ function useCustomVizDevReload(try {await loadCustomVizPlugin(plugin, {cacheBustSuffix: `?t=${Date.now()}`,- onInfo,+ onMessage,sandboxMode,});} finally {@@ -149,11 +150,12 @@ function useCustomVizDevReload(return () => {eventSource.close();};- }, [display, onInfo, plugins, setLoading, sandboxMode]);+ }, [display, onMessage, plugins, setLoading, sandboxMode]);}export type UseAutoLoadCustomVizPluginOptions = {sandboxMode?: SandboxMode;+ onMessage?: (toast: ToastArgs) => void;};/**@@ -173,6 +175,7 @@ export function useAutoLoadCustomVizPlugin(const { sandboxMode = "hosted" } = options;const { plugins, disabled } = useCustomVizPlugins();const [sendToast] = useToast();+ const onMessage = options.onMessage ?? sendToast;const [loading, setLoadingState] = useState(false);const loadingRef = useRef<string | null>(null);@@ -185,13 +188,6 @@ export function useAutoLoadCustomVizPlugin(setLoadingState(loadingCountRef.current > 0);}, []);- const onInfo = useCallback(- (message: string) => {- sendToast({ message });- },- [sendToast],- );-const load = useCallback(async (pluginToLoad: CustomVizPluginRuntime) => {const identifier = getCustomPluginIdentifier(pluginToLoad);@@ -210,7 +206,7 @@ export function useAutoLoadCustomVizPlugin(setLoading(true);try {await loadCustomVizPlugin(pluginToLoad, {- onInfo,+ onMessage,sandboxMode,});} finally {@@ -218,7 +214,7 @@ export function useAutoLoadCustomVizPlugin(setLoading(false);}},- [onInfo, sandboxMode, setLoading],+ [onMessage, sandboxMode, setLoading],);useEffect(() => {@@ -234,7 +230,7 @@ export function useAutoLoadCustomVizPlugin(load(plugin);}, [display, plugins, load]);- useCustomVizDevReload(display, plugins, setLoading, onInfo, sandboxMode);+ useCustomVizDevReload(display, plugins, setLoading, onMessage, sandboxMode);// `loading` state drives re-renders when async load completes.// Without it, the Map-based check alone wouldn't trigger a re-render.@@ -290,7 +286,7 @@ export function useAutoLoadCustomVizPlugin(export type LoadCustomVizPluginOptions = {cacheBustSuffix?: string;- onInfo?: (message: string) => void;+ onMessage?: (toast: ToastArgs) => void;sandboxMode?: SandboxMode;};@@ -310,7 +306,7 @@ export async function loadCustomVizPlugin(plugin: CustomVizPluginRuntime,options: LoadCustomVizPluginOptions = {},): Promise<string | null> {- const { cacheBustSuffix, onInfo, sandboxMode = "hosted" } = options;+ const { cacheBustSuffix, onMessage, sandboxMode = "hosted" } = options;const existing = loadedPlugins.get(plugin.id);const currentHash = plugin.bundle_hash ?? null;if (@@ -454,11 +450,7 @@ export async function loadCustomVizPlugin(}console.error(t`Failed to load plugin "${plugin.display_name}":`, error);if (!failedPluginHashes.has(plugin.id)) {- onInfo?.(- plugin.warnings.length > 0- ? t`The "${plugin.display_name}" visualization is currently unavailable. It was built for a different version and may need to be updated.`- : t`The "${plugin.display_name}" visualization is currently unavailable.`,- );+ reportUnavailableCustomVizPlugin(plugin, onMessage);}failedPluginHashes.set(plugin.id, currentHash);return null;diff --git a/enterprise/frontend/src/metabase-enterprise/custom_viz/utils/unavailable-toast.ts b/enterprise/frontend/src/metabase-enterprise/custom_viz/utils/unavailable-toast.tsnew file mode 100644index 00000000000..c3c5f6af9b3--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/custom_viz/utils/unavailable-toast.ts@@ -0,0 +1,94 @@+import { c, t } from "ttag";++import type {+ CustomVizPluginId,+ CustomVizPluginRuntime,+} from "metabase-types/api";++import type { LoadCustomVizPluginOptions } from "../custom-viz-plugins";++const FLUSH_DELAY_MS = 300;++const pendingPlugins = new Map<CustomVizPluginId, CustomVizPluginRuntime>();+let latestOnMessage: LoadCustomVizPluginOptions["onMessage"] | undefined;+let flushTimeoutId: ReturnType<typeof setTimeout> | null = null;++/**+ * Collects unavailable plugin reports over a short window and shows them as a single toast.+ */+export function reportUnavailableCustomVizPlugin(+ plugin: CustomVizPluginRuntime,+ onMessage?: LoadCustomVizPluginOptions["onMessage"],+) {+ pendingPlugins.set(plugin.id, plugin);+ latestOnMessage = onMessage;++ if (!latestOnMessage) {+ return;+ }++ if (flushTimeoutId != null) {+ clearTimeout(flushTimeoutId);+ }++ flushTimeoutId = setTimeout(+ flushUnavailableCustomVizPluginReports,+ FLUSH_DELAY_MS,+ );+}++export function resetUnavailableCustomVizPluginReports() {+ pendingPlugins.clear();+ latestOnMessage = undefined;++ if (flushTimeoutId != null) {+ clearTimeout(flushTimeoutId);+ flushTimeoutId = null;+ }+}++function flushUnavailableCustomVizPluginReports() {+ const plugins = [...pendingPlugins.values()];+ const onMessage = latestOnMessage;++ resetUnavailableCustomVizPluginReports();++ if (plugins.length > 0 && onMessage) {+ onMessage({+ icon: "warning_triangle_filled",+ iconColor: "feedback-warning",+ message: getUnavailableMessage(plugins),+ });+ }+}++function getUnavailableMessage(plugins: CustomVizPluginRuntime[]) {+ return plugins.length === 1+ ? getSingularMessage(plugins[0])+ : getPluralMessage(plugins);+}++function getSingularMessage({+ display_name,+ warnings,+}: CustomVizPluginRuntime) {+ return warnings.length > 0+ ? t`The "${display_name}" visualization is currently unavailable. It was built for a different version and may need to be updated.`+ : t`The "${display_name}" visualization is currently unavailable.`;+}++function getPluralMessage(plugins: CustomVizPluginRuntime[]) {+ const names = plugins+ .map(({ display_name }) => display_name)+ .sort((a, b) => a.localeCompare(b))+ .map((name) => `"${name}"`)+ .join(", ");+ const message = c(+ "{0} is the number of visualizations, {1} is a comma-separated list of their names",+ ).t`${plugins.length} visualizations are currently unavailable: ${names}.`;++ const hasAnyWarnings = plugins.some(({ warnings }) => warnings.length > 0);+ return hasAnyWarnings+ ? `${message} ${t`They may have been built for a different version and may need to be updated.`}`+ : message;+}diff --git a/enterprise/frontend/src/metabase-enterprise/custom_viz/utils/unavailable-toast.unit.spec.ts b/enterprise/frontend/src/metabase-enterprise/custom_viz/utils/unavailable-toast.unit.spec.tsnew file mode 100644index 00000000000..03d0907ac97--- /dev/null+++ b/enterprise/frontend/src/metabase-enterprise/custom_viz/utils/unavailable-toast.unit.spec.ts@@ -0,0 +1,230 @@+import { createMockCustomVizPluginRuntime } from "metabase-types/api/mocks";++import {+ reportUnavailableCustomVizPlugin,+ resetUnavailableCustomVizPluginReports,+} from "./unavailable-toast";++const FLUSH_DELAY_MS = 300;++const SDK_VERSION_WARNING = {+ type: "sdk-version-mismatch" as const,+ sdk_version: "1.0.0",+ tested_sdk_range: "2.x",+};++const warningToast = (message: string) => ({+ icon: "warning_triangle_filled",+ iconColor: "feedback-warning",+ message,+});++describe("reportUnavailableCustomVizPlugin", () => {+ beforeEach(() => {+ jest.useFakeTimers();+ });++ afterEach(() => {+ resetUnavailableCustomVizPluginReports();+ jest.useRealTimers();+ });++ it("shows a toast for a single unavailable plugin", () => {+ const onMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ display_name: "Viz A" }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(onMessage).toHaveBeenCalledTimes(1);+ expect(onMessage).toHaveBeenCalledWith(+ warningToast('The "Viz A" visualization is currently unavailable.'),+ );+ });++ it("mentions the version mismatch for a single plugin with warnings", () => {+ const onMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({+ display_name: "Viz A",+ warnings: [SDK_VERSION_WARNING],+ }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(onMessage).toHaveBeenCalledWith(+ warningToast(+ 'The "Viz A" visualization is currently unavailable. It was built for a different version and may need to be updated.',+ ),+ );+ });++ it("does not show a toast before the flush delay elapses", () => {+ const onMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime(),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS - 1);++ expect(onMessage).not.toHaveBeenCalled();+ });++ it("combines plugins reported within the window into one toast and sorts vizualizations by name", () => {+ const onMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 1, display_name: "Viz B" }),+ onMessage,+ );+ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 2, display_name: "Viz A" }),+ onMessage,+ );+ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 3, display_name: "Viz C" }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(onMessage).toHaveBeenCalledTimes(1);+ expect(onMessage).toHaveBeenCalledWith(+ warningToast(+ '3 visualizations are currently unavailable: "Viz A", "Viz B", "Viz C".',+ ),+ );+ });++ it("mentions the version mismatch when any combined plugin has warnings", () => {+ const onMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 1, display_name: "Viz B" }),+ onMessage,+ );+ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({+ id: 2,+ display_name: "Viz A",+ warnings: [SDK_VERSION_WARNING],+ }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(onMessage).toHaveBeenCalledWith(+ warningToast(+ '2 visualizations are currently unavailable: "Viz A", "Viz B". They may have been built for a different version and may need to be updated.',+ ),+ );+ });++ it("collapses reports of the same plugin into one entry", () => {+ const onMessage = jest.fn();+ const plugin = createMockCustomVizPluginRuntime({+ display_name: "Viz A",+ });++ reportUnavailableCustomVizPlugin(plugin, onMessage);+ reportUnavailableCustomVizPlugin(plugin, onMessage);+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(onMessage).toHaveBeenCalledTimes(1);+ expect(onMessage).toHaveBeenCalledWith(+ warningToast('The "Viz A" visualization is currently unavailable.'),+ );+ });++ it("extends the window while reports keep arriving", () => {+ const onMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 1, display_name: "Viz B" }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS - 100);+ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 2, display_name: "Viz A" }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS - 100);++ expect(onMessage).not.toHaveBeenCalled();++ jest.advanceTimersByTime(100);++ expect(onMessage).toHaveBeenCalledTimes(1);+ expect(onMessage).toHaveBeenCalledWith(+ warningToast(+ '2 visualizations are currently unavailable: "Viz A", "Viz B".',+ ),+ );+ });++ it("shows a new toast for plugins reported after a flush", () => {+ const onMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 1, display_name: "Viz B" }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);+ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 2, display_name: "Viz A" }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(onMessage).toHaveBeenCalledTimes(2);+ expect(onMessage).toHaveBeenLastCalledWith(+ warningToast('The "Viz A" visualization is currently unavailable.'),+ );+ });++ it("keeps collecting reports until a callback arrives", () => {+ const onMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 1, display_name: "Viz B" }),+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(jest.getTimerCount()).toBe(0);++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 2, display_name: "Viz A" }),+ onMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(onMessage).toHaveBeenCalledTimes(1);+ expect(onMessage).toHaveBeenCalledWith(+ warningToast(+ '2 visualizations are currently unavailable: "Viz A", "Viz B".',+ ),+ );+ });++ it("uses the most recent onMessage callback for the whole batch", () => {+ const firstOnMessage = jest.fn();+ const secondOnMessage = jest.fn();++ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 1, display_name: "Viz B" }),+ firstOnMessage,+ );+ reportUnavailableCustomVizPlugin(+ createMockCustomVizPluginRuntime({ id: 2, display_name: "Viz A" }),+ secondOnMessage,+ );+ jest.advanceTimersByTime(FLUSH_DELAY_MS);++ expect(firstOnMessage).not.toHaveBeenCalled();+ expect(secondOnMessage).toHaveBeenCalledTimes(1);+ });+});diff --git a/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/hooks/use-sensible-visualizations.ts b/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/hooks/use-sensible-visualizations.tsindex 882340ca406..5a7234b7c0d 100644--- a/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/hooks/use-sensible-visualizations.ts+++ b/frontend/src/embedding-sdk-bundle/components/private/SdkQuestion/hooks/use-sensible-visualizations.ts@@ -1,6 +1,6 @@-import { useCallback, useEffect, useMemo, useState } from "react";+import { useEffect, useMemo, useState } from "react";-import { useToast } from "metabase/common/hooks";+import { logUnavailableCustomVizMessage } from "embedding-sdk-bundle/lib/log-unavailable-custom-viz";import { PLUGIN_CUSTOM_VIZ } from "metabase/plugins";import { getSensibleVisualizations } from "metabase/visualizations/lib/sensibility";import type { CardDisplayType } from "metabase-types/api";@@ -9,15 +9,9 @@ import { useSdkQuestionContext } from "../context";export const useSensibleVisualizations = () => {const { queryResults } = useSdkQuestionContext();- const [sendToast] = useToast();const { plugins: customVizPlugins } = PLUGIN_CUSTOM_VIZ.useCustomVizPlugins();const [pluginsLoadedVersion, setPluginsLoadedVersion] = useState(0);- const onInfo = useCallback(- (message: string) => sendToast({ message }),- [sendToast],- );-// Eagerly load all custom-viz plugins so their displays register in the// visualizations Map and appear in the chart-type picker. Mirrors the// main-app ChartTypeSidebar.@@ -28,7 +22,9 @@ export const useSensibleVisualizations = () => {let cancelled = false;Promise.all(customVizPlugins.map((plugin) =>- PLUGIN_CUSTOM_VIZ.loadCustomVizPlugin(plugin, { onInfo }),+ PLUGIN_CUSTOM_VIZ.loadCustomVizPlugin(plugin, {+ onMessage: logUnavailableCustomVizMessage,+ }),),).then(() => {if (!cancelled) {@@ -38,7 +34,7 @@ export const useSensibleVisualizations = () => {return () => {cancelled = true;};- }, [customVizPlugins, onInfo]);+ }, [customVizPlugins]);const result = queryResults?.[0] ?? null;diff --git a/frontend/src/embedding-sdk-bundle/lib/log-unavailable-custom-viz.ts b/frontend/src/embedding-sdk-bundle/lib/log-unavailable-custom-viz.tsnew file mode 100644index 00000000000..afdc68a162e--- /dev/null+++ b/frontend/src/embedding-sdk-bundle/lib/log-unavailable-custom-viz.ts@@ -0,0 +1,7 @@+import type { ToastArgs } from "metabase/common/hooks";++// The SDK renders no toast host, so unavailable custom viz warnings+// go to the console instead.+export const logUnavailableCustomVizMessage = ({ message }: ToastArgs) => {+ console.warn(message);+};diff --git a/frontend/src/metabase/common/components/UndoListing.module.css b/frontend/src/metabase/common/components/UndoListing.module.cssindex 5c626e74b2c..f2f02e24eb8 100644--- a/frontend/src/metabase/common/components/UndoListing.module.css+++ b/frontend/src/metabase/common/components/UndoListing.module.css@@ -11,6 +11,7 @@.toast {position: absolute;bottom: 0;+ width: max-content;}.progress {diff --git a/frontend/src/metabase/common/components/UndoListing.styled.tsx b/frontend/src/metabase/common/components/UndoListing.styled.tsxindex 4b05d9a10e8..809c7a3cd5a 100644--- a/frontend/src/metabase/common/components/UndoListing.styled.tsx+++ b/frontend/src/metabase/common/components/UndoListing.styled.tsx@@ -18,23 +18,26 @@ export const UndoList = styled.ul`export const CardContent = styled.div`display: flex;- align-items: center;+ align-items: flex-start;justify-content: space-between;`;// Unjustified type cast. FIXMEexport const CardContentSide = styled(Box)<BoxProps>`display: flex;- align-items: center;+ align-items: flex-start;overflow: hidden;` as unknown as typeof Box;// Unjustified type cast. FIXMEexport const ControlsCardContent = styled(CardContentSide)`+ align-items: center;flex-shrink: 0;` as unknown as typeof Box;export const CardIcon = styled(Icon)`+ position: relative;+ top: 1px;margin-right: var(--mantine-spacing-sm);flex-shrink: 0;`;@@ -57,6 +60,8 @@ export const UndoButton = styled(Link)``;export const DismissIcon = styled(Icon)<{ color?: string }>`+ position: relative;+ top: 1px;margin-left: var(--mantine-spacing-md);cursor: pointer;diff --git a/frontend/src/metabase/common/components/UndoListing.tsx b/frontend/src/metabase/common/components/UndoListing.tsxindex ee7ab8fbb44..168562f123b 100644--- a/frontend/src/metabase/common/components/UndoListing.tsx+++ b/frontend/src/metabase/common/components/UndoListing.tsx@@ -40,6 +40,7 @@ import {const TOAST_TRANSITION_DURATION = 300;const MARGIN = 8;+const TOAST_MESSAGE_MAX_LINES = 4;function DefaultMessage({undo: { verb = t`modified`, count = 1, subject = t`item` },@@ -143,7 +144,9 @@ function UndoToast({{undo.renderChildren ? (undo.renderChildren(undo)) : (- <Ellipsified showTooltip={false}>{renderMessage(undo)}</Ellipsified>+ <Ellipsified showTooltip={false} lines={TOAST_MESSAGE_MAX_LINES}>+ {renderMessage(undo)}+ </Ellipsified>)}</CardContentSide><ControlsCardContent>diff --git a/frontend/src/metabase/plugins/oss/custom-viz.ts b/frontend/src/metabase/plugins/oss/custom-viz.tsindex 6647532f871..49e6e12128f 100644--- a/frontend/src/metabase/plugins/oss/custom-viz.ts+++ b/frontend/src/metabase/plugins/oss/custom-viz.ts@@ -1,5 +1,6 @@import type { ComponentType } from "react";+import type { ToastArgs } from "metabase/common/hooks";import type { IconData } from "metabase/common/utils/icon";import { PluginPlaceholder } from "metabase/plugins/components/PluginPlaceholder";import type { Dispatch } from "metabase/redux/store";@@ -41,7 +42,7 @@ const getDefaultPluginCustomViz = () => ({_plugin: CustomVizPluginRuntime,_options?: {cacheBustSuffix?: string;- onInfo?: (message: string) => void;+ onMessage?: (toast: ToastArgs) => void;},// Unjustified type cast. FIXME) => null as string | null,diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/ChartTypeSidebar/ChartTypeSidebar.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/ChartTypeSidebar/ChartTypeSidebar.tsxindex 7db9df0ab60..035332032f6 100644--- a/frontend/src/metabase/query_builder/components/view/sidebars/ChartTypeSidebar/ChartTypeSidebar.tsx+++ b/frontend/src/metabase/query_builder/components/view/sidebars/ChartTypeSidebar/ChartTypeSidebar.tsx@@ -1,5 +1,5 @@import cx from "classnames";-import { useCallback, useEffect, useMemo, useRef, useState } from "react";+import { useEffect, useMemo, useRef, useState } from "react";import { t } from "ttag";import { SidebarContent } from "metabase/common/components/SidebarContent";@@ -41,11 +41,6 @@ export const ChartTypeSidebar = ({const { plugins: customVizPlugins } = PLUGIN_CUSTOM_VIZ.useCustomVizPlugins();const [pluginsLoaded, setPluginsLoaded] = useState(false);- const onInfo = useCallback(- (message: string) => sendToast({ message }),- [sendToast],- );-// Eagerly load all custom viz plugins so they register in the// visualizations Map and can be rendered by ChartTypeOption.useEffect(() => {@@ -63,7 +58,7 @@ export const ChartTypeSidebar = ({let cancelled = false;Promise.all(customVizPlugins.map((plugin) =>- PLUGIN_CUSTOM_VIZ.loadCustomVizPlugin(plugin, { onInfo }),+ PLUGIN_CUSTOM_VIZ.loadCustomVizPlugin(plugin, { onMessage: sendToast }),),).then(() => {if (!cancelled) {@@ -74,7 +69,7 @@ export const ChartTypeSidebar = ({return () => {cancelled = true;};- }, [customVizPlugins, onInfo]);+ }, [customVizPlugins, sendToast]);const onUpdateQuestion = (newQuestion: Question) => {if (question) {