feat(workspaces): rename method to openCreateForm and update workspace creation logic

This commit is contained in:
mr. M 2025-03-24 18:36:05 +01:00
parent f89478bf67
commit e4e92a463f
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB
3 changed files with 50 additions and 3 deletions

View file

@ -149,7 +149,7 @@
<toolbarbutton id="PanelUI-zen-workspaces-reorder-mode" oncommand="ZenWorkspaces.toggleReorderMode();" class="subviewbutton">
<image></image>
</toolbarbutton>
<toolbarbutton id="PanelUI-zen-workspaces-new" oncommand="ZenWorkspaces.openSaveDialog();" class="subviewbutton">
<toolbarbutton id="PanelUI-zen-workspaces-new" oncommand="ZenWorkspaces.openCreateForm();" class="subviewbutton">
<image></image>
</toolbarbutton>
</hbox>

View file

@ -365,7 +365,7 @@ menuitem {
}
& .zen-toast {
padding: 0.9rem 0.8rem;
padding: 0.5rem 0.6rem;
border-radius: 12px;
background: linear-gradient(
170deg,

View file

@ -1913,7 +1913,7 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
return window;
}
async createAndSaveWorkspace(name = 'New Workspace', isDefault = false, icon = undefined, dontChange = false) {
async createAndSaveWorkspace(name = 'Space', isDefault = false, icon = undefined, dontChange = false) {
if (!this.workspaceEnabled) {
return;
}
@ -2395,4 +2395,51 @@ var ZenWorkspaces = new (class extends ZenMultiWindowFeature {
this._processingResize = false;
});
}
async openCreateForm() {
window.docShell.treeOwner
.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIAppWindow)
.rollupAllPopups();
this.selectEmptyTab();
const sidebarWidth = gNavToolbox.style.getPropertyValue('--actual-zen-sidebar-width');
let elementsToAnimate = [gNavToolbox];
if (gZenVerticalTabsManager._hasSetSingleToolbar) {
elementsToAnimate.push(gURLBar.textbox);
}
this._creatingNewWorkspace = true;
gNavToolbox.style.zIndex = -1;
await Promise.all([
gZenUIManager.motion.animate(elementsToAnimate, {
transform: ['scale(1)', 'scale(0.8)'],
opacity: [1, 0],
}),
gZenUIManager.motion.animate(
gBrowser.tabpanels,
{
marginLeft: ['0px', '-' + sidebarWidth],
},
{
delay: 0.2,
}
),
this.createAndSaveWorkspace()
]);
const form = window.MozXULElement.parseXULToFragment(`
<hbox id="zen-workspace-create-form-wrapper">
<vbox id="zen-workspace-create-form">
<vbox>
<label id="zen-workspace-create-form-title" data-l10n-id="zen-workspace-create-form-title" />
<description data-l10n-id="zen-workspace-create-form-description" />
</vbox>
<vbox>
<hbox class="PanelUI-zen-workspaces-creation-wraper">
<hbox class="PanelUI-zen-workspaces-icons-container create" onclick="ZenWorkspaces.onWorkspaceIconContainerClick(event);"></hbox>
<html:input autofocus="true" id="PanelUI-zen-workspaces-create-input" type="text" placeholder="Enter workspace name" oninput="ZenWorkspaces.onWorkspaceCreationNameChange(this);" />
</hbox>
</vbox>
</vbox>
</hbox>
`);
}
})();