set default cancel button in message boxes

上级 ab8061ab
...@@ -13,6 +13,7 @@ export interface MessageBoxOptions { ...@@ -13,6 +13,7 @@ export interface MessageBoxOptions {
detail?: string detail?: string
buttons: string[] buttons: string[]
defaultId?: number defaultId?: number
cancelId?: number
} }
export interface MessageBoxResult { export interface MessageBoxResult {
......
...@@ -43,6 +43,7 @@ export class TransfersMenuComponent { ...@@ -43,6 +43,7 @@ export class TransfersMenuComponent {
message: 'There are active file transfers', message: 'There are active file transfers',
buttons: ['Abort all', 'Do not abort'], buttons: ['Abort all', 'Do not abort'],
defaultId: 1, defaultId: 1,
cancelId: 1,
})).response === 1) { })).response === 1) {
return return
} }
......
...@@ -375,6 +375,7 @@ export class ConfigService { ...@@ -375,6 +375,7 @@ export class ConfigService {
detail: e.toString(), detail: e.toString(),
buttons: ['Erase config', 'Quit'], buttons: ['Erase config', 'Quit'],
defaultId: 1, defaultId: 1,
cancelId: 1,
}) })
if (result.response === 1) { if (result.response === 1) {
this.platform.quit() this.platform.quit()
......
...@@ -126,10 +126,11 @@ export class ElectronUpdaterService extends UpdaterService { ...@@ -126,10 +126,11 @@ export class ElectronUpdaterService extends UpdaterService {
{ {
type: 'warning', type: 'warning',
message: 'Installing the update will close all tabs and restart Tabby.', message: 'Installing the update will close all tabs and restart Tabby.',
buttons: ['Cancel', 'Update'], buttons: ['Update', 'Cancel'],
defaultId: 1, defaultId: 0,
cancelId: 1,
} }
)).response === 1) { )).response === 0) {
await this.downloaded await this.downloaded
this.electron.autoUpdater.quitAndInstall() this.electron.autoUpdater.quitAndInstall()
} }
......
...@@ -106,10 +106,11 @@ export class TerminalTabComponent extends BaseTerminalTabComponent { ...@@ -106,10 +106,11 @@ export class TerminalTabComponent extends BaseTerminalTabComponent {
{ {
type: 'warning', type: 'warning',
message: `"${children[0].command}" is still running. Close?`, message: `"${children[0].command}" is still running. Close?`,
buttons: ['Cancel', 'Kill'], buttons: ['Kill', 'Cancel'],
defaultId: 1, defaultId: 0,
cancelId: 1,
} }
)).response === 1 )).response === 0
} }
ngOnDestroy (): void { ngOnDestroy (): void {
......
...@@ -73,6 +73,7 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent { ...@@ -73,6 +73,7 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent {
message: 'Overwrite the config on the remote side and start syncing?', message: 'Overwrite the config on the remote side and start syncing?',
buttons: ['Overwrite remote and sync', 'Cancel'], buttons: ['Overwrite remote and sync', 'Cancel'],
defaultId: 1, defaultId: 1,
cancelId: 1,
})).response === 1) { })).response === 1) {
return return
} }
...@@ -89,6 +90,7 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent { ...@@ -89,6 +90,7 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent {
message: 'Overwrite the local config and start syncing?', message: 'Overwrite the local config and start syncing?',
buttons: ['Overwrite local and sync', 'Cancel'], buttons: ['Overwrite local and sync', 'Cancel'],
defaultId: 1, defaultId: 1,
cancelId: 1,
})).response === 1) { })).response === 1) {
return return
} }
......
...@@ -106,10 +106,11 @@ export class ProfilesSettingsTabComponent extends BaseComponent { ...@@ -106,10 +106,11 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
{ {
type: 'warning', type: 'warning',
message: `Delete "${profile.name}"?`, message: `Delete "${profile.name}"?`,
buttons: ['Keep', 'Delete'], buttons: ['Delete', 'Keep'],
defaultId: 0, defaultId: 1,
cancelId: 1,
} }
)).response === 1) { )).response === 0) {
this.profilesService.providerForProfile(profile)?.deleteProfile( this.profilesService.providerForProfile(profile)?.deleteProfile(
this.profilesService.getConfigProxyForProfile(profile)) this.profilesService.getConfigProxyForProfile(profile))
this.config.store.profiles = this.config.store.profiles.filter(x => x !== profile) this.config.store.profiles = this.config.store.profiles.filter(x => x !== profile)
...@@ -164,16 +165,18 @@ export class ProfilesSettingsTabComponent extends BaseComponent { ...@@ -164,16 +165,18 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
{ {
type: 'warning', type: 'warning',
message: `Delete "${group.name}"?`, message: `Delete "${group.name}"?`,
buttons: ['Keep', 'Delete'], buttons: ['Delete', 'Keep'],
defaultId: 0, defaultId: 1,
cancelId: 1,
} }
)).response === 1) { )).response === 0) {
if ((await this.platform.showMessageBox( if ((await this.platform.showMessageBox(
{ {
type: 'warning', type: 'warning',
message: `Delete the group's profiles?`, message: `Delete the group's profiles?`,
buttons: ['Move to "Ungrouped"', 'Delete'], buttons: ['Move to "Ungrouped"', 'Delete'],
defaultId: 0, defaultId: 0,
cancelId: 0,
} }
)).response === 0) { )).response === 0) {
for (const profile of this.profiles.filter(x => x.group === group.name)) { for (const profile of this.profiles.filter(x => x.group === group.name)) {
......
...@@ -42,10 +42,11 @@ export class VaultSettingsTabComponent extends BaseComponent { ...@@ -42,10 +42,11 @@ export class VaultSettingsTabComponent extends BaseComponent {
{ {
type: 'warning', type: 'warning',
message: 'Delete vault contents?', message: 'Delete vault contents?',
buttons: ['Keep', 'Delete'], buttons: ['Delete', 'Keep'],
defaultId: 1, defaultId: 1,
cancelId: 1,
} }
)).response === 1) { )).response === 0) {
await this.vault.setEnabled(false) await this.vault.setEnabled(false)
} }
} }
......
...@@ -209,10 +209,11 @@ export class SSHTabComponent extends BaseTerminalTabComponent { ...@@ -209,10 +209,11 @@ export class SSHTabComponent extends BaseTerminalTabComponent {
{ {
type: 'warning', type: 'warning',
message: `Disconnect from ${this.profile?.options.host}?`, message: `Disconnect from ${this.profile?.options.host}?`,
buttons: ['Cancel', 'Disconnect'], buttons: ['Disconnect', 'Do not close'],
defaultId: 1, defaultId: 0,
cancelId: 1,
} }
)).response === 1 )).response === 0
} }
async openSFTP (): Promise<void> { async openSFTP (): Promise<void> {
......
...@@ -27,6 +27,7 @@ export class CommonSFTPContextMenu extends SFTPContextMenuItemProvider { ...@@ -27,6 +27,7 @@ export class CommonSFTPContextMenu extends SFTPContextMenuItemProvider {
type: 'warning', type: 'warning',
message: `Delete ${item.fullPath}?`, message: `Delete ${item.fullPath}?`,
defaultId: 0, defaultId: 0,
cancelId: 1,
buttons: ['Delete', 'Cancel'], buttons: ['Delete', 'Cancel'],
})).response === 0) { })).response === 0) {
await this.deleteItem(item, panel.sftp) await this.deleteItem(item, panel.sftp)
......
...@@ -119,9 +119,10 @@ export class TelnetTabComponent extends BaseTerminalTabComponent { ...@@ -119,9 +119,10 @@ export class TelnetTabComponent extends BaseTerminalTabComponent {
{ {
type: 'warning', type: 'warning',
message: `Disconnect from ${this.profile?.options.host}?`, message: `Disconnect from ${this.profile?.options.host}?`,
buttons: ['Cancel', 'Disconnect'], buttons: ['Disconnect', 'Do not close'],
defaultId: 1, defaultId: 0,
cancelId: 1,
} }
)).response === 1 )).response === 0
} }
} }
...@@ -445,6 +445,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit ...@@ -445,6 +445,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
message: `Paste multiple lines?`, message: `Paste multiple lines?`,
buttons, buttons,
defaultId: 0, defaultId: 0,
cancelId: 1,
} }
)).response )).response
if (result === 1) { if (result === 1) {
......
...@@ -79,10 +79,11 @@ export class ColorSchemeSettingsTabComponent { ...@@ -79,10 +79,11 @@ export class ColorSchemeSettingsTabComponent {
{ {
type: 'warning', type: 'warning',
message: `Delete "${scheme.name}"?`, message: `Delete "${scheme.name}"?`,
buttons: ['Keep', 'Delete'], buttons: ['Delete', 'Keep'],
defaultId: 1, defaultId: 1,
cancelId: 1,
} }
)).response === 1) { )).response === 0) {
this.customColorSchemes = this.customColorSchemes.filter(x => x.name !== scheme.name) this.customColorSchemes = this.customColorSchemes.filter(x => x.name !== scheme.name)
this.config.store.terminal.customColorSchemes = this.customColorSchemes this.config.store.terminal.customColorSchemes = this.customColorSchemes
this.config.save() this.config.save()
......
...@@ -27,10 +27,11 @@ export class LoginScriptsSettingsComponent { ...@@ -27,10 +27,11 @@ export class LoginScriptsSettingsComponent {
type: 'warning', type: 'warning',
message: 'Delete this script?', message: 'Delete this script?',
detail: script.expect, detail: script.expect,
buttons: ['Keep', 'Delete'], buttons: ['Delete', 'Keep'],
defaultId: 1, defaultId: 0,
cancelId: 1,
} }
)).response === 1) { )).response === 0) {
this.scripts = this.scripts.filter(x => x !== script) this.scripts = this.scripts.filter(x => x !== script)
} }
} }
......
...@@ -100,7 +100,7 @@ export class WebPlatformService extends PlatformService { ...@@ -100,7 +100,7 @@ export class WebPlatformService extends PlatformService {
const response = await modal.result const response = await modal.result
return { response } return { response }
} catch { } catch {
return { response: 0 } return { response: options.cancelId ?? 1 }
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册