From edd7e9c7b727f15365d852c5ce2d8dca902fa1c9 Mon Sep 17 00:00:00 2001 From: Eugene Pankov Date: Mon, 2 Aug 2021 21:01:35 +0200 Subject: [PATCH] set default cancel button in message boxes --- tabby-core/src/api/platform.ts | 1 + .../src/components/transfersMenu.component.ts | 1 + tabby-core/src/services/config.service.ts | 1 + tabby-electron/src/services/updater.service.ts | 7 ++++--- .../src/components/terminalTab.component.ts | 7 ++++--- .../components/configSyncSettingsTab.component.ts | 2 ++ .../components/profilesSettingsTab.component.ts | 15 +++++++++------ .../src/components/vaultSettingsTab.component.ts | 5 +++-- tabby-ssh/src/components/sshTab.component.ts | 7 ++++--- tabby-ssh/src/sftpContextMenu.ts | 1 + .../src/components/telnetTab.component.ts | 7 ++++--- .../src/api/baseTerminalTab.component.ts | 1 + .../colorSchemeSettingsTab.component.ts | 5 +++-- .../components/loginScriptsSettings.component.ts | 7 ++++--- tabby-web/src/platform.ts | 2 +- 15 files changed, 43 insertions(+), 26 deletions(-) diff --git a/tabby-core/src/api/platform.ts b/tabby-core/src/api/platform.ts index d87b6fef..d3898a2c 100644 --- a/tabby-core/src/api/platform.ts +++ b/tabby-core/src/api/platform.ts @@ -13,6 +13,7 @@ export interface MessageBoxOptions { detail?: string buttons: string[] defaultId?: number + cancelId?: number } export interface MessageBoxResult { diff --git a/tabby-core/src/components/transfersMenu.component.ts b/tabby-core/src/components/transfersMenu.component.ts index 66d0591b..b3b67701 100644 --- a/tabby-core/src/components/transfersMenu.component.ts +++ b/tabby-core/src/components/transfersMenu.component.ts @@ -43,6 +43,7 @@ export class TransfersMenuComponent { message: 'There are active file transfers', buttons: ['Abort all', 'Do not abort'], defaultId: 1, + cancelId: 1, })).response === 1) { return } diff --git a/tabby-core/src/services/config.service.ts b/tabby-core/src/services/config.service.ts index a1267dfb..a4bb59d3 100644 --- a/tabby-core/src/services/config.service.ts +++ b/tabby-core/src/services/config.service.ts @@ -375,6 +375,7 @@ export class ConfigService { detail: e.toString(), buttons: ['Erase config', 'Quit'], defaultId: 1, + cancelId: 1, }) if (result.response === 1) { this.platform.quit() diff --git a/tabby-electron/src/services/updater.service.ts b/tabby-electron/src/services/updater.service.ts index ab58a4fc..9cfa0013 100644 --- a/tabby-electron/src/services/updater.service.ts +++ b/tabby-electron/src/services/updater.service.ts @@ -126,10 +126,11 @@ export class ElectronUpdaterService extends UpdaterService { { type: 'warning', message: 'Installing the update will close all tabs and restart Tabby.', - buttons: ['Cancel', 'Update'], - defaultId: 1, + buttons: ['Update', 'Cancel'], + defaultId: 0, + cancelId: 1, } - )).response === 1) { + )).response === 0) { await this.downloaded this.electron.autoUpdater.quitAndInstall() } diff --git a/tabby-local/src/components/terminalTab.component.ts b/tabby-local/src/components/terminalTab.component.ts index 4070b4e2..4f566c8f 100644 --- a/tabby-local/src/components/terminalTab.component.ts +++ b/tabby-local/src/components/terminalTab.component.ts @@ -106,10 +106,11 @@ export class TerminalTabComponent extends BaseTerminalTabComponent { { type: 'warning', message: `"${children[0].command}" is still running. Close?`, - buttons: ['Cancel', 'Kill'], - defaultId: 1, + buttons: ['Kill', 'Cancel'], + defaultId: 0, + cancelId: 1, } - )).response === 1 + )).response === 0 } ngOnDestroy (): void { diff --git a/tabby-settings/src/components/configSyncSettingsTab.component.ts b/tabby-settings/src/components/configSyncSettingsTab.component.ts index a61ab243..3c613a54 100644 --- a/tabby-settings/src/components/configSyncSettingsTab.component.ts +++ b/tabby-settings/src/components/configSyncSettingsTab.component.ts @@ -73,6 +73,7 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent { message: 'Overwrite the config on the remote side and start syncing?', buttons: ['Overwrite remote and sync', 'Cancel'], defaultId: 1, + cancelId: 1, })).response === 1) { return } @@ -89,6 +90,7 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent { message: 'Overwrite the local config and start syncing?', buttons: ['Overwrite local and sync', 'Cancel'], defaultId: 1, + cancelId: 1, })).response === 1) { return } diff --git a/tabby-settings/src/components/profilesSettingsTab.component.ts b/tabby-settings/src/components/profilesSettingsTab.component.ts index 06f2de00..2e10a4b3 100644 --- a/tabby-settings/src/components/profilesSettingsTab.component.ts +++ b/tabby-settings/src/components/profilesSettingsTab.component.ts @@ -106,10 +106,11 @@ export class ProfilesSettingsTabComponent extends BaseComponent { { type: 'warning', message: `Delete "${profile.name}"?`, - buttons: ['Keep', 'Delete'], - defaultId: 0, + buttons: ['Delete', 'Keep'], + defaultId: 1, + cancelId: 1, } - )).response === 1) { + )).response === 0) { this.profilesService.providerForProfile(profile)?.deleteProfile( this.profilesService.getConfigProxyForProfile(profile)) this.config.store.profiles = this.config.store.profiles.filter(x => x !== profile) @@ -164,16 +165,18 @@ export class ProfilesSettingsTabComponent extends BaseComponent { { type: 'warning', message: `Delete "${group.name}"?`, - buttons: ['Keep', 'Delete'], - defaultId: 0, + buttons: ['Delete', 'Keep'], + defaultId: 1, + cancelId: 1, } - )).response === 1) { + )).response === 0) { if ((await this.platform.showMessageBox( { type: 'warning', message: `Delete the group's profiles?`, buttons: ['Move to "Ungrouped"', 'Delete'], defaultId: 0, + cancelId: 0, } )).response === 0) { for (const profile of this.profiles.filter(x => x.group === group.name)) { diff --git a/tabby-settings/src/components/vaultSettingsTab.component.ts b/tabby-settings/src/components/vaultSettingsTab.component.ts index d0251bf4..b013a050 100644 --- a/tabby-settings/src/components/vaultSettingsTab.component.ts +++ b/tabby-settings/src/components/vaultSettingsTab.component.ts @@ -42,10 +42,11 @@ export class VaultSettingsTabComponent extends BaseComponent { { type: 'warning', message: 'Delete vault contents?', - buttons: ['Keep', 'Delete'], + buttons: ['Delete', 'Keep'], defaultId: 1, + cancelId: 1, } - )).response === 1) { + )).response === 0) { await this.vault.setEnabled(false) } } diff --git a/tabby-ssh/src/components/sshTab.component.ts b/tabby-ssh/src/components/sshTab.component.ts index 7c9fc734..51a741ac 100644 --- a/tabby-ssh/src/components/sshTab.component.ts +++ b/tabby-ssh/src/components/sshTab.component.ts @@ -209,10 +209,11 @@ export class SSHTabComponent extends BaseTerminalTabComponent { { type: 'warning', message: `Disconnect from ${this.profile?.options.host}?`, - buttons: ['Cancel', 'Disconnect'], - defaultId: 1, + buttons: ['Disconnect', 'Do not close'], + defaultId: 0, + cancelId: 1, } - )).response === 1 + )).response === 0 } async openSFTP (): Promise { diff --git a/tabby-ssh/src/sftpContextMenu.ts b/tabby-ssh/src/sftpContextMenu.ts index 85f17ffc..726a4498 100644 --- a/tabby-ssh/src/sftpContextMenu.ts +++ b/tabby-ssh/src/sftpContextMenu.ts @@ -27,6 +27,7 @@ export class CommonSFTPContextMenu extends SFTPContextMenuItemProvider { type: 'warning', message: `Delete ${item.fullPath}?`, defaultId: 0, + cancelId: 1, buttons: ['Delete', 'Cancel'], })).response === 0) { await this.deleteItem(item, panel.sftp) diff --git a/tabby-telnet/src/components/telnetTab.component.ts b/tabby-telnet/src/components/telnetTab.component.ts index d310b3dd..96438693 100644 --- a/tabby-telnet/src/components/telnetTab.component.ts +++ b/tabby-telnet/src/components/telnetTab.component.ts @@ -119,9 +119,10 @@ export class TelnetTabComponent extends BaseTerminalTabComponent { { type: 'warning', message: `Disconnect from ${this.profile?.options.host}?`, - buttons: ['Cancel', 'Disconnect'], - defaultId: 1, + buttons: ['Disconnect', 'Do not close'], + defaultId: 0, + cancelId: 1, } - )).response === 1 + )).response === 0 } } diff --git a/tabby-terminal/src/api/baseTerminalTab.component.ts b/tabby-terminal/src/api/baseTerminalTab.component.ts index d26b90ab..4d902ea6 100644 --- a/tabby-terminal/src/api/baseTerminalTab.component.ts +++ b/tabby-terminal/src/api/baseTerminalTab.component.ts @@ -445,6 +445,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit message: `Paste multiple lines?`, buttons, defaultId: 0, + cancelId: 1, } )).response if (result === 1) { diff --git a/tabby-terminal/src/components/colorSchemeSettingsTab.component.ts b/tabby-terminal/src/components/colorSchemeSettingsTab.component.ts index 4c20cc7c..60048534 100644 --- a/tabby-terminal/src/components/colorSchemeSettingsTab.component.ts +++ b/tabby-terminal/src/components/colorSchemeSettingsTab.component.ts @@ -79,10 +79,11 @@ export class ColorSchemeSettingsTabComponent { { type: 'warning', message: `Delete "${scheme.name}"?`, - buttons: ['Keep', 'Delete'], + buttons: ['Delete', 'Keep'], defaultId: 1, + cancelId: 1, } - )).response === 1) { + )).response === 0) { this.customColorSchemes = this.customColorSchemes.filter(x => x.name !== scheme.name) this.config.store.terminal.customColorSchemes = this.customColorSchemes this.config.save() diff --git a/tabby-terminal/src/components/loginScriptsSettings.component.ts b/tabby-terminal/src/components/loginScriptsSettings.component.ts index 158b3cc7..5f610908 100644 --- a/tabby-terminal/src/components/loginScriptsSettings.component.ts +++ b/tabby-terminal/src/components/loginScriptsSettings.component.ts @@ -27,10 +27,11 @@ export class LoginScriptsSettingsComponent { type: 'warning', message: 'Delete this script?', detail: script.expect, - buttons: ['Keep', 'Delete'], - defaultId: 1, + buttons: ['Delete', 'Keep'], + defaultId: 0, + cancelId: 1, } - )).response === 1) { + )).response === 0) { this.scripts = this.scripts.filter(x => x !== script) } } diff --git a/tabby-web/src/platform.ts b/tabby-web/src/platform.ts index 91aac26f..074d66e2 100644 --- a/tabby-web/src/platform.ts +++ b/tabby-web/src/platform.ts @@ -100,7 +100,7 @@ export class WebPlatformService extends PlatformService { const response = await modal.result return { response } } catch { - return { response: 0 } + return { response: options.cancelId ?? 1 } } }