Skip to content

Commit b2802d7

Browse files
refactor(overmind-devtools): refactor devtools to react
1 parent 9ec5a0d commit b2802d7

File tree

28 files changed

+104
-85
lines changed

28 files changed

+104
-85
lines changed

packages/node_modules/overmind-devtools/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@
2727
"color-hash": "^1.0.3",
2828
"electron": "^2.0.4",
2929
"electron-json-storage": "^4.1.0",
30-
"overmind-components": "next",
30+
"overmind-react": "next",
31+
"react": "16.7.0-alpha.2",
32+
"react-dom": "16.7.0-alpha.2",
3133
"overmind-themes": "next",
3234
"emotion": "^9.2.12",
3335
"ws": "^5.2.1"

packages/node_modules/overmind-devtools/src/app/actions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ export const toggleGroupedComponent: Action<string> = ({
145145
state,
146146
}) => {
147147
const index = state.expandedComponents.indexOf(name)
148+
148149
if (index === -1) {
149150
state.expandedComponents.push(name)
150151
} else {

packages/node_modules/overmind-devtools/src/app/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { Overmind, TConfig } from 'overmind'
2+
import { createHook } from 'overmind-react'
23

34
import * as actions from './actions'
45
import * as effects from './effects'
@@ -15,6 +16,8 @@ declare module 'overmind' {
1516
interface IConfig extends TConfig<typeof config> {}
1617
}
1718

18-
export default new Overmind(config, {
19+
export const app = new Overmind(config, {
1920
devtools: false,
2021
})
22+
23+
export const useOvermind = createHook(app)

packages/node_modules/overmind-devtools/src/components/Action/index.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1-
import { h, Component, useOvermind } from 'overmind-components'
1+
import { createElement, SFC } from 'react'
2+
import { useOvermind } from '../../app'
23
import * as styles from './styles'
34
import ActionOperator from '../ActionOperator'
45
import Flush from '../ActionFlush'
56
import { getActionId, getOperatorId } from '../../app/utils'
67
import { css } from 'emotion'
78

8-
const Action: Component = () => {
9+
const Action: SFC = () => {
910
const { state, actions } = useOvermind()
1011
const flushReference =
1112
state.currentApp.flushByActionId[getActionId(state.currentAction)]
@@ -34,9 +35,8 @@ const Action: Component = () => {
3435

3536
if (flush) {
3637
return (
37-
<div>
38+
<div key={operator.actionId + '_' + operator.operatorId}>
3839
<ActionOperator
39-
key={operator.actionId + '_' + operator.operatorId}
4040
prevOperator={prevOperator}
4141
operator={operator}
4242
value={value}

packages/node_modules/overmind-devtools/src/components/ActionFlush/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { h, Component, useOvermind } from 'overmind-components'
1+
import { createElement, SFC } from 'react'
2+
import { useOvermind } from '../../app'
23
import { Flush as FlushType } from '../../app/types'
34
import * as actionStyles from '../Action/styles'
45
import * as styles from './styles'
@@ -10,7 +11,7 @@ type Props = {
1011
flush: FlushType
1112
}
1213

13-
const ActionFlush: Component<Props> = ({ flush }) => {
14+
const ActionFlush: SFC<Props> = ({ flush }) => {
1415
const { state, actions } = useOvermind()
1516
const isExpanded = state.expandAllActionDetails || !flush.isCollapsed
1617

packages/node_modules/overmind-devtools/src/components/ActionOperator/index.tsx

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import { h, Component, useOvermind } from 'overmind-components'
1+
import { createElement, SFC } from 'react'
2+
import { useOvermind } from '../../app'
23
import { Operator as OperatorType } from '../../app/types'
34
import ValueInspector from '../ValueInspector'
45
import Icon from '../common/Icon'
@@ -15,7 +16,7 @@ type Props = {
1516
operatorIndex: number
1617
}
1718

18-
const ActionOperator: Component<Props> = ({
19+
const ActionOperator: SFC<Props> = ({
1920
prevOperator,
2021
operator,
2122
value,
@@ -108,23 +109,32 @@ const ActionOperator: Component<Props> = ({
108109
textStyles.monospace
109110
)}
110111
>
111-
{effect.name + '.' + effect.method}
112+
{effect.name
113+
? effect.name + '.' + effect.method
114+
: effect.method}
112115
</span>
113-
<ValueInspector
114-
small
115-
value={
116-
effect.args.length > 1 ? effect.args : effect.args[0]
117-
}
118-
/>
119-
<span
120-
className={css(
121-
textStyles.description,
122-
textStyles.monospace
123-
)}
124-
>
125-
=>
126-
</span>
127-
<ValueInspector small value={effect.result} />
116+
{effect.args.length === 1 &&
117+
effect.args[0] === undefined ? null : (
118+
<ValueInspector
119+
small
120+
value={
121+
effect.args.length > 1 ? effect.args : effect.args[0]
122+
}
123+
/>
124+
)}
125+
{effect.result === undefined ? null : (
126+
<span
127+
className={css(
128+
textStyles.description,
129+
textStyles.monospace
130+
)}
131+
>
132+
=>
133+
</span>
134+
)}
135+
{effect.result === undefined ? null : (
136+
<ValueInspector small value={effect.result} />
137+
)}
128138
</div>
129139
))}
130140
{operator.mutations.map((mutation, index) => (

packages/node_modules/overmind-devtools/src/components/ActionPath/index.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,12 @@
1-
import { h, Component } from 'overmind-components'
1+
import { createElement, SFC } from 'react'
22
import * as styles from './styles'
33

44
type Props = {
55
visible?: boolean
66
showPathTag?: boolean
77
}
88

9-
const ActionPath: Component<Props> = ({
10-
showPathTag = true,
11-
visible,
12-
children,
13-
}) => (
9+
const ActionPath: SFC<Props> = ({ showPathTag = true, visible, children }) => (
1410
<div className={styles.path(visible)}>
1511
<div className={styles.pathLine} />
1612
{children ? (

packages/node_modules/overmind-devtools/src/components/Actions/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { h, Component, useOvermind } from 'overmind-components'
1+
import { createElement, SFC } from 'react'
2+
import { useOvermind } from '../../app'
23
import ActionsList from '../ActionsList'
34
import Action from '../Action'
45
import * as styles from './styles'
56
import * as textStyles from '../../styles/text'
67

7-
const Actions: Component = () => {
8+
const Actions: SFC = () => {
89
const { state } = useOvermind()
910

1011
if (!state.currentAction) {

packages/node_modules/overmind-devtools/src/components/ActionsList/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
import { h, Component, useOvermind } from 'overmind-components'
1+
import { createElement, SFC } from 'react'
2+
import { useOvermind } from '../../app'
23
import { ActionsListItemType } from '../../app/types'
34
import { nameToColor } from '../../app/utils'
45
import * as textStyles from '../../styles/text'
56
import * as styles from './styles'
67

7-
const ActionsList: Component = () => {
8+
const ActionsList: SFC = () => {
89
const { state, actions } = useOvermind()
910

1011
return (

packages/node_modules/overmind-devtools/src/components/Apps/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import { h, Component, useOvermind } from 'overmind-components'
1+
import { createElement, SFC } from 'react'
2+
import { useOvermind } from '../../app'
23
import { getAppShortName, nameToColor } from '../../app/utils'
34
import * as styles from './styles'
45
import { css } from 'emotion'
56

6-
const Apps: Component = () => {
7+
const Apps: SFC = () => {
78
const { state, actions } = useOvermind()
89
return (
910
<div className={styles.wrapper}>

0 commit comments

Comments
 (0)