mirror of
https://github.com/rowyio/rowy.git
synced 2026-09-01 19:50:46 +02:00
link for action scripts
This commit is contained in:
@@ -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" ? (
|
||||
<Button
|
||||
variant="outlined"
|
||||
href={link}
|
||||
component={Link}
|
||||
target="_blank"
|
||||
>
|
||||
Link
|
||||
</Button>
|
||||
) : (
|
||||
<Button
|
||||
href={link.url}
|
||||
component={Link}
|
||||
variant="outlined"
|
||||
target="_blank"
|
||||
>
|
||||
{link.label}
|
||||
</Button>
|
||||
)
|
||||
) : undefined,
|
||||
}
|
||||
);
|
||||
} catch (e) {
|
||||
|
||||
1
src/components/fields/Action/action.d.ts
vendored
1
src/components/fields/Action/action.d.ts
vendored
@@ -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> | ActionResult;
|
||||
|
||||
Reference in New Issue
Block a user