Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM-28992 Remove unused notPresent and mustBePresent props from MultiS…
Browse files Browse the repository at this point in the history
…electSetting (#6544)

* MM-28992 Remove unused notPresent and mustBePresent props from MultiSelectSetting

* Remove another unused prop
  • Loading branch information
hmhealey committed Sep 24, 2020
1 parent fe97c78 commit b618284
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -385,12 +385,6 @@ exports[`components/admin_console/SchemaAdminSettings should match snapshot with
id="no-result-j"
/>
}
notPresent={
<FormattedMessage
defaultMessage="No present"
id="no-present-j"
/>
}
onChange={[Function]}
selected={Array []}
setByEnv={false}
Expand Down
19 changes: 2 additions & 17 deletions components/admin_console/multiselect_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ export default class MultiSelectSetting extends React.PureComponent {
values: PropTypes.array.isRequired,
label: PropTypes.node.isRequired,
selected: PropTypes.array.isRequired,
mustBePresent: PropTypes.string,
onChange: PropTypes.func.isRequired,
disabled: PropTypes.bool,
setByEnv: PropTypes.bool.isRequired,
helpText: PropTypes.node,
noResultText: PropTypes.node,
errorText: PropTypes.node,
notPresent: PropTypes.node,
};

static defaultProps = {
Expand All @@ -40,20 +37,8 @@ export default class MultiSelectSetting extends React.PureComponent {
return n.value;
});

if (this.props.selected.length > 0 && this.props.mustBePresent && values.join(',').indexOf(this.props.mustBePresent) === -1) {
this.setState({error: this.props.notPresent});
} else {
this.props.onChange(this.props.id, values);
this.setState({error: false});
}
}

UNSAFE_componentWillReceiveProps(newProps) { // eslint-disable-line camelcase
if (newProps.selected.length > 0 && newProps.mustBePresent && newProps.selected.join(',').indexOf(newProps.mustBePresent) === -1) {
this.setState({error: this.props.notPresent});
} else {
this.setState({error: false});
}
this.props.onChange(this.props.id, values);
this.setState({error: false});
}

calculateValue = () => {
Expand Down
8 changes: 1 addition & 7 deletions components/admin_console/schema_admin_settings.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -539,12 +539,7 @@ export default class SchemaAdminSettings extends React.PureComponent {
defaultMessage={setting.no_result_default}
/>
);
const notPresent = (
<FormattedMessage
id={setting.not_present}
defaultMessage={setting.not_present_default}
/>
);

return (
<MultiSelectSetting
key={this.props.schema.id + '_language_' + setting.key}
Expand All @@ -557,7 +552,6 @@ export default class SchemaAdminSettings extends React.PureComponent {
setByEnv={this.isSetByEnv(setting.key)}
onChange={(changedId, value) => this.handleChange(changedId, value.join(','))}
noResultText={noResultText}
notPresent={notPresent}
/>
);
}
Expand Down

0 comments on commit b618284

Please sign in to comment.