mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 22:39:58 +02:00
refactor: Update ZenWorkspaces to enable setting default workspace and opening workspaces
This commit is contained in:
parent
43c47ad710
commit
dab7fd0b2f
1 changed files with 27 additions and 0 deletions
|
@ -412,6 +412,18 @@ var ZenWorkspaces = {
|
|||
} else {
|
||||
deleteMenuItem.removeAttribute("disabled");
|
||||
}
|
||||
let defaultMenuItem = document.getElementById("context_zenSetAsDefaultWorkspace");
|
||||
if (workspaces.workspaces.find(workspace => workspace.uuid === this._contextMenuId).default) {
|
||||
defaultMenuItem.setAttribute("disabled", "true");
|
||||
} else {
|
||||
defaultMenuItem.removeAttribute("disabled");
|
||||
}
|
||||
let openMenuItem = document.getElementById("context_zenOpenWorkspace");
|
||||
if (workspaces.workspaces.find(workspace => workspace.uuid === this._contextMenuId).used) {
|
||||
openMenuItem.setAttribute("disabled", "true");
|
||||
} else {
|
||||
openMenuItem.removeAttribute("disabled");
|
||||
}
|
||||
},
|
||||
|
||||
onContextMenuClose() {
|
||||
|
@ -422,6 +434,21 @@ var ZenWorkspaces = {
|
|||
this._contextMenuId = null;
|
||||
},
|
||||
|
||||
async setDefaultWorkspace() {
|
||||
let workspaces = await this._workspaces();
|
||||
for (let workspace of workspaces.workspaces) {
|
||||
workspace.default = workspace.uuid === this._contextMenuId;
|
||||
}
|
||||
await this.unsafeSaveWorkspaces(workspaces);
|
||||
await this._propagateWorkspaceData();
|
||||
},
|
||||
|
||||
async openWorkspace() {
|
||||
let workspaces = await this._workspaces();
|
||||
let workspace = workspaces.workspaces.find(workspace => workspace.uuid === this._contextMenuId);
|
||||
await this.changeWorkspace(workspace);
|
||||
},
|
||||
|
||||
async contextDelete() {
|
||||
await this.removeWorkspace(this._contextMenuId);
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue