mirror of
https://github.com/Eugeny/tabby.git
synced 2024-12-25 19:42:42 +03:00
better messageboxes
This commit is contained in:
parent
d5b6a686f8
commit
9faa346699
@ -15,6 +15,8 @@ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'
|
|||||||
import { getRootModule } from './app.module'
|
import { getRootModule } from './app.module'
|
||||||
import { findPlugins, loadPlugins, IPluginInfo } from './plugins'
|
import { findPlugins, loadPlugins, IPluginInfo } from './plugins'
|
||||||
|
|
||||||
|
;(process as any).enablePromiseAPI = true
|
||||||
|
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
process.env.HOME = process.env.HOMEDRIVE + process.env.HOMEPATH
|
process.env.HOME = process.env.HOMEDRIVE + process.env.HOMEPATH
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,11 @@
|
|||||||
import { Injectable } from '@angular/core'
|
import { Injectable } from '@angular/core'
|
||||||
import { TouchBar, BrowserWindow, Menu, MenuItem } from 'electron'
|
import { TouchBar, BrowserWindow, Menu, MenuItem } from 'electron'
|
||||||
|
|
||||||
|
export interface MessageBoxResponse {
|
||||||
|
response: number
|
||||||
|
checkboxChecked?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class ElectronService {
|
export class ElectronService {
|
||||||
app: any
|
app: any
|
||||||
@ -54,4 +59,15 @@ export class ElectronService {
|
|||||||
this.remote.Menu.sendActionToFirstResponder('hide:')
|
this.remote.Menu.sendActionToFirstResponder('hide:')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
showMessageBox (
|
||||||
|
browserWindow: Electron.BrowserWindow,
|
||||||
|
options: Electron.MessageBoxOptions
|
||||||
|
): Promise<MessageBoxResponse> {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
this.dialog.showMessageBox(browserWindow, options, (response, checkboxChecked) => {
|
||||||
|
resolve({ response, checkboxChecked })
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ button.btn.btn-outline-warning.btn-block(*ngIf='config.restartRequested', '(clic
|
|||||||
ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
||||||
ngb-tab(id='application')
|
ngb-tab(id='application')
|
||||||
ng-template(ngbTabTitle)
|
ng-template(ngbTabTitle)
|
||||||
|
i.fas.fa-fw.fa-window-maximize.mr-2
|
||||||
| Application
|
| Application
|
||||||
ng-template(ngbTabContent)
|
ng-template(ngbTabContent)
|
||||||
.d-flex.align-items-center.mb-4
|
.d-flex.align-items-center.mb-4
|
||||||
@ -247,6 +248,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
|||||||
|
|
||||||
ngb-tab(id='hotkeys')
|
ngb-tab(id='hotkeys')
|
||||||
ng-template(ngbTabTitle)
|
ng-template(ngbTabTitle)
|
||||||
|
i.fas.fa-fw.fa-keyboard.mr-2
|
||||||
| Hotkeys
|
| Hotkeys
|
||||||
ng-template(ngbTabContent)
|
ng-template(ngbTabContent)
|
||||||
h3.mb-3 Hotkeys
|
h3.mb-3 Hotkeys
|
||||||
@ -274,6 +276,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
|||||||
|
|
||||||
ngb-tab(*ngFor='let provider of settingsProviders', [id]='provider.id')
|
ngb-tab(*ngFor='let provider of settingsProviders', [id]='provider.id')
|
||||||
ng-template(ngbTabTitle)
|
ng-template(ngbTabTitle)
|
||||||
|
i(class='fas fa-fw mr-2 fa-{{provider.icon || "puzzle-piece"}}')
|
||||||
| {{provider.title}}
|
| {{provider.title}}
|
||||||
ng-template(ngbTabContent)
|
ng-template(ngbTabContent)
|
||||||
settings-tab-body([provider]='provider')
|
settings-tab-body([provider]='provider')
|
||||||
@ -281,6 +284,7 @@ ngb-tabset.vertical(type='pills', [activeId]='activeTab')
|
|||||||
|
|
||||||
ngb-tab(id='config-file')
|
ngb-tab(id='config-file')
|
||||||
ng-template(ngbTabTitle)
|
ng-template(ngbTabTitle)
|
||||||
|
i.fas.fa-fw.fa-code.mr-2
|
||||||
| Config file
|
| Config file
|
||||||
ng-template.test(ngbTabContent)
|
ng-template.test(ngbTabContent)
|
||||||
.d-flex.flex-column.w-100.h-100
|
.d-flex.flex-column.w-100.h-100
|
||||||
|
@ -66,8 +66,17 @@ export class EditConnectionModalComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteScript (script: LoginScript) {
|
async deleteScript (script: LoginScript) {
|
||||||
if (confirm(`Delete?`)) {
|
if ((await this.electron.showMessageBox(
|
||||||
|
this.hostApp.getWindow(),
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
message: 'Delete this script?',
|
||||||
|
detail: script.expect,
|
||||||
|
buttons: ['Keep', 'Delete'],
|
||||||
|
defaultId: 1,
|
||||||
|
}
|
||||||
|
)).response === 1) {
|
||||||
this.connection.scripts = this.connection.scripts.filter(x => x !== script)
|
this.connection.scripts = this.connection.scripts.filter(x => x !== script)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { Component } from '@angular/core'
|
import { Component } from '@angular/core'
|
||||||
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { ConfigService } from 'terminus-core'
|
import { ConfigService, ElectronService, HostAppService } from 'terminus-core'
|
||||||
import { SSHConnection, ISSHConnectionGroup } from '../api'
|
import { SSHConnection, ISSHConnectionGroup } from '../api'
|
||||||
import { EditConnectionModalComponent } from './editConnectionModal.component'
|
import { EditConnectionModalComponent } from './editConnectionModal.component'
|
||||||
import { PromptModalComponent } from './promptModal.component'
|
import { PromptModalComponent } from './promptModal.component'
|
||||||
@ -15,6 +15,8 @@ export class SSHSettingsTabComponent {
|
|||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
public config: ConfigService,
|
public config: ConfigService,
|
||||||
|
private electron: ElectronService,
|
||||||
|
private hostApp: HostAppService,
|
||||||
private ngbModal: NgbModal,
|
private ngbModal: NgbModal,
|
||||||
) {
|
) {
|
||||||
this.connections = this.config.store.ssh.connections
|
this.connections = this.config.store.ssh.connections
|
||||||
@ -49,8 +51,16 @@ export class SSHSettingsTabComponent {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteConnection (connection: SSHConnection) {
|
async deleteConnection (connection: SSHConnection) {
|
||||||
if (confirm(`Delete "${connection.name}"?`)) {
|
if ((await this.electron.showMessageBox(
|
||||||
|
this.hostApp.getWindow(),
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
message: `Delete "${connection.name}"?`,
|
||||||
|
buttons: ['Keep', 'Delete'],
|
||||||
|
defaultId: 1,
|
||||||
|
}
|
||||||
|
)).response === 1) {
|
||||||
this.connections = this.connections.filter(x => x !== connection)
|
this.connections = this.connections.filter(x => x !== connection)
|
||||||
this.config.store.ssh.connections = this.connections
|
this.config.store.ssh.connections = this.connections
|
||||||
this.config.save()
|
this.config.save()
|
||||||
@ -73,8 +83,16 @@ export class SSHSettingsTabComponent {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteGroup (group: ISSHConnectionGroup) {
|
async deleteGroup (group: ISSHConnectionGroup) {
|
||||||
if (confirm(`Delete "${group}"?`)) {
|
if ((await this.electron.showMessageBox(
|
||||||
|
this.hostApp.getWindow(),
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
message: `Delete "${group}"?`,
|
||||||
|
buttons: ['Keep', 'Delete'],
|
||||||
|
defaultId: 1,
|
||||||
|
}
|
||||||
|
)).response === 1) {
|
||||||
for (let connection of this.connections.filter(x => x.group === group.name)) {
|
for (let connection of this.connections.filter(x => x.group === group.name)) {
|
||||||
connection.group = null
|
connection.group = null
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import deepEqual = require('deep-equal')
|
|||||||
const fontManager = require('font-manager')
|
const fontManager = require('font-manager')
|
||||||
|
|
||||||
import { Component, Inject } from '@angular/core'
|
import { Component, Inject } from '@angular/core'
|
||||||
import { ConfigService, HostAppService, Platform } from 'terminus-core'
|
import { ConfigService, HostAppService, Platform, ElectronService } from 'terminus-core'
|
||||||
import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api'
|
import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api'
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
@ -22,6 +22,7 @@ export class AppearanceSettingsTabComponent {
|
|||||||
constructor (
|
constructor (
|
||||||
@Inject(TerminalColorSchemeProvider) private colorSchemeProviders: TerminalColorSchemeProvider[],
|
@Inject(TerminalColorSchemeProvider) private colorSchemeProviders: TerminalColorSchemeProvider[],
|
||||||
private hostApp: HostAppService,
|
private hostApp: HostAppService,
|
||||||
|
private electron: ElectronService,
|
||||||
public config: ConfigService,
|
public config: ConfigService,
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
@ -71,8 +72,16 @@ export class AppearanceSettingsTabComponent {
|
|||||||
this.editingColorScheme = null
|
this.editingColorScheme = null
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteScheme (scheme: ITerminalColorScheme) {
|
async deleteScheme (scheme: ITerminalColorScheme) {
|
||||||
if (confirm(`Delete "${scheme.name}"?`)) {
|
if ((await this.electron.showMessageBox(
|
||||||
|
this.hostApp.getWindow(),
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
message: `Delete "${scheme.name}"?`,
|
||||||
|
buttons: ['Keep', 'Delete'],
|
||||||
|
defaultId: 1,
|
||||||
|
}
|
||||||
|
)).response === 1) {
|
||||||
let schemes = this.config.store.terminal.customColorSchemes
|
let schemes = this.config.store.terminal.customColorSchemes
|
||||||
schemes = schemes.filter(x => x !== scheme)
|
schemes = schemes.filter(x => x !== scheme)
|
||||||
this.config.store.terminal.customColorSchemes = schemes
|
this.config.store.terminal.customColorSchemes = schemes
|
||||||
|
@ -48,10 +48,13 @@ export class ShellSettingsTabComponent {
|
|||||||
pickWorkingDirectory () {
|
pickWorkingDirectory () {
|
||||||
let shell = this.shells.find(x => x.id === this.config.store.terminal.shell)
|
let shell = this.shells.find(x => x.id === this.config.store.terminal.shell)
|
||||||
console.log(shell)
|
console.log(shell)
|
||||||
let paths = this.electron.dialog.showOpenDialog({
|
let paths = this.electron.dialog.showOpenDialog(
|
||||||
|
this.hostApp.getWindow(),
|
||||||
|
{
|
||||||
defaultPath: shell.fsBase,
|
defaultPath: shell.fsBase,
|
||||||
properties: ['openDirectory', 'showHiddenFiles'],
|
properties: ['openDirectory', 'showHiddenFiles'],
|
||||||
})
|
}
|
||||||
|
)
|
||||||
if (paths) {
|
if (paths) {
|
||||||
this.config.store.terminal.workingDirectory = paths[0]
|
this.config.store.terminal.workingDirectory = paths[0]
|
||||||
}
|
}
|
||||||
|
@ -380,7 +380,15 @@ export class TerminalTabComponent extends BaseTabComponent {
|
|||||||
if (children.length === 0) {
|
if (children.length === 0) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return confirm(`"${children[0].command}" is still running. Close?`)
|
return (await this.electron.showMessageBox(
|
||||||
|
this.hostApp.getWindow(),
|
||||||
|
{
|
||||||
|
type: 'warning',
|
||||||
|
message: `"${children[0].command}" is still running. Close?`,
|
||||||
|
buttons: ['Cancel', 'Kill'],
|
||||||
|
defaultId: 1,
|
||||||
|
}
|
||||||
|
)).response === 1
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveAsProfile () {
|
async saveAsProfile () {
|
||||||
|
Loading…
Reference in New Issue
Block a user