mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-09 05:50:08 +00:00
fix: avoid error Uncaught (in promise) on modal dismiss
This commit is contained in:
parent
d2752382aa
commit
d21282501f
@ -285,7 +285,7 @@ export class VaultFileProvider extends FileProvider {
|
|||||||
icon: 'fas fa-file',
|
icon: 'fas fa-file',
|
||||||
result: f,
|
result: f,
|
||||||
})),
|
})),
|
||||||
])
|
]).catch(() => null)
|
||||||
if (result) {
|
if (result) {
|
||||||
return `${this.prefix}${result.key.id}`
|
return `${this.prefix}${result.key.id}`
|
||||||
}
|
}
|
||||||
|
@ -149,7 +149,7 @@ export class CommonOptionsContextMenu extends TabContextMenuItemProvider {
|
|||||||
click: async () => {
|
click: async () => {
|
||||||
const modal = this.ngbModal.open(PromptModalComponent)
|
const modal = this.ngbModal.open(PromptModalComponent)
|
||||||
modal.componentInstance.prompt = this.translate.instant('Profile name')
|
modal.componentInstance.prompt = this.translate.instant('Profile name')
|
||||||
const name = (await modal.result)?.value
|
const name = (await modal.result.catch(() => null))?.value
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -59,7 +59,7 @@ export class ConfigSyncSettingsTabComponent extends BaseComponent {
|
|||||||
const modal = this.ngbModal.open(PromptModalComponent)
|
const modal = this.ngbModal.open(PromptModalComponent)
|
||||||
modal.componentInstance.prompt = this.translate.instant('Name for the new config')
|
modal.componentInstance.prompt = this.translate.instant('Name for the new config')
|
||||||
modal.componentInstance.value = name
|
modal.componentInstance.value = name
|
||||||
name = (await modal.result)?.value
|
name = (await modal.result.catch(() => null))?.value
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -144,7 +144,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
async newProfileGroup (): Promise<void> {
|
async newProfileGroup (): Promise<void> {
|
||||||
const modal = this.ngbModal.open(PromptModalComponent)
|
const modal = this.ngbModal.open(PromptModalComponent)
|
||||||
modal.componentInstance.prompt = this.translate.instant('New group name')
|
modal.componentInstance.prompt = this.translate.instant('New group name')
|
||||||
const result = await modal.result
|
const result = await modal.result.catch(() => null)
|
||||||
if (result?.value.trim()) {
|
if (result?.value.trim()) {
|
||||||
await this.profilesService.newProfileGroup({ id: '', name: result.value })
|
await this.profilesService.newProfileGroup({ id: '', name: result.value })
|
||||||
}
|
}
|
||||||
@ -296,8 +296,8 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
modal.componentInstance.profile = Object.assign({}, model)
|
modal.componentInstance.profile = Object.assign({}, model)
|
||||||
modal.componentInstance.profileProvider = provider
|
modal.componentInstance.profileProvider = provider
|
||||||
modal.componentInstance.defaultsMode = 'enabled'
|
modal.componentInstance.defaultsMode = 'enabled'
|
||||||
const result = await modal.result
|
const result = await modal.result.catch(() => null)
|
||||||
|
if (result) {
|
||||||
// Fully replace the config
|
// Fully replace the config
|
||||||
for (const k in model) {
|
for (const k in model) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
|
||||||
@ -307,6 +307,7 @@ export class ProfilesSettingsTabComponent extends BaseComponent {
|
|||||||
this.profilesService.setProviderDefaults(provider, model)
|
this.profilesService.setProviderDefaults(provider, model)
|
||||||
await this.config.save()
|
await this.config.save()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async deleteDefaults (provider: ProfileProvider<Profile>): Promise<void> {
|
async deleteDefaults (provider: ProfileProvider<Profile>): Promise<void> {
|
||||||
if ((await this.platform.showMessageBox(
|
if ((await this.platform.showMessageBox(
|
||||||
|
@ -35,10 +35,12 @@ export class VaultSettingsTabComponent extends BaseComponent {
|
|||||||
|
|
||||||
async enableVault () {
|
async enableVault () {
|
||||||
const modal = this.ngbModal.open(SetVaultPassphraseModalComponent)
|
const modal = this.ngbModal.open(SetVaultPassphraseModalComponent)
|
||||||
const newPassphrase = await modal.result
|
const newPassphrase = await modal.result.catch(() => null)
|
||||||
|
if (newPassphrase) {
|
||||||
await this.vault.setEnabled(true, newPassphrase)
|
await this.vault.setEnabled(true, newPassphrase)
|
||||||
this.vaultContents = await this.vault.load(newPassphrase)
|
this.vaultContents = await this.vault.load(newPassphrase)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async disableVault () {
|
async disableVault () {
|
||||||
if ((await this.platform.showMessageBox(
|
if ((await this.platform.showMessageBox(
|
||||||
@ -65,9 +67,11 @@ export class VaultSettingsTabComponent extends BaseComponent {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
const modal = this.ngbModal.open(SetVaultPassphraseModalComponent)
|
const modal = this.ngbModal.open(SetVaultPassphraseModalComponent)
|
||||||
const newPassphrase = await modal.result
|
const newPassphrase = await modal.result.catch(() => null)
|
||||||
|
if (newPassphrase) {
|
||||||
this.vault.save(this.vaultContents, newPassphrase)
|
this.vault.save(this.vaultContents, newPassphrase)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async toggleConfigEncrypted () {
|
async toggleConfigEncrypted () {
|
||||||
this.config.store.encrypted = !this.config.store.encrypted
|
this.config.store.encrypted = !this.config.store.encrypted
|
||||||
@ -118,7 +122,7 @@ export class VaultSettingsTabComponent extends BaseComponent {
|
|||||||
modal.componentInstance.prompt = this.translate.instant('New name')
|
modal.componentInstance.prompt = this.translate.instant('New name')
|
||||||
modal.componentInstance.value = secret.key.description
|
modal.componentInstance.value = secret.key.description
|
||||||
|
|
||||||
const description = (await modal.result)?.value
|
const description = (await modal.result.catch(() => null))?.value
|
||||||
if (!description) {
|
if (!description) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -113,8 +113,8 @@ export class SFTPPanelComponent {
|
|||||||
|
|
||||||
async openCreateDirectoryModal (): Promise<void> {
|
async openCreateDirectoryModal (): Promise<void> {
|
||||||
const modal = this.ngbModal.open(SFTPCreateDirectoryModalComponent)
|
const modal = this.ngbModal.open(SFTPCreateDirectoryModalComponent)
|
||||||
const directoryName = await modal.result
|
const directoryName = await modal.result.catch(() => null)
|
||||||
if (directoryName !== '') {
|
if (directoryName?.trim()) {
|
||||||
this.sftp.mkdir(path.join(this.path, directoryName)).then(() => {
|
this.sftp.mkdir(path.join(this.path, directoryName)).then(() => {
|
||||||
this.notifications.notice('The directory was created successfully')
|
this.notifications.notice('The directory was created successfully')
|
||||||
this.navigate(path.join(this.path, directoryName))
|
this.navigate(path.join(this.path, directoryName))
|
||||||
|
@ -75,7 +75,7 @@ export class SSHProfileSettingsComponent {
|
|||||||
modal.componentInstance.prompt = `Password for ${this.profile.options.user}@${this.profile.options.host}`
|
modal.componentInstance.prompt = `Password for ${this.profile.options.user}@${this.profile.options.host}`
|
||||||
modal.componentInstance.password = true
|
modal.componentInstance.password = true
|
||||||
try {
|
try {
|
||||||
const result = await modal.result
|
const result = await modal.result.catch(() => null)
|
||||||
if (result?.value) {
|
if (result?.value) {
|
||||||
this.passwordStorage.savePassword(this.profile, result.value)
|
this.passwordStorage.savePassword(this.profile, result.value)
|
||||||
this.hasSavedPassword = true
|
this.hasSavedPassword = true
|
||||||
@ -89,12 +89,14 @@ export class SSHProfileSettingsComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async addPrivateKey () {
|
async addPrivateKey () {
|
||||||
const ref = await this.fileProviders.selectAndStoreFile(`private key for ${this.profile.name}`)
|
const ref = await this.fileProviders.selectAndStoreFile(`private key for ${this.profile.name}`).catch(() => null)
|
||||||
|
if (ref) {
|
||||||
this.profile.options.privateKeys = [
|
this.profile.options.privateKeys = [
|
||||||
...this.profile.options.privateKeys!,
|
...this.profile.options.privateKeys!,
|
||||||
ref,
|
ref,
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
removePrivateKey (path: string) {
|
removePrivateKey (path: string) {
|
||||||
this.profile.options.privateKeys = this.profile.options.privateKeys?.filter(x => x !== path)
|
this.profile.options.privateKeys = this.profile.options.privateKeys?.filter(x => x !== path)
|
||||||
|
@ -210,7 +210,6 @@ export class SSHSession {
|
|||||||
if (!await this.verifyHostKey(handshake)) {
|
if (!await this.verifyHostKey(handshake)) {
|
||||||
this.ssh.end()
|
this.ssh.end()
|
||||||
reject(new Error('Host key verification failed'))
|
reject(new Error('Host key verification failed'))
|
||||||
return
|
|
||||||
}
|
}
|
||||||
this.logger.info('Handshake complete:', handshake)
|
this.logger.info('Handshake complete:', handshake)
|
||||||
resolve()
|
resolve()
|
||||||
@ -300,7 +299,7 @@ export class SSHSession {
|
|||||||
const modal = this.ngbModal.open(PromptModalComponent)
|
const modal = this.ngbModal.open(PromptModalComponent)
|
||||||
modal.componentInstance.prompt = `Username for ${this.profile.options.host}`
|
modal.componentInstance.prompt = `Username for ${this.profile.options.host}`
|
||||||
try {
|
try {
|
||||||
const result = await modal.result
|
const result = await modal.result.catch(() => null)
|
||||||
this.authUsername = result?.value ?? null
|
this.authUsername = result?.value ?? null
|
||||||
} catch {
|
} catch {
|
||||||
this.authUsername = 'root'
|
this.authUsername = 'root'
|
||||||
@ -428,11 +427,7 @@ export class SSHSession {
|
|||||||
const modal = this.ngbModal.open(HostKeyPromptModalComponent)
|
const modal = this.ngbModal.open(HostKeyPromptModalComponent)
|
||||||
modal.componentInstance.selector = selector
|
modal.componentInstance.selector = selector
|
||||||
modal.componentInstance.digest = this.hostKeyDigest
|
modal.componentInstance.digest = this.hostKeyDigest
|
||||||
try {
|
return modal.result.catch(() => false)
|
||||||
return await modal.result
|
|
||||||
} catch {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -495,7 +490,7 @@ export class SSHSession {
|
|||||||
modal.componentInstance.showRememberCheckbox = true
|
modal.componentInstance.showRememberCheckbox = true
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const result = await modal.result
|
const result = await modal.result.catch(() => null)
|
||||||
if (result) {
|
if (result) {
|
||||||
if (result.remember) {
|
if (result.remember) {
|
||||||
this.savedPassword = result.value
|
this.savedPassword = result.value
|
||||||
|
@ -53,6 +53,6 @@ export class CommonSFTPContextMenu extends SFTPContextMenuItemProvider {
|
|||||||
const modal = this.ngbModal.open(SFTPDeleteModalComponent)
|
const modal = this.ngbModal.open(SFTPDeleteModalComponent)
|
||||||
modal.componentInstance.item = item
|
modal.componentInstance.item = item
|
||||||
modal.componentInstance.sftp = session
|
modal.componentInstance.sftp = session
|
||||||
await modal.result
|
await modal.result.catch(() => {return})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,7 +175,7 @@ export class SaveAsProfileContextMenu extends TabContextMenuItemProvider {
|
|||||||
const modal = this.ngbModal.open(PromptModalComponent)
|
const modal = this.ngbModal.open(PromptModalComponent)
|
||||||
modal.componentInstance.prompt = this.translate.instant('New profile name')
|
modal.componentInstance.prompt = this.translate.instant('New profile name')
|
||||||
modal.componentInstance.value = tab.profile.name
|
modal.componentInstance.value = tab.profile.name
|
||||||
const name = (await modal.result)?.value
|
const name = (await modal.result.catch(() => null))?.value
|
||||||
if (!name) {
|
if (!name) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user