Skip to content

Commit 5e752c4

Browse files
feat(overmind-devtools): splitter for actions and fixed storage issue
1 parent d6555dd commit 5e752c4

File tree

10 files changed

+118
-54
lines changed

10 files changed

+118
-54
lines changed

package-lock.json

Lines changed: 24 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@babel/plugin-syntax-dynamic-import": "^7.2.0",
2828
"@babel/plugin-transform-runtime": "^7.2.0",
2929
"@babel/preset-env": "^7.2.0",
30-
"axios": "0.18.1",
30+
"axios": "0.18.0",
3131
"color": "3.0.0",
3232
"color-hash": "1.0.3",
3333
"electron": "2.0.8",
@@ -56,7 +56,8 @@
5656
"vue": "2.5.16",
5757
"vue-hot-reload-api": "2.3.0",
5858
"vue-styled-components": "1.3.0",
59-
"ws": "7.0.0"
59+
"ws": "7.0.0",
60+
"react-split-pane": "0.1.87"
6061
},
6162
"devDependencies": {
6263
"@babel/core": "7.4.5",

packages/node_modules/overmind-devtools-client/DevtoolBackend.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,12 @@ class DevtoolBackend {
6565
)
6666
break
6767
case 'storage:set':
68-
this.evaluateDevtoolMessage(parsedMessage, () =>
68+
this.evaluateDevtoolMessage(parsedMessage, () => {
6969
this.options.storage.set(
7070
parsedMessage.data.key,
7171
parsedMessage.data.data
7272
)
73-
)
73+
})
7474
break
7575
case 'storage:clear':
7676
this.evaluateDevtoolMessage(parsedMessage, () =>

packages/node_modules/overmind-devtools-client/package.json

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@
1919
"devtool"
2020
],
2121
"dependencies": {
22+
"emotion": "^9.2.12",
23+
"lodash.throttle": "^4.1.1",
2224
"overmind-react": "next",
25+
"overmind-themes": "next",
2326
"react": "16.8.1",
2427
"react-dom": "16.8.1",
25-
"overmind-themes": "next",
26-
"ws": "^7.0.0",
27-
"emotion": "^9.2.12",
28-
"lodash.throttle": "^4.1.1"
28+
"react-split-pane": "^0.1.87",
29+
"ws": "^7.0.0"
2930
},
3031
"devDependencies": {
31-
"@types/node": "^10.12.21",
32-
"@types/ws": "6.0.1",
32+
"@types/node": "^10.12.21",
33+
"@types/ws": "6.0.1",
3334
"@babel/plugin-proposal-class-properties": "^7.3.4",
34-
"terser-webpack-plugin": "^1.3.0",
35-
"webpack-merge": "^4.2.1"
35+
"terser-webpack-plugin": "^1.3.0",
36+
"webpack-merge": "^4.2.1"
3637
}
3738
}

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { createElement, FunctionComponent } from 'react'
2+
import SplitPane from 'react-split-pane'
23
import { useOvermind } from '../../overmind'
34
import ActionsList from '../ActionsList'
45
import Action from '../Action'
@@ -7,15 +8,22 @@ import * as textStyles from '../../styles/text'
78
import ActionsTools from '../ActionsTools'
89

910
const Actions: FunctionComponent = () => {
10-
const { state } = useOvermind()
11+
const { state, actions } = useOvermind()
1112

1213
return (
1314
<div className={styles.wrapper}>
1415
<ActionsTools />
1516
{state.currentAction ? (
1617
<div className={styles.columns}>
17-
<ActionsList />
18-
<Action action={state.currentAction} />
18+
<SplitPane
19+
split="vertical"
20+
minSize={100}
21+
defaultSize={state.actionsSplitSize}
22+
onChange={(size) => actions.updateActionsSplitSize(size)}
23+
>
24+
<ActionsList />
25+
<Action action={state.currentAction} />
26+
</SplitPane>
1927
</div>
2028
) : (
2129
<div className={styles.centerWrapper}>

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,37 @@ injectGlobal`
2525
#app {
2626
height: 100%;
2727
}
28+
29+
.Resizer {
30+
background: var(--colors-background);
31+
opacity: .2;
32+
z-index: 1;
33+
box-sizing: border-box;
34+
background-clip: padding-box;
35+
}
36+
37+
.Resizer:hover {
38+
transition: all 0.5s ease;
39+
}
40+
.Resizer.vertical {
41+
width: 5px;
42+
margin: 0 -5px;
43+
border-left: 2px solid var(--colors-border);
44+
border-right: 2px solid var(--colors-border);
45+
opacity: 0.8;
46+
cursor: col-resize;
47+
}
48+
49+
.Resizer.vertical:hover {
50+
opacity: 1;
51+
}
52+
53+
.Resizer.disabled {
54+
cursor: not-allowed;
55+
}
56+
.Resizer.disabled:hover {
57+
border-color: transparent;
58+
}
2859
`
2960

3061
window.onerror = (_, _2, _3, _4, error) => {

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Action, pipe, Operator, AsyncAction } from 'overmind'
1+
import { Action, pipe, Operator, AsyncAction, mutate, debounce } from 'overmind'
22
import {
33
Message,
44
Tab,
@@ -215,3 +215,12 @@ export const setAppDataFromStorage: AsyncAction<{
215215
: ''
216216
state.currentTab = tab || state.currentTab
217217
})
218+
219+
export const updateActionsSplitSize: Operator<number> = pipe(
220+
debounce(200),
221+
mutate(async ({ state, effects }, size) => {
222+
state.actionsSplitSize = size
223+
224+
await effects.storage.set('devtool.actionsSplitSize', size)
225+
})
226+
)

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ const onInitialize: OnInitialize = async ({ state, effects }, app) => {
77
effects.connector.onDisconnect(app.actions.onDisconnect)
88

99
await effects.connector.connect(state.port)
10+
11+
state.actionsSplitSize =
12+
(await effects.storage.get('devtool.actionsSplitSize')) || 200
1013
}
1114

1215
export default onInitialize

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ type State = {
4040
history: Derive<State, HistoryRecord<any, any>[]>
4141
currentOperatorsByPath: Derive<State, OperatorsByPath[]>
4242
isShowingRuntime: boolean
43+
actionsSplitSize: number
4344
}
4445

4546
const state: State = {
@@ -48,6 +49,7 @@ const state: State = {
4849
error: null,
4950
showApps: false,
5051
currentAppName: null,
52+
actionsSplitSize: 200,
5153
port: 3031,
5254
apps: {},
5355
newPortValue: '',

packages/node_modules/overmind-devtools/src/main.js

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,29 @@ function createWindow() {
2222
app.relaunch()
2323
app.quit()
2424
},
25-
storage,
25+
// This storage requires objects to be stored, for some weird reason
26+
storage: {
27+
get(key) {
28+
return new Promise((resolve) => {
29+
storage.get(key, null, (_, data) => {
30+
if (data) {
31+
resolve(data.value)
32+
}
33+
})
34+
})
35+
},
36+
set(key, value) {
37+
return new Promise((resolve) => {
38+
storage.set(
39+
key,
40+
{
41+
value,
42+
},
43+
resolve
44+
)
45+
})
46+
},
47+
},
2648
})
2749

2850
function onPortSubmit(newPort) {

0 commit comments

Comments
 (0)