Skip to content

Commit cc4381b

Browse files
committed
Disabled some cmd_bar option if it's a comparison
1 parent ba84a45 commit cc4381b

File tree

6 files changed

+43
-11
lines changed

6 files changed

+43
-11
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@complat/react-spectra-editor",
3-
"version": "1.3.4",
3+
"version": "1.4.0",
44
"description": "An editor to View and Edit Chemical Spectra data (NMR, IR, MS, CV, UIVIS, XRD, GC, and DSC).",
55
"repository": {
66
"type": "git",

src/app.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ const SpectraEditor = ({
3535
entity, others, cLabel, xLabel, yLabel,
3636
operations, forecast, molSvg, editorOnly, descriptions, theoryMass,
3737
canChangeDescription, onDescriptionChanged,
38-
multiEntities, multiMolSvgs, entityFileNames, userManualLink,
38+
multiEntities, multiMolSvgs, entityFileNames, userManualLink, isComparison,
3939
}) => (
4040
<Provider store={store}>
4141
<StyledEngineProvider injectFirst>
@@ -57,6 +57,7 @@ const SpectraEditor = ({
5757
theoryMass={theoryMass}
5858
canChangeDescription={canChangeDescription}
5959
onDescriptionChanged={onDescriptionChanged}
60+
isComparison={isComparison}
6061
/>
6162
</StyledEngineProvider>
6263
</Provider>
@@ -83,6 +84,7 @@ SpectraEditor.propTypes = {
8384
onDescriptionChanged: PropTypes.func,
8485
userManualLink: PropTypes.object,
8586
theoryMass: PropTypes.string,
87+
isComparison: PropTypes.bool,
8688
};
8789

8890
SpectraEditor.defaultProps = {
@@ -101,6 +103,7 @@ SpectraEditor.defaultProps = {
101103
editorOnly: false,
102104
canChangeDescription: false,
103105
userManualLink: {},
106+
isComparison: true,
104107
};
105108

106109
export {

src/components/cmd_bar/index.js

+26-5
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,16 @@ const styles = () => (
3333
);
3434

3535
const CmdBar = ({
36-
classes, feature, hasEdit, forecast, operations, editorOnly, jcampIdx, hideThreshold,
37-
}) => (
36+
classes,
37+
feature,
38+
hasEdit,
39+
forecast,
40+
operations,
41+
editorOnly,
42+
jcampIdx,
43+
hideThreshold,
44+
isComparison,
45+
}) => (!isComparison ? (
3846
<div className={classes.card}>
3947
<Viewer editorOnly={editorOnly} />
4048
<Zoom />
@@ -51,14 +59,26 @@ const CmdBar = ({
5159
hideSwitch={false}
5260
disabled={false}
5361
/>
54-
{
55-
hideThreshold ? null : (<Threshold feature={feature} hasEdit={hasEdit} />)
56-
}
62+
{hideThreshold ? null : <Threshold feature={feature} hasEdit={hasEdit} />}
5763
<Layout feature={feature} hasEdit={hasEdit} />
5864
<Wavelength />
5965
<ChangeAxes />
6066
<Detector />
6167
</div>
68+
) : (
69+
<div className={classes.card}>
70+
<Viewer editorOnly={editorOnly} />
71+
<Zoom />
72+
<Submit
73+
operations={operations}
74+
feature={feature}
75+
forecast={forecast}
76+
editorOnly={editorOnly}
77+
hideSwitch={false}
78+
disabled={false}
79+
/>
80+
</div>
81+
)
6282
);
6383

6484
const mapStateToProps = (state, _) => ( // eslint-disable-line
@@ -80,6 +100,7 @@ CmdBar.propTypes = {
80100
editorOnly: PropTypes.bool.isRequired,
81101
jcampIdx: PropTypes.any,
82102
hideThreshold: PropTypes.bool,
103+
isComparison: PropTypes.bool.isRequired,
83104
};
84105

85106
export default compose(

src/components/multi_jcamps_viewer.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class MultiJcampsViewer extends React.Component { // eslint-disable-line
5555
const {
5656
classes, curveSt, operations, entityFileNames,
5757
entities, userManualLink, molSvg, theoryMass, layoutSt,
58-
integrationSt,
58+
integrationSt, isComparison,
5959
} = this.props;
6060
if (!entities || entities.length === 0) return (<div />);
6161

@@ -74,6 +74,7 @@ class MultiJcampsViewer extends React.Component { // eslint-disable-line
7474
operations={operations}
7575
editorOnly={true}
7676
hideThreshold={true}
77+
isComparison={isComparison}
7778
/>
7879
<div className="react-spectrum-editor">
7980
<Grid container>
@@ -145,6 +146,7 @@ MultiJcampsViewer.propTypes = {
145146
layoutSt: PropTypes.string.isRequired,
146147
theoryMass: PropTypes.string,
147148
integrationSt: PropTypes.object.isRequired,
149+
isComparison: PropTypes.bool.isRequired,
148150
};
149151

150152
MultiJcampsViewer.defaultProps = {
@@ -155,6 +157,7 @@ MultiJcampsViewer.defaultProps = {
155157
xLabel: '',
156158
yLabel: '',
157159
entities: [],
160+
isComparison: false,
158161
};
159162

160163
export default compose(

src/layer_init.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ class LayerInit extends React.Component {
110110
entity, cLabel, xLabel, yLabel, forecast, operations,
111111
descriptions, molSvg, editorOnly, theoryMass,
112112
canChangeDescription, onDescriptionChanged,
113-
multiEntities, entityFileNames, userManualLink,
113+
multiEntities, entityFileNames, userManualLink, isComparison,
114114
} = this.props;
115115
const target = entity.spectra[0];
116-
117116
const { layout } = entity;
118117

119118
const xxLabel = !xLabel && xLabel === '' ? `X (${target.xUnit})` : xLabel;
@@ -128,6 +127,7 @@ class LayerInit extends React.Component {
128127
molSvg={molSvg}
129128
theoryMass={theoryMass}
130129
operations={operations}
130+
isComparison={isComparison}
131131
/>
132132
);
133133
} else if (Format.isCyclicVoltaLayout(layout)) { // eslint-disable-line
@@ -139,6 +139,7 @@ class LayerInit extends React.Component {
139139
molSvg={molSvg}
140140
theoryMass={theoryMass}
141141
operations={operations}
142+
isComparison={isComparison}
142143
/>
143144
);
144145
}
@@ -157,6 +158,7 @@ class LayerInit extends React.Component {
157158
theoryMass={theoryMass}
158159
canChangeDescription={canChangeDescription}
159160
onDescriptionChanged={onDescriptionChanged}
161+
isComparison={isComparison}
160162
/>
161163
);
162164
}
@@ -208,6 +210,7 @@ LayerInit.propTypes = {
208210
userManualLink: PropTypes.object, // eslint-disable-line
209211
resetDetectorAct: PropTypes.func.isRequired,
210212
updateDSCMetaDataAct: PropTypes.func.isRequired,
213+
isComparison: PropTypes.bool.isRequired,
211214
};
212215

213216
export default connect( // eslint-disable-line

src/layer_prism.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const LayerPrism = ({
2222
entity, cLabel, xLabel, yLabel, forecast, operations,
2323
descriptions, molSvg, editorOnly, theoryMass,
2424
thresSt, scanSt, uiSt,
25-
canChangeDescription, onDescriptionChanged,
25+
canChangeDescription, onDescriptionChanged, isComparison,
2626
}) => {
2727
const {
2828
topic, feature, hasEdit, integration,
@@ -67,6 +67,7 @@ const LayerPrism = ({
6767
forecast={forecast}
6868
operations={operations}
6969
editorOnly={editorOnly}
70+
isComparison={isComparison}
7071
/>
7172
<div className="react-spectrum-editor">
7273
<Grid container>
@@ -128,6 +129,7 @@ LayerPrism.propTypes = {
128129
uiSt: PropTypes.object.isRequired,
129130
canChangeDescription: PropTypes.bool.isRequired,
130131
onDescriptionChanged: PropTypes.func,
132+
isComparison: PropTypes.bool.isRequired,
131133
};
132134

133135
export default connect( // eslint-disable-line

0 commit comments

Comments
 (0)