-
Notifications
You must be signed in to change notification settings - Fork 994
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refs #36867 - Add bulk modal with bulk params
- Loading branch information
1 parent
d99858a
commit a879797
Showing
7 changed files
with
149 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/bulkDelete.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import React from 'react'; | ||
import { FormattedMessage } from 'react-intl'; | ||
import { visit } from '../../../../foreman_navigation'; | ||
import { foremanUrl } from '../../../common/helpers'; | ||
import { sprintf, translate as __ } from '../../../common/I18n'; | ||
import { openConfirmModal } from '../../ConfirmModal'; | ||
import { APIActions } from '../../../redux/API'; | ||
import './bulkDeleteModal.scss'; | ||
|
||
export const bulkDeleteHosts = ({ | ||
bulkParams, | ||
selectedCount, | ||
destroyVmOnHostDelete, | ||
}) => dispatch => { | ||
const successToast = () => sprintf(__('%s hosts deleted'), selectedCount); | ||
const errorToast = ({ message }) => message; | ||
const url = foremanUrl(`/api/hosts/bulk_destroy?search=${bulkParams}`); | ||
|
||
// TODO: Replace with a checkbox instead of a global setting for cascade host destroy | ||
const cascadeMessage = () => | ||
destroyVmOnHostDelete | ||
? __( | ||
'For hosts with compute resources, this will delete the VM and its disks.' | ||
) | ||
: __( | ||
'For hosts with compute resources, VMs and their disks will not be deleted.' | ||
); | ||
|
||
dispatch( | ||
openConfirmModal({ | ||
isWarning: true, | ||
isDireWarning: true, | ||
title: ( | ||
<FormattedMessage | ||
defaultMessage="Delete {count, plural, one {{singular}} other {{plural}}}?" | ||
values={{ | ||
count: selectedCount, | ||
singular: __('host'), | ||
plural: __('hosts'), | ||
}} | ||
id="bulk-delete-host-count" | ||
/> | ||
), | ||
confirmButtonText: __('Delete'), | ||
onConfirm: () => | ||
dispatch( | ||
APIActions.delete({ | ||
url, | ||
key: `BULK-HOSTS-DELETE`, | ||
successToast, | ||
errorToast, | ||
handleSuccess: () => visit(foremanUrl('/hosts')), | ||
}) | ||
), | ||
message: ( | ||
<FormattedMessage | ||
id="bulk-delete-hosts" | ||
values={{ | ||
hostsCount: ( | ||
<strong> | ||
<FormattedMessage | ||
defaultMessage="{count, plural, one {# {singular}} other {# {plural}}}" | ||
values={{ | ||
count: selectedCount, | ||
singular: __('host'), | ||
plural: __('hosts'), | ||
}} | ||
id="bulk-delete-host-count" | ||
/> | ||
</strong> | ||
), | ||
cascade: cascadeMessage(), | ||
settings: ( | ||
<a href={foremanUrl('/settings?search=destroy')}> | ||
{__('Provisioning settings')} | ||
</a> | ||
), | ||
br: <br />, | ||
}} | ||
defaultMessage={__( | ||
'{hostsCount} will be deleted. This action is irreversible. {br}{br} {cascade} {br}{br} This behavior can be changed via global setting "Destroy associated VM on host delete" in {settings}.{br}{br}' | ||
)} | ||
/> | ||
), | ||
}) | ||
); | ||
}; |
8 changes: 8 additions & 0 deletions
8
webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/bulkDeleteModal.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#app-confirm-modal { | ||
min-height: 21rem; | ||
.pf-c-check label { | ||
font-size: 14px; | ||
position: relative; | ||
top: 2px; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters