-
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 #37395 - Moved error notifications to a separate file
- Loading branch information
Showing
3 changed files
with
38 additions
and
27 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
1 change: 0 additions & 1 deletion
1
webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/buildHosts/actions.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
34 changes: 34 additions & 0 deletions
34
webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/helpers.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,34 @@ | ||
import { actionTypeGenerator } from '../../../redux/API/APIActionTypeGenerator'; | ||
import { translate as __ } from '../../../common/I18n'; | ||
import { urlWithSearch } from '../../../common/urlHelpers'; | ||
import { foremanUrl } from '../../../common/helpers'; | ||
|
||
export const searchLink = ({ query, message, baseUrl }) => { | ||
Check failure on line 6 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/helpers.js GitHub Actions / test (13, 2.7, 14)
Check failure on line 6 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/helpers.js GitHub Actions / test (13, 2.7, 18)
Check failure on line 6 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/helpers.js GitHub Actions / test (13, 3.0, 14)
Check failure on line 6 in webpack/assets/javascripts/react_app/components/HostsIndex/BulkActions/helpers.js GitHub Actions / test (13, 3.0, 18)
|
||
return { | ||
children: message, | ||
href: urlWithSearch(baseUrl, query), | ||
}; | ||
}; | ||
|
||
export const failedHostsToastParams = ({ | ||
message, | ||
failed_host_ids: failedHostIds, | ||
key, | ||
}) => { | ||
const { FAILURE } = actionTypeGenerator(key); | ||
const toastParams = { | ||
type: 'danger', | ||
message, | ||
key: FAILURE, | ||
}; | ||
if (failedHostIds) { | ||
const query = `id ^ (${failedHostIds.join(',')})`; | ||
toastParams.link = searchLink({ | ||
query, | ||
message: __('Failed hosts'), | ||
baseUrl: foremanUrl('new/hosts'), | ||
}); | ||
} | ||
|
||
return toastParams; | ||
}; |