From 24dc2a1f6e2db8dfed9b36bcb2831f9028331e6e Mon Sep 17 00:00:00 2001 From: shamsmosowi Date: Thu, 19 Jan 2023 14:52:53 +0100 Subject: [PATCH] link for action scripts --- src/components/fields/Action/ActionFab.tsx | 25 ++++++++++++++++++++-- src/components/fields/Action/action.d.ts | 1 + 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/components/fields/Action/ActionFab.tsx b/src/components/fields/Action/ActionFab.tsx index 6f87fb15..c09c2903 100644 --- a/src/components/fields/Action/ActionFab.tsx +++ b/src/components/fields/Action/ActionFab.tsx @@ -4,7 +4,7 @@ import { get } from "lodash-es"; import { useAtom, useSetAtom } from "jotai"; import { httpsCallable } from "firebase/functions"; -import { Fab, FabProps } from "@mui/material"; +import { Button, Fab, FabProps, Link } from "@mui/material"; import RunIcon from "@mui/icons-material/PlayArrow"; import RedoIcon from "@mui/icons-material/Refresh"; import UndoIcon from "@mui/icons-material/Undo"; @@ -118,11 +118,32 @@ export default function ActionFab({ } else { result = await handleCallableAction(data); } - const { message, success } = result ?? {}; + const { message, success, link } = result ?? {}; enqueueSnackbar( typeof message === "string" ? message : JSON.stringify(message), { variant: success ? "success" : "error", + action: link ? ( + typeof link === "string" ? ( + + ) : ( + + ) + ) : undefined, } ); } catch (e) { diff --git a/src/components/fields/Action/action.d.ts b/src/components/fields/Action/action.d.ts index 1daab613..b41ff94c 100644 --- a/src/components/fields/Action/action.d.ts +++ b/src/components/fields/Action/action.d.ts @@ -22,6 +22,7 @@ type ActionResult = { success: boolean; message?: any; status?: string | number | null | undefined; + link?: string | { url: string; label: string }; }; type Action = (context: ActionContext) => Promise | ActionResult;