Sha256: 53b8f44cffd5ff34aeae874094d516b21aff8aae128a5392811e5655aaf08897
Contents?: true
Size: 1.14 KB
Versions: 54
Compression:
Stored size: 1.14 KB
Contents
import React from 'react'; import { translate as __ } from 'foremanReact/common/I18n'; import { urlBuilder } from 'foremanReact/common/urlHelpers'; export const bulkSearchKey = key => `${key}_TASK_SEARCH`; export const pollTaskKey = key => `${key}_POLL_TASK`; const link = id => ({ children: __('Go to task page'), href: urlBuilder('foreman_tasks/tasks', '', id), }); const getErrors = task => ( <ul> {task.humanized.errors.map(error => ( <li key={error}> {error} </li> ))} </ul> ); export const renderTaskStartedToast = (task) => { if (!task) return; const message = (__(`Task ${task.humanized.action} has started.`)); window.tfm.toastNotifications.notify({ message, type: 'info', link: link(task.id), }); }; export const taskFinishedToast = (task) => { const message = __(`Task ${task.humanized.action} completed with a result of ${task.result}. ${task.errors ? getErrors(task) : ''}`); return { message, type: task.result, link: link(task.id), }; }; export const renderTaskFinishedToast = (task) => { if (!task) return; window.tfm.toastNotifications.notify(taskFinishedToast(task)); };
Version data entries
54 entries across 54 versions & 1 rubygems