diff options
author | alinayejin <alina_kim@brown.edu> | 2023-12-06 23:40:41 -0500 |
---|---|---|
committer | alinayejin <alina_kim@brown.edu> | 2023-12-06 23:40:41 -0500 |
commit | 41d5ef99eaa30afe59b15e0c8c7f3f3bed57d33d (patch) | |
tree | 6c81e07b188b9df77bcd8e72bb018863e8c21697 | |
parent | 173df6c015790e00edd9c9305b1b520b31dc3134 (diff) |
info ui fsa cleanup
-rw-r--r-- | src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx | 77 |
1 files changed, 29 insertions, 48 deletions
diff --git a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx index 8b2b32581..74b5545bd 100644 --- a/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx +++ b/src/client/views/collections/collectionFreeForm/CollectionFreeFormInfoUI.tsx @@ -25,73 +25,54 @@ export class CollectionFreeFormInfoUI extends React.Component<CollectionFreeForm constructor(props: any) { super(props); - this.currState = this.state0; + this.currState = this.start; } + @observable currState: infoState; + @computed get first_doc() { return this.props.Freeform.childDocs.lastElement(); } - @observable currState: infoState; - state0: infoState = { + start: infoState = { Message: 'Click to create Object', - Arcs: [ - { - events: () => this.props.Freeform.childDocs.slice(), - actions: (docs: Doc[]) => { - if (docs.length === 1) this.currState = this.state1; - if (docs.length > 1) this.currState = this.state2; - }, - }, - ], + Events: () => this.props.Freeform.childDocs, + Actions: (docs: Doc[]) => { + if (docs.length === 1) this.currState = this.state1; + if (docs.length > 1) this.currState = this.state2; + }, }; state1: infoState = { Message: 'Create a second doc', - Arcs: [ - { - events: () => this.props.Freeform.childDocs.slice(), - actions: (docs: Doc[]) => { - if (docs.length === 0) this.currState = this.state0; - if (docs.length === 2) this.currState = this.state2; - }, - }, - ], + Events: () => this.props.Freeform.childDocs, + Actions: (docs: Doc[]) => { + if (docs.length === 0) this.currState = this.start; + if (docs.length === 2) this.currState = this.state2; + }, }; state2: infoState = { Message: 'Create a link', - Arcs: [ - { - events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), docs: this.props.Freeform.childDocs.slice() }), - actions: arc => { - const { links, docs } = arc; - if (docs.length === 0) this.currState = this.state0; - if (docs.length === 1) this.currState = this.state1; - if (links.length) this.currState = this.state3; - }, - }, - ], + Events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), docs: this.props.Freeform.childDocs.slice() }), + Actions: arc => { + const { links, docs } = arc; + if (docs.length === 0) this.currState = this.start; + if (docs.length === 1) this.currState = this.state1; + if (links?.length) this.currState = this.state3; + }, }; state3: infoState = { Message: 'View links', - Arcs: [ - { - events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), viewingLinks: DocumentLinksButton.LinkEditorDocView }), - actions: arc => { - const { links, viewingLinks } = arc; - if (viewingLinks) this.currState = this.state4; - if (links.length === 0) this.currState = this.state2; - }, - }, - ], + Events: () => ({ links: this.first_doc && LinkManager.Instance.getAllDirectLinks(this.first_doc), viewingLinks: DocumentLinksButton.LinkEditorDocView }), + Actions: arc => { + const { links, viewingLinks } = arc; + if (viewingLinks) this.currState = this.state4; + if (links?.length === 0) this.currState = this.state2; + }, }; state4: infoState = { Message: 'You did it!', - Arcs: [ - { - events: () => false, - actions: arc => {}, - }, - ], + Events: () => false, + Actions: arc => {}, }; /* |