Moved infobox to modal
This commit is contained in:
1 parent
1719148c58
commit
0e4e4783fa
16 files changed
+222
-182
No files matched your search
@@ -1,31 +1,16 @@
|
||||
.automation-editor--info-box {
|
||||
height: 100%;
|
||||
padding-left: 10px;
|
||||
padding-right: 10px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: flex-start;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
align-items: center;
|
||||
gap: 0.5em;
|
||||
}
|
||||
|
||||
.automation-editor--info-box-inner {
|
||||
height: 100%;
|
||||
max-width: 95vw;
|
||||
max-height: 90vh;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.automation-editor--info-box.show {
|
||||
min-width: 20em;
|
||||
}
|
||||
|
||||
.automation-editor--info-box.hide {
|
||||
min-width: 1em;
|
||||
}
|
||||
|
||||
.automation-editor--info-box.hide>.automation-editor--info-box-inner {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.automation-editor--info-box--tags {
|
||||
padding: 0.25em 0.75em 1em 0.75em;
|
||||
border-color: var(--mui-grey-400);
|
||||
|
||||
@@ -1,40 +1,35 @@
|
||||
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { makeTagDB } from "components/AutomationList/TagDB";
|
||||
import { Page } from "components/Page";
|
||||
import { useState } from "react";
|
||||
import { AutoInfoBox } from "./AutoInfoBox";
|
||||
import { defaultAutomation } from 'utils/defaults';
|
||||
import { defaultAutomation } from "utils/defaults";
|
||||
|
||||
export default {
|
||||
title: 'App/AutomationList/Editor/InfoBox',
|
||||
title: "App/AutomationList/Editor/InfoBox",
|
||||
component: AutoInfoBox,
|
||||
parameters: { actions: { argTypesRegex: '^on.*' } },
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
args: {
|
||||
tagDB: makeTagDB([
|
||||
defaultAutomation("test")
|
||||
])
|
||||
}
|
||||
tagDB: makeTagDB([defaultAutomation("test")]),
|
||||
},
|
||||
} as ComponentMeta<typeof AutoInfoBox>;
|
||||
|
||||
|
||||
export const NoTags: ComponentStory<typeof AutoInfoBox> = args => {
|
||||
const [[metadata, tags], setState] = useState([args.metadata, args.tags])
|
||||
export const NoTags: ComponentStory<typeof AutoInfoBox> = (args) => {
|
||||
const [[metadata, tags], setState] = useState([args.metadata, args.tags]);
|
||||
return (
|
||||
<Page>
|
||||
<AutoInfoBox
|
||||
{...args}
|
||||
className=""
|
||||
metadata={metadata}
|
||||
tags={tags}
|
||||
onUpdate={(m, t) => {
|
||||
args.onUpdate(m, t)
|
||||
setState([m, t])
|
||||
args.onUpdate(m, t);
|
||||
setState([m, t]);
|
||||
}}
|
||||
/>
|
||||
</Page>
|
||||
)
|
||||
}
|
||||
);
|
||||
};
|
||||
NoTags.args = {
|
||||
...NoTags.args,
|
||||
tags: [],
|
||||
@@ -43,13 +38,13 @@ NoTags.args = {
|
||||
alias: "Random",
|
||||
description: "Example Metadata",
|
||||
trigger_variables: {
|
||||
'wowo': '!'
|
||||
wowo: "!",
|
||||
},
|
||||
mode: 'single',
|
||||
mode: "single",
|
||||
},
|
||||
}
|
||||
};
|
||||
|
||||
export const SomeTags: ComponentStory<typeof AutoInfoBox> = NoTags.bind({})
|
||||
export const SomeTags: ComponentStory<typeof AutoInfoBox> = NoTags.bind({});
|
||||
SomeTags.args = {
|
||||
...SomeTags.args,
|
||||
tags: [
|
||||
@@ -61,8 +56,8 @@ SomeTags.args = {
|
||||
alias: "Bathroom Vent",
|
||||
description: "Turn the vent when the humidity is high",
|
||||
trigger_variables: {
|
||||
'wowo': '!'
|
||||
wowo: "!",
|
||||
},
|
||||
mode: 'single',
|
||||
mode: "single",
|
||||
},
|
||||
}
|
||||
};
|
||||
@@ -9,7 +9,6 @@ import { TagDB } from "components/AutomationList/TagDB";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
|
||||
interface Props {
|
||||
className: string;
|
||||
metadata: AutomationMetadata;
|
||||
tags: Array<[string, string]>;
|
||||
onUpdate: (m: AutomationMetadata, tags: Array<[string, string]>) => void;
|
||||
@@ -20,7 +19,6 @@ export const AutoInfoBox: FC<Props> = ({
|
||||
metadata,
|
||||
tags,
|
||||
onUpdate,
|
||||
className,
|
||||
children,
|
||||
tagDB,
|
||||
}) => {
|
||||
@@ -97,7 +95,7 @@ export const AutoInfoBox: FC<Props> = ({
|
||||
]);
|
||||
// render
|
||||
return (
|
||||
<div className={`automation-editor--info-box ${className}`}>
|
||||
<div className="automation-editor--info-box">
|
||||
<div className="automation-editor--info-box-inner">
|
||||
<InputText
|
||||
label="ID"
|
||||
|
||||
@@ -50,6 +50,15 @@
|
||||
white-space: break-word;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
padding-bottom: 0.25em;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper--toolbar .automation-editor--flow-wrapper--toolbar--title--text {
|
||||
min-width: 5em;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper--toolbar .automation-editor--flow-wrapper--toolbar--modes {
|
||||
min-width: 6em;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper--toolbar .automation-editor--flow-wrapper--toolbar--modes .MuiSelect-select {
|
||||
@@ -64,7 +73,8 @@
|
||||
left: -0.5em;
|
||||
}
|
||||
|
||||
.automation-editor--flow-wrapper.changed>.automation-editor--flow-wrapper--toolbar button {
|
||||
.automation-editor.changed .automation-editor--flow-wrapper--toolbar--save-btn,
|
||||
.automation-editor--info-box--buttons.changed .automation-editor--flow-wrapper--toolbar--save-btn {
|
||||
border-color: var(--mui-success-light);
|
||||
color: var(--mui-success-light);
|
||||
}
|
||||
@@ -92,21 +102,6 @@
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.automation-editor .automation-editor--info-box--icon {
|
||||
position: absolute;
|
||||
left: 0.25em;
|
||||
bottom: 0em;
|
||||
z-index: 10;
|
||||
max-width: 1.5em;
|
||||
max-height: 1.5em;
|
||||
}
|
||||
|
||||
.automation-editor--info-box.hide>.automation-editor--info-box--icon {
|
||||
transform: rotate(180deg);
|
||||
z-index: 2;
|
||||
left: 0.1em;
|
||||
}
|
||||
|
||||
.automation-editor.loading .mock-list {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
@@ -127,4 +122,9 @@
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.automation-editor--info-box--buttons {
|
||||
display: flex;
|
||||
gap: 1em;
|
||||
}
|
||||
@@ -3,8 +3,9 @@ import Icon from "@mui/material/Icon";
|
||||
import { CheckMarkIcon } from "components/Icons";
|
||||
import { FC, useState } from "react";
|
||||
import { AutomationData } from "types/automations";
|
||||
import { Modal } from "components/Modal";
|
||||
import { AutoInfoBox } from "./AutoInfoBox";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
import ModeEditOutlineTwoToneIcon from "@mui/icons-material/ModeEditOutlineTwoTone";
|
||||
import { Button } from "components/Inputs/Button";
|
||||
import { useAutomatioEditorState, EditorData } from "./state";
|
||||
import { MiniFailure } from "types/validators/helper";
|
||||
@@ -12,13 +13,12 @@ import InputYaml from "components/Inputs/InputYaml";
|
||||
import { TagDB } from "components/AutomationList/TagDB";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import { ArrowBack } from "@mui/icons-material";
|
||||
import { useCookies } from "react-cookie";
|
||||
import { DAGDims } from "components/DAGGraph/elements/types";
|
||||
import { DAGAutomationGraph } from "components/DAGGraph";
|
||||
import { InputAutoComplete } from "components/Inputs/InputAutoComplete";
|
||||
import { InputList } from "components/Inputs/InputList";
|
||||
import { InputTextView } from "components/Inputs/InputTextView";
|
||||
import { ControlButton } from "react-flow-renderer";
|
||||
|
||||
interface Props {
|
||||
automation?: AutomationData;
|
||||
@@ -43,7 +43,7 @@ export const AutomationEditor: FC<Props> = ({
|
||||
save,
|
||||
saveAndUpdate,
|
||||
} = useAutomatioEditorState(propsAutos, propsOnUpdate);
|
||||
const [closeInfo, setCloseInfo] = useState(false);
|
||||
const [infoBoxOpen, setInfoBox] = useState(false);
|
||||
const [
|
||||
{ ckFlipped },
|
||||
setCookies,
|
||||
@@ -74,25 +74,34 @@ export const AutomationEditor: FC<Props> = ({
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div className="automation-editor">
|
||||
<div className={["automation-editor", state.status].join(" ")}>
|
||||
{state.status === "saving" && (
|
||||
<LinearProgress className="linear-loader" />
|
||||
)}
|
||||
<AutoInfoBox
|
||||
className={closeInfo ? "hide" : "show"}
|
||||
metadata={state.data.metadata}
|
||||
tags={state.data.tags}
|
||||
onUpdate={updateMetadata}
|
||||
tagDB={tagDB}
|
||||
>
|
||||
<ButtonIcon
|
||||
className="automation-editor--info-box--icon"
|
||||
onClick={() => setCloseInfo(!closeInfo)}
|
||||
title={closeInfo ? "Show Metadata" : "Hide Metadata"}
|
||||
color="success"
|
||||
icon={<ArrowBack />}
|
||||
/>
|
||||
</AutoInfoBox>
|
||||
<Modal open={infoBoxOpen}>
|
||||
<AutoInfoBox
|
||||
metadata={state.data.metadata}
|
||||
tags={state.data.tags}
|
||||
onUpdate={updateMetadata}
|
||||
tagDB={tagDB}
|
||||
>
|
||||
<div
|
||||
className={[
|
||||
"automation-editor--info-box--buttons",
|
||||
state.status,
|
||||
].join(" ")}
|
||||
>
|
||||
<Button onClick={() => setInfoBox(false)}>Close</Button>
|
||||
<Button
|
||||
className={"automation-editor--flow-wrapper--toolbar--save-btn"}
|
||||
onClick={save}
|
||||
disabled={state.status !== "changed"}
|
||||
>
|
||||
Save <CheckMarkIcon color="#bf4" />
|
||||
</Button>
|
||||
</div>
|
||||
</AutoInfoBox>
|
||||
</Modal>
|
||||
|
||||
<div
|
||||
className={["automation-editor--flow-wrapper", state.status].join(" ")}
|
||||
@@ -156,6 +165,7 @@ export const AutomationEditor: FC<Props> = ({
|
||||
]}
|
||||
/>
|
||||
<InputTextView
|
||||
className="description"
|
||||
value={state.data.metadata.description ?? ""}
|
||||
placeholder="Description"
|
||||
onChange={(description) =>
|
||||
@@ -194,6 +204,11 @@ export const AutomationEditor: FC<Props> = ({
|
||||
onTriggerUpdate={updateTrigger}
|
||||
onConditionUpdate={updateCondition}
|
||||
isFlipped={flipped}
|
||||
additionalControls={
|
||||
<ControlButton onClick={() => setInfoBox(!infoBoxOpen)}>
|
||||
<ModeEditOutlineTwoToneIcon />
|
||||
</ControlButton>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user