Skip to content

Commit

Permalink
[Bug fix] Edit parameter mapping: error when trying to change mapping…
Browse files Browse the repository at this point in the history
… type to Static; cannot change static value (#3800)

* Edit parameter mapping: error when trying to change mapping type to Static

* Parameter mapping editor: cannot change static value
  • Loading branch information
kravets-levko authored May 14, 2019
1 parent c74d469 commit b9b30a3
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions client/app/components/ParameterMappingInput.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ import Form from 'antd/lib/form';
import Tooltip from 'antd/lib/tooltip';
import { ParameterValueInput } from '@/components/ParameterValueInput';
import { ParameterMappingType } from '@/services/widget';
import { clientConfig } from '@/services/auth';
import { Query, Parameter } from '@/services/query';
import { Parameter } from '@/services/query';
import { HelpTrigger } from '@/components/HelpTrigger';

import './ParameterMappingInput.less';
Expand Down Expand Up @@ -120,17 +119,13 @@ export class ParameterMappingInput extends React.Component {
mapping: PropTypes.object, // eslint-disable-line react/forbid-prop-types
existingParamNames: PropTypes.arrayOf(PropTypes.string),
onChange: PropTypes.func,
clientConfig: PropTypes.any, // eslint-disable-line react/forbid-prop-types
Query: PropTypes.any, // eslint-disable-line react/forbid-prop-types
inputError: PropTypes.string,
};

static defaultProps = {
mapping: {},
existingParamNames: [],
onChange: () => {},
clientConfig: null,
Query: null,
inputError: null,
};

Expand Down Expand Up @@ -159,6 +154,10 @@ export class ParameterMappingInput extends React.Component {
updateParamMapping = (update) => {
const { onChange, mapping } = this.props;
const newMapping = extend({}, mapping, update);
if (newMapping.value !== mapping.value) {
newMapping.param = newMapping.param.clone();
newMapping.param.setValue(newMapping.value);
}
onChange(newMapping);
};

Expand Down Expand Up @@ -228,9 +227,8 @@ export class ParameterMappingInput extends React.Component {
value={mapping.param.normalizedValue}
enumOptions={mapping.param.enumOptions}
queryId={mapping.param.queryId}
parameter={mapping.param}
onSelect={value => this.updateParamMapping({ value })}
clientConfig={this.props.clientConfig}
Query={this.props.Query}
/>
);
}
Expand Down Expand Up @@ -345,8 +343,6 @@ class MappingEditor extends React.Component {
mapping={mapping}
existingParamNames={this.props.existingParamNames}
onChange={this.onChange}
clientConfig={clientConfig}
Query={Query}
inputError={inputError}
/>
<footer>
Expand Down

0 comments on commit b9b30a3

Please sign in to comment.