enabled/disabled
This commit is contained in:
1 parent
5bd5c5e445
commit
dc3470fdf5
6 files changed
+54
-16
No files matched your search
@@ -18,6 +18,7 @@
|
||||
"autosuggest-highlight": "3.2.1",
|
||||
"home-assistant-js-websocket": "7.1.0",
|
||||
"jss": "10.9.0",
|
||||
"material-ui-confirm": "^3.0.4",
|
||||
"notistack": "2.0.5",
|
||||
"react": "18.2.0",
|
||||
"react-cookie": "4.1.1",
|
||||
|
||||
@@ -13,6 +13,8 @@ import { SpeedDial } from "components/SpeedDial";
|
||||
import Edit from "@mui/icons-material/Edit";
|
||||
import { useTheme } from "@mui/material";
|
||||
import InputBoolean from "components/Inputs/InputBoolean";
|
||||
import { useConfirm } from "material-ui-confirm";
|
||||
import { useSnackbar } from "notistack";
|
||||
|
||||
export type DAGNodeOnMove<Direction extends string> = Record<
|
||||
Direction,
|
||||
@@ -77,6 +79,8 @@ export const DAGNode: FC<DAGNodeProps> = ({
|
||||
onSetEnabled,
|
||||
}) => {
|
||||
const theme = useTheme();
|
||||
const confirm = useConfirm();
|
||||
const snackbr = useSnackbar();
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
@@ -130,9 +134,29 @@ export const DAGNode: FC<DAGNodeProps> = ({
|
||||
<ArrowBackIcon fontSize="inherit" />
|
||||
</IconButton>
|
||||
))}
|
||||
<IconButton onClick={onXClick} size="small">
|
||||
<DeleteForeverIcon fontSize="inherit" color="error" />
|
||||
</IconButton>
|
||||
{onXClick && (
|
||||
<IconButton
|
||||
onClick={() => {
|
||||
confirm({
|
||||
description: "Are you sure you want to delete this node?",
|
||||
})
|
||||
.then(() => {
|
||||
onXClick();
|
||||
snackbr.enqueueSnackbar("Deleted.", {
|
||||
variant: "info",
|
||||
});
|
||||
})
|
||||
.catch(() =>
|
||||
snackbr.enqueueSnackbar("Did not delete node.", {
|
||||
variant: "info",
|
||||
})
|
||||
);
|
||||
}}
|
||||
size="small"
|
||||
>
|
||||
<DeleteForeverIcon fontSize="inherit" color="error" />
|
||||
</IconButton>
|
||||
)}
|
||||
</SpeedDial>
|
||||
{!!onSetEnabled && (
|
||||
<InputBoolean
|
||||
|
||||
@@ -142,7 +142,7 @@ export const DAGAutomationFlow: FC<DAGAutomationFlowProps> = ({
|
||||
onSetEnabled: (i) =>
|
||||
onTriggerUpdate([
|
||||
...trigger.slice(0, i),
|
||||
{ ...trigger[i], enabled: !(trigger[i] ?? true) },
|
||||
{ ...trigger[i], enabled: !(trigger[i].enabled ?? true) },
|
||||
...trigger.slice(i + 1),
|
||||
]),
|
||||
});
|
||||
|
||||
@@ -239,6 +239,9 @@ const addChooseNode = (
|
||||
}),
|
||||
});
|
||||
let lastPos: XYPosition = position;
|
||||
if (!(node.enabled ?? true)) {
|
||||
return { lastPos, flowData };
|
||||
}
|
||||
// conditions
|
||||
node.choose.forEach(({ sequence, conditions }, j) => {
|
||||
const sequenceId = `${nodeId}.${j}`;
|
||||
|
||||
@@ -5,6 +5,7 @@ import { VersionBox } from "components/VersionBox";
|
||||
import { SnackbarKey, SnackbarProvider, useSnackbar } from "notistack";
|
||||
import Button from "@mui/material/Button";
|
||||
import { useHAConnection } from "haService/connection";
|
||||
import { ConfirmProvider } from "material-ui-confirm";
|
||||
|
||||
const theme = createTheme({
|
||||
palette: {
|
||||
@@ -104,18 +105,22 @@ export const Page: FC<{
|
||||
};
|
||||
return (
|
||||
<ThemeProvider theme={theme}>
|
||||
<SnackbarProvider
|
||||
anchorOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "center",
|
||||
}}
|
||||
ref={notistackRef}
|
||||
action={(key) => <Button onClick={onClickDismiss(key)}>Dismiss</Button>}
|
||||
dense
|
||||
preventDuplicate
|
||||
>
|
||||
<InternalPage>{children}</InternalPage>
|
||||
</SnackbarProvider>
|
||||
<ConfirmProvider>
|
||||
<SnackbarProvider
|
||||
anchorOrigin={{
|
||||
vertical: "bottom",
|
||||
horizontal: "center",
|
||||
}}
|
||||
ref={notistackRef}
|
||||
action={(key) => (
|
||||
<Button onClick={onClickDismiss(key)}>Dismiss</Button>
|
||||
)}
|
||||
dense
|
||||
preventDuplicate
|
||||
>
|
||||
<InternalPage>{children}</InternalPage>
|
||||
</SnackbarProvider>
|
||||
</ConfirmProvider>
|
||||
</ThemeProvider>
|
||||
);
|
||||
};
|
||||
@@ -10705,6 +10705,11 @@ markdown-to-jsx@^7.1.0:
|
||||
resolved "https://registry.yarnpkg.com/markdown-to-jsx/-/markdown-to-jsx-7.1.7.tgz#a5f22102fb12241c8cea1ca6a4050bb76b23a25d"
|
||||
integrity sha512-VI3TyyHlGkO8uFle0IOibzpO1c1iJDcXcS/zBrQrXQQvJ2tpdwVzVZ7XdKsyRz1NdRmre4dqQkMZzUHaKIG/1w==
|
||||
|
||||
material-ui-confirm@^3.0.4:
|
||||
version "3.0.4"
|
||||
resolved "https://registry.yarnpkg.com/material-ui-confirm/-/material-ui-confirm-3.0.4.tgz#db4892452f65628f4bb9da3166bfbc0c53877d3b"
|
||||
integrity sha512-2Aqh1gU6JqGvFtm2KTEUsFf+SKkNQPxWXz6CU3lJlbuFkLmIm28kjmT9sUjNkcdFOL0WhRmI3UwIbBVVBPckiA==
|
||||
|
||||
md5.js@^1.3.4:
|
||||
version "1.3.5"
|
||||
resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f"
|
||||
|
||||
Reference in new issue
Block a user