Skip to content

Commit 89d5364

Browse files
authored
fix: redux dev tools config (#465)
* redux dev tools config * upgrade typescript to 3.7 * add id to redux store name * missing exports
1 parent 4edbb85 commit 89d5364

File tree

7 files changed

+58
-31
lines changed

7 files changed

+58
-31
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
src/mocks

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@
8686
"@types/storybook__react": "^4.0.2",
8787
"@types/url-parse": "^1.4.3",
8888
"@types/uuid": "^3.4.4",
89-
"@typescript-eslint/eslint-plugin": "^2.9.0",
90-
"@typescript-eslint/parser": "^2.9.0",
89+
"@typescript-eslint/eslint-plugin": "^2.10.0",
90+
"@typescript-eslint/parser": "^2.10.0",
9191
"autoprefixer": "^9.6.1",
9292
"babel-loader": "^8.0.5",
9393
"canvas": "^2.4.1",
@@ -132,7 +132,7 @@
132132
"ts-jest": "^24.1.0",
133133
"ts-loader": "^6.1.2",
134134
"ts-prune": "^0.3.0",
135-
"typescript": "^3.6.3",
135+
"typescript": "^3.7.0",
136136
"utility-types": "^3.9.0",
137137
"webpack": "^4.29.5",
138138
"webpack-cli": "^3.3.1",

src/components/chart.tsx

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
import React, { CSSProperties, createRef } from 'react';
22
import classNames from 'classnames';
33
import { Provider } from 'react-redux';
4+
import { createStore, Store } from 'redux';
5+
import Konva from 'konva';
6+
import { Stage } from 'react-konva';
7+
import uuid from 'uuid';
8+
49
import { SpecsParser } from '../specs/specs_parser';
510
import { ChartResizer } from './chart_resizer';
611
import { Legend } from './legend/legend';
@@ -10,9 +15,6 @@ import { Position } from '../chart_types/xy_chart/utils/specs';
1015
import { ChartSize, getChartSize } from '../utils/chart_size';
1116
import { ChartStatus } from './chart_status';
1217
import { chartStoreReducer, GlobalChartState } from '../state/chart_state';
13-
import { createStore, Store } from 'redux';
14-
import uuid from 'uuid';
15-
import { devToolsEnhancer } from 'redux-devtools-extension';
1618
import { isInitialized } from '../state/selectors/is_initialized';
1719
import { createOnElementOutCaller } from '../chart_types/xy_chart/state/selectors/on_element_out_caller';
1820
import { createOnElementOverCaller } from '../chart_types/xy_chart/state/selectors/on_element_over_caller';
@@ -23,8 +25,6 @@ import { createOnBrushEndCaller } from '../chart_types/xy_chart/state/selectors/
2325
import { onExternalPointerEvent } from '../state/actions/events';
2426
import { CursorEvent } from '../specs';
2527
import { createOnPointerMoveCaller } from '../chart_types/xy_chart/state/selectors/on_pointer_move_caller';
26-
import Konva from 'konva';
27-
import { Stage } from 'react-konva';
2828

2929
interface ChartProps {
3030
/** The type of rendered
@@ -57,17 +57,19 @@ export class Chart extends React.Component<ChartProps, ChartState> {
5757
private chartStore: Store<GlobalChartState>;
5858
private chartContainerRef: React.RefObject<HTMLDivElement>;
5959
private chartStageRef: React.RefObject<Stage>;
60+
6061
constructor(props: any) {
6162
super(props);
6263
this.chartContainerRef = createRef();
6364
this.chartStageRef = createRef();
6465

65-
const storeReducer = chartStoreReducer(uuid.v4());
66-
if (process.env.NODE_ENV !== 'production') {
67-
this.chartStore = createStore(storeReducer, devToolsEnhancer({ trace: true }));
68-
} else {
69-
this.chartStore = createStore(storeReducer);
70-
}
66+
const id = uuid.v4();
67+
const storeReducer = chartStoreReducer(id);
68+
const enhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
69+
? (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ trace: true, name: `@elastic/charts (id: ${id})` })()
70+
: undefined;
71+
72+
this.chartStore = createStore(storeReducer, enhancers);
7173
this.state = {
7274
legendPosition: Position.Right,
7375
};
@@ -135,7 +137,7 @@ export class Chart extends React.Component<ChartProps, ChartState> {
135137
const canvasStage = stage.toCanvas({
136138
width,
137139
height,
138-
callback: () => {},
140+
callback: () => undefined,
139141
});
140142
// @ts-ignore
141143
if (canvasStage.msToBlob) {

src/components/chart_resizer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class Resizer extends React.Component<ResizerProps> {
2323
private containerRef: RefObject<HTMLDivElement>;
2424
private ro: ResizeObserver;
2525
private animationFrameID: number | null;
26-
private onResizeDebounced: (entries: ResizeObserverEntry[]) => void = () => {};
26+
private onResizeDebounced: (entries: ResizeObserverEntry[]) => void = () => undefined;
2727

2828
constructor(props: ResizerProps) {
2929
super(props);

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ export {
2020
AnnotationDomainType,
2121
AnnotationDomainTypes,
2222
CustomSeriesColors,
23+
SeriesColorsArray,
24+
SeriesColorAccessorFn,
2325
HistogramModeAlignment,
2426
HistogramModeAlignments,
2527
LineAnnotationDatum,

src/specs/settings.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ export const DEFAULT_SETTINGS_SPEC = {
133133
theme: LIGHT_THEME,
134134
};
135135

136-
type SpecProps = Partial<Omit<SettingsSpec, 'chartType' | 'specType' | 'id'>>;
136+
export type SettingsSpecProps = Partial<Omit<SettingsSpec, 'chartType' | 'specType' | 'id'>>;
137137

138-
export const Settings: React.FunctionComponent<SpecProps> = getConnect()(
138+
export const Settings: React.FunctionComponent<SettingsSpecProps> = getConnect()(
139139
specComponentFactory<SettingsSpec, DefaultSettingsProps>(DEFAULT_SETTINGS_SPEC),
140140
);

yarn.lock

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2635,18 +2635,27 @@
26352635
dependencies:
26362636
"@types/yargs-parser" "*"
26372637

2638-
"@typescript-eslint/eslint-plugin@^2.9.0":
2639-
version "2.9.0"
2640-
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.9.0.tgz#fa810282c0e45f6c2310b9c0dfcd25bff97ab7e9"
2641-
integrity sha512-98rfOt3NYn5Gr9wekTB8TexxN6oM8ZRvYuphPs1Atfsy419SDLYCaE30aJkRiiTCwGEY98vOhFsEVm7Zs4toQQ==
2638+
"@typescript-eslint/eslint-plugin@^2.10.0":
2639+
version "2.10.0"
2640+
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-2.10.0.tgz#c4cb103275e555e8a7e9b3d14c5951eb6d431e70"
2641+
integrity sha512-rT51fNLW0u3fnDGnAHVC5nu+Das+y2CpW10yqvf6/j5xbuUV3FxA3mBaIbM24CXODXjbgUznNb4Kg9XZOUxKAw==
26422642
dependencies:
2643-
"@typescript-eslint/experimental-utils" "2.9.0"
2643+
"@typescript-eslint/experimental-utils" "2.10.0"
26442644
eslint-utils "^1.4.3"
26452645
functional-red-black-tree "^1.0.1"
26462646
regexpp "^3.0.0"
26472647
tsutils "^3.17.1"
26482648

2649-
"@typescript-eslint/experimental-utils@2.9.0", "@typescript-eslint/experimental-utils@^2.5.0":
2649+
"@typescript-eslint/experimental-utils@2.10.0":
2650+
version "2.10.0"
2651+
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.10.0.tgz#8db1656cdfd3d9dcbdbf360b8274dea76f0b2c2c"
2652+
integrity sha512-FZhWq6hWWZBP76aZ7bkrfzTMP31CCefVIImrwP3giPLcoXocmLTmr92NLZxuIcTL4GTEOE33jQMWy9PwelL+yQ==
2653+
dependencies:
2654+
"@types/json-schema" "^7.0.3"
2655+
"@typescript-eslint/typescript-estree" "2.10.0"
2656+
eslint-scope "^5.0.0"
2657+
2658+
"@typescript-eslint/experimental-utils@^2.5.0":
26502659
version "2.9.0"
26512660
resolved "https://registry.yarnpkg.com/@typescript-eslint/experimental-utils/-/experimental-utils-2.9.0.tgz#bbe99a8d9510240c055fc4b17230dd0192ba3c7f"
26522661
integrity sha512-0lOLFdpdJsCMqMSZT7l7W2ta0+GX8A3iefG3FovJjrX+QR8y6htFlFdU7aOVPL6pDvt6XcsOb8fxk5sq+girTw==
@@ -2655,16 +2664,29 @@
26552664
"@typescript-eslint/typescript-estree" "2.9.0"
26562665
eslint-scope "^5.0.0"
26572666

2658-
"@typescript-eslint/parser@^2.9.0":
2659-
version "2.9.0"
2660-
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.9.0.tgz#2e9cf438de119b143f642a3a406e1e27eb70b7cd"
2661-
integrity sha512-fJ+dNs3CCvEsJK2/Vg5c2ZjuQ860ySOAsodDPwBaVlrGvRN+iCNC8kUfLFL8cT49W4GSiLPa/bHiMjYXA7EhKQ==
2667+
"@typescript-eslint/parser@^2.10.0":
2668+
version "2.10.0"
2669+
resolved "https://registry.yarnpkg.com/@typescript-eslint/parser/-/parser-2.10.0.tgz#24b2e48384ab6d5a6121e4c4faf8892c79657ad3"
2670+
integrity sha512-wQNiBokcP5ZsTuB+i4BlmVWq6o+oAhd8en2eSm/EE9m7BgZUIfEeYFd6z3S+T7bgNuloeiHA1/cevvbBDLr98g==
26622671
dependencies:
26632672
"@types/eslint-visitor-keys" "^1.0.0"
2664-
"@typescript-eslint/experimental-utils" "2.9.0"
2665-
"@typescript-eslint/typescript-estree" "2.9.0"
2673+
"@typescript-eslint/experimental-utils" "2.10.0"
2674+
"@typescript-eslint/typescript-estree" "2.10.0"
26662675
eslint-visitor-keys "^1.1.0"
26672676

2677+
"@typescript-eslint/typescript-estree@2.10.0":
2678+
version "2.10.0"
2679+
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.10.0.tgz#89cdabd5e8c774e9d590588cb42fb9afd14dcbd9"
2680+
integrity sha512-oOYnplddQNm/LGVkqbkAwx4TIBuuZ36cAQq9v3nFIU9FmhemHuVzAesMSXNQDdAzCa5bFgCrfD3JWhYVKlRN2g==
2681+
dependencies:
2682+
debug "^4.1.1"
2683+
eslint-visitor-keys "^1.1.0"
2684+
glob "^7.1.6"
2685+
is-glob "^4.0.1"
2686+
lodash.unescape "4.0.1"
2687+
semver "^6.3.0"
2688+
tsutils "^3.17.1"
2689+
26682690
"@typescript-eslint/typescript-estree@2.9.0":
26692691
version "2.9.0"
26702692
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-2.9.0.tgz#09138daf8f47d0e494ba7db9e77394e928803017"
@@ -15289,7 +15311,7 @@ typedarray@^0.0.6:
1528915311
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
1529015312
integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=
1529115313

15292-
typescript@^3.0.1, typescript@^3.6.3:
15314+
typescript@^3.0.1, typescript@^3.7.0:
1529315315
version "3.7.2"
1529415316
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.7.2.tgz#27e489b95fa5909445e9fef5ee48d81697ad18fb"
1529515317
integrity sha512-ml7V7JfiN2Xwvcer+XAf2csGO1bPBdRbFCkYBczNZggrBZ9c7G3riSUeJmqEU5uOtXNPMhE3n+R4FA/3YOAWOQ==

0 commit comments

Comments
 (0)