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 2, 2024
1 parent 639a00b commit 966eebb
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 49 deletions.
19 changes: 7 additions & 12 deletions app/controllers/hosts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -515,8 +515,7 @@ def submit_rebuild_config
if message.blank?
respond_to do |format|
format.html do
process_success :success_msg => _('Configuration successfully rebuilt')
redirect_to(helpers.current_hosts_path)
process_success(:success_redirect => helpers.current_hosts_path, :success_msg => _('Configuration successfully rebuilt'))
end
format.json do
render :json => { :success_msg => _('Configuration successfully rebuilt') }
Expand All @@ -526,8 +525,7 @@ def submit_rebuild_config
else
respond_to do |format|
format.html do
process_response(false, {:message => message})
redirect_to(helpers.current_hosts_path)
process_error(:redirect => helpers.current_hosts_path, :error_msg => message)
end
format.json do
render :json => { :error_msg => message }
Expand All @@ -536,7 +534,6 @@ def submit_rebuild_config
end
end


def submit_multiple_build
reboot = Foreman::Cast.to_bool(params[:host][:build])

Expand All @@ -551,9 +548,9 @@ def submit_multiple_build
message = _('Failed to redeploy %s.') % host
Foreman::Logging.exception(message, error)
success = false
message = _('Failed to reboot %s.') % @host
warning(message)
Foreman::Logging.exception(message, error)
message = _('Failed to reboot %s.') % @host
warning(message)
Foreman::Logging.exception(message, error)
end
!success
end
Expand All @@ -567,8 +564,7 @@ def submit_multiple_build

respond_to do |format|
format.html do
process_success :success_msg => message
redirect_to(helpers.current_hosts_path)
process_success(:success_redirect => helpers.current_hosts_path, :success_msg => message)
end
format.json do
render :json => { :success_msg => message }
Expand All @@ -578,8 +574,7 @@ def submit_multiple_build
message = _("The following hosts failed the build operation: %s") % missed_hosts.map(&:name).to_sentence
respond_to do |format|
format.html do
process_response(false, {:message => message})
redirect_to(helpers.current_hosts_path)
process_error(:redirect => helpers.current_hosts_path, :error_msg => message)
end
format.json do
render :json => { :error_msg => message }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@ import {
Button,
TextContent,
Text,
TextVariants,
Checkbox,
Radio,
} from '@patternfly/react-core';
import { translate as __ } from '../../../../common/I18n';
import { STATUS } from '../../../../constants';
import { useAPI } from '../../../../common/hooks/API/APIHooks';
import { selectAPIStatus } from '../../../../redux/API/APISelectors';
import { bulkBuildHosts } from './actions';

Expand Down Expand Up @@ -44,26 +42,29 @@ const BulkBuildHostModal = ({
organization_id: orgId,
included: {
search: fetchBulkParams(),
}
},
},
host: {build: rebootChecked},
rebuild_configuration: !buildRadioChecked,
host: { build: rebootChecked },
};

dispatch(bulkBuildHosts(
requestBody,
handleModalClose, handleModalClose,
));
dispatch(
bulkBuildHosts(
requestBody,
handleModalClose,
handleModalClose,
!buildRadioChecked
)
);
};

const handleBuildRadioSelected = (selected) => {
const handleBuildRadioSelected = selected => {
setBuildRadioChecked(selected);
if (!selected) {
setRebootChecked(false);
}
}
};

const modalActions = ([
const modalActions = [
<Button
key="add"
ouiaId="bulk-build-hosts-modal-add-button"
Expand All @@ -82,7 +83,7 @@ const BulkBuildHostModal = ({
>
Cancel
</Button>,
]);
];
return (
<Modal
isOpen={isOpen}
Expand All @@ -99,7 +100,9 @@ const BulkBuildHostModal = ({
<TextContent>
<Text ouiaId="bulk-set-build-options">
<FormattedMessage
defaultMessage={__('Choose an action that will be performed on {hosts}.')}
defaultMessage={__(
'Choose an action that will be performed on {hosts}.'
)}
values={{
hosts: (
<strong>
Expand All @@ -126,24 +129,27 @@ const BulkBuildHostModal = ({
onChange={() => handleBuildRadioSelected(true)}
label={__('Build')}
id="build-host-radio"
body = {
ouiaId="build-host-radio"
body={
<Checkbox
label={__('Reboot now')}
id="reboot-now-checkbox-id"
name="reboot-now"
isChecked={rebootChecked}
isDisabled={!buildRadioChecked}
onChange={() => setRebootChecked(true)}
/>
label={__('Reboot now')}
id="reboot-now-checkbox-id"
name="reboot-now"
isChecked={rebootChecked}
isDisabled={!buildRadioChecked}
onChange={() => setRebootChecked(true)}
ouiaId="build-reboot-checkbox"
/>
}
></Radio>
<hr/>
/>
<hr />
<Radio
name="buildHostRadioGroup"
onChange={() => handleBuildRadioSelected(false)}
label={__('Rebuild provisioning configuration only')}
id="rebuild-host-radio"
></Radio>
ouiaId="rebuild-host-radio"
/>
</Modal>
);
};
Expand All @@ -161,5 +167,4 @@ BulkBuildHostModal.defaultProps = {
closeModal: () => {},
};


export default BulkBuildHostModal;
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
import { translate as __ } from '../../../../common/I18n';
import { API_OPERATIONS, put, APIActions } from '../../../../redux/API';
import { API_OPERATIONS, APIActions } from '../../../../redux/API';
import { foremanUrl } from '../../../../common/helpers';

export const bulkBuildHosts = (
params,
handleSuccess,
handleError
handleError,
rebuildConfiguration
) => {
const errorToast = ({ message }) => message;
let url = '/hosts/submit_multiple_build';
if (params['rebuild_configuration']) {
url = '/hosts/submit_rebuild_config';
};
const url = rebuildConfiguration
? '/hosts/submit_rebuild_config'
: '/hosts/submit_multiple_build';

const successMessage = rebuildConfiguration
? __('Configurations successfully rebuilt')
: __('Built hosts.');
return APIActions.post({
type: API_OPERATIONS.POST,
key: 'HOST_BUILD_KEY',
url: foremanUrl(url),
successToast: () => __('Built hosts.'),
successToast: () => successMessage,
handleSuccess: response => {
if (handleSuccess) handleSuccess(response);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@ import { useForemanOrganization } from '../../../../Root/Context/ForemanContext'
import BulkBuildHostModal from './BulkBuildHostModal';

const BulkBuildHostModalScene = () => {
const { selectedCount, fetchBulkParams } = useContext(ForemanActionsBarContext);
const { modalOpen, setModalClosed } = useForemanModal({ id: 'bulk-build-hosts-modal' });
const { selectedCount, fetchBulkParams } = useContext(
ForemanActionsBarContext
);
const { modalOpen, setModalClosed } = useForemanModal({
id: 'bulk-build-hosts-modal',
});
const org = useForemanOrganization();
return (
<BulkBuildHostModal
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,9 @@ import {
Split,
SplitItem,
} from '@patternfly/react-core';
import { UndoIcon } from '@patternfly/react-icons';
import { useForemanModal } from '../ForemanModal/ForemanModalHooks';
import { addModal } from '../ForemanModal/ForemanModalActions';

import { UndoIcon } from '@patternfly/react-icons';
import { Table } from '../PF4/TableIndexPage/Table/Table';
import { translate as __ } from '../../common/I18n';
import TableIndexPage from '../PF4/TableIndexPage/TableIndexPage';
Expand Down

0 comments on commit 966eebb

Please sign in to comment.