mirror of
https://github.com/Eugeny/tabby.git
synced 2025-09-12 03:14:38 +00:00
fixed #7588 - prevent selector from opening when one is already open
This commit is contained in:
@@ -204,6 +204,10 @@ export default class AppModule { // eslint-disable-line @typescript-eslint/no-ex
|
|||||||
}
|
}
|
||||||
|
|
||||||
async showSelector (provider: ProfileProvider<Profile>): Promise<void> {
|
async showSelector (provider: ProfileProvider<Profile>): Promise<void> {
|
||||||
|
if (this.selector.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
let profiles = await this.profilesService.getProfiles()
|
let profiles = await this.profilesService.getProfiles()
|
||||||
|
|
||||||
profiles = profiles.filter(x => !x.isTemplate && x.type === provider.id)
|
profiles = profiles.filter(x => !x.isTemplate && x.type === provider.id)
|
||||||
|
@@ -67,6 +67,10 @@ export class CommandService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async showSelector (): Promise<void> {
|
async showSelector (): Promise<void> {
|
||||||
|
if (this.selector.active) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const context: CommandContext = {}
|
const context: CommandContext = {}
|
||||||
const tab = this.app.activeTab
|
const tab = this.app.activeTab
|
||||||
if (tab instanceof SplitTabComponent) {
|
if (tab instanceof SplitTabComponent) {
|
||||||
|
@@ -106,6 +106,10 @@ export class ProfilesService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
showProfileSelector (): Promise<PartialProfile<Profile>|null> {
|
showProfileSelector (): Promise<PartialProfile<Profile>|null> {
|
||||||
|
if (this.selector.active) {
|
||||||
|
return Promise.resolve(null)
|
||||||
|
}
|
||||||
|
|
||||||
return new Promise<PartialProfile<Profile>|null>(async (resolve, reject) => {
|
return new Promise<PartialProfile<Profile>|null>(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
const recentProfiles = this.getRecentProfiles()
|
const recentProfiles = this.getRecentProfiles()
|
||||||
|
@@ -1,12 +1,18 @@
|
|||||||
|
|
||||||
import { Injectable } from '@angular/core'
|
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 { SelectorModalComponent } from '../components/selectorModal.component'
|
||||||
import { SelectorOption } from '../api/selector'
|
import { SelectorOption } from '../api/selector'
|
||||||
|
|
||||||
@Injectable({ providedIn: 'root' })
|
@Injectable({ providedIn: 'root' })
|
||||||
export class SelectorService {
|
export class SelectorService {
|
||||||
|
private current: NgbModalRef|null = null
|
||||||
|
|
||||||
|
get active (): boolean {
|
||||||
|
return !!this.current
|
||||||
|
}
|
||||||
|
|
||||||
/** @hidden */
|
/** @hidden */
|
||||||
private constructor (
|
private constructor (
|
||||||
private ngbModal: NgbModal,
|
private ngbModal: NgbModal,
|
||||||
@@ -14,6 +20,10 @@ export class SelectorService {
|
|||||||
|
|
||||||
show <T> (name: string, options: SelectorOption<T>[]): Promise<T> {
|
show <T> (name: string, options: SelectorOption<T>[]): Promise<T> {
|
||||||
const modal = this.ngbModal.open(SelectorModalComponent)
|
const modal = this.ngbModal.open(SelectorModalComponent)
|
||||||
|
this.current = modal
|
||||||
|
modal.result.then(() => {
|
||||||
|
this.current = null
|
||||||
|
})
|
||||||
const instance: SelectorModalComponent<T> = modal.componentInstance
|
const instance: SelectorModalComponent<T> = modal.componentInstance
|
||||||
instance.name = name
|
instance.name = name
|
||||||
instance.options = options
|
instance.options = options
|
||||||
|
Reference in New Issue
Block a user