Check for duplicate portals
This commit is contained in:
@@ -24,13 +24,9 @@ class AddEditHost extends Component {
|
||||
TimeoutMs: 60000,
|
||||
};
|
||||
|
||||
originalState = {};
|
||||
|
||||
componentDidMount() {
|
||||
if (this.props.HostData) {
|
||||
const state = { ...this.state, ...this.props.HostData };
|
||||
this.originalState = { ...state };
|
||||
this.setState(state);
|
||||
this.setState({ ...this.state, ...this.props.HostData });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,14 +35,29 @@ class AddEditHost extends Component {
|
||||
this.props.notifyError('Host / IP cannot be empty');
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.state.HostNameOrIp.trim().indexOf('/') >= 0) {
|
||||
this.props.notifyError(`Host / IP cannot be contain '/'`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.state.HostNameOrIp.trim().indexOf(':') >= 0) {
|
||||
this.props.notifyError(`Host / IP cannot be contain ':'`);
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
this.props.HostList.find(
|
||||
(i) =>
|
||||
(i.HostNameOrIp || '').trim() === this.state.HostNameOrIp &&
|
||||
i.Protocol === this.state.Protocol &&
|
||||
i.ApiPort == this.state.ApiPort
|
||||
)
|
||||
) {
|
||||
this.props.notifyError(`Portal already exists`);
|
||||
return;
|
||||
}
|
||||
|
||||
this.props.completeAddEditHost(this.state);
|
||||
};
|
||||
|
||||
@@ -200,6 +211,7 @@ class AddEditHost extends Component {
|
||||
const mapStateToProps = (state) => {
|
||||
return {
|
||||
HostData: state.host.HostData,
|
||||
HostList: state.host.HostList,
|
||||
};
|
||||
};
|
||||
|
||||
@@ -215,6 +227,7 @@ AddEditHost.propTypes = {
|
||||
Close: PropTypes.func.isRequired,
|
||||
completeAddEditHost: PropTypes.func.isRequired,
|
||||
HostData: PropTypes.object,
|
||||
HostList: PropTypes.array.isRequired,
|
||||
notifyError: PropTypes.func.isRequired,
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user