mirror of
https://github.com/Eugeny/tabby.git
synced 2025-06-09 05:50:08 +00: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-perfect-scrollbar": "^10.1.0",
|
||||||
"ngx-translate-messageformat-compiler": "^4.11.0",
|
"ngx-translate-messageformat-compiler": "^4.11.0",
|
||||||
"readable-stream": "3.6.0",
|
"readable-stream": "3.6.0",
|
||||||
|
"thenby": "^1.3.4",
|
||||||
"uuid": "^8.0.0"
|
"uuid": "^8.0.0"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
|
@ -6,5 +6,6 @@ export interface SelectorOption<T> {
|
|||||||
icon?: string
|
icon?: string
|
||||||
freeInputPattern?: string
|
freeInputPattern?: string
|
||||||
color?: string
|
color?: string
|
||||||
|
weight?: number
|
||||||
callback?: (string?) => void
|
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 { 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 { NgbActiveModal } from '@ng-bootstrap/ng-bootstrap'
|
||||||
import { SelectorOption } from '../api/selector'
|
import { SelectorOption } from '../api/selector'
|
||||||
@ -52,8 +53,11 @@ export class SelectorModalComponent<T> {
|
|||||||
onFilterChange (): void {
|
onFilterChange (): void {
|
||||||
const f = this.filter.trim().toLowerCase()
|
const f = this.filter.trim().toLowerCase()
|
||||||
if (!f) {
|
if (!f) {
|
||||||
this.filteredOptions = this.options.slice()
|
this.filteredOptions = this.options.slice().sort(
|
||||||
.sort((a, b) => a.group?.localeCompare(b.group ?? '') ?? 0)
|
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)
|
.filter(x => !x.freeInputPattern)
|
||||||
} else {
|
} else {
|
||||||
const terms = f.split(' ')
|
const terms = f.split(' ')
|
||||||
|
@ -112,6 +112,7 @@ export class ProfilesService {
|
|||||||
group: this.translate.instant('Recent'),
|
group: this.translate.instant('Recent'),
|
||||||
icon: 'fas fa-history',
|
icon: 'fas fa-history',
|
||||||
color: p.color,
|
color: p.color,
|
||||||
|
weight: -1,
|
||||||
callback: async () => {
|
callback: async () => {
|
||||||
if (p.id) {
|
if (p.id) {
|
||||||
p = (await this.getProfiles()).find(x => x.id === p.id) ?? p
|
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'),
|
name: this.translate.instant('Clear recent profiles'),
|
||||||
group: this.translate.instant('Recent'),
|
group: this.translate.instant('Recent'),
|
||||||
icon: 'fas fa-eraser',
|
icon: 'fas fa-eraser',
|
||||||
|
weight: -1,
|
||||||
callback: async () => {
|
callback: async () => {
|
||||||
window.localStorage.removeItem('recentProfiles')
|
window.localStorage.removeItem('recentProfiles')
|
||||||
this.config.save()
|
this.config.save()
|
||||||
@ -142,6 +144,7 @@ export class ProfilesService {
|
|||||||
|
|
||||||
options = [...options, ...profiles.map((p): SelectorOption<void> => ({
|
options = [...options, ...profiles.map((p): SelectorOption<void> => ({
|
||||||
...this.selectorOptionForProfile(p),
|
...this.selectorOptionForProfile(p),
|
||||||
|
weight: p.isBuiltin ? 2 : 1,
|
||||||
callback: () => resolve(p),
|
callback: () => resolve(p),
|
||||||
}))]
|
}))]
|
||||||
|
|
||||||
@ -150,6 +153,7 @@ export class ProfilesService {
|
|||||||
options.push({
|
options.push({
|
||||||
name: this.translate.instant('Manage profiles'),
|
name: this.translate.instant('Manage profiles'),
|
||||||
icon: 'fas fa-window-restore',
|
icon: 'fas fa-window-restore',
|
||||||
|
weight: 10,
|
||||||
callback: () => {
|
callback: () => {
|
||||||
this.app.openNewTabRaw({
|
this.app.openNewTabRaw({
|
||||||
type: SettingsTabComponent,
|
type: SettingsTabComponent,
|
||||||
|
@ -161,6 +161,11 @@ string_decoder@^1.1.1:
|
|||||||
dependencies:
|
dependencies:
|
||||||
safe-buffer "~5.2.0"
|
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:
|
tslib@^1.10.0:
|
||||||
version "1.14.1"
|
version "1.14.1"
|
||||||
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
|
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.14.1.tgz#cf2d38bdc34a134bcaf1091c41f6619e2f672d00"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user