summaryrefslogtreecommitdiffstats
path: root/browser/components/newtab/content-src/lib/section-menu-options.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /browser/components/newtab/content-src/lib/section-menu-options.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/newtab/content-src/lib/section-menu-options.js')
-rw-r--r--browser/components/newtab/content-src/lib/section-menu-options.js93
1 files changed, 93 insertions, 0 deletions
diff --git a/browser/components/newtab/content-src/lib/section-menu-options.js b/browser/components/newtab/content-src/lib/section-menu-options.js
new file mode 100644
index 0000000000..9a3070a9f4
--- /dev/null
+++ b/browser/components/newtab/content-src/lib/section-menu-options.js
@@ -0,0 +1,93 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+import { actionCreators as ac, actionTypes as at } from "common/Actions.jsm";
+
+/**
+ * List of functions that return items that can be included as menu options in a
+ * SectionMenu. All functions take the section as the only parameter.
+ */
+export const SectionMenuOptions = {
+ Separator: () => ({ type: "separator" }),
+ MoveUp: section => ({
+ id: "newtab-section-menu-move-up",
+ icon: "arrowhead-up",
+ action: ac.OnlyToMain({
+ type: at.SECTION_MOVE,
+ data: { id: section.id, direction: -1 },
+ }),
+ userEvent: "MENU_MOVE_UP",
+ disabled: !!section.isFirst,
+ }),
+ MoveDown: section => ({
+ id: "newtab-section-menu-move-down",
+ icon: "arrowhead-down",
+ action: ac.OnlyToMain({
+ type: at.SECTION_MOVE,
+ data: { id: section.id, direction: +1 },
+ }),
+ userEvent: "MENU_MOVE_DOWN",
+ disabled: !!section.isLast,
+ }),
+ RemoveSection: section => ({
+ id: "newtab-section-menu-remove-section",
+ icon: "dismiss",
+ action: ac.SetPref(section.showPrefName, false),
+ userEvent: "MENU_REMOVE",
+ }),
+ CollapseSection: section => ({
+ id: "newtab-section-menu-collapse-section",
+ icon: "minimize",
+ action: ac.OnlyToMain({
+ type: at.UPDATE_SECTION_PREFS,
+ data: { id: section.id, value: { collapsed: true } },
+ }),
+ userEvent: "MENU_COLLAPSE",
+ }),
+ ExpandSection: section => ({
+ id: "newtab-section-menu-expand-section",
+ icon: "maximize",
+ action: ac.OnlyToMain({
+ type: at.UPDATE_SECTION_PREFS,
+ data: { id: section.id, value: { collapsed: false } },
+ }),
+ userEvent: "MENU_EXPAND",
+ }),
+ ManageSection: section => ({
+ id: "newtab-section-menu-manage-section",
+ icon: "settings",
+ action: ac.OnlyToMain({ type: at.SETTINGS_OPEN }),
+ userEvent: "MENU_MANAGE",
+ }),
+ ManageWebExtension: section => ({
+ id: "newtab-section-menu-manage-webext",
+ icon: "settings",
+ action: ac.OnlyToMain({ type: at.OPEN_WEBEXT_SETTINGS, data: section.id }),
+ }),
+ AddTopSite: section => ({
+ id: "newtab-section-menu-add-topsite",
+ icon: "add",
+ action: { type: at.TOP_SITES_EDIT, data: { index: -1 } },
+ userEvent: "MENU_ADD_TOPSITE",
+ }),
+ AddSearchShortcut: section => ({
+ id: "newtab-section-menu-add-search-engine",
+ icon: "search",
+ action: { type: at.TOP_SITES_OPEN_SEARCH_SHORTCUTS_MODAL },
+ userEvent: "MENU_ADD_SEARCH",
+ }),
+ PrivacyNotice: section => ({
+ id: "newtab-section-menu-privacy-notice",
+ icon: "info",
+ action: ac.OnlyToMain({
+ type: at.OPEN_LINK,
+ data: { url: section.privacyNoticeURL },
+ }),
+ userEvent: "MENU_PRIVACY_NOTICE",
+ }),
+ CheckCollapsed: section =>
+ section.collapsed
+ ? SectionMenuOptions.ExpandSection(section)
+ : SectionMenuOptions.CollapseSection(section),
+};