Bug 1936831 - Allow searching for closed and saved tab groups in the address bar and display matching tab groups as actions. r=daleharvey,fluent-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D232336
This commit is contained in:
@@ -12,6 +12,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
|
||||
BrowserWindowTracker: "resource:///modules/BrowserWindowTracker.sys.mjs",
|
||||
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
|
||||
UrlbarPrefs: "resource:///modules/UrlbarPrefs.sys.mjs",
|
||||
SessionStore: "resource:///modules/sessionstore/SessionStore.sys.mjs",
|
||||
});
|
||||
|
||||
const MIN_SEARCH_PREF = "tabGroups.minSearchLength";
|
||||
@@ -43,21 +44,31 @@ class ProviderTabGroups extends ActionsProvider {
|
||||
for (let group of gBrowser.getAllTabGroups()) {
|
||||
if (group.label.toLowerCase().startsWith(input)) {
|
||||
results.push(
|
||||
new ActionsResult({
|
||||
this.#makeResult({
|
||||
key: `tabgroup-${i++}`,
|
||||
icon: "chrome://browser/skin/tabbrowser/tab-groups.svg",
|
||||
l10nId: "urlbar-result-action-switch-to-tabgroup",
|
||||
l10nArgs: { group: group.label },
|
||||
onPick: (_queryContext, _controller) => {
|
||||
this.openGroup(group);
|
||||
this.#switchToGroup(group);
|
||||
},
|
||||
dataset: {
|
||||
style: {
|
||||
"--tab-group-color": `var(--tab-group-color-${group.color})`,
|
||||
"--tab-group-color-invert": `var(--tab-group-color-${group.color}-invert)`,
|
||||
"--tab-group-color-pale": `var(--tab-group-color-${group.color}-pale)`,
|
||||
},
|
||||
color: group.color,
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (let savedGroup of lazy.SessionStore.getSavedTabGroups()) {
|
||||
if (savedGroup.name.toLowerCase().startsWith(input)) {
|
||||
results.push(
|
||||
this.#makeResult({
|
||||
key: `tabgroup-${i++}`,
|
||||
l10nId: "urlbar-result-action-open-saved-tabgroup",
|
||||
l10nArgs: { group: savedGroup.name },
|
||||
onPick: (_queryContext, _controller) => {
|
||||
let group = lazy.SessionStore.openSavedTabGroup(savedGroup.id);
|
||||
this.#switchToGroup(group);
|
||||
},
|
||||
color: savedGroup.color,
|
||||
})
|
||||
);
|
||||
}
|
||||
@@ -66,7 +77,24 @@ class ProviderTabGroups extends ActionsProvider {
|
||||
return results;
|
||||
}
|
||||
|
||||
openGroup(group) {
|
||||
#makeResult({ key, l10nId, l10nArgs, onPick, color }) {
|
||||
return new ActionsResult({
|
||||
key,
|
||||
l10nId,
|
||||
l10nArgs,
|
||||
onPick,
|
||||
icon: "chrome://browser/skin/tabbrowser/tab-groups.svg",
|
||||
dataset: {
|
||||
style: {
|
||||
"--tab-group-color": `var(--tab-group-color-${color})`,
|
||||
"--tab-group-color-invert": `var(--tab-group-color-${color}-invert)`,
|
||||
"--tab-group-color-pale": `var(--tab-group-color-${color}-pale)`,
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
#switchToGroup(group) {
|
||||
group.ownerGlobal.gBrowser.selectedTab = group.tabs[0];
|
||||
group.ownerGlobal.focus();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user