Update buttonProvider.ts

This commit is contained in:
Eugene Pankov 2021-07-10 14:47:41 +02:00
parent c49ff68ed6
commit f39b4c6dbe
No known key found for this signature in database
GPG Key ID: 5896FCBBDD1CF4F4

View File

@ -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) {
result.callback = () => this.launchProfile(profile) p = (await this.profilesServices.getProfiles()).find(x => x.id === p.id) ?? p
return result }
} this.launchProfile(p)
},
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')