Sha256: 049a306aa5e6211785ce7e1f0fd41079b6cb86dd9877d466e22cd92a392b314b

Contents?: true

Size: 986 Bytes

Versions: 21

Compression:

Stored size: 986 Bytes

Contents

import React from 'react';
import { translate as __ } from 'foremanReact/common/I18n';
import helpers from '../../move_to_foreman/common/helpers';
import { notify } from '../../move_to_foreman/foreman_toast_notifications';

const link = id => ({
  children: __('Go to task page'),
  href: helpers.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.`));

  notify({
    message,
    type: 'info',
    link: link(task.id),

  });
};

export const renderTaskFinishedToast = (task) => {
  if (!task) return;

  const message = __(`Task ${task.action} completed with a result of ${task.result}.
  ${task.errors ? getErrors(task) : ''}`);

  notify({
    message,
    type: task.result,
    link: link(task.id),
  });
};

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
katello-3.12.3 webpack/scenes/Tasks/helpers.js
katello-3.12.2 webpack/scenes/Tasks/helpers.js
katello-3.12.1 webpack/scenes/Tasks/helpers.js
katello-3.11.2 webpack/scenes/Tasks/helpers.js
katello-3.10.2 webpack/scenes/Tasks/helpers.js
katello-3.12.0 webpack/scenes/Tasks/helpers.js
katello-3.12.0.rc2 webpack/scenes/Tasks/helpers.js
katello-3.10.1.1 webpack/scenes/Tasks/helpers.js
katello-3.12.0.rc1 webpack/scenes/Tasks/helpers.js
katello-3.10.1 webpack/scenes/Tasks/helpers.js
katello-3.11.1 webpack/scenes/Tasks/helpers.js
katello-3.11.0 webpack/scenes/Tasks/helpers.js
katello-3.11.0.rc2 webpack/scenes/Tasks/helpers.js
katello-3.11.0.rc1 webpack/scenes/Tasks/helpers.js
katello-3.10.0 webpack/scenes/Tasks/helpers.js
katello-3.10.0.rc1.1 webpack/scenes/Tasks/helpers.js
katello-3.9.1 webpack/scenes/Tasks/helpers.js
katello-3.10.0.rc1 webpack/scenes/Tasks/helpers.js
katello-3.9.0 webpack/scenes/Tasks/helpers.js
katello-3.9.0.rc2 webpack/scenes/Tasks/helpers.js