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-3.18.1 webpack/scenes/Tasks/helpers.js
katello-3.18.0 webpack/scenes/Tasks/helpers.js
katello-3.17.1 webpack/scenes/Tasks/helpers.js
katello-3.16.2 webpack/scenes/Tasks/helpers.js
katello-3.18.0.rc2.1 webpack/scenes/Tasks/helpers.js
katello-3.18.0.rc2 webpack/scenes/Tasks/helpers.js
katello-3.17.0 webpack/scenes/Tasks/helpers.js
katello-3.18.0.rc1 webpack/scenes/Tasks/helpers.js
katello-3.17.0.rc2.2 webpack/scenes/Tasks/helpers.js
katello-3.17.0.rc2.1 webpack/scenes/Tasks/helpers.js
katello-3.16.1.2 webpack/scenes/Tasks/helpers.js
katello-3.16.1.1 webpack/scenes/Tasks/helpers.js
katello-3.17.0.rc2 webpack/scenes/Tasks/helpers.js
katello-3.16.1 webpack/scenes/Tasks/helpers.js
katello-3.17.0.rc1 webpack/scenes/Tasks/helpers.js
katello-3.16.0 webpack/scenes/Tasks/helpers.js
katello-3.16.0.rc5.1 webpack/scenes/Tasks/helpers.js
katello-3.16.0.rc5 webpack/scenes/Tasks/helpers.js
katello-3.16.0.rc4.1 webpack/scenes/Tasks/helpers.js
katello-3.15.3.1 webpack/scenes/Tasks/helpers.js