File tree Expand file tree Collapse file tree 9 files changed +138
-10
lines changed
packages/node_modules/overmind-devtools-client/src Expand file tree Collapse file tree 9 files changed +138
-10
lines changed Original file line number Diff line number Diff line change 1+ import { FunctionComponent , createElement } from 'react'
2+ import SplitPane from 'react-split-pane'
3+
4+ import { useOvermind } from '../../overmind'
5+ import * as textStyles from '../../styles/text'
6+ import * as styles from './styles'
7+
8+ const Charts : FunctionComponent = ( ) => {
9+ const { state, actions } = useOvermind ( )
10+
11+ return (
12+ < div className = { styles . wrapper } >
13+ { state . currentAction ? (
14+ < div className = { styles . columns } >
15+ < SplitPane
16+ split = "vertical"
17+ minSize = { 100 }
18+ defaultSize = { state . actionsSplitSize }
19+ onChange = { ( size ) => actions . updateActionsSplitSize ( size ) }
20+ >
21+ < div > List</ div >
22+ < div > Chart</ div >
23+ </ SplitPane >
24+ </ div >
25+ ) : (
26+ < div className = { styles . centerWrapper } >
27+ < span className = { textStyles . header } > no actions triggered...</ span >
28+ </ div >
29+ ) }
30+ </ div >
31+ )
32+ }
33+
34+ export default Charts
Original file line number Diff line number Diff line change 1+ import { css } from 'emotion'
2+
3+ import { colors } from '../../theme'
4+
5+ export const wrapper = css ( {
6+ position : 'relative' ,
7+ display : 'flex' ,
8+ flexDirection : 'column' ,
9+ height : '100%' ,
10+ } )
11+
12+ export const centerWrapper = css ( {
13+ display : 'flex' ,
14+ height : '100%' ,
15+ alignItems : 'center' ,
16+ justifyContent : 'center' ,
17+ } )
18+
19+ export const columns = css ( {
20+ display : 'flex' ,
21+ '> *:first-child' : {
22+ flex : '0 0 300px' ,
23+ } ,
24+ '> *:last-child' : {
25+ flex : 1 ,
26+ } ,
27+ flex : 1 ,
28+ position : 'relative' ,
29+ } )
Original file line number Diff line number Diff line change 1- import { createElement , FunctionComponent } from 'react'
2- import { useOvermind } from '../../overmind'
3- import Apps from '../Apps'
4- import * as styles from './styles'
5- import { Tab } from '../../overmind/types'
6- import Tooltip from '../common/Tooltip'
71import { css } from 'emotion'
2+ import { FunctionComponent , createElement } from 'react'
83import {
9- FaDatabase ,
10- FaCogs ,
4+ FaChrome ,
115 FaCode ,
6+ FaCogs ,
7+ FaDatabase ,
8+ FaHistory ,
9+ FaProjectDiagram ,
1210 FaSave ,
1311 FaTerminal ,
14- FaHistory ,
15- FaChrome ,
1612} from 'react-icons/fa'
13+
14+ import { useOvermind } from '../../overmind'
15+ import { Tab } from '../../overmind/types'
1716import { colors } from '../../theme'
17+ import Apps from '../Apps'
18+ import Tooltip from '../common/Tooltip'
1819import RuntimeConfig from '../RuntimeConfig'
20+ import * as styles from './styles'
1921
2022const Tabs : FunctionComponent = ( ) => {
2123 const { state, actions } = useOvermind ( )
@@ -67,6 +69,17 @@ const Tabs: FunctionComponent = () => {
6769 < FaCogs />
6870 </ button >
6971 </ Tooltip >
72+ < Tooltip text = "Charts" >
73+ < button
74+ className = { css (
75+ styles . button ,
76+ state . currentTab === Tab . Charts && styles . activeButton
77+ ) }
78+ onClick = { ( ) => actions . changeTab ( Tab . Charts ) }
79+ >
80+ < FaProjectDiagram />
81+ </ button >
82+ </ Tooltip >
7083 < Tooltip text = "Components" >
7184 < button
7285 className = { css (
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ import State from '../State'
1010import Components from '../Components'
1111import Flushes from '../Flushes'
1212import History from '../History'
13+ import Charts from '../Charts'
1314
1415const pages : { [ key in Tab ] : SFC } = {
1516 [ Tab . Actions ] : Actions ,
@@ -19,6 +20,7 @@ const pages: { [key in Tab]: SFC } = {
1920 [ Tab . Flushes ] : Flushes ,
2021 [ Tab . Remove ] : ( ) => null ,
2122 [ Tab . History ] : History ,
23+ [ Tab . Charts ] : Charts ,
2224}
2325
2426const Workspace : SFC = ( ) => {
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ export const onMessage: Operator<Message> = pipe(
3232 [ ExecutionType . ACTION_END ] : o . updateAction ( ) ,
3333 [ ExecutionType . OPERATOR_ASYNC ] : o . updateOperatorAsync ( ) ,
3434 [ ExecutionType . GETTER ] : o . runGetterMutation ( ) ,
35+ [ ExecutionType . CHART ] : o . addChart ( ) ,
3536 } )
3637)
3738
Original file line number Diff line number Diff line change @@ -25,6 +25,7 @@ import {
2525 GetterMessage ,
2626 StateMessage ,
2727 Tab ,
28+ ChartMessage ,
2829} from './types'
2930import {
3031 createApp ,
@@ -216,6 +217,20 @@ export const addAction: () => Operator<StartActionMessage> = () =>
216217 }
217218 } )
218219
220+ export const addChart : ( ) => Operator < ChartMessage > = ( ) =>
221+ mutate ( ( { state } , message ) => {
222+ const app = state . apps [ message . appName ]
223+ const data = message . data
224+ const chartId = data . path . join ( '.' )
225+ const isSelectingFirstChart = ! app . currentChartId
226+
227+ app . charts [ chartId ] = data
228+
229+ if ( isSelectingFirstChart ) {
230+ app . currentChartId = chartId
231+ }
232+ } )
233+
219234export const addOperator : ( ) => Operator < StartOperatorMessage > = ( ) =>
220235 mutate ( ( { state } , message ) => {
221236 const operatorData = message . data
Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ import {
1717 EffectMessage ,
1818 EffectHistoryRecord ,
1919 OperatorsByPath ,
20+ Chart ,
2021} from './types'
2122
2223type State = {
@@ -29,6 +30,7 @@ type State = {
2930 currentTab : Tab
3031 showApps : boolean
3132 currentAction : Derive < State , Action >
33+ currentChart : Derive < State , Chart >
3234 currentApp : Derive < State , App >
3335 componentsMounted : Derive < State , Component [ ] >
3436 componentsUpdateCount : Derive < State , number >
@@ -98,6 +100,8 @@ const state: State = {
98100 } , [ ] ) . length ,
99101 currentAction : ( state ) =>
100102 state . currentApp . actions [ state . currentApp . currentActionId ] ,
103+ currentChart : ( state ) =>
104+ state . currentApp . charts [ state . currentApp . currentChartId ] ,
101105 groupedComponents ( state ) {
102106 const components = state . componentsMounted
103107
Original file line number Diff line number Diff line change @@ -163,6 +163,10 @@ export type EffectHistoryRecord = HistoryRecord<
163163 Effect
164164>
165165
166+ export type Charts = {
167+ [ path : string ] : Chart
168+ }
169+
166170export type App = {
167171 name : string
168172 messages : AppMessage < any > [ ]
@@ -177,8 +181,10 @@ export type App = {
177181 [ id : string ] : FlushReference
178182 }
179183 actions : Actions
184+ charts : Charts
180185 actionsList : ActionsListItem [ ]
181186 currentActionId : string
187+ currentChartId : string
182188 actionQuery : string
183189 actionQuerySuggestion : string
184190 selectedActionQuery : string
@@ -213,6 +219,7 @@ export enum ExecutionType {
213219 ACTION_END = 'action:end' ,
214220 GETTER = 'getter' ,
215221 STATE = 'state' ,
222+ CHART = 'chart' ,
216223}
217224
218225export enum AppMessageType {
@@ -289,6 +296,8 @@ export type StartActionMessage = AppMessage<{
289296 parentExecution ?: any
290297} >
291298
299+ export type ChartMessage = AppMessage < Chart >
300+
292301export type StartOperatorMessage = AppMessage < {
293302 actionId : number
294303 actionName : string
@@ -366,6 +375,7 @@ export enum Tab {
366375 Flushes = 'Flushes' ,
367376 Remove = 'Remove' ,
368377 History = 'History' ,
378+ Charts = 'Charts' ,
369379}
370380
371381export type GroupedComponent = {
@@ -377,3 +387,21 @@ export type GroupedComponent = {
377387export type GroupedComponents = {
378388 [ name : string ] : GroupedComponent
379389}
390+
391+ export type Chart = {
392+ path : string [ ]
393+ state : string
394+ chart : {
395+ [ key : string ] : {
396+ entry ?: string
397+ exit ?: string
398+ on : {
399+ [ key : string ] :
400+ | string
401+ | {
402+ target : string
403+ }
404+ }
405+ }
406+ }
407+ }
Original file line number Diff line number Diff line change @@ -39,8 +39,10 @@ export const createApp = (data: Partial<App>): App =>
3939 derived : { } ,
4040 flushes : { } ,
4141 actions : { } ,
42+ charts : { } ,
4243 actionsList : [ ] ,
4344 currentActionId : null ,
45+ currentChartId : null ,
4446 flushByActionId : { } ,
4547 flushByOperatorId : { } ,
4648 actionQuery : '' ,
You can’t perform that action at this time.
0 commit comments