clean up
This commit is contained in:
1 parent
2a827c24f6
commit
57c86093a4
29 files changed
+145
-1901
No files matched your search
@@ -1,25 +1,27 @@
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { makeTagDB } from "components/AutomationList/TagDB";
|
||||
import { Page } from "components/Page";
|
||||
import { useTagDB } from "components/AutomationManager/TagDB";
|
||||
import { useState } from "react";
|
||||
import { AutoInfoBox } from "./AutoInfoBox";
|
||||
import { defaultAutomation } from "utils/defaults";
|
||||
import { AutoInfoBox, AutoInfoBoxProps } from "./AutoInfoBox";
|
||||
import { makeStory } from "devUtils";
|
||||
|
||||
export default {
|
||||
title: "App/AutomationList/Editor/InfoBox",
|
||||
component: AutoInfoBox,
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
args: {
|
||||
tagDB: makeTagDB([defaultAutomation("test")]),
|
||||
const { componentMeta, make } = makeStory({
|
||||
meta: {
|
||||
title: "App/AutomationEditor/InfoBox",
|
||||
},
|
||||
} as ComponentMeta<typeof AutoInfoBox>;
|
||||
Component: (args: {
|
||||
metadata: AutoInfoBoxProps["metadata"];
|
||||
tags: AutoInfoBoxProps["tags"];
|
||||
onUpdate: AutoInfoBoxProps["onUpdate"];
|
||||
}) => {
|
||||
const [[metadata, tags], setState] = useState([args.metadata, args.tags]);
|
||||
const tagDB = useTagDB(
|
||||
[{ id: metadata.id, tags: Object.fromEntries(tags) }],
|
||||
(_, t) => setState([metadata, Object.entries(t)])
|
||||
);
|
||||
|
||||
export const NoTags: ComponentStory<typeof AutoInfoBox> = (args) => {
|
||||
const [[metadata, tags], setState] = useState([args.metadata, args.tags]);
|
||||
return (
|
||||
<Page>
|
||||
return (
|
||||
<AutoInfoBox
|
||||
{...args}
|
||||
tagDB={tagDB}
|
||||
metadata={metadata}
|
||||
tags={tags}
|
||||
onUpdate={(m, t) => {
|
||||
@@ -27,11 +29,12 @@ export const NoTags: ComponentStory<typeof AutoInfoBox> = (args) => {
|
||||
setState([m, t]);
|
||||
}}
|
||||
/>
|
||||
</Page>
|
||||
);
|
||||
};
|
||||
NoTags.args = {
|
||||
...NoTags.args,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
export default componentMeta;
|
||||
export const NoTags = make({
|
||||
tags: [],
|
||||
metadata: {
|
||||
id: "random",
|
||||
@@ -42,11 +45,9 @@ NoTags.args = {
|
||||
},
|
||||
mode: "single",
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
export const SomeTags: ComponentStory<typeof AutoInfoBox> = NoTags.bind({});
|
||||
SomeTags.args = {
|
||||
...SomeTags.args,
|
||||
export const SomeTags = make({
|
||||
tags: [
|
||||
["Room", "Bathroom"],
|
||||
["Type", "Climate"],
|
||||
@@ -60,4 +61,4 @@ SomeTags.args = {
|
||||
},
|
||||
mode: "single",
|
||||
},
|
||||
};
|
||||
});
|
||||
@@ -5,17 +5,17 @@ import InputText from "components/Inputs/InputText";
|
||||
import { FC, ReactNode, useRef, useState } from "react";
|
||||
import { AddIcon, TrashIcon } from "components/Icons";
|
||||
import InputAutoText from "components/Inputs/InputAutoText";
|
||||
import { TagDB } from "components/AutomationList/TagDB";
|
||||
import { TagDB } from "components/AutomationManager/TagDB";
|
||||
import { ButtonIcon } from "components/Icons/ButtonIcons";
|
||||
|
||||
interface Props {
|
||||
export interface AutoInfoBoxProps {
|
||||
metadata: AutomationMetadata;
|
||||
tags: Array<[string, string]>;
|
||||
onUpdate: (m: AutomationMetadata, tags: Array<[string, string]>) => void;
|
||||
tagDB: TagDB;
|
||||
children?: ReactNode;
|
||||
}
|
||||
export const AutoInfoBox: FC<Props> = ({
|
||||
export const AutoInfoBox: FC<AutoInfoBoxProps> = ({
|
||||
metadata,
|
||||
tags,
|
||||
onUpdate,
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
import React from "react";
|
||||
import { ComponentMeta, ComponentStory } from "@storybook/react";
|
||||
import { AutomationEditor } from "./index";
|
||||
import { useState } from "react";
|
||||
import { Page } from "components/Page";
|
||||
import { makeTagDB } from "components/AutomationList/TagDB";
|
||||
import { useTagDB } from "components/AutomationManager/TagDB";
|
||||
import { DEFAULT_DIMS } from "components/DAGGraph/elements/constants";
|
||||
|
||||
export default {
|
||||
title: "App/AutomationList/Editor",
|
||||
title: "App/AutomationEditor",
|
||||
component: AutomationEditor,
|
||||
parameters: { actions: { argTypesRegex: "^on.*" } },
|
||||
args: {
|
||||
@@ -21,7 +20,10 @@ const Template: ComponentStory<typeof AutomationEditor> = (args) => {
|
||||
<Page>
|
||||
<AutomationEditor
|
||||
{...args}
|
||||
tagDB={makeTagDB(state ? [state] : [])}
|
||||
tagDB={useTagDB(
|
||||
state ? [{ id: state.metadata.id, tags: state.tags }] : [],
|
||||
() => {}
|
||||
)}
|
||||
automation={state}
|
||||
onUpdate={(s) => {
|
||||
window.setTimeout(() => setState(s), 3000);
|
||||
|
||||
@@ -10,7 +10,7 @@ import { Button } from "components/Inputs/Button";
|
||||
import { useAutomatioEditorState, EditorData } from "./state";
|
||||
import { MiniFailure } from "types/validators/helper";
|
||||
import InputYaml from "components/Inputs/InputYaml";
|
||||
import { TagDB } from "components/AutomationList/TagDB";
|
||||
import { TagDB } from "components/AutomationManager/TagDB";
|
||||
import Skeleton from "@mui/material/Skeleton";
|
||||
import LinearProgress from "@mui/material/LinearProgress";
|
||||
import { useCookies } from "react-cookie";
|
||||
|
||||
Reference in new issue
Block a user