mirror of
https://github.com/Eugeny/tabby.git
synced 2025-01-30 14:20:18 +08:00
fixed profile order in the selector dialog - fixes #5537
This commit is contained in:
parent
fc4bbfcd5d
commit
2c00b9a4bc
@ -27,6 +27,7 @@
|
||||
"ngx-perfect-scrollbar": "^10.1.0",
|
||||
"ngx-translate-messageformat-compiler": "^4.11.0",
|
||||
"readable-stream": "3.6.0",
|
||||
"thenby": "^1.3.4",
|
||||
"uuid": "^8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
@ -6,5 +6,6 @@ export interface SelectorOption<T> {
|
||||
icon?: string
|
||||
freeInputPattern?: string
|
||||
color?: string
|
||||
weight?: number
|
||||
callback?: (string?) => void
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
import { firstBy } from 'thenby'
|
||||
import { Component, Input, HostListener, ViewChildren, QueryList, ElementRef } from '@angular/core' // eslint-disable-line @typescript-eslint/no-unused-vars
|
||||
import { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||
import { SelectorOption } from '../api/selector'
|
||||
@ -52,8 +53,11 @@ export class SelectorModalComponent<T> {
|
||||
onFilterChange (): void {
|
||||
const f = this.filter.trim().toLowerCase()
|
||||
if (!f) {
|
||||
this.filteredOptions = this.options.slice()
|
||||
.sort((a, b) => a.group?.localeCompare(b.group ?? '') ?? 0)
|
||||
this.filteredOptions = this.options.slice().sort(
|
||||
firstBy<SelectorOption<T>, number>(x => x.weight ?? 0)
|
||||
.thenBy<SelectorOption<T>, string>(x => x.group ?? '')
|
||||
.thenBy<SelectorOption<T>, string>(x => x.name)
|
||||
)
|
||||
.filter(x => !x.freeInputPattern)
|
||||
} else {
|
||||
const terms = f.split(' ')
|
||||
|
@ -112,6 +112,7 @@ export class ProfilesService {
|
||||
group: this.translate.instant('Recent'),
|
||||
icon: 'fas fa-history',
|
||||
color: p.color,
|
||||
weight: -1,
|
||||
callback: async () => {
|
||||
if (p.id) {
|
||||
p = (await this.getProfiles()).find(x => x.id === p.id) ?? p
|
||||
@ -124,6 +125,7 @@ export class ProfilesService {
|
||||
name: this.translate.instant('Clear recent profiles'),
|
||||
group: this.translate.instant('Recent'),
|
||||
icon: 'fas fa-eraser',
|
||||
weight: -1,
|
||||
callback: async () => {
|
||||
window.localStorage.removeItem('recentProfiles')
|
||||
this.config.save()
|
||||
@ -142,6 +144,7 @@ export class ProfilesService {
|
||||
|
||||
options = [...options, ...profiles.map((p): SelectorOption<void> => ({
|
||||
...this.selectorOptionForProfile(p),
|
||||
weight: p.isBuiltin ? 2 : 1,
|
||||
callback: () => resolve(p),
|
||||
}))]
|
||||
|
||||
@ -150,6 +153,7 @@ export class ProfilesService {
|
||||
options.push({
|
||||
name: this.translate.instant('Manage profiles'),
|
||||
icon: 'fas fa-window-restore',
|
||||
weight: 10,
|
||||
callback: () => {
|
||||
this.app.openNewTabRaw({
|
||||
type: SettingsTabComponent,
|
||||
|
@ -161,6 +161,11 @@ string_decoder@^1.1.1:
|
||||
dependencies:
|
||||
safe-buffer "~5.2.0"
|
||||
|
||||
thenby@^1.3.4:
|
||||
version "1.3.4"
|
||||
resolved "https://registry.yarnpkg.com/thenby/-/thenby-1.3.4.tgz#81581f6e1bb324c6dedeae9bfc28e59b1a2201cc"
|
||||
integrity sha512-89Gi5raiWA3QZ4b2ePcEwswC3me9JIg+ToSgtE0JWeCynLnLxNr/f9G+xfo9K+Oj4AFdom8YNJjibIARTJmapQ==
|
||||
|
||||
tslib@^1.10.0:
|
||||
version "1.14.1"
|
||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
|
||||
|
Loading…
Reference in New Issue
Block a user