From 194c1fa2bc95ad2b34ac8efbdd56250e36de04c9 Mon Sep 17 00:00:00 2001 From: He4eT Date: Sun, 21 Jan 2024 22:08:45 +0100 Subject: [PATCH] pages/search: actions: extract tab to popup --- pages/search/modules/actionboxHandlers.js | 11 ++++++++++- pages/search/modules/store.js | 7 +++++++ pages/search/search.js | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pages/search/modules/actionboxHandlers.js b/pages/search/modules/actionboxHandlers.js index ff1c686..8fcf892 100644 --- a/pages/search/modules/actionboxHandlers.js +++ b/pages/search/modules/actionboxHandlers.js @@ -19,7 +19,7 @@ export const actionboxHandlers = (commandQuery, store, flush) => { 'c': duplicateTab, 's': discardTab, 'p': pinOrUnpinTab, - // 'e': Pop the tab into it's own window with minimal UI + 'e': moveTabToPopup, }[command] ?? noop(command))(store, label, flush) } @@ -78,6 +78,15 @@ function duplicateTab (store, label, flush) { } } +function moveTabToPopup (store, label, flush) { + const tab = getTabByLabel(store, label) + if (tab) { + flush() + store.actions.moveTabToPopup(tab.id) + store.actions.closeCurrentTab() + } +} + function pinOrUnpinTab (store, label, flush) { const tab = getTabByLabel(store, label) if (tab) { diff --git a/pages/search/modules/store.js b/pages/search/modules/store.js index 8b7d076..5ff5a0c 100644 --- a/pages/search/modules/store.js +++ b/pages/search/modules/store.js @@ -3,6 +3,7 @@ const fuzzysort = window.fuzzysort export const init = ({ tabs: browserTabs, + windows: browserWindows, onStateUpdate, closeCurrentTab, }) => { @@ -94,6 +95,12 @@ export const init = ({ browserTabs.discard(id) .then(updateState) }, + moveTabToPopup(id) { + browserWindows.create({ + tabId: id, + type: 'popup', + }).then(updateState) + }, updateTab(id, options) { browserTabs.update(id, options) .then(updateState) diff --git a/pages/search/search.js b/pages/search/search.js index 016ad48..45c32fe 100644 --- a/pages/search/search.js +++ b/pages/search/search.js @@ -4,6 +4,7 @@ import * as inputHandlers from './modules/inputHandlers.js' const store = Store.init({ tabs: browser.tabs, + windows: browser.windows, onStateUpdate: dom.updateSearchResults, closeCurrentTab: () => window.close(), })