Skip to content

Commit c04ba81

Browse files
refactor(overmind-devtools-client): handle nested charts on chart property
1 parent 53fde2a commit c04ba81

File tree

2 files changed

+46
-46
lines changed
  • packages/node_modules/overmind-devtools-client/src

2 files changed

+46
-46
lines changed

packages/node_modules/overmind-devtools-client/src/components/Chart/index.tsx

Lines changed: 43 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -100,56 +100,55 @@ const ChartComponent: FunctionComponent<Props> = ({
100100
className={styles.wrapper}
101101
style={{ margin: 0, width: '100%' }}
102102
>
103-
{Object.keys(nestedChart.states[key].on).map((onKey) => {
104-
let target
105-
if (nestedChart.states[key].on[onKey]) {
106-
target =
107-
// @ts-ignore
108-
nestedChart.states[key].on[onKey].target ||
109-
nestedChart.states[key].on[onKey]
110-
}
111-
return (
112-
<div key={onKey} className={styles.stateItem}>
113-
<div
114-
onClick={
115-
chart.actions[onKey]
116-
? () =>
117-
actions.selectQueryAction(
118-
chart.path.concat(onKey).join('.')
119-
)
120-
: null
121-
}
122-
className={css(
123-
styles.stateNameCell,
124-
styles.onName,
125-
chart.actions[onKey] && styles.activeAction,
126-
chart.path.concat(onKey).join('.') ===
127-
state.currentApp.selectedActionQuery &&
128-
styles.selectedAction
129-
)}
130-
>
131-
<span className={textStyles.normal}>{onKey}</span>
132-
</div>
133-
<div className={styles.stateLineCell}>
134-
{target ? (
135-
<div className={styles.transitionLine} />
136-
) : null}
103+
{Object.keys(nestedChart.states[key].on || {}).map(
104+
(onKey) => {
105+
let target
106+
if (nestedChart.states[key].on[onKey]) {
107+
target =
108+
// @ts-ignore
109+
nestedChart.states[key].on[onKey].target ||
110+
nestedChart.states[key].on[onKey]
111+
}
112+
return (
113+
<div key={onKey} className={styles.stateItem}>
114+
<div
115+
onClick={
116+
chart.actions[onKey]
117+
? () =>
118+
actions.selectQueryAction(
119+
chart.path.concat(onKey).join('.')
120+
)
121+
: null
122+
}
123+
className={css(
124+
styles.stateNameCell,
125+
styles.onName,
126+
chart.actions[onKey] && styles.activeAction,
127+
chart.path.concat(onKey).join('.') ===
128+
state.currentApp.selectedActionQuery &&
129+
styles.selectedAction
130+
)}
131+
>
132+
<span className={textStyles.normal}>{onKey}</span>
133+
</div>
134+
<div className={styles.stateLineCell}>
135+
{target ? (
136+
<div className={styles.transitionLine} />
137+
) : null}
138+
</div>
139+
<div className={styles.transitionCell}>{target}</div>
140+
<div className={styles.nestedRoomCell} />
137141
</div>
138-
<div className={styles.transitionCell}>{target}</div>
139-
<div className={styles.nestedRoomCell} />
140-
</div>
141-
)
142-
})}
143-
{nestedChart.states[key].initial ? (
142+
)
143+
}
144+
)}
145+
{nestedChart.states[key].chart ? (
144146
<div className={styles.stateItem}>
145147
<div className={styles.nestedChart}>
146148
<ChartComponent
147149
chart={chart}
148150
statePath={statePath.concat(key)}
149-
nestedChart={{
150-
initial: nestedChart.states[key].initial,
151-
states: nestedChart.states[key].states,
152-
}}
151+
nestedChart={nestedChart.states[key].chart}
153152
/>
154153
</div>
155154
</div>

packages/node_modules/overmind-devtools-client/src/overmind/types.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,10 +391,11 @@ export type GroupedComponents = {
391391
export type NestedChart = {
392392
initial: string
393393
states: {
394-
[key: string]: Partial<NestedChart> & {
394+
[key: string]: {
395395
entry?: string
396396
exit?: string
397-
on: {
397+
chart?: NestedChart
398+
on?: {
398399
[key: string]:
399400
| string
400401
| {

0 commit comments

Comments
 (0)