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
Define addUndo function argument type and fix usages (#73250)
Anderson9be226812968
diff --git a/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionMenu/SnippetCollectionMenu.tsx b/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionMenu/SnippetCollectionMenu.tsxindex 754ce084d7e..5898c922f41 100644--- a/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionMenu/SnippetCollectionMenu.tsx+++ b/enterprise/frontend/src/metabase-enterprise/snippets/components/SnippetCollectionMenu/SnippetCollectionMenu.tsx@@ -47,7 +47,7 @@ export function SnippetCollectionMenu({message: wasArchived? t`"${collection.name}" has been unarchived`: t`"${collection.name}" has been archived`,- undo: async () => {+ action: async () => {await updateCollection({id: collection.id,archived: wasArchived,diff --git a/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/toasts/use-table-editing-toast-controller.tsx b/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/toasts/use-table-editing-toast-controller.tsxindex 220b2c327c9..b09bb8337c6 100644--- a/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/toasts/use-table-editing-toast-controller.tsx+++ b/enterprise/frontend/src/metabase-enterprise/table-editing/table-edit/toasts/use-table-editing-toast-controller.tsx@@ -28,7 +28,6 @@ export function useTableEditingToastController() {icon: null,renderChildren: () => <ErrorUpdateToast error={error} />,timeout: null, // removes automatic toast hide- undo: false,onDismiss,}),);diff --git a/frontend/src/metabase/admin/performance/hooks/useInvalidateTarget.tsx b/frontend/src/metabase/admin/performance/hooks/useInvalidateTarget.tsxindex 720f43d14bb..cb005645af1 100644--- a/frontend/src/metabase/admin/performance/hooks/useInvalidateTarget.tsx+++ b/frontend/src/metabase/admin/performance/hooks/useInvalidateTarget.tsx@@ -36,7 +36,7 @@ export const useInvalidateTarget = (icon: "warning",message: e.data.message,toastColor: "error",- dismissIconColor: "var(--mb-color-text-primary-inverse)",+ dismissIconColor: "text-primary-inverse",}),);}diff --git a/frontend/src/metabase/admin/settings/components/CloudPanel/MigrationInProgress.tsx b/frontend/src/metabase/admin/settings/components/CloudPanel/MigrationInProgress.tsxindex c0fcc3a57b0..0cf523fbc93 100644--- a/frontend/src/metabase/admin/settings/components/CloudPanel/MigrationInProgress.tsx+++ b/frontend/src/metabase/admin/settings/components/CloudPanel/MigrationInProgress.tsx@@ -57,7 +57,6 @@ export const MigrationInProgress = ({addUndo({icon: "info",message: t`Migration to Metabase Cloud has been canceled.`,- undo: false,}),);};diff --git a/frontend/src/metabase/collections/components/CollectionBulkActions/ArchivedBulkActions.tsx b/frontend/src/metabase/collections/components/CollectionBulkActions/ArchivedBulkActions.tsxindex 6d5946b0c80..31b82c8b4e0 100644--- a/frontend/src/metabase/collections/components/CollectionBulkActions/ArchivedBulkActions.tsx+++ b/frontend/src/metabase/collections/components/CollectionBulkActions/ArchivedBulkActions.tsx@@ -83,7 +83,6 @@ export const ArchivedBulkActions = ({`${selected.length} items have been permanently deleted.`,selected.length,),- undo: false,canDismiss: true,}),);diff --git a/frontend/src/metabase/common/components/ErrorPages/ErrorDiagnosticModal.tsx b/frontend/src/metabase/common/components/ErrorPages/ErrorDiagnosticModal.tsxindex 41d7263a861..ac2033cf88c 100644--- a/frontend/src/metabase/common/components/ErrorPages/ErrorDiagnosticModal.tsx+++ b/frontend/src/metabase/common/components/ErrorPages/ErrorDiagnosticModal.tsx@@ -111,7 +111,6 @@ export const ErrorDiagnosticModal = ({addUndo({message: t`Failed to send diagnostic information to Slack`,icon: "warning",- variant: "error",}),);}@@ -121,7 +120,6 @@ export const ErrorDiagnosticModal = ({addUndo({message: t`Error sending diagnostic information to Slack`,icon: "warning",- variant: "error",}),);} finally {diff --git a/frontend/src/metabase/dashboard/actions/cards-typed.ts b/frontend/src/metabase/dashboard/actions/cards-typed.tsindex 8471b898ae3..a1711a084ad 100644--- a/frontend/src/metabase/dashboard/actions/cards-typed.ts+++ b/frontend/src/metabase/dashboard/actions/cards-typed.ts@@ -501,7 +501,6 @@ export const removeCardFromDashboard = createThunkAction(message: isLastDashboardQuestionDashcard? t`Trashed and removed card`: t`Removed card`,- undo: true,action: () =>dispatch(undoRemoveCardFromDashboard({diff --git a/frontend/src/metabase/dashboard/actions/parameters.tsx b/frontend/src/metabase/dashboard/actions/parameters.tsxindex 31bc36bcb11..5665fabb5c9 100644--- a/frontend/src/metabase/dashboard/actions/parameters.tsx+++ b/frontend/src/metabase/dashboard/actions/parameters.tsx@@ -243,7 +243,6 @@ export const moveParameter =dispatch(addUndo({- undo: true,action: undoMove,// Workaround to make the text show up without being truncated@@ -257,7 +256,7 @@ export const moveParameter =// Top nav filters are always visible, so we don't need a "Show" buttonextraAction: isMovedToTopNav- ? null+ ? undefined: {label: t`Show filter`,action: () => {@@ -1106,7 +1105,9 @@ export const SHOW_AUTO_APPLY_FILTERS_TOAST =export const showAutoApplyFiltersToast = createThunkAction(SHOW_AUTO_APPLY_FILTERS_TOAST,() => (dispatch, getState) => {- const action = toggleAutoApplyFilters(false);+ const action = () => {+ dispatch(toggleAutoApplyFilters(false));+ };const toastId = _.uniqueId();const dashboardId = getDashboardId(getState());diff --git a/frontend/src/metabase/dashboard/actions/tabs.ts b/frontend/src/metabase/dashboard/actions/tabs.tsindex f76c63c7106..69e0b5d72c0 100644--- a/frontend/src/metabase/dashboard/actions/tabs.ts+++ b/frontend/src/metabase/dashboard/actions/tabs.ts@@ -179,7 +179,6 @@ export const moveDashCardToTab =dispatch(addUndo({message: getDashCardMoveToTabUndoMessage(dashCard),- undo: true,action: () => {dispatch(undoMoveDashCardToTab({diff --git a/frontend/src/metabase/dashboard/components/DashboardGrid.tsx b/frontend/src/metabase/dashboard/components/DashboardGrid.tsxindex 8105830a21b..0d40a491ae8 100644--- a/frontend/src/metabase/dashboard/components/DashboardGrid.tsx+++ b/frontend/src/metabase/dashboard/components/DashboardGrid.tsx@@ -398,7 +398,6 @@ class DashboardGridInner extends Component<addUndo({message: getUndoReplaceCardMessage(replaceCardModalDashCard.card),- undo: true,action: () =>setDashCardAttributes({id: replaceCardModalDashCard.id,diff --git a/frontend/src/metabase/dashboard/components/DashboardTabs/use-dashboard-tabs.ts b/frontend/src/metabase/dashboard/components/DashboardTabs/use-dashboard-tabs.tsindex eba8adbdeac..21721b49a4d 100644--- a/frontend/src/metabase/dashboard/components/DashboardTabs/use-dashboard-tabs.ts+++ b/frontend/src/metabase/dashboard/components/DashboardTabs/use-dashboard-tabs.ts@@ -55,7 +55,6 @@ export function useDashboardTabs() {dispatch(addUndo({message: t`Deleted "${tabName}"`,- undo: true,action: () => undoDeleteTab({ tabDeletionId: id }),}),);diff --git a/frontend/src/metabase/dashboard/containers/DashboardApp/use-slow-card-notification.ts b/frontend/src/metabase/dashboard/containers/DashboardApp/use-slow-card-notification.tsindex 42e2f5b5d42..588d5f971ee 100644--- a/frontend/src/metabase/dashboard/containers/DashboardApp/use-slow-card-notification.ts+++ b/frontend/src/metabase/dashboard/containers/DashboardApp/use-slow-card-notification.ts@@ -53,7 +53,7 @@ export const useSlowCardNotification = () => {dispatch(addUndo({id: slowToastId,- timeout: false,+ timeout: null,message: t`Want to get notified when this dashboard loads?`,action: onConfirmToast,actionLabel: t`Notify me`,diff --git a/frontend/src/metabase/home/components/CustomHomePageModal/CustomHomePageModal.tsx b/frontend/src/metabase/home/components/CustomHomePageModal/CustomHomePageModal.tsxindex dfe172a0e40..995b5e113b4 100644--- a/frontend/src/metabase/home/components/CustomHomePageModal/CustomHomePageModal.tsx+++ b/frontend/src/metabase/home/components/CustomHomePageModal/CustomHomePageModal.tsx@@ -56,7 +56,7 @@ export const CustomHomePageModal = ({icon: "info",timeout: 10000,id,- actions: [dismissUndo({ undoId: id })],+ action: () => dispatch(dismissUndo({ undoId: id })),actionLabel: "Got it",canDismiss: false,}),diff --git a/frontend/src/metabase/home/components/HomePage/HomePage.tsx b/frontend/src/metabase/home/components/HomePage/HomePage.tsxindex 0c68952aa88..29a173746f5 100644--- a/frontend/src/metabase/home/components/HomePage/HomePage.tsx+++ b/frontend/src/metabase/home/components/HomePage/HomePage.tsx@@ -47,12 +47,14 @@ const useDashboardRedirect = () => {message: t`Your admin has set this dashboard as your homepage`,icon: "info",timeout: 10000,- actions: [- updateUserSetting({- key: "dismissed-custom-dashboard-toast",- value: true,- }),- ],+ action: () => {+ dispatch(+ updateUserSetting({+ key: "dismissed-custom-dashboard-toast",+ value: true,+ }),+ );+ },actionLabel: t`Got it`,canDismiss: false,}),diff --git a/frontend/src/metabase/query_builder/actions/models.ts b/frontend/src/metabase/query_builder/actions/models.tsindex cca5e70ce5c..18a27bf7703 100644--- a/frontend/src/metabase/query_builder/actions/models.ts+++ b/frontend/src/metabase/query_builder/actions/models.ts@@ -47,7 +47,8 @@ export const turnQuestionIntoModel =dispatch(addUndo({message: t`This is a model now.`,- actions: [apiUpdateQuestion(question, { rerunQuery: true })],+ action: () =>+ dispatch(apiUpdateQuestion(question, { rerunQuery: true })),}),);};@@ -70,7 +71,7 @@ export const turnModelIntoQuestion =dispatch(addUndo({message: t`This is a question now.`,- actions: [apiUpdateQuestion(model)],+ action: () => dispatch(apiUpdateQuestion(model)),}),);};diff --git a/frontend/src/metabase/questions/components/MoveCardModal/MoveCardModal.tsx b/frontend/src/metabase/questions/components/MoveCardModal/MoveCardModal.tsxindex c754309d8b6..4d045f1deec 100644--- a/frontend/src/metabase/questions/components/MoveCardModal/MoveCardModal.tsx+++ b/frontend/src/metabase/questions/components/MoveCardModal/MoveCardModal.tsx@@ -82,7 +82,6 @@ export const MoveCardModal = ({ card, onClose }: MoveCardModalProps) => {dispatch(addUndo({message: <MoveCardToast card={card} destination={destination} />,- undo: false,}),);diff --git a/frontend/src/metabase/redux/store/undo.ts b/frontend/src/metabase/redux/store/undo.tsindex fdca279501c..678014b0fef 100644--- a/frontend/src/metabase/redux/store/undo.ts+++ b/frontend/src/metabase/redux/store/undo.ts@@ -9,8 +9,8 @@ export interface Undo {type?: string;action?: (() => void) | null;message?: ReactNode | ((undo: Undo) => ReactNode);- timeout?: number;- initialTimeout?: number;+ timeout?: number | null;+ initialTimeout?: number | null;actions?: (() => void)[];showProgress?: boolean;icon?: IconName | null;diff --git a/frontend/src/metabase/redux/undo.ts b/frontend/src/metabase/redux/undo.tsindex ce6d6b0d3de..10e93e16a8e 100644--- a/frontend/src/metabase/redux/undo.ts+++ b/frontend/src/metabase/redux/undo.ts@@ -14,7 +14,7 @@ const PERFORM_UNDO = "metabase/questions/PERFORM_UNDO";let nextUndoId = 0;-export const addUndo = createThunkAction(ADD_UNDO, (undo) => {+export const addUndo = createThunkAction(ADD_UNDO, (undo: Partial<Undo>) => {return (dispatch, getState) => {const { icon = "check_filled", timeout = 5000, canDismiss = true } = undo;const id = undo.id ?? nextUndoId++;