Skip to content

Commit afbaeaa

Browse files
Merge pull request cerebral#83 from cerebral/expandAllInDevtools
feat(overmind-devtools): add expand all toggle
2 parents b4f7b16 + ee87b9e commit afbaeaa

File tree

15 files changed

+318
-270
lines changed

15 files changed

+318
-270
lines changed

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Action } from 'overmind'
22
import * as mutations from './mutations'
33
import * as operations from './operations'
4-
import { Message, Tab } from './state'
4+
import { Message, Tab } from './types'
55

66
const onMessage: Action<Message> = (action) =>
77
action()
@@ -52,7 +52,9 @@ type Collapsed = {
5252
}
5353

5454
export const toggleCollapsed: Action<Collapsed> = (action) =>
55-
action().mutate(mutations.toggleCollapsed)
55+
action()
56+
.filter(operations.isNotExpandingAllActions)
57+
.mutate(mutations.toggleCollapsed)
5658

5759
export const configurePort: Action = (action) =>
5860
action().mutate(mutations.configurePort)
@@ -72,3 +74,6 @@ export const selectPort: Action<string> = (action) =>
7274
action()
7375
.mutate(mutations.selectPort)
7476
.do(operations.connectCurrentPort(onMessage(action as any)))
77+
78+
export const toggleExpandAllActions: Action = (action) =>
79+
action().mutate(mutations.toggleExpandAllActions)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Derive } from 'overmind'
2-
import { Component, App, Flush, Action } from './state'
2+
import { Component, App, Flush, Action } from './types'
33

