From 6dd93347638e21ecf4b7a3fcff4e8682de49375f Mon Sep 17 00:00:00 2001 From: Stefan Wimmer Date: Fri, 29 Nov 2024 19:30:17 +0100 Subject: [PATCH] feat: Prompt when deleting workspace --- browser/base/content/browser-workspaces.mjs | 24 ++++++++++++++------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/browser/base/content/browser-workspaces.mjs b/browser/base/content/browser-workspaces.mjs index 176b09a..f043c9e 100644 --- a/browser/base/content/browser-workspaces.mjs +++ b/browser/base/content/browser-workspaces.mjs @@ -552,15 +552,23 @@ export const gWorkspaces = { async deleteWorkspace(workspaceId) { let windowId = await this.getCurrentWindowId(); let currentWorkspaceId = await this.getCurrentWorkspaceId(); - await WorkspacesService.deleteWorkspace(workspaceId, windowId); - this.removeWorkspaceTabs(workspaceId); - if (workspaceId == currentWorkspaceId) { - await this.changeWorkspace( - await WorkspacesWindowIdUtils.getDefaultWorkspaceId(windowId), - 0 - ); + const workspace = await this.getWorkspaceById(workspaceId); + const result = Services.prompt.confirm( + window, + this.l10n.formatValueSync("delete-workspace-prompt-title"), + this.l10n.formatValueSync("delete-workspace-prompt-text", { name: workspace.name }), + ); + if (result) { + await WorkspacesService.deleteWorkspace(workspaceId, windowId); + this.removeWorkspaceTabs(workspaceId); + if (workspaceId == currentWorkspaceId) { + await this.changeWorkspace( + await WorkspacesWindowIdUtils.getDefaultWorkspaceId(windowId), + 0 + ); + } + this.rebuildWorkspacesToolbar(); } - this.rebuildWorkspacesToolbar(); }, async renameWorkspace(workspaceId, newName) {