Sha256: 81f8c960c0dc78c64586b9997f0a7064d0f8d46e2473aa20d675eb26595d15e3

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

import React from 'react';
import PropTypes from 'prop-types';
import Immutable from 'seamless-immutable';

import DonutChart from 'foremanReact/components/common/charts/DonutChart';
import { translate as __ } from 'foremanReact/common/I18n';

import AggregateStatus from './AggregateStatus';

const RoundProgress = ({ progress }) => {
  const data = [
    [__('Success'), progress.success, '#5CB85C'],
    [__('Warning'), progress.warning, '#DB843D'],
    [__('Failed'), progress.error, '#D9534F'],
    [__('Running'), progress.running, '#3D96AE'],
    [__('Pending'), progress.pending + progress.planned, '#DEDEDE'],
    [__('Cancelled'), progress.cancelled, '#B7312D'],
  ];

  const iMax = data.reduce((im, e, i, arr) => 
    (e[1] > arr[im][1] ? i : im), 0);

  return (
    <div id="round_progress">
      <DonutChart 
        data={Immutable.asMutable(data)}
        title={{
          type: 'percent',
          secondary: (data[iMax] || [])[0],
        }}
      />
      <AggregateStatus progress={progress} />
    </div>
  );
};

RoundProgress.propTypes = {
  progress: PropTypes.shape({
    pending: PropTypes.number,
    planned: PropTypes.number,
    running: PropTypes.number,
    success: PropTypes.number,
    warning: PropTypes.number,
    error: PropTypes.number,
    cancelled: PropTypes.number,
  }).isRequired,
};

export default RoundProgress;

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
foreman_patch-1.1.6.alpha5 webpack/components/RoundProgress/RoundProgress.js
foreman_patch-1.1.6.alpha4 webpack/components/RoundProgress/RoundProgress.js
foreman_patch-1.1.5 webpack/components/RoundProgress/RoundProgress.js
foreman_patch-1.1.4 webpack/components/RoundProgress/RoundProgress.js
foreman_patch-1.1.3 webpack/components/RoundProgress/RoundProgress.js