Sfoglia il codice sorgente

set default cancel button in message boxes

Eugene Pankov 4 anni fa
parent
commit
edd7e9c7b7

+ 1 - 0
tabby-core/src/api/platform.ts

@@ -13,6 +13,7 @@ export interface MessageBoxOptions {
     detail?: string
     buttons: string[]
     defaultId?: number
+    cancelId?: number
 }
 
 export interface MessageBoxResult {

+ 1 - 0
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
             }

+ 1 - 0
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()

+ 4 - 3
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()
             }

+ 4 - 3
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 {

+ 2 - 0
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
         }

+ 9 - 6
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)) {

+ 3 - 2
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)
         }
     }

+ 4 - 3
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<void> {

+ 1 - 0
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)

+ 4 - 3
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
     }
 }

+ 1 - 0
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) {

+ 3 - 2
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()

+ 4 - 3
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)
         }
     }

+ 1 - 1
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 }
         }
     }