1
1
mirror of https://github.com/Eugeny/tabby.git synced 2024-11-27 00:50:49 +03:00

fixed #7588 - prevent selector from opening when one is already open

This commit is contained in:
Eugene Pankov 2022-12-03 12:27:58 +01:00
parent 7b2bc5e48b
commit fa1649de83
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4
4 changed files with 23 additions and 1 deletions

View File

@ -204,6 +204,10 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
}
async showSelector (provider: ProfileProvider<Profile>): Promise<void> {
if (this.selector.active) {
return
}
let profiles = await this.profilesService.getProfiles()
profiles = profiles.filter(x => !x.isTemplate && x.type === provider.id)

View File

@ -67,6 +67,10 @@ export class CommandService {
}
async showSelector (): Promise<void> {
if (this.selector.active) {
return
}
const context: CommandContext = {}
const tab = this.app.activeTab
if (tab instanceof SplitTabComponent) {

View File

@ -106,6 +106,10 @@ export class ProfilesService {
}
showProfileSelector (): Promise<PartialProfile<Profile>|null> {
if (this.selector.active) {
return Promise.resolve(null)
}
return new Promise<PartialProfile<Profile>|null>(async (resolve, reject) => {
try {
const recentProfiles = this.getRecentProfiles()

View File

@ -1,12 +1,18 @@
import { Injectable } from '@angular/core'
import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap'
import { SelectorModalComponent } from '../components/selectorModal.component'
import { SelectorOption } from '../api/selector'
@Injectable({ providedIn: 'root' })
export class SelectorService {
private current: NgbModalRef|null = null
get active (): boolean {
return !!this.current
}
/** @hidden */
private constructor (
private ngbModal: NgbModal,
@ -14,6 +20,10 @@ export class SelectorService {
show <T> (name: string, options: SelectorOption<T>[]): Promise<T> {
const modal = this.ngbModal.open(SelectorModalComponent)
this.current = modal
modal.result.then(() => {
this.current = null
})
const instance: SelectorModalComponent<T> = modal.componentInstance
instance.name = name
instance.options = options