footer.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import Plugins from './plugins';
  4. import { trackAnalyticsEvent } from '../utils/tracking-utils';
  5. import {
  6. clickDownloadGraph,
  7. clickForceRelayout,
  8. toggleHelp,
  9. toggleTroubleshootingMenu,
  10. setContrastMode
  11. } from '../actions/app-actions';
  12. class Footer extends React.Component {
  13. handleContrastClick = (ev) => {
  14. ev.preventDefault();
  15. this.props.setContrastMode(!this.props.contrastMode);
  16. }
  17. handleRelayoutClick = (ev) => {
  18. ev.preventDefault();
  19. trackAnalyticsEvent('scope.layout.refresh.click', {
  20. layout: this.props.topologyViewMode,
  21. });
  22. this.props.clickForceRelayout();
  23. }
  24. render() {
  25. const {
  26. hostname, version, versionUpdate, contrastMode
  27. } = this.props;
  28. const otherContrastModeTitle = contrastMode
  29. ? 'Switch to normal contrast' : 'Switch to high contrast';
  30. const forceRelayoutTitle = 'Force re-layout (might reduce edge crossings, '
  31. + 'but may shift nodes around)';
  32. const versionUpdateTitle = versionUpdate
  33. ? `New version available: ${versionUpdate.get('version')} Click to download`
  34. : '';
  35. return (
  36. <div className="footer">
  37. {/* <div className="footer-status">
  38. {versionUpdate
  39. && (
  40. <a
  41. className="footer-versionupdate"
  42. title={versionUpdateTitle}
  43. href={versionUpdate.get('downloadUrl')}
  44. target="_blank"
  45. rel="noopener noreferrer">
  46. Update available:
  47. {' '}
  48. {versionUpdate.get('version')}
  49. </a>
  50. )
  51. }
  52. <span className="footer-label">Version</span>
  53. {version || '...'}
  54. <span className="footer-label">on</span>
  55. {hostname}
  56. </div>
  57. <div className="footer-plugins">
  58. <Plugins />
  59. </div> */}
  60. <div className="footer-tools">
  61. <button
  62. type="button"
  63. className="footer-icon"
  64. onClick={this.handleRelayoutClick}
  65. title={forceRelayoutTitle}>
  66. <i className="fa fa-sync" />
  67. </button>
  68. {/* <button
  69. type="button"
  70. onClick={this.handleContrastClick}
  71. className="footer-icon"
  72. title={otherContrastModeTitle}>
  73. <i className="fa fa-adjust" />
  74. </button>
  75. <button
  76. type="button"
  77. onClick={this.props.toggleTroubleshootingMenu}
  78. className="footer-icon"
  79. title="Open troubleshooting menu"
  80. href=""
  81. >
  82. <i className="fa fa-bug" />
  83. </button>
  84. <button
  85. type="button"
  86. className="footer-icon"
  87. onClick={this.props.toggleHelp}
  88. title="Show help">
  89. <i className="fa fa-question" />
  90. </button> */}
  91. </div>
  92. </div>
  93. );
  94. }
  95. }
  96. function mapStateToProps(state) {
  97. return {
  98. contrastMode: state.get('contrastMode'),
  99. hostname: state.get('hostname'),
  100. topologyViewMode: state.get('topologyViewMode'),
  101. version: state.get('version'),
  102. versionUpdate: state.get('versionUpdate'),
  103. };
  104. }
  105. export default connect(
  106. mapStateToProps,
  107. {
  108. clickDownloadGraph,
  109. clickForceRelayout,
  110. setContrastMode,
  111. toggleHelp,
  112. toggleTroubleshootingMenu
  113. }
  114. )(Footer);