Sha256: 2ce9b330bc31aff6ae15df305756c4a229613a0dd6fca5fbc6fa82b93129d0e5

Contents?: true

Size: 1.13 KB

Versions: 34

Compression:

Stored size: 1.13 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(e => (
      <li key={e}> {e} </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

34 entries across 34 versions & 1 rubygems

Version Path
katello-4.4.2.2 webpack/scenes/Tasks/helpers.js
katello-4.4.2.1 webpack/scenes/Tasks/helpers.js
katello-4.4.2 webpack/scenes/Tasks/helpers.js
katello-4.4.1 webpack/scenes/Tasks/helpers.js
katello-4.4.0.2 webpack/scenes/Tasks/helpers.js
katello-4.4.0.1 webpack/scenes/Tasks/helpers.js
katello-4.3.1 webpack/scenes/Tasks/helpers.js
katello-4.4.0 webpack/scenes/Tasks/helpers.js
katello-4.4.0.rc2 webpack/scenes/Tasks/helpers.js
katello-4.4.0.rc1 webpack/scenes/Tasks/helpers.js
katello-4.2.2 webpack/scenes/Tasks/helpers.js
katello-4.3.0 webpack/scenes/Tasks/helpers.js
katello-4.3.0.rc4 webpack/scenes/Tasks/helpers.js
katello-4.3.0.rc3 webpack/scenes/Tasks/helpers.js
katello-4.3.0.rc2.1 webpack/scenes/Tasks/helpers.js
katello-4.3.0.rc2 webpack/scenes/Tasks/helpers.js
katello-4.3.0.rc1 webpack/scenes/Tasks/helpers.js
katello-4.2.1 webpack/scenes/Tasks/helpers.js
katello-4.2.0.1 webpack/scenes/Tasks/helpers.js
katello-4.1.4 webpack/scenes/Tasks/helpers.js