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

Version Path
katello-4.0.3 webpack/scenes/Tasks/helpers.js
katello-3.18.5 webpack/scenes/Tasks/helpers.js
katello-4.0.2.1 webpack/scenes/Tasks/helpers.js
katello-4.0.2 webpack/scenes/Tasks/helpers.js
katello-3.18.4 webpack/scenes/Tasks/helpers.js
katello-4.0.1.2 webpack/scenes/Tasks/helpers.js
katello-3.18.3.1 webpack/scenes/Tasks/helpers.js
katello-4.0.1.1 webpack/scenes/Tasks/helpers.js
katello-3.18.3 webpack/scenes/Tasks/helpers.js
katello-4.0.1 webpack/scenes/Tasks/helpers.js
katello-4.0.0 webpack/scenes/Tasks/helpers.js
katello-4.0.0.rc3.1 webpack/scenes/Tasks/helpers.js
katello-4.0.0.rc3 webpack/scenes/Tasks/helpers.js
katello-3.18.2.1 webpack/scenes/Tasks/helpers.js
katello-3.18.2 webpack/scenes/Tasks/helpers.js
katello-3.17.3 webpack/scenes/Tasks/helpers.js
katello-4.0.0.rc2 webpack/scenes/Tasks/helpers.js
katello-3.18.1.1 webpack/scenes/Tasks/helpers.js
katello-3.17.2 webpack/scenes/Tasks/helpers.js
katello-4.0.0.rc1 webpack/scenes/Tasks/helpers.js