toolbar-view.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /* globals dumpn, $, NetMonitorView */
  2. "use strict";
  3. const { createFactory, DOM } = require("devtools/client/shared/vendor/react");
  4. const ReactDOM = require("devtools/client/shared/vendor/react-dom");
  5. const Provider = createFactory(require("devtools/client/shared/vendor/react-redux").Provider);
  6. const FilterButtons = createFactory(require("./components/filter-buttons"));
  7. const ToggleButton = createFactory(require("./components/toggle-button"));
  8. const SearchBox = createFactory(require("./components/search-box"));
  9. const SummaryButton = createFactory(require("./components/summary-button"));
  10. const { L10N } = require("./l10n");
  11. // Shortcuts
  12. const { button } = DOM;
  13. /**
  14. * Functions handling the toolbar view: expand/collapse button etc.
  15. */
  16. function ToolbarView() {
  17. dumpn("ToolbarView was instantiated");
  18. }
  19. ToolbarView.prototype = {
  20. /**
  21. * Initialization function, called when the debugger is started.
  22. */
  23. initialize: function (store) {
  24. dumpn("Initializing the ToolbarView");
  25. this._clearContainerNode = $("#react-clear-button-hook");
  26. this._filterContainerNode = $("#react-filter-buttons-hook");
  27. this._summaryContainerNode = $("#react-summary-button-hook");
  28. this._searchContainerNode = $("#react-search-box-hook");
  29. this._toggleContainerNode = $("#react-details-pane-toggle-hook");
  30. // clear button
  31. ReactDOM.render(button({
  32. id: "requests-menu-clear-button",
  33. className: "devtools-button devtools-clear-icon",
  34. title: L10N.getStr("netmonitor.toolbar.clear"),
  35. onClick: () => {
  36. NetMonitorView.RequestsMenu.clear();
  37. }
  38. }), this._clearContainerNode);
  39. // filter button
  40. ReactDOM.render(Provider(
  41. { store },
  42. FilterButtons()
  43. ), this._filterContainerNode);
  44. // summary button
  45. ReactDOM.render(Provider(
  46. { store },
  47. SummaryButton()
  48. ), this._summaryContainerNode);
  49. // search box
  50. ReactDOM.render(Provider(
  51. { store },
  52. SearchBox()
  53. ), this._searchContainerNode);
  54. // details pane toggle button
  55. ReactDOM.render(Provider(
  56. { store },
  57. ToggleButton()
  58. ), this._toggleContainerNode);
  59. },
  60. /**
  61. * Destruction function, called when the debugger is closed.
  62. */
  63. destroy: function () {
  64. dumpn("Destroying the ToolbarView");
  65. ReactDOM.unmountComponentAtNode(this._clearContainerNode);
  66. ReactDOM.unmountComponentAtNode(this._filterContainerNode);
  67. ReactDOM.unmountComponentAtNode(this._summaryContainerNode);
  68. ReactDOM.unmountComponentAtNode(this._searchContainerNode);
  69. ReactDOM.unmountComponentAtNode(this._toggleContainerNode);
  70. }
  71. };
  72. exports.ToolbarView = ToolbarView;