Skip to content

Commit 8a2a595

Browse files
authored
Merge pull request #445 from plotly/fixes
Fixes
2 parents 95673d4 + c870870 commit 8a2a595

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+362
-354
lines changed

src/DefaultEditor.js

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import React, {Fragment} from 'react';
1+
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
33
import {PanelMenuWrapper} from './components';
4-
import {localize} from './lib';
54
import {
65
GraphCreatePanel,
76
StyleLayoutPanel,
@@ -16,28 +15,34 @@ import {
1615
StyleUpdateMenusPanel,
1716
} from './default_panels';
1817

19-
const DefaultEditor = ({children, localize: _}) => (
20-
<Fragment>
21-
<PanelMenuWrapper>
22-
<GraphCreatePanel group={_('Graph')} name={_('Create')} />
23-
<StyleTracesPanel group={_('Style')} name={_('Traces')} />
24-
<StyleLayoutPanel group={_('Style')} name={_('Layout')} />
25-
<StyleNotesPanel group={_('Style')} name={_('Notes')} />
26-
<StyleAxesPanel group={_('Style')} name={_('Axes')} />
27-
<StyleLegendPanel group={_('Style')} name={_('Legend')} />
28-
<StyleColorbarsPanel group={_('Style')} name={_('Color Bars')} />
29-
<StyleShapesPanel group={_('Style')} name={_('Shapes')} />
30-
<StyleImagesPanel group={_('Style')} name={_('Images')} />
31-
<StyleSlidersPanel group={_('Style')} name={_('Sliders')} />
32-
<StyleUpdateMenusPanel group={_('Style')} name={_('Menus')} />
33-
{children ? children : null}
34-
</PanelMenuWrapper>
35-
</Fragment>
36-
);
18+
class DefaultEditor extends Component {
19+
render() {
20+
const _ = this.context.localize;
21+
return (
22+
<PanelMenuWrapper>
23+
<GraphCreatePanel group={_('Graph')} name={_('Create')} />
24+
<StyleTracesPanel group={_('Style')} name={_('Traces')} />
25+
<StyleLayoutPanel group={_('Style')} name={_('Layout')} />
26+
<StyleNotesPanel group={_('Style')} name={_('Notes')} />
27+
<StyleAxesPanel group={_('Style')} name={_('Axes')} />
28+
<StyleLegendPanel group={_('Style')} name={_('Legend')} />
29+
<StyleColorbarsPanel group={_('Style')} name={_('Color Bars')} />
30+
<StyleShapesPanel group={_('Style')} name={_('Shapes')} />
31+
<StyleImagesPanel group={_('Style')} name={_('Images')} />
32+
<StyleSlidersPanel group={_('Style')} name={_('Sliders')} />
33+
<StyleUpdateMenusPanel group={_('Style')} name={_('Menus')} />
34+
{this.props.children ? this.props.children : null}
35+
</PanelMenuWrapper>
36+
);
37+
}
38+
}
3739

3840
DefaultEditor.propTypes = {
39-
localize: PropTypes.func,
4041
children: PropTypes.node,
4142
};
4243

43-
export default localize(DefaultEditor);
44+
DefaultEditor.contextTypes = {
45+
localize: PropTypes.func,
46+
};
47+
48+
export default DefaultEditor;

src/EditorControls.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import DefaultEditor from './DefaultEditor';
22
import PropTypes from 'prop-types';
33
import React, {Component} from 'react';
4-
import {bem} from './lib';
4+
import {bem, localizeString} from './lib';
55
import {
66
shamefullyClearAxisTypes,
77
shamefullyAdjustAxisRef,
@@ -34,6 +34,8 @@ class EditorControls extends Component {
3434
dataSourceValueRenderer: this.props.dataSourceValueRenderer,
3535
dataSourceOptionRenderer: this.props.dataSourceOptionRenderer,
3636
dictionaries: this.props.dictionaries || {},
37+
localize: key =>
38+
localizeString(this.props.dictionaries || {}, this.props.locale, key),
3739
frames: gd._transitionData ? gd._transitionData._frames : [],
3840
fullData: gd._fullData,
3941
fullLayout: gd._fullLayout,
@@ -313,6 +315,7 @@ EditorControls.childContextTypes = {
313315
graphDiv: PropTypes.any,
314316
layout: PropTypes.object,
315317
locale: PropTypes.string,
318+
localize: PropTypes.func,
316319
onUpdate: PropTypes.func,
317320
plotly: PropTypes.object,
318321
plotSchema: PropTypes.object,

src/components/containers/AnnotationAccordion.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import PlotlyFold from './PlotlyFold';
22
import TraceRequiredPanel from './TraceRequiredPanel';
33
import PropTypes from 'prop-types';
44
import React, {Component} from 'react';
5-
import {connectAnnotationToLayout, localize} from 'lib';
5+
import {connectAnnotationToLayout} from 'lib';
66

77
const AnnotationFold = connectAnnotationToLayout(PlotlyFold);
88

99
class AnnotationAccordion extends Component {
1010
render() {
11-
const {layout: {annotations = []}} = this.context;
12-
const {canAdd, children, localize: _} = this.props;
11+
const {layout: {annotations = []}, localize: _} = this.context;
12+
const {canAdd, children} = this.props;
1313

1414
const content =
1515
annotations.length &&
@@ -53,12 +53,12 @@ class AnnotationAccordion extends Component {
5353

5454
AnnotationAccordion.contextTypes = {
5555
layout: PropTypes.object,
56+
localize: PropTypes.func,
5657
};
5758

5859
AnnotationAccordion.propTypes = {
5960
children: PropTypes.node,
6061
canAdd: PropTypes.bool,
61-
localize: PropTypes.func,
6262
};
6363

64-
export default localize(AnnotationAccordion);
64+
export default AnnotationAccordion;

src/components/containers/ImageAccordion.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@ import PlotlyFold from './PlotlyFold';
22
import TraceRequiredPanel from './TraceRequiredPanel';
33
import PropTypes from 'prop-types';
44
import React, {Component} from 'react';
5-
import {connectImageToLayout, localize} from 'lib';
5+
import {connectImageToLayout} from 'lib';
66

77
const ImageFold = connectImageToLayout(PlotlyFold);
88

99
class ImageAccordion extends Component {
1010
render() {
11-
const {layout: {images = []}} = this.context;
12-
const {canAdd, children, localize: _} = this.props;
11+
const {layout: {images = []}, localize: _} = this.context;
12+
const {canAdd, children} = this.props;
1313

1414
const content =
1515
images.length &&
@@ -54,12 +54,12 @@ class ImageAccordion extends Component {
5454

5555
ImageAccordion.contextTypes = {
5656
layout: PropTypes.object,
57+
localize: PropTypes.func,
5758
};
5859

5960
ImageAccordion.propTypes = {
6061
children: PropTypes.node,
6162
canAdd: PropTypes.bool,
62-
localize: PropTypes.func,
6363
};
6464

65-
export default localize(ImageAccordion);
65+
export default ImageAccordion;

src/components/containers/PanelEmpty.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class PanelEmpty extends Component {
2929
PanelEmpty.propTypes = {
3030
heading: PropTypes.string,
3131
message: PropTypes.any,
32-
localize: PropTypes.func,
3332
children: PropTypes.node,
3433
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
3534
};

src/components/containers/PanelHeader.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import Button from 'components/widgets/Button';
22
import PropTypes from 'prop-types';
33
import React, {Component} from 'react';
44
import {PlusIcon, ResizeUpIcon, ResizeDownIcon} from 'plotly-icons';
5-
import {localize} from 'lib';
65
import ModalBox from './ModalBox';
76

87
class PanelHeader extends Component {
@@ -18,13 +17,13 @@ class PanelHeader extends Component {
1817
}
1918

2019
render() {
20+
const {localize: _} = this.context;
2121
const {
2222
children,
2323
addAction,
2424
allowCollapse,
2525
toggleFolds,
2626
hasOpen,
27-
localize: _,
2827
} = this.props;
2928

3029
const icon = <PlusIcon />;
@@ -91,15 +90,15 @@ PanelHeader.contextTypes = {
9190
fullContainer: PropTypes.object,
9291
onUpdate: PropTypes.func,
9392
updateContainer: PropTypes.func,
93+
localize: PropTypes.func,
9494
};
9595

9696
PanelHeader.propTypes = {
9797
addAction: PropTypes.object,
9898
allowCollapse: PropTypes.bool,
9999
children: PropTypes.node,
100100
hasOpen: PropTypes.bool,
101-
localize: PropTypes.func,
102101
toggleFolds: PropTypes.func,
103102
};
104103

105-
export default localize(PanelHeader);
104+
export default PanelHeader;

src/components/containers/PlotlyFold.js

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,9 @@ import PropTypes from 'prop-types';
33
import React, {Component} from 'react';
44
import classnames from 'classnames';
55
import {CloseIcon, AngleDownIcon} from 'plotly-icons';
6-
import {
7-
unpackPlotProps,
8-
localize,
9-
containerConnectedContextTypes,
10-
striptags,
11-
} from 'lib';
12-
13-
class UnlocalizedFold extends Component {
6+
import {unpackPlotProps, containerConnectedContextTypes, striptags} from 'lib';
7+
8+
export class Fold extends Component {
149
constructor() {
1510
super();
1611
this.foldVisible = true;
@@ -103,9 +98,9 @@ class UnlocalizedFold extends Component {
10398
}
10499
}
105100

106-
UnlocalizedFold.plotly_editor_traits = {foldable: true};
101+
Fold.plotly_editor_traits = {foldable: true};
107102

108-
UnlocalizedFold.propTypes = {
103+
Fold.propTypes = {
109104
canDelete: PropTypes.bool,
110105
children: PropTypes.node,
111106
className: PropTypes.string,
@@ -114,13 +109,10 @@ UnlocalizedFold.propTypes = {
114109
hideHeader: PropTypes.bool,
115110
icon: PropTypes.oneOfType([PropTypes.node, PropTypes.func]),
116111
messageIfEmpty: PropTypes.string,
117-
localize: PropTypes.func,
118112
name: PropTypes.string,
119113
};
120114

121-
export const Fold = localize(UnlocalizedFold);
122-
123-
class PlotlyFold extends UnlocalizedFold {
115+
class PlotlyFold extends Fold {
124116
constructor(props, context) {
125117
super(props, context);
126118

@@ -171,4 +163,4 @@ PlotlyFold.contextTypes = Object.assign(
171163
containerConnectedContextTypes
172164
);
173165

174-
export default localize(PlotlyFold);
166+
export default PlotlyFold;

src/components/containers/PlotlyPanel.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import PanelEmpty from './PanelEmpty';
33
import PropTypes from 'prop-types';
44
import React, {Component, cloneElement} from 'react';
55
import update from 'immutability-helper';
6-
import {bem, localize} from 'lib';
6+
import {bem} from 'lib';
77
import {EmbedIconIcon} from 'plotly-icons';
88

99
class PanelErrorImpl extends Component {
1010
render() {
11-
const {localize: _} = this.props;
11+
const {localize: _} = this.context;
1212

1313
return (
1414
<PanelEmpty
@@ -20,13 +20,13 @@ class PanelErrorImpl extends Component {
2020
}
2121
}
2222

23-
PanelErrorImpl.propTypes = {
23+
PanelErrorImpl.contextTypes = {
2424
localize: PropTypes.func,
2525
};
2626

27-
const PanelError = localize(PanelErrorImpl);
27+
const PanelError = PanelErrorImpl;
2828

29-
class UnlocalizedPanel extends Component {
29+
export class Panel extends Component {
3030
constructor(props) {
3131
super(props);
3232
this.state = {
@@ -123,23 +123,25 @@ class UnlocalizedPanel extends Component {
123123
}
124124
}
125125

126-
UnlocalizedPanel.propTypes = {
126+
Panel.propTypes = {
127127
children: PropTypes.node,
128128
addAction: PropTypes.object,
129129
showExpandCollapse: PropTypes.bool,
130130
noPadding: PropTypes.bool,
131131
};
132132

133-
UnlocalizedPanel.defaultProps = {
133+
Panel.defaultProps = {
134134
showExpandCollapse: true,
135135
};
136136

137-
export const Panel = localize(UnlocalizedPanel);
137+
Panel.contextTypes = {
138+
localize: PropTypes.func,
139+
};
138140

139-
class PlotlyPanel extends UnlocalizedPanel {}
141+
class PlotlyPanel extends Panel {}
140142

141143
PlotlyPanel.plotly_editor_traits = {
142144
no_visibility_forcing: true,
143145
};
144146

145-
export default localize(PlotlyPanel);
147+
export default PlotlyPanel;

src/components/containers/PlotlySection.js

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
import React, {Component} from 'react';
22
import PropTypes from 'prop-types';
3-
import {
4-
containerConnectedContextTypes,
5-
localize,
6-
unpackPlotProps,
7-
} from '../../lib';
3+
import {containerConnectedContextTypes, unpackPlotProps} from '../../lib';
84

9-
class UnlocalizedSection extends Component {
5+
export class Section extends Component {
106
constructor() {
117
super();
128
this.sectionVisible = true;
@@ -30,16 +26,14 @@ class UnlocalizedSection extends Component {
3026
}
3127
}
3228

33-
UnlocalizedSection.plotly_editor_traits = {no_visibility_forcing: false};
34-
UnlocalizedSection.propTypes = {
29+
Section.plotly_editor_traits = {no_visibility_forcing: false};
30+
Section.propTypes = {
3531
children: PropTypes.node,
3632
name: PropTypes.string,
3733
attr: PropTypes.string,
3834
};
3935

40-
export const Section = localize(UnlocalizedSection);
41-
42-
class PlotlySection extends UnlocalizedSection {
36+
export default class PlotlySection extends Section {
4337
constructor(props, context) {
4438
super(props, context);
4539
this.determineVisibility(props, context);
@@ -78,4 +72,3 @@ class PlotlySection extends UnlocalizedSection {
7872

7973
PlotlySection.plotly_editor_traits = {no_visibility_forcing: true};
8074
PlotlySection.contextTypes = containerConnectedContextTypes;
81-
export default localize(PlotlySection);

src/components/containers/RangeSelectorAccordion.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import PlotlyFold from './PlotlyFold';
22
import PlotlyPanel from './PlotlyPanel';
33
import PropTypes from 'prop-types';
44
import React, {Component} from 'react';
5-
import {connectRangeSelectorToAxis, localize} from 'lib';
5+
import {connectRangeSelectorToAxis} from 'lib';
66

77
const RangeSelectorFold = connectRangeSelectorToAxis(PlotlyFold);
88

@@ -18,8 +18,11 @@ class RangeSelectorAccordion extends Component {
1818
return null;
1919
}
2020

21-
const {fullContainer: {rangeselector: {buttons = []}}} = this.context;
22-
const {children, localize: _} = this.props;
21+
const {
22+
fullContainer: {rangeselector: {buttons = []}},
23+
localize: _,
24+
} = this.context;
25+
const {children} = this.props;
2326

2427
const content =
2528
buttons.length &&
@@ -62,15 +65,15 @@ class RangeSelectorAccordion extends Component {
6265

6366
RangeSelectorAccordion.contextTypes = {
6467
fullContainer: PropTypes.object,
68+
localize: PropTypes.func,
6569
};
6670

6771
RangeSelectorAccordion.propTypes = {
6872
children: PropTypes.node,
69-
localize: PropTypes.func,
7073
};
7174

7275
RangeSelectorAccordion.plotly_editor_traits = {
7376
no_visibility_forcing: true,
7477
};
7578

76-
export default localize(RangeSelectorAccordion);
79+
export default RangeSelectorAccordion;

0 commit comments

Comments
 (0)