Skip to content

Commit c8628c8

Browse files
feat(overmind-devtools): add error indication to actions list
1 parent 411d02a commit c8628c8

File tree

6 files changed

+33
-7
lines changed

6 files changed

+33
-7
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const ActionsList: SFC = () => {
1313
{state.currentApp.actionsList.map((item) => {
1414
if (item.type === ActionsListItemType.ACTION) {
1515
const action = state.currentApp.actions[item.id]
16+
1617
return (
1718
<div
1819
className={styles.actionItem}
@@ -32,6 +33,12 @@ const ActionsList: SFC = () => {
3233
action.actionName
3334
)}
3435
</span>
36+
<span
37+
className={styles.errorIndication}
38+
style={{
39+
visibility: action.hasError ? 'visible' : 'hidden',
40+
}}
41+
/>
3542
</div>
3643
)
3744
}

packages/node_modules/overmind-devtools/src/components/ActionsList/styles.ts

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,31 @@ export const list = css`
66

77
export const actionItem = css`
88
position: relative;
9+
display: flex;
10+
align-items: center;
911
padding: var(--padding-1);
1012
cursor: pointer;
11-
text-indent: 30px;
1213
border-bottom: 1px solid var(--color-dark-3);
1314
:hover {
1415
background-color: var(--color-dark-3);
1516
}
1617
`
1718

18-
export const actionColor = css`
19-
position: absolute;
20-
top: calc(50% - 5px);
21-
left: 10px;
19+
export const errorIndication = css`
20+
margin-left: auto;
21+
background-color: var(--color-red);
2222
border-radius: 2px;
2323
width: 10px;
2424
height: 10px;
25+
margin-right: 10px;
26+
`
27+
28+
export const actionColor = css`
29+
border-radius: 2px;
30+
flex: 0 0 10px;
31+
height: 10px;
32+
margin-left: 10px;
33+
margin-right: 10px;
2534
`
2635

2736
export const actionSubItem = css`

packages/node_modules/overmind-devtools/src/overmind/operators.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ export const addAction: Operator<StartActionMessage> = action(
195195
...action,
196196
isRunning: true,
197197
operators: [],
198+
hasError: false,
198199
}
199200

200201
if (
@@ -306,6 +307,7 @@ export const updateEffect: Operator<EffectMessage> = action(
306307
({ value: message, state }) => {
307308
const effect = message.data
308309
const id = getActionId(effect)
310+
const action = state.apps[message.appName].actions[id]
309311
const operator =
310312
state.apps[message.appName].actions[id].operators[effect.operatorId]
311313
const existingEvent = operator.events.find(
@@ -322,6 +324,10 @@ export const updateEffect: Operator<EffectMessage> = action(
322324
data: effect,
323325
})
324326
}
327+
328+
if (effect.error) {
329+
action.hasError = true
330+
}
325331
}
326332
)
327333

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export type Action = {
7777
isRunning: boolean
7878
operators: Operator[]
7979
value: any
80+
hasError: boolean
8081
}
8182

8283
export type Actions = {

packages/node_modules/overmind-devtools/src/styles/text.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,12 +84,12 @@ export const description = css`
8484
font-size: var(--font-size-2);
8585
text-transform: none;
8686
font-weight: normal;
87-
padding: none;
87+
padding: 0;
8888
`
8989

9090
export const hint = css`
9191
font-size: var(--font-size-1);
9292
text-transform: none;
9393
font-weight: normal;
94-
padding: none;
94+
padding: 0;
9595
`

packages/node_modules/overmind-devtools/webpack.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ module.exports = {
1010
path: path.resolve('dist'),
1111
filename: 'bundle.js',
1212
},
13+
devServer: {
14+
disableHostCheck: true,
15+
},
1316
module: {
1417
rules: [
1518
{

0 commit comments

Comments
 (0)