diff --git a/webapp/src/components/AutomationEditor/NodesRow/index.css b/webapp/src/components/AutomationEditor/NodesRow/index.css deleted file mode 100644 index 027ffeb..0000000 --- a/webapp/src/components/AutomationEditor/NodesRow/index.css +++ /dev/null @@ -1,9 +0,0 @@ -.automation-editor--nodes-row .collection-nodes--wrap { - --node-height: 12em !important; - --node-width: 100% !important; -} - -.automation-editor--nodes-row .collection-nodes--wrap .collection-nodes { - min-width: 90%; - min-height: 10em; -} \ No newline at end of file diff --git a/webapp/src/components/AutomationEditor/NodesRow/index.stories.tsx b/webapp/src/components/AutomationEditor/NodesRow/index.stories.tsx deleted file mode 100644 index 7b763b5..0000000 --- a/webapp/src/components/AutomationEditor/NodesRow/index.stories.tsx +++ /dev/null @@ -1,40 +0,0 @@ -import { DEFAULT_DIMS } from "components/DAGGraph/elements/constants"; -import { makeStory } from "devUtils"; -import { useState } from "react"; -import { NodesRow } from "."; - -const { make, componentMeta } = makeStory({ - Component: NodesRow, - BaseTemplate: (props) => { - const [data, setData] = useState(props.data); - return ( - { - setData(up); - props.onUpdate(up); - }} - /> - ); - }, - meta: { - title: "App/AutomationEditor/NodesRow", - args: { - data: [], - sequenceNodeDims: DEFAULT_DIMS.node, - }, - }, -}); - -export default componentMeta; -export const Empty = make({}); -export const One = make({ - type: "trigger", - data: [ - { - platform: "calendar", - event: "test", - }, - ], -}); diff --git a/webapp/src/components/AutomationEditor/NodesRow/index.tsx b/webapp/src/components/AutomationEditor/NodesRow/index.tsx deleted file mode 100644 index 9530ae3..0000000 --- a/webapp/src/components/AutomationEditor/NodesRow/index.tsx +++ /dev/null @@ -1,42 +0,0 @@ -import "./index.css"; - -import { AutomationNode, AutomationNodeMapping } from "types/automations"; -import { useHA } from "services/ha"; -import { CollectionNodeElement } from "components/DAGGraph/nodes/CollectionNode/CollectionNodeElement"; -import { getDescriptionFromAutomationNode } from "utils/formatting"; -import { Size } from "components/DAGGraph/elements/types"; - -export type NodesRowProps< - K extends keyof AutomationNodeMapping, - T extends AutomationNode -> = { - type: K; - data: T[]; - onUpdate: (d: T[]) => void; - sequenceNodeDims: Size; -}; - -export function NodesRow< - K extends keyof AutomationNodeMapping, - T extends AutomationNode ->({ type: collectionType, data, sequenceNodeDims }: NodesRowProps) { - const { namer } = useHA(); - return ( -
- ({ - enabled: node.enabled ?? true, - label: getDescriptionFromAutomationNode(node, namer, true), - onXClick: () => {}, - }))} - onAddNode={() => {}} - collectionType={collectionType} - title="if" - sequenceNode={sequenceNodeDims} - flipped - /> -
- ); -} diff --git a/webapp/src/components/AutomationEditor/index.css b/webapp/src/components/AutomationEditor/index.css index 1f10a1f..25b81f9 100644 --- a/webapp/src/components/AutomationEditor/index.css +++ b/webapp/src/components/AutomationEditor/index.css @@ -127,4 +127,13 @@ .automation-editor--info-box--buttons { display: flex; gap: 1em; +} + +.automation-editor.fullscreen .automation-editor--flow-wrapper--toolbar--title { + display: none; +} + +.automation-editor.fullscreen .automation-editor--flow-wrapper--toolbar { + justify-content: flex-end; + margin-top: 0.5em; } \ No newline at end of file diff --git a/webapp/src/components/AutomationEditor/index.tsx b/webapp/src/components/AutomationEditor/index.tsx index 54ac2aa..32a40ec 100644 --- a/webapp/src/components/AutomationEditor/index.tsx +++ b/webapp/src/components/AutomationEditor/index.tsx @@ -2,7 +2,6 @@ import "./index.css"; import "./index.mobile.css"; import { FC, useState } from "react"; -import { useCookies } from "react-cookie"; import Skeleton from "@mui/material/Skeleton"; import LinearProgress from "@mui/material/LinearProgress"; @@ -11,7 +10,6 @@ import SpeedDialAction from "@mui/material/SpeedDialAction"; import SpeedDialIcon from "@mui/icons-material/SettingsRounded"; import UndoIcon from "@mui/icons-material/UndoSharp"; -import Icon from "@mui/material/Icon"; import EditIcon from "@mui/icons-material/ModeEditOutlineTwoTone"; import DeleteIcon from "@mui/icons-material/DeleteForever"; import { CheckMarkIcon } from "components/Icons"; @@ -34,7 +32,16 @@ import { useAutomatioEditorState, EditorData } from "./state"; import { useLang } from "services/lang"; import { useSnackbar } from "notistack"; import { Alert } from "@mui/material"; - +import { useUserProfile } from "services/api"; +import { + ControlButton, + ReactFlowProvider, + useReactFlow, +} from "react-flow-renderer"; +import FitInIcon from "@mui/icons-material/FitScreenRounded"; +import FullscreenIcon from "@mui/icons-material/FullscreenRounded"; +import FullscreenExitIcon from "@mui/icons-material/FullscreenExitRounded"; +import { useEffect } from "react"; interface Props { automation?: AutomationData | BareAutomationData; dims: DAGDims; @@ -46,7 +53,14 @@ interface Props { readonly: boolean; issue?: string; } -export const AutomationEditor: FC = ({ +export const AutomationEditor: FC = (props) => { + return ( + + + + ); +}; +export const AutomationEditorInner: FC = ({ dims, automation: propsAutos, onUpdate: propsOnUpdate, @@ -57,6 +71,8 @@ export const AutomationEditor: FC = ({ issue, }) => { // state + const reactFlow = useReactFlow(); + const userProfile = useUserProfile(); const langStore = useLang(); const snackbr = useSnackbar(); const { @@ -79,15 +95,18 @@ export const AutomationEditor: FC = ({ } }); const [infoBoxOpen, setInfoBox] = useState(false); - const [ - { ckFlipped }, - setCookies, - // eslint-disable-next-line - _, - ] = useCookies(["ckFlipped"]); + const [fullScreenMode, setFullScreenMode] = useState(false); // alias - const flipped = dims.flipped ? true : ckFlipped === "1"; - const setFlipped = (v: boolean) => setCookies("ckFlipped", v ? "1" : "0"); + const flipped = userProfile.flags.flipped ?? !dims.flipped; + const useNodesRow = userProfile.flags.useNodesRow !== false; + // effect + useEffect(() => { + if (reactFlow) { + setTimeout(() => { + reactFlow.fitView(); + }, 500); + } + }, [flipped, fullScreenMode, reactFlow]); // render if (state.status === "loading") { return ( @@ -114,6 +133,7 @@ export const AutomationEditor: FC = ({ "automation-editor", state.status, readonly ? "readonly" : "", + fullScreenMode ? "fullscreen" : "", ].join(" ")} > {state.status === "saving" && ( @@ -220,15 +240,6 @@ export const AutomationEditor: FC = ({ } /> - {!dims.flipped && ( - - )} {state.status === "changed" && (