set default cancel button in message boxes

上级 ab8061ab
......@@ -13,6 +13,7 @@ export interface MessageBoxOptions {
detail?: string
buttons: string[]
defaultId?: number
cancelId?: number
}
export interface MessageBoxResult {
......
......@@ -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
}
......
......@@ -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()
......
......@@ -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()
}
......
......@@ -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 {
......
......@@ -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
}
......
......@@ -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)) {
......
......@@ -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)
}
}
......
......@@ -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> {
......
......@@ -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)
......
......@@ -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
}
}
......@@ -445,6 +445,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
message: `Paste multiple lines?`,
buttons,
defaultId: 0,
cancelId: 1,
}
)).response
if (result === 1) {
......
......@@ -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()
......
......@@ -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)
}
}
......
......@@ -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 }
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册