mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-08 13:30:02 +00:00
feat: installed plugin search bar
This commit is contained in:
parent
72db81aafa
commit
ddfe073cf8
@ -60,8 +60,19 @@ ul.nav-tabs.mb-2(ngbNav, #nav='ngbNav')
|
|||||||
li(ngbNavItem)
|
li(ngbNavItem)
|
||||||
a(ngbNavLink, translate) Installed
|
a(ngbNavLink, translate) Installed
|
||||||
ng-template(ngbNavContent)
|
ng-template(ngbNavContent)
|
||||||
|
.input-group.mb-3.mt-3
|
||||||
|
.input-group-prepend
|
||||||
|
.input-group-text
|
||||||
|
i.fas.fa-fw.fa-search
|
||||||
|
input.form-control(
|
||||||
|
type='text',
|
||||||
|
[(ngModel)]='_2',
|
||||||
|
(ngModelChange)='searchInstalled(_2)',
|
||||||
|
[placeholder]='"Search plugins"|translate'
|
||||||
|
)
|
||||||
|
|
||||||
ngb-accordion.mb-4([closeOthers]='true')
|
ngb-accordion.mb-4([closeOthers]='true')
|
||||||
ng-container(*ngFor='let plugin of pluginManager.installedPlugins')
|
ng-container(*ngFor='let plugin of installedPlugins$')
|
||||||
ngb-panel
|
ngb-panel
|
||||||
ng-template(ngbPanelTitle)
|
ng-template(ngbPanelTitle)
|
||||||
.text-left.mr-auto
|
.text-left.mr-auto
|
||||||
|
@ -23,6 +23,7 @@ export class PluginsSettingsTabComponent {
|
|||||||
@Input() availablePlugins$: Observable<PluginInfo[]>
|
@Input() availablePlugins$: Observable<PluginInfo[]>
|
||||||
@Input() availablePluginsQuery$ = new BehaviorSubject<string>('')
|
@Input() availablePluginsQuery$ = new BehaviorSubject<string>('')
|
||||||
@Input() availablePluginsReady = false
|
@Input() availablePluginsReady = false
|
||||||
|
@Input() installedPluginsQuery$ = new BehaviorSubject<string>('')
|
||||||
@Input() knownUpgrades: Record<string, PluginInfo|null> = {}
|
@Input() knownUpgrades: Record<string, PluginInfo|null> = {}
|
||||||
@Input() busy = new Map<string, BusyState>()
|
@Input() busy = new Map<string, BusyState>()
|
||||||
@Input() erroredPlugin: string
|
@Input() erroredPlugin: string
|
||||||
@ -30,6 +31,8 @@ export class PluginsSettingsTabComponent {
|
|||||||
|
|
||||||
@HostBinding('class.content-box') true
|
@HostBinding('class.content-box') true
|
||||||
|
|
||||||
|
installedPlugins$: PluginInfo[] = []
|
||||||
|
|
||||||
constructor (
|
constructor (
|
||||||
private config: ConfigService,
|
private config: ConfigService,
|
||||||
private platform: PlatformService,
|
private platform: PlatformService,
|
||||||
@ -58,6 +61,18 @@ export class PluginsSettingsTabComponent {
|
|||||||
this.knownUpgrades[plugin.name] = available.find(x => x.name === plugin.name && semverGt(x.version, plugin.version)) ?? null
|
this.knownUpgrades[plugin.name] = available.find(x => x.name === plugin.name && semverGt(x.version, plugin.version)) ?? null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
this.installedPluginsQuery$
|
||||||
|
.asObservable()
|
||||||
|
.pipe(
|
||||||
|
debounceTime(200),
|
||||||
|
distinctUntilChanged(),
|
||||||
|
flatMap(query => {
|
||||||
|
return this.pluginManager.listInstalled(query)
|
||||||
|
})
|
||||||
|
).subscribe(plugin => {
|
||||||
|
this.installedPlugins$ = plugin
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
openPluginsFolder (): void {
|
openPluginsFolder (): void {
|
||||||
@ -68,6 +83,10 @@ export class PluginsSettingsTabComponent {
|
|||||||
this.availablePluginsQuery$.next(query)
|
this.availablePluginsQuery$.next(query)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
searchInstalled (query: string) {
|
||||||
|
this.installedPluginsQuery$.next(query)
|
||||||
|
}
|
||||||
|
|
||||||
isAlreadyInstalled (plugin: PluginInfo): boolean {
|
isAlreadyInstalled (plugin: PluginInfo): boolean {
|
||||||
return this.pluginManager.installedPlugins.some(x => x.name === plugin.name)
|
return this.pluginManager.installedPlugins.some(x => x.name === plugin.name)
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import { compare as semverCompare } from 'semver'
|
import { compare as semverCompare } from 'semver'
|
||||||
import { Observable, from, forkJoin, map } from 'rxjs'
|
import { Observable, from, forkJoin, map, of } from 'rxjs'
|
||||||
import { Injectable, Inject } from '@angular/core'
|
import { Injectable, Inject } from '@angular/core'
|
||||||
import { Logger, LogService, PlatformService, BOOTSTRAP_DATA, BootstrapData, PluginInfo } from 'tabby-core'
|
import { Logger, LogService, PlatformService, BOOTSTRAP_DATA, BootstrapData, PluginInfo } from 'tabby-core'
|
||||||
import { PLUGIN_BLACKLIST } from '../../../app/src/pluginBlacklist'
|
import { PLUGIN_BLACKLIST } from '../../../app/src/pluginBlacklist'
|
||||||
@ -45,6 +45,10 @@ export class PluginManagerService {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
listInstalled (query: string): Observable<PluginInfo[]> {
|
||||||
|
return of(this.installedPlugins.filter(x=>x.name.includes(query)))
|
||||||
|
}
|
||||||
|
|
||||||
_listAvailableInternal (namePrefix: string, keyword: string, query?: string): Observable<PluginInfo[]> {
|
_listAvailableInternal (namePrefix: string, keyword: string, query?: string): Observable<PluginInfo[]> {
|
||||||
return from(
|
return from(
|
||||||
axios.get(`https://api.npms.io/v2/search?q=keywords%3A${keyword}+${encodeURIComponent(query ?? '')}&size=250`)
|
axios.get(`https://api.npms.io/v2/search?q=keywords%3A${keyword}+${encodeURIComponent(query ?? '')}&size=250`)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user