mirror of
https://github.com/Eugeny/tabby.git
synced 2025-07-04 18:39:54 +00:00
Update buttonProvider.ts
This commit is contained in:
parent
c49ff68ed6
commit
f39b4c6dbe
@ -35,21 +35,21 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
|||||||
async activate () {
|
async activate () {
|
||||||
const recentProfiles: Profile[] = this.config.store.recentProfiles
|
const recentProfiles: Profile[] = this.config.store.recentProfiles
|
||||||
|
|
||||||
const getProfileOptions = (profile): SelectorOption<void> => {
|
let options: SelectorOption<void>[] = recentProfiles.map(p => ({
|
||||||
const result: SelectorOption<void> = this.profilesServices.selectorOptionForProfile(profile)
|
...this.profilesServices.selectorOptionForProfile(p),
|
||||||
if (recentProfiles.includes(profile)) {
|
icon: 'fas fa-history',
|
||||||
result.icon = 'fas fa-history'
|
callback: async () => {
|
||||||
|
if (p.id) {
|
||||||
|
p = (await this.profilesServices.getProfiles()).find(x => x.id === p.id) ?? p
|
||||||
}
|
}
|
||||||
result.callback = () => this.launchProfile(profile)
|
this.launchProfile(p)
|
||||||
return result
|
},
|
||||||
}
|
}))
|
||||||
|
|
||||||
let options = recentProfiles.map(getProfileOptions)
|
|
||||||
if (recentProfiles.length) {
|
if (recentProfiles.length) {
|
||||||
options.push({
|
options.push({
|
||||||
name: 'Clear recent connections',
|
name: 'Clear recent connections',
|
||||||
icon: 'fas fa-eraser',
|
icon: 'fas fa-eraser',
|
||||||
callback: () => {
|
callback: async () => {
|
||||||
this.config.store.recentProfiles = []
|
this.config.store.recentProfiles = []
|
||||||
this.config.save()
|
this.config.save()
|
||||||
},
|
},
|
||||||
@ -64,7 +64,10 @@ export class ButtonProvider extends ToolbarButtonProvider {
|
|||||||
|
|
||||||
profiles = profiles.filter(x => !x.isTemplate)
|
profiles = profiles.filter(x => !x.isTemplate)
|
||||||
|
|
||||||
options = [...options, ...profiles.map(getProfileOptions)]
|
options = [...options, ...profiles.map((p): SelectorOption<void> => ({
|
||||||
|
...this.profilesServices.selectorOptionForProfile(p),
|
||||||
|
callback: () => this.launchProfile(p),
|
||||||
|
}))]
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const { SettingsTabComponent } = window['nodeRequire']('tabby-settings')
|
const { SettingsTabComponent } = window['nodeRequire']('tabby-settings')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user