44
export const currentApp: Derive<App> = (state) => state.apps[state.currentPort]
55

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
ActionsListItemType,
77
ActionItem,
88
ActionGroupItem,
9-
} from './state'
9+
} from './types'
1010
import {
1111
runMutation,
1212
getActionId,
@@ -365,3 +365,6 @@ type Collapse = {
365365

366366
export const toggleCollapsed: Mutate<Collapse> = (_, item) =>
367367
(item.isCollapsed = !item.isCollapsed)
368+
369+
export const toggleExpandAllActions: Mutate = (state) =>
370+
(state.expandAllActionDetails = !state.expandAllActionDetails)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Operation } from 'overmind'
2-
import { Apps } from './state'
2+
import { Apps } from './types'
33

44
export const getAppsFromStorage: Operation.Map<any, Promise<Apps>> = ({
55
storage,
@@ -34,3 +34,6 @@ export const connectCurrentPort: (
3434

3535
export const removeCurrentPort: Operation.Do = ({ state, connector }) =>
3636
connector.removePort(state.currentPort)
37+
38+
export const isNotExpandingAllActions: Operation.Filter = ({ state }) =>
39+
!state.expandAllActionDetails
Lines changed: 3 additions & 161 deletions
Original file line numberDiff line numberDiff line change
@@ -1,166 +1,6 @@
11
import { derive } from 'overmind'
22
import * as derived from './derived'
3-
4-
export type Mutation = {
5-
args: any[]
6-
method: string
7-
path: string
8-
}
9-
10-
export type Effect = {
11-
args: any[]
12-
method: string
13-
name: string
14-
result: any
15-
}
16-
17-
export enum ActionsListItemType {
18-
ACTION = 'ACTION',
19-
GROUP = 'GROUP',
20-
}
21-
22-
export type ActionItem = {
23-
type: ActionsListItemType.ACTION
24-
id: string
25-
actionId: string
26-
}
27-
28-
export type ActionGroupItem = {
29-
type: ActionsListItemType.GROUP
30-
id: string
31-
actionId: string
32-
isCollapsed: boolean
33-
actionIds: string[]
34-
}
35-
36-
export type ActionsListItem = ActionItem | ActionGroupItem
37-
38-
export type Operator = {
39-
name: string
40-
actionId: number
41-
executionId: number
42-
isAsync: boolean
43-
isRunning: boolean
44-
isCollapsed: boolean
45-
operatorId: number
46-
mutations: Mutation[]
47-
effects: Effect[]
48-
path: string[]
49-
type: string
50-
result: any
51-
}
52-
53-
export type Action = {
54-
actionName: string
55-
actionId: number
56-
executionId: number
57-
isRunning: boolean
58-
operators: Operator[]
59-
value: any
60-
}
61-
62-
export type Actions = {
63-
[id: string]: Action
64-
}
65-
66-
export type Flush = {
67-
flushId: number
68-
mutations: Mutation[]
69-
components: string[]
70-
derived: string[]
71-
computed: string[]
72-
}
73-
74-
export type FlushReference = {
75-
flushId: number
76-
isCollapsed: boolean
77-
}
78-
79-
export type Flushes = {
80-
[id: string]: Flush
81-
}
82-
83-
export type Component = {
84-
id: string
85-
name: string
86-
isMounted: boolean
87-
paths: string[]
88-
updateCount: number
89-
}
90-
91-
export type Derived = {
92-
flushId: number
93-
path: string
94-
paths: string[]
95-
updateCount: number
96-
value: any
97-
}
98-
99-
export type Computed = {
100-
cacheKeyIndex: number
101-
cacheKeysCount: number
102-
flushId: number
103-
limit: number
104-
path: string
105-
paths: string[]
106-
updateCount: number
107-
value: number
108-
}
109-
110-
export type Components = {
111-
[id: string]: Component
112-
}
113-
114-
export type DerivedMap = {
115-
[path: string]: Derived
116-
}
117-
118-
export type ComputedMap = {
119-
[path: string]: Computed
120-
}
121-
122-
export type App = {
123-
name: string
124-
port: string
125-
messages: AppMessage[]
126-
state: object
127-
components: Components
128-
derived: Derived
129-
computed: Computed
130-
flushes: Flushes
131-
flushByActionId: {
132-
[id: string]: FlushReference
133-
}
134-
flushByOperatorId: {
135-
[id: string]: FlushReference
136-
}
137-
actions: Actions
138-
actionsList: ActionsListItem[]
139-
currentActionId: string
140-
}
141-
142-
export type Apps = {
143-
[port: string]: App
144-
}
145-
146-
export type AppMessage = {
147-
type: string
148-
data: any
149-
}
150-
151-
export type Message = {
152-
port: string
153-
message: AppMessage[]
154-
}
155-
156-
export enum Tab {
157-
Actions = 'Actions',
158-
State = 'State',
159-
Console = 'Console',
160-
Components = 'Components',
161-
Flushes = 'Flushes',
162-
Remove = 'Remove',
163-
}
3+
import { Apps, Tab, App, Component, Flush, Action } from './types'
1644

1655
export let isConnecting: boolean = true
1666

@@ -203,3 +43,5 @@ export const flushesStatePathCount: number = derive(
20343
)
20444

20545
export const currentAction: Action = derive(derived.currentAction)
46+
47+
export let expandAllActionDetails: boolean = false
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
export type Mutation = {
2+
args: any[]
3+
method: string
4+
path: string
5+
}
6+
7+
export type Effect = {
8+
args: any[]
9+
method: string
10+
name: string
11+
result: any
12+
}
13+
14+
export enum ActionsListItemType {
15+
ACTION = 'ACTION',
16+
GROUP = 'GROUP',
17+
}
18+
19+
export type ActionItem = {
20+
type: ActionsListItemType.ACTION
21+
id: string
22+
actionId: string
23+
}
24+
25+
export type ActionGroupItem = {
26+
type: ActionsListItemType.GROUP
27+
id: string
28+
actionId: string
29+
isCollapsed: boolean
30+
actionIds: string[]
31+
}
32+
33+
export type ActionsListItem = ActionItem | ActionGroupItem
34+
35+
export type Operator = {
36+
name: string
37+
actionId: number
38+
executionId: number
39+
isAsync: boolean
40+
isRunning: boolean
41+
isCollapsed: boolean
42+
operatorId: number
43+
mutations: Mutation[]
44+
effects: Effect[]
45+
path: string[]
46+
type: string
47+
result: any
48+
}
49+
50+
export type Action = {
51+
actionName: string
52+
actionId: number
53+
executionId: number
54+
isRunning: boolean
55+
operators: Operator[]
56+
value: any
57+
}
58+
59+
export type Actions = {
60+
[id: string]: Action
61+
}
62+
63+
export type Flush = {
64+
flushId: number
65+
mutations: Mutation[]
66+
components: string[]
67+
derived: string[]
68+
computed: string[]
69+
}
70+
71+
export type FlushReference = {
72+
flushId: number
73+
isCollapsed: boolean
74+
}
75+
76+
export type Flushes = {
77+
[id: string]: Flush
78+
}
79+
80+
export type Component = {
81+
id: string
82+
name: string
83+
isMounted: boolean
84+
paths: string[]
85+
updateCount: number
86+
}
87+
88+
export type Derived = {
89+
flushId: number
90+
path: string
91+
paths: string[]
92+
updateCount: number
93+
value: any
94+
}
95+
96+
export type Computed = {
97+
cacheKeyIndex: number
98+
cacheKeysCount: number
99+
flushId: number
100+
limit: number
101+
path: string
102+
paths: string[]
103+
updateCount: number
104+
value: number
105+
}
106+
107+
export type Components = {
108+
[id: string]: Component
109+
}
110+
111+
export type DerivedMap = {
112+
[path: string]: Derived
113+
}
114+
115+
export type ComputedMap = {
116+
[path: string]: Computed
117+
}
118+
119+
export type App = {
120+
name: string
121+
port: string
122+
messages: AppMessage[]
123+
state: object
124+
components: Components
125+
derived: Derived
126+
computed: Computed
127+
flushes: Flushes
128+
flushByActionId: {
129+
[id: string]: FlushReference
130+
}
131+
flushByOperatorId: {
132+
[id: string]: FlushReference
133+
}
134+
actions: Actions
135+
actionsList: ActionsListItem[]
136+
currentActionId: string
137+
}
138+
139+
export type Apps = {
140+
[port: string]: App
141+
}
142+
143+
export type AppMessage = {
144+
type: string
145+
data: any
146+
}
147+
148+
export type Message = {
149+
port: string
150+
message: AppMessage[]
151+
}
152+
153+
export enum Tab {
154+
Actions = 'Actions',
155+
State = 'State',
156+
Console = 'Console',
157+
Components = 'Components',
158+
Flushes = 'Flushes',
159+
Remove = 'Remove',
160+
}

0 commit comments

Comments
 (0)