section-menu-options.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. import {actionCreators as ac, actionTypes as at} from "common/Actions.jsm";
  2. /**
  3. * List of functions that return items that can be included as menu options in a
  4. * SectionMenu. All functions take the section as the only parameter.
  5. */
  6. export const SectionMenuOptions = {
  7. Separator: () => ({type: "separator"}),
  8. MoveUp: section => ({
  9. id: "section_menu_action_move_up",
  10. icon: "arrowhead-up",
  11. action: ac.OnlyToMain({
  12. type: at.SECTION_MOVE,
  13. data: {id: section.id, direction: -1},
  14. }),
  15. userEvent: "MENU_MOVE_UP",
  16. disabled: !!section.isFirst,
  17. }),
  18. MoveDown: section => ({
  19. id: "section_menu_action_move_down",
  20. icon: "arrowhead-down",
  21. action: ac.OnlyToMain({
  22. type: at.SECTION_MOVE,
  23. data: {id: section.id, direction: +1},
  24. }),
  25. userEvent: "MENU_MOVE_DOWN",
  26. disabled: !!section.isLast,
  27. }),
  28. RemoveSection: section => ({
  29. id: "section_menu_action_remove_section",
  30. icon: "dismiss",
  31. action: ac.SetPref(section.showPrefName, false),
  32. userEvent: "MENU_REMOVE",
  33. }),
  34. CollapseSection: section => ({
  35. id: "section_menu_action_collapse_section",
  36. icon: "minimize",
  37. action: ac.OnlyToMain({type: at.UPDATE_SECTION_PREFS, data: {id: section.id, value: {collapsed: true}}}),
  38. userEvent: "MENU_COLLAPSE",
  39. }),
  40. ExpandSection: section => ({
  41. id: "section_menu_action_expand_section",
  42. icon: "maximize",
  43. action: ac.OnlyToMain({type: at.UPDATE_SECTION_PREFS, data: {id: section.id, value: {collapsed: false}}}),
  44. userEvent: "MENU_EXPAND",
  45. }),
  46. ManageSection: section => ({
  47. id: "section_menu_action_manage_section",
  48. icon: "settings",
  49. action: ac.OnlyToMain({type: at.SETTINGS_OPEN}),
  50. userEvent: "MENU_MANAGE",
  51. }),
  52. ManageWebExtension: section => ({
  53. id: "section_menu_action_manage_webext",
  54. icon: "settings",
  55. action: ac.OnlyToMain({type: at.OPEN_WEBEXT_SETTINGS, data: section.id}),
  56. }),
  57. AddTopSite: section => ({
  58. id: "section_menu_action_add_topsite",
  59. icon: "add",
  60. action: {type: at.TOP_SITES_EDIT, data: {index: -1}},
  61. userEvent: "MENU_ADD_TOPSITE",
  62. }),
  63. AddSearchShortcut: section => ({
  64. id: "section_menu_action_add_search_engine",
  65. icon: "search",
  66. action: {type: at.TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL},
  67. userEvent: "MENU_ADD_SEARCH",
  68. }),
  69. PrivacyNotice: section => ({
  70. id: "section_menu_action_privacy_notice",
  71. icon: "info",
  72. action: ac.OnlyToMain({
  73. type: at.OPEN_LINK,
  74. data: {url: section.privacyNoticeURL},
  75. }),
  76. userEvent: "MENU_PRIVACY_NOTICE",
  77. }),
  78. CheckCollapsed: section => (section.collapsed ? SectionMenuOptions.ExpandSection(section) : SectionMenuOptions.CollapseSection(section)),
  79. };