node-details-controls.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import React from 'react';
  2. import { sortBy } from 'lodash';
  3. import NodeDetailsControlButton from './node-details-control-button';
  4. export default function NodeDetailsControls({
  5. controls, error, nodeId, pending
  6. }) {
  7. let spinnerClassName = 'fa fa-circle-notch fa-spin';
  8. if (pending) {
  9. spinnerClassName += ' node-details-controls-spinner';
  10. } else {
  11. spinnerClassName += ' node-details-controls-spinner hide';
  12. }
  13. return (
  14. <div className="node-details-controls">
  15. {error
  16. && (
  17. <div className="node-details-controls-error" title={error}>
  18. <i className="node-details-controls-error-icon fa fa-exclamation-triangle" />
  19. <span className="node-details-controls-error-messages">{error}</span>
  20. </div>
  21. )
  22. }
  23. <span className="node-details-controls-buttons">
  24. {sortBy(controls, 'rank').map(control => (
  25. <NodeDetailsControlButton
  26. nodeId={nodeId}
  27. control={control}
  28. pending={pending}
  29. key={control.id}
  30. />
  31. ))}
  32. </span>
  33. {controls && <span title="Applying..." className={spinnerClassName} />}
  34. </div>
  35. );
  36. }