Skip to content

Commit

Permalink
Refs #37395 - lint changes
Browse files Browse the repository at this point in the history
  • Loading branch information
parthaa committed May 29, 2024
1 parent 041c1da commit ee0e910
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 61 deletions.
42 changes: 21 additions & 21 deletions app/controllers/api/v2/hosts_bulk_actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,25 +40,25 @@ def build
if missed_hosts.empty?
if reboot
process_response(true, { :message => n_("%s host set to build and rebooting.",
"%s hosts set to build and rebooting.", @hosts.count) % @hosts.count })
"%s hosts set to build and rebooting.",
@hosts.count) % @hosts.count,
})
else
process_response(true, { :message => n_("Built %s host",
"Built %s hosts", @hosts.count) % @hosts.count })
"Built %s hosts", @hosts.count) % @hosts.count })
end
elsif reboot
render_error(:bulk_hosts_error, :status => :unprocessable_entity,
:locals => { :message => n_("Failed to build and reboot %s host",
"Failed to build and reboot %s hosts", missed_hosts.count) % missed_hosts.count,
:failed_host_ids => missed_hosts.map(&:id),
})
else
if reboot
render_error(:bulk_hosts_error, :status => :unprocessable_entity,
:locals => { :message => n_("Failed to build and reboot %s host",
"Failed to build and reboot %s hosts", missed_hosts.count) % missed_hosts.count,
:failed_host_ids => missed_hosts.map(&:id)
})
else
render_error(:bulk_hosts_error, :status => :unprocessable_entity,
:locals => { :message => n_("Failed to build %s host",
"Failed to build %s hosts", missed_hosts.count) % missed_hosts.count,
:failed_host_ids => missed_hosts.map(&:id)
})
end
render_error(:bulk_hosts_error, :status => :unprocessable_entity,
:locals => { :message => n_("Failed to build %s host",
"Failed to build %s hosts", missed_hosts.count) % missed_hosts.count,
:failed_host_ids => missed_hosts.map(&:id),
})
end
end
end
Expand Down Expand Up @@ -93,16 +93,16 @@ def rebuild_config
failed_host_ids.uniq!
if failed_host_ids.blank?
process_response(true, { :message => n_("Rebuilt configuration for %s host",
"Rebuilt configuration for %s hosts",
@hosts.count) % @hosts.count })
"Rebuilt configuration for %s hosts",
@hosts.count) % @hosts.count })
else
render_error(:bulk_hosts_error, :status => :unprocessable_entity,
:locals => { :message => n_("Failed to rebuild configuration for %s host",
"Failed to rebuild configuration for %s hosts",
failed_host_ids.count) % failed_host_ids.count,
:failed_host_ids => failed_host_ids
"Failed to rebuild configuration for %s hosts",
failed_host_ids.count) % failed_host_ids.count,
:failed_host_ids => failed_host_ids,
}
)
)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { addToast } from '../../../ToastsList/slice';
import { actionTypeGenerator } from '../../../../redux/API/APIActionTypeGenerator';
import { translate as __ } from '../../../../common/I18n';
import { urlWithSearch } from '../../../../common/urlHelpers';
import { HOSTS_PATH } from '../../../../routes/Hosts/constants';

import { STATUS } from '../../../../constants';
import { selectAPIStatus } from '../../../../redux/API/APISelectors';
Expand All @@ -40,32 +39,33 @@ const BulkBuildHostModal = ({
closeModal();
};

const search_link = ({ query, message, baseUrl }) => {
console.log({baseUrl});
const searchLink = ({ query, message, baseUrl }) => {

Check failure on line 42 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/BulkBuildHostModal.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 14)

Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`

Check failure on line 42 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/BulkBuildHostModal.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 18)

Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`

Check failure on line 42 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/BulkBuildHostModal.js

View workflow job for this annotation

GitHub Actions / test (13, 2.7, 14)

Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`

Check failure on line 42 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/BulkBuildHostModal.js

View workflow job for this annotation

GitHub Actions / test (13, 2.7, 18)

Unexpected block statement surrounding arrow body; parenthesize the returned value and move it immediately after the `=>`
return {
children: message,
href: urlWithSearch(baseUrl, query),
}
children: message,
href: urlWithSearch(baseUrl, query),
};
};

const handleError = ({response}) => {
console.log({response})
const handleError = ({ response }) => {
handleModalClose();
const { FAILURE } = actionTypeGenerator(
HOST_BUILD_KEY
);
const { FAILURE } = actionTypeGenerator(HOST_BUILD_KEY);
const data = response.data.error;
const query = `id ^ (${data.failed_host_ids.join(",")})`;
const query = `id ^ (${data.failed_host_ids.join(',')})`;
const hostsBaseUrl = foremanUrl('new/hosts');

dispatch(
addToast({ type: 'danger',
link: search_link({query,
message: __('Failed Hosts'),
baseUrl: hostsBaseUrl}),
message: data.message, key: FAILURE })
);
}
addToast({
type: 'danger',
link: searchLink({
query,
message: __('Failed hosts'),
baseUrl: hostsBaseUrl,
}),
message: data.message,
key: FAILURE,
})
);
};
const handleSave = () => {
const requestBody = {
included: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,18 @@
import { translate as __ } from '../../../../common/I18n';

Check failure on line 1 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/actions.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 14)

'__' is defined but never used

Check failure on line 1 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/actions.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 18)

'__' is defined but never used

Check failure on line 1 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/actions.js

View workflow job for this annotation

GitHub Actions / test (13, 2.7, 14)

'__' is defined but never used

Check failure on line 1 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/actions.js

View workflow job for this annotation

GitHub Actions / test (13, 2.7, 18)

'__' is defined but never used
import { API_OPERATIONS, APIActions } from '../../../../redux/API';
import { APIActions } from '../../../../redux/API';
import { foremanUrl } from '../../../../common/helpers';
export const HOST_BUILD_KEY = "HOST_BUILD_KEY";

export const HOST_BUILD_KEY = 'HOST_BUILD_KEY';
export const bulkBuildHosts = (params, handleSuccess, handleError) => {
const errorToast = ({ message }) => message;
const url = foremanUrl(`/api/v2/hosts/bulk/build`);
return APIActions.put({
key: HOST_BUILD_KEY,
url,
successToast: (response) => response.data.message,
successToast: response => response.data.message,
handleSuccess,
handleError,
params,
});
};


// dispatch(
// APIActions.put({
// url: `/api/hosts/${hostId}/parameters/${param.id}`,
// key: `${param.id}-EDIT`,
// params: {
// name,
// value,
// parameter_type: type,
// hidden_value: isHide,
// },
// successToast: () => sprintf(__('Edited parameter %s'), name),
// ...APIActionsProps,
// })



export default bulkBuildHosts;

0 comments on commit ee0e910

Please sign in to comment.