troubleshooting-menu.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import {
  4. toggleTroubleshootingMenu,
  5. resetLocalViewState,
  6. clickDownloadGraph
  7. } from '../actions/app-actions';
  8. import { getReportUrl } from '../utils/web-api-utils';
  9. class DebugMenu extends React.Component {
  10. constructor(props, context) {
  11. super(props, context);
  12. this.handleClickReset = this.handleClickReset.bind(this);
  13. }
  14. handleClickReset(ev) {
  15. ev.preventDefault();
  16. this.props.resetLocalViewState();
  17. }
  18. render() {
  19. const { pausedAt } = this.props;
  20. return (
  21. <div className="troubleshooting-menu-wrapper">
  22. <div className="troubleshooting-menu">
  23. <div className="troubleshooting-menu-content">
  24. <h3>Debugging/Troubleshooting</h3>
  25. <div className="troubleshooting-menu-item">
  26. <a
  27. className="footer-icon"
  28. title="Save raw data as JSON"
  29. href={getReportUrl(pausedAt)}
  30. download
  31. >
  32. <i className="fa fa-code" />
  33. <span className="description">Save raw data as JSON</span>
  34. {pausedAt && (
  35. <span className="soft">
  36. {' '}
  37. (
  38. {pausedAt}
  39. )
  40. </span>
  41. )}
  42. </a>
  43. </div>
  44. <div className="troubleshooting-menu-item">
  45. <button
  46. type="button"
  47. className="footer-icon"
  48. onClick={this.props.clickDownloadGraph}
  49. title="Save canvas as SVG (does not include search highlighting)"
  50. >
  51. <i className="fa fa-download" />
  52. <span className="description">Save canvas as SVG</span>
  53. <span className="soft"> (does not include search highlighting)</span>
  54. </button>
  55. </div>
  56. <div className="troubleshooting-menu-item">
  57. <button
  58. type="button"
  59. className="footer-icon"
  60. title="Reset view state"
  61. onClick={this.handleClickReset}
  62. >
  63. <i className="fa fa-undo" />
  64. <span className="description">Reset your local view state and reload the page</span>
  65. </button>
  66. </div>
  67. <div className="troubleshooting-menu-item">
  68. <a
  69. className="footer-icon"
  70. title="Report an issue"
  71. href="https://gitreports.com/issue/weaveworks/scope"
  72. target="_blank"
  73. rel="noopener noreferrer"
  74. >
  75. <i className="fa fa-bug" />
  76. <span className="description">Report a bug</span>
  77. </a>
  78. </div>
  79. <div className="help-panel-tools">
  80. <i
  81. title="Close menu"
  82. className="fa fa-times"
  83. onClick={this.props.toggleTroubleshootingMenu}
  84. />
  85. </div>
  86. </div>
  87. </div>
  88. </div>
  89. );
  90. }
  91. }
  92. function mapStateToProps(state) {
  93. return {
  94. pausedAt: state.get('pausedAt'),
  95. };
  96. }
  97. export default connect(mapStateToProps, {
  98. clickDownloadGraph,
  99. resetLocalViewState,
  100. toggleTroubleshootingMenu
  101. })(DebugMenu);