webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js in foreman_acd-0.9.7 vs webpack/components/ExistingHostSelection/ExistingHostSelectionReducer.js in foreman_acd-0.10.0
- old
+ new
@@ -1,15 +1,9 @@
import Immutable from 'seamless-immutable';
+import { translate as __ } from 'foremanReact/common/I18n';
-import {
- cloneDeep,
- findIndex,
- findLastIndex,
-} from 'lodash';
-
import { shortHostname } from '../../helper';
-import * as sort from 'sortabular';
import {
EXISTING_HOST_SELECTION_INIT,
EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS,
EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE,
@@ -27,60 +21,63 @@
switch (action.type) {
case EXISTING_HOST_SELECTION_INIT: {
return state.merge(payload);
}
case EXISTING_HOST_SELECTION_LOAD_HOSTS_SUCCESS: {
- let alreadyUsedHosts = [];
+ const alreadyUsedHosts = [];
state.allHosts.forEach(host => {
- if ((host.service == payload.serviceId) && (host.isExistingHost == true)) {
+ if (
+ host.service === payload.serviceId &&
+ host.isExistingHost === true
+ ) {
alreadyUsedHosts.push({
value: host.hostname,
label: host.hostname,
disabled: true,
tooltipText: __('Host already used for this application instance'),
});
}
});
- let availableHosts = [];
- let hostsInHostgroup = {};
+ const availableHosts = [];
+ const hostsInHostgroup = {};
payload.hosts.forEach(host => {
- let shortName = shortHostname(host.name);
- if (state.allHosts.find(h => h.hostname == shortName) == undefined) {
+ const shortName = shortHostname(host.name);
+ if (state.allHosts.find(h => h.hostname === shortName) === undefined) {
availableHosts.push({
value: shortName,
label: shortName,
});
}
hostsInHostgroup[shortName] = host;
});
return state.merge({
- hostsInHostgroup: hostsInHostgroup,
- availableHosts: availableHosts,
- alreadyUsedHosts: alreadyUsedHosts,
+ hostsInHostgroup,
+ availableHosts,
+ alreadyUsedHosts,
serviceId: payload.serviceId,
});
}
case EXISTING_HOST_SELECTION_LOAD_HOSTS_FAILURE: {
return state.merge({ error: payload.error });
}
case EXISTING_HOST_SELECTION_SELECTION_CHANGED: {
- let selectedHosts = [];
+ const selectedHosts = [];
payload.selection.forEach(selHost => {
- let hostData = state.hostsInHostgroup[selHost.value];
+ const hostData = state.hostsInHostgroup[selHost.value];
selectedHosts.push({
fqdn: hostData.name,
hostname: shortHostname(hostData.name),
hostgroupId: hostData.hostgroup_id,
serviceId: state.serviceId,
});
});
return state.merge({
- selectedHosts: selectedHosts,
+ selectedHosts,
});
}
default:
return state;
}