UBERF-8516: Stable mentions popup (#6993)
Some checks failed
CI / build (push) Has been cancelled
CI / uitest (push) Has been cancelled
CI / uitest-pg (push) Has been cancelled
CI / uitest-qms (push) Has been cancelled
CI / svelte-check (push) Has been cancelled
CI / formatting (push) Has been cancelled
CI / test (push) Has been cancelled
CI / docker-build (push) Has been cancelled
CI / dist-build (push) Has been cancelled

Signed-off-by: Andrey Sobolev <haiodo@gmail.com>
This commit is contained in:
Andrey Sobolev 2024-10-20 00:47:07 +07:00 committed by GitHub
parent 7bd0db43c4
commit d65176fb84
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 34 additions and 14 deletions

View File

@ -860,7 +860,8 @@ export function createModel (builder: Builder): void {
title: contact.string.Employees,
query: contact.completion.EmployeeQuery,
context: ['search', 'mention'],
classToSearch: contact.mixin.Employee
classToSearch: contact.mixin.Employee,
priority: 1000
},
contact.completion.EmployeeCategory
)
@ -874,7 +875,8 @@ export function createModel (builder: Builder): void {
title: contact.string.People,
query: contact.completion.PersonQuery,
context: ['search', 'spotlight'],
classToSearch: contact.class.Person
classToSearch: contact.class.Person,
priority: 900
},
contact.completion.PersonCategory
)
@ -888,7 +890,8 @@ export function createModel (builder: Builder): void {
title: contact.string.Organizations,
query: contact.completion.OrganizationQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: contact.class.Organization
classToSearch: contact.class.Organization,
priority: 800
},
contact.completion.OrganizationCategory
)

View File

@ -908,7 +908,8 @@ export function defineSearch (builder: Builder): void {
label: documents.string.SearchDocument,
query: documents.completion.DocumentMetaQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: documents.class.DocumentMeta
classToSearch: documents.class.DocumentMeta,
priority: 800
},
documents.completion.DocumentMetaCategory
)

View File

@ -492,7 +492,8 @@ function defineDocument (builder: Builder): void {
label: document.string.SearchDocument,
query: document.completion.DocumentQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: document.class.Document
classToSearch: document.class.Document,
priority: 800
},
document.completion.DocumentQueryCategory
)

View File

@ -444,7 +444,8 @@ function defineFolder (builder: Builder): void {
label: presentation.string.Search,
query: drive.completion.FolderQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: drive.class.Folder
classToSearch: drive.class.Folder,
priority: 700
},
drive.completion.FolderCategory
)
@ -594,7 +595,8 @@ function defineFile (builder: Builder): void {
label: presentation.string.Search,
query: drive.completion.FileQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: drive.class.File
classToSearch: drive.class.File,
priority: 600
},
drive.completion.FileCategory
)

View File

@ -1048,7 +1048,8 @@ export function createModel (builder: Builder): void {
title: recruit.string.Applications,
query: recruit.completion.ApplicationQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: recruit.class.Applicant
classToSearch: recruit.class.Applicant,
priority: 500
},
recruit.completion.ApplicationCategory
)
@ -1062,7 +1063,8 @@ export function createModel (builder: Builder): void {
title: recruit.string.Vacancies,
query: recruit.completion.VacancyQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: recruit.class.Vacancy
classToSearch: recruit.class.Vacancy,
priority: 550
},
recruit.completion.VacancyCategory
)

View File

@ -602,7 +602,8 @@ export function createModel (builder: Builder): void {
title: tracker.string.Issues,
query: tracker.completion.IssueQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: tracker.class.Issue
classToSearch: tracker.class.Issue,
priority: 300
},
tracker.completion.IssueCategory
)

View File

@ -98,9 +98,14 @@ async function doFulltextSearch (
}
return sections.sort((a, b) => {
const maxScoreA = Math.max(...(a?.items ?? []).map((obj) => obj?.score ?? 0))
const maxScoreB = Math.max(...(b?.items ?? []).map((obj) => obj?.score ?? 0))
return maxScoreB - maxScoreA
const ac = categories.indexOf(a.category)
const bc = categories.indexOf(b.category)
if (ac === bc) {
const maxScoreA = Math.max(...(a?.items ?? []).map((obj) => obj?.score ?? 0))
const maxScoreB = Math.max(...(b?.items ?? []).map((obj) => obj?.score ?? 0))
return maxScoreB - maxScoreA
}
return ac - bc
})
}
@ -114,6 +119,8 @@ export async function searchFor (
let categories = categoriesByContext.get(context)
if (categories === undefined) {
categories = await client.findAll(plugin.class.ObjectSearchCategory, { context })
categories.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0))
categoriesByContext.set(context, categories)
}

View File

@ -72,6 +72,8 @@ export interface ObjectSearchCategory extends Doc {
// Query for documents with pattern
query: Resource<ObjectSearchFactory>
classToSearch?: Ref<Class<Doc>>
priority?: number
}
export interface ComponentExt {

View File

@ -988,7 +988,8 @@ export function createModel (builder: Builder): void {
label: github.string.PullRequests,
query: tracker.completion.IssueQuery,
context: ['search', 'mention', 'spotlight'],
classToSearch: github.class.GithubPullRequest
classToSearch: github.class.GithubPullRequest,
priority: 280
},
github.completion.PullRequestCategory
)