Skip to content

Commit 94021ef

Browse files
sroy3mattseddon
andauthored
Adding Redux to plots (#1832)
* WIP add redux * WIP add redux * Fix sections and zoomedInPlot * Fix storybook * Fix lint errors * Fix some tests * Fix tests * Revert demo changed files * Revert demo changed files * Revert demo changed files * Clean up zoomable plot * Uppercase enum keys * Make template plot data external * Make checkpoint plots data external * Self review * Rename plotStore to plotsDataStore for clarity * Revert "Rename plotStore to plotsDataStore for clarity" This reverts commit 696b4dd. * Rename plotStore to plotsDataStore for clarity Co-authored-by: mattseddon <[email protected]>
1 parent ecdb189 commit 94021ef

33 files changed

+1074
-649
lines changed

extension/src/plots/webview/contract.ts

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -121,14 +121,24 @@ export type ComparisonPlot = {
121121
revision: string
122122
}
123123

124+
export enum PlotsDataKeys {
125+
COMPARISON = 'comparison',
126+
CHECKPOINT = 'checkpoint',
127+
HAS_PLOTS = 'hasPlots',
128+
HAS_SELECTED_PLOTS = 'hasSelectedPlots',
129+
SELECTED_REVISIONS = 'selectedRevisions',
130+
TEMPLATE = 'template',
131+
SECTION_COLLAPSED = 'sectionCollapsed'
132+
}
133+
124134
export type PlotsData =
125135
| {
126-
comparison?: PlotsComparisonData | null
127-
checkpoint?: CheckpointPlotsData | null
128-
hasPlots?: boolean
129-
hasSelectedPlots?: boolean
130-
selectedRevisions?: Revision[]
131-
template?: TemplatePlotsData | null
132-
sectionCollapsed?: SectionCollapsed
136+
[PlotsDataKeys.COMPARISON]?: PlotsComparisonData | null
137+
[PlotsDataKeys.CHECKPOINT]?: CheckpointPlotsData | null
138+
[PlotsDataKeys.HAS_PLOTS]?: boolean
139+
[PlotsDataKeys.HAS_SELECTED_PLOTS]?: boolean
140+
[PlotsDataKeys.SELECTED_REVISIONS]?: Revision[]
141+
[PlotsDataKeys.TEMPLATE]?: TemplatePlotsData | null
142+
[PlotsDataKeys.SECTION_COLLAPSED]?: SectionCollapsed
133143
}
134144
| undefined

webview/package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@
2222
"typescript": "*"
2323
},
2424
"dependencies": {
25+
"@reduxjs/toolkit": "^1.8.2",
2526
"@tippyjs/react": "^4.2.6",
2627
"@vscode/webview-ui-toolkit": "^1.0.0",
2728
"classnames": "^2.2.6",
2829
"lodash.clonedeep": "^4.5.0",
2930
"lodash.merge": "^4.6.2",
3031
"react": "^17.0.1",
3132
"react-dom": "^17.0.1",
33+
"react-redux": "^8.0.2",
3234
"react-table": "^7.7.0",
3335
"react-vega": "^7.4.4",
3436
"react-virtualized": "^9.22.3",

webview/src/plots/actions.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import { createAction } from '@reduxjs/toolkit'
2+
import { ReducerName } from './constants'
3+
4+
export enum PlotAction {
5+
CLEAR_DATA = 'clearData'
6+
}
7+
8+
export const clearData = createAction<ReducerName | undefined>(
9+
PlotAction.CLEAR_DATA
10+
)

0 commit comments

Comments
 (0)