Check for duplicate portals
This commit is contained in:
@@ -57,6 +57,7 @@ exports.WINFSP_VERSION_NAMES = [
|
||||
'WinFsp 2020.0',
|
||||
'WinFsp 2020.1',
|
||||
'WinFsp 2020.2',
|
||||
'WinFsp 2021',
|
||||
'WinFsp 2021 B1',
|
||||
'WinFsp 2021 B2',
|
||||
'WinFsp 2021 Beta1',
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@ class HostList extends Component {
|
||||
|
||||
componentWillUnmount() {}
|
||||
|
||||
checkDuplicates = () => {
|
||||
return false;
|
||||
};
|
||||
|
||||
handleAddHost = () => {
|
||||
this.props.addEditHost(this.state.items, (changed, host_data) => {
|
||||
if (changed) {
|
||||
@@ -87,7 +83,7 @@ class HostList extends Component {
|
||||
onDelete={() => this.handleDeleted(index)}
|
||||
allowDelete={this.state.items.length > 1}
|
||||
host_data={v}
|
||||
host_list={this.state.items}
|
||||
host_list={this.state.items.filter((i) => i !== v)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -6,6 +6,7 @@ export const hostReducer = createReducer(
|
||||
DisplayAddEditHost: false,
|
||||
Edit: false,
|
||||
HostData: {},
|
||||
HostList: [],
|
||||
},
|
||||
{
|
||||
[Actions.DISPLAY_ADD_EDIT_HOST]: (state, action) => {
|
||||
@@ -14,6 +15,7 @@ export const hostReducer = createReducer(
|
||||
DisplayAddEditHost: action.payload.display,
|
||||
Edit: !!action.payload.host_data,
|
||||
HostData: action.payload.host_data || {},
|
||||
HostList: action.payload.host_list || [],
|
||||
};
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user