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