1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-22 20:55:03 +03:00

set default cancel button in message boxes

This commit is contained in:
Eugene Pankov 2021-08-02 21:01:35 +02:00
parent ab8061ab39
commit edd7e9c7b7
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
15 changed files with 43 additions and 26 deletions

View File

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

View File

@ -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
}

View File

@ -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()

View File

@ -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()
}

View File

@ -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 {

View File

@ -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
}

View File

@ -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)) {

View File

@ -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)
}
}

View File

@ -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> {

View File

@ -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)

View File

@ -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
}
}

View File

@ -445,6 +445,7 @@ export class BaseTerminalTabComponent extends BaseTabComponent implements OnInit
message: `Paste multiple lines?`,
buttons,
defaultId: 0,
cancelId: 1,
}
)).response
if (result === 1) {

View File

@ -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()

View File

@ -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)
}
}

View File

@ -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 }
}
}