ui.js 917 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const I = require("devtools/client/shared/vendor/immutable");
  6. const {
  7. OPEN_SIDEBAR,
  8. TOGGLE_SIDEBAR,
  9. } = require("../constants");
  10. const Sidebar = I.Record({
  11. open: false,
  12. });
  13. const UI = I.Record({
  14. sidebar: new Sidebar(),
  15. });
  16. function openSidebar(state, action) {
  17. return state.setIn(["sidebar", "open"], action.open);
  18. }
  19. function toggleSidebar(state, action) {
  20. return state.setIn(["sidebar", "open"], !state.sidebar.open);
  21. }
  22. function ui(state = new UI(), action) {
  23. switch (action.type) {
  24. case OPEN_SIDEBAR:
  25. return openSidebar(state, action);
  26. case TOGGLE_SIDEBAR:
  27. return toggleSidebar(state, action);
  28. default:
  29. return state;
  30. }
  31. }
  32. module.exports = ui;