diff --git a/web/src/automation/StateManager/Generic.tsx b/web/src/automation/StateManager/Generic.tsx index 233e6bd..9856655 100644 --- a/web/src/automation/StateManager/Generic.tsx +++ b/web/src/automation/StateManager/Generic.tsx @@ -1,4 +1,4 @@ -import InputWrapper from "../../components/InputWrapper"; +import InputText from "../../components/InputText"; import { ServiceScript } from "../types/script"; import { BaseState } from "./BaseState"; @@ -12,15 +12,10 @@ export default class Generic extends BaseState<{alias: string}> { } renderOptionList(state: ServiceScript): JSX.Element { return
- - { - e.preventDefault(); - this.setState({ - ...state, - alias: e.target.value, - }) - }}/> - + this.setState({...state, alias})} + />
THIS IS NOT SUPPORTED YET!
diff --git a/web/src/automation/StateManager/ScriptService.tsx b/web/src/automation/StateManager/ScriptService.tsx index fa3f4a0..f2de323 100644 --- a/web/src/automation/StateManager/ScriptService.tsx +++ b/web/src/automation/StateManager/ScriptService.tsx @@ -1,3 +1,4 @@ +import InputText from "../../components/InputText"; import InputWrapper from "../../components/InputWrapper"; import { ServiceScript } from "../types/script"; import { BaseState } from "./BaseState"; @@ -17,33 +18,18 @@ export default class ScriptCallServiceState extends BaseState { } renderOptionList(state: ServiceScript): JSX.Element { return
- - { - e.preventDefault(); - this.setState({ - ...state, - alias: e.target.value, - }) - }}/> - - - { - e.preventDefault(); - this.setState({ - ...state, - service: e.target.value, - }) - }}/> - - - { - e.preventDefault(); - this.setState({ - ...state, - target: e.target.value, - }) - }}/> - + this.setState({...state, alias})} + /> + this.setState({...state, service})} + /> + this.setState({...state, target})} + />
} } \ No newline at end of file diff --git a/web/src/automation/StateManager/index.ts b/web/src/automation/StateManager/index.ts index 9e41f6d..2b58f02 100644 --- a/web/src/automation/StateManager/index.ts +++ b/web/src/automation/StateManager/index.ts @@ -1,4 +1,4 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { AutomationNodeType, NodeSubType } from "../types"; import { BaseState } from "./BaseState"; import Generic from "./Generic"; @@ -24,9 +24,15 @@ export default class StateManager { } this.nodeType = nodeType; this.nodeSubtype = nodeSubtype; + useEffect(() => { + this.setState(this.baseState.defaultState()); + }, [this.nodeType, this.nodeSubtype]); return this.baseState; } renderOptionList() { return this.baseState.renderOptionList(this.state) } + get isReady() { + return this.baseState.isReady(this.state); + } } \ No newline at end of file diff --git a/web/src/components/AutomationEditor/NewNodeModal.tsx b/web/src/components/AutomationEditor/NewNodeModal.tsx index 6eb0c50..50697e2 100644 --- a/web/src/components/AutomationEditor/NewNodeModal.tsx +++ b/web/src/components/AutomationEditor/NewNodeModal.tsx @@ -28,14 +28,19 @@ export default function NewNodeModal({
e.preventDefault()}>
Create {node_type[0].toUpperCase()}{node_type.slice(1)}
- - setSubType(n as NodeSubType)}/> - + setSubType(n as NodeSubType)} + /> {stateManager.renderOptionList()}
- - + +
diff --git a/web/src/components/InputList.tsx b/web/src/components/InputList.tsx index 9976896..8b261c4 100644 --- a/web/src/components/InputList.tsx +++ b/web/src/components/InputList.tsx @@ -1,4 +1,5 @@ import { SelectHTMLAttributes } from "react"; +import InputWrapper from "./InputWrapper"; export interface Props { @@ -7,12 +8,15 @@ export interface Props { onChange: (n: string) => void; id?: string; className?: string; + label: string; } -export default function InputList({current, options, onChange, ...selattr}: Props) { - return +export default function InputList({current, options, onChange, label, ...selattr}: Props) { + return + + } \ No newline at end of file diff --git a/web/src/components/InputText.tsx b/web/src/components/InputText.tsx new file mode 100644 index 0000000..8938668 --- /dev/null +++ b/web/src/components/InputText.tsx @@ -0,0 +1,18 @@ +import InputWrapper from "./InputWrapper"; + + +export interface Props { + label: string; + value: string; + onChange: (v: string) => void; +} +export default function InputText({ + label, value, onChange +}: Props) { + return + { + e.preventDefault(); + onChange(e.target.value) + }}/> + +} \ No newline at end of file diff --git a/web/src/components/Node/index.tsx b/web/src/components/Node/index.tsx index b8b1fba..821027c 100644 --- a/web/src/components/Node/index.tsx +++ b/web/src/components/Node/index.tsx @@ -16,7 +16,6 @@ export default function AutomationNode({ onXClick = () => {}, }: PropsWithChildren) { const [isOpen, setOpen] = useState(initialOpenState); - console.log(children); return
diff --git a/web/src/styles/colors.scss b/web/src/styles/colors.scss index 7573b64..6b253c6 100644 --- a/web/src/styles/colors.scss +++ b/web/src/styles/colors.scss @@ -5,5 +5,6 @@ $secondary-accent: #929191; $font-color-primary: #e1e1e1; +$gray: #403f3f; $green: #68caa4; $blue: #68aaca; diff --git a/web/src/styles/index.scss b/web/src/styles/index.scss index 01fedd1..45815da 100644 --- a/web/src/styles/index.scss +++ b/web/src/styles/index.scss @@ -80,6 +80,13 @@ button { border-color: $secondary-accent; } + &:disabled { + background-color: $gray; + border-color: $gray; + color: darken($gray, 50); + cursor: not-allowed; + } + &.secondary { background-color: $primary; color: $secondary-accent; @@ -103,3 +110,8 @@ select { @extend button; margin: 0; } +input { + @extend button; + margin: 0; + cursor: text; +}