mirror of
https://github.com/zen-browser/desktop.git
synced 2025-10-16 14:56:14 +00:00
feat: Unload a workspace context menu, p=#10688
Co-authored-by: mr. m <91018726+mr-cheffy@users.noreply.github.com>
This commit is contained in:
@@ -23,6 +23,9 @@ zen-workspaces-panel-change-icon =
|
|||||||
zen-workspaces-panel-context-default-profile =
|
zen-workspaces-panel-context-default-profile =
|
||||||
.label = Set Profile
|
.label = Set Profile
|
||||||
|
|
||||||
|
zen-workspaces-panel-unload =
|
||||||
|
.label = Unload Space
|
||||||
|
|
||||||
zen-workspaces-how-to-reorder-title = How to reorder spaces
|
zen-workspaces-how-to-reorder-title = How to reorder spaces
|
||||||
zen-workspaces-how-to-reorder-desc = Drag the space icons at the bottom of the sidebar to reorder them
|
zen-workspaces-how-to-reorder-desc = Drag the space icons at the bottom of the sidebar to reorder them
|
||||||
|
|
||||||
|
@@ -39,6 +39,7 @@
|
|||||||
<command id="cmd_contextZenRemoveFromEssentials" />
|
<command id="cmd_contextZenRemoveFromEssentials" />
|
||||||
|
|
||||||
<command id="cmd_zenCtxDeleteWorkspace" />
|
<command id="cmd_zenCtxDeleteWorkspace" />
|
||||||
|
<command id="cmd_zenUnloadWorkspace" />
|
||||||
<command id="cmd_zenChangeWorkspaceName" />
|
<command id="cmd_zenChangeWorkspaceName" />
|
||||||
<command id="cmd_zenChangeWorkspaceIcon" />
|
<command id="cmd_zenChangeWorkspaceIcon" />
|
||||||
<command id="cmd_zenReorderWorkspaces" />
|
<command id="cmd_zenReorderWorkspaces" />
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
hide-if-usercontext-disabled="true">
|
hide-if-usercontext-disabled="true">
|
||||||
<menupopup />
|
<menupopup />
|
||||||
</menu>
|
</menu>
|
||||||
|
<menuitem id="context_zenUnloadWorkspace" data-l10n-id="zen-workspaces-panel-unload" command="cmd_zenUnloadWorkspace"/>
|
||||||
<menuseparator id="context_zenWorkspacesSeparator"/>
|
<menuseparator id="context_zenWorkspacesSeparator"/>
|
||||||
<menuseparator/>
|
<menuseparator/>
|
||||||
<menuitem id="context_zenReorderWorkspaces" data-l10n-id="zen-workspaces-panel-context-reorder" command="cmd_zenReorderWorkspaces"/>
|
<menuitem id="context_zenReorderWorkspaces" data-l10n-id="zen-workspaces-panel-context-reorder" command="cmd_zenReorderWorkspaces"/>
|
||||||
|
@@ -122,6 +122,10 @@ document.addEventListener(
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case 'cmd_zenUnloadWorkspace': {
|
||||||
|
gZenWorkspaces.unloadWorkspace();
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
gZenGlanceManager.handleMainCommandSet(event);
|
gZenGlanceManager.handleMainCommandSet(event);
|
||||||
if (event.target.id.startsWith('cmd_zenWorkspaceSwitch')) {
|
if (event.target.id.startsWith('cmd_zenWorkspaceSwitch')) {
|
||||||
|
@@ -1479,6 +1479,26 @@ var gZenWorkspaces = new (class extends nsZenMultiWindowFeature {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async unloadWorkspace() {
|
||||||
|
const workspaceId = this.#contextMenuData?.workspaceId || this.activeWorkspace;
|
||||||
|
|
||||||
|
const tabsToUnload = this.allStoredTabs.filter(
|
||||||
|
(tab) =>
|
||||||
|
tab.getAttribute('zen-workspace-id') === workspaceId &&
|
||||||
|
!tab.hasAttribute('zen-empty-tab') &&
|
||||||
|
!tab.hasAttribute('zen-essential') &&
|
||||||
|
!tab.hasAttribute('pending')
|
||||||
|
);
|
||||||
|
|
||||||
|
if (tabsToUnload.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.log('Unloading workspace', workspaceId);
|
||||||
|
|
||||||
|
await gBrowser.explicitUnloadTabs(tabsToUnload); // TODO: unit test this
|
||||||
|
}
|
||||||
|
|
||||||
moveTabToWorkspace(tab, workspaceID) {
|
moveTabToWorkspace(tab, workspaceID) {
|
||||||
return this.moveTabsToWorkspace([tab], workspaceID);
|
return this.moveTabsToWorkspace([tab], workspaceID);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user