mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 19:07:41 +00:00
feat(tasks): filter GitHub tasks by several authors (#42450)
* feat(tasks): filter GitHub tasks by several authors * fix(tasks): keep author candidates across picks * refactor(tasks): share author filter summary and only-me check
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { parseTaskQuery } from '../../../../shared/work-items/task-query'
|
||||
import { buildWorkItemListRequest } from './work-item-list-request'
|
||||
|
||||
const ownerRepo = { owner: 'acme', repo: 'widgets' }
|
||||
|
||||
describe('buildWorkItemListRequest', () => {
|
||||
it('ORs several authors in the grammar each GitHub search understands', () => {
|
||||
const query = parseTaskQuery('is:open author:alice author:bob')
|
||||
const issues = buildWorkItemListRequest({ kind: 'issue', ownerRepo, limit: 20, query, page: 1 })
|
||||
const prs = buildWorkItemListRequest({ kind: 'pr', ownerRepo, limit: 20, query, page: 1 })
|
||||
|
||||
expect(issues.search).toBe('repo:acme/widgets is:issue is:open author:alice author:bob')
|
||||
expect(prs.search).toBe(
|
||||
'( is:open (author:alice OR author:bob) sort:created-desc ) repo:acme/widgets type:pr'
|
||||
)
|
||||
expect(prs.args.at(prs.args.indexOf('--search') + 1)).toBe(
|
||||
'is:open (author:alice OR author:bob) sort:created-desc'
|
||||
)
|
||||
})
|
||||
})
|
||||
@@ -54,8 +54,12 @@ export function buildWorkItemListRequest(args: {
|
||||
if (query.assignee) {
|
||||
searchParts.push(`assignee:${quoteGitHubSearchValue(query.assignee)}`)
|
||||
}
|
||||
if (query.author) {
|
||||
searchParts.push(`author:${quoteGitHubSearchValue(query.author)}`)
|
||||
const authorTerms = query.authors.map((author) => `author:${quoteGitHubSearchValue(author)}`)
|
||||
// search/issues ORs repeated author:, but gh pr list's advanced search ANDs them.
|
||||
if (kind === 'pr' && authorTerms.length > 1) {
|
||||
searchParts.push(`(${authorTerms.join(' OR ')})`)
|
||||
} else {
|
||||
searchParts.push(...authorTerms)
|
||||
}
|
||||
if (query.labels.length > 0) {
|
||||
for (const label of query.labels) {
|
||||
|
||||
@@ -29,8 +29,8 @@ export function buildSearchQueryString(
|
||||
if (query.assignee) {
|
||||
parts.push(`assignee:${quoteGitHubSearchValue(query.assignee)}`)
|
||||
}
|
||||
if (query.author) {
|
||||
parts.push(`author:${quoteGitHubSearchValue(query.author)}`)
|
||||
for (const author of query.authors) {
|
||||
parts.push(`author:${quoteGitHubSearchValue(author)}`)
|
||||
}
|
||||
if (query.reviewRequested) {
|
||||
parts.push(`review-requested:${quoteGitHubSearchValue(query.reviewRequested)}`)
|
||||
@@ -57,7 +57,7 @@ export function defaultOpenWorkItemQuery(): ParsedTaskQuery {
|
||||
state: 'open',
|
||||
draft: false,
|
||||
assignee: null,
|
||||
author: null,
|
||||
authors: [],
|
||||
reviewRequested: null,
|
||||
reviewedBy: null,
|
||||
labels: [],
|
||||
|
||||
@@ -5,9 +5,9 @@ import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover
|
||||
import { cn } from '@/lib/class-names'
|
||||
import { useRepoLabelsBySlug, useRepoAssigneesBySlug } from '@/hooks/useGitHubSlugMetadata'
|
||||
import type { PickerOption } from '@/components/github/PRFilterPickers'
|
||||
import { filterAuthorsValue, filterLabelsValue } from '@/components/github/pr-filter-value-summary'
|
||||
import {
|
||||
filterDraftLabel,
|
||||
filterLabelsValue,
|
||||
filterStateLabel,
|
||||
SectionDetail,
|
||||
SectionMenu,
|
||||
@@ -83,6 +83,8 @@ export default function PRFilterDropdowns({
|
||||
const t = useTranslate()
|
||||
const [openSection, setOpenSection] = useState<SectionKey | null>(null)
|
||||
const [popoverOpen, setPopoverOpen] = useState(false)
|
||||
// Each author pick reloads the list, so keep the authors visible at open as candidates.
|
||||
const [authorLoginsAtOpen, setAuthorLoginsAtOpen] = useState<string[]>([])
|
||||
const owner = primarySlug?.owner ?? null
|
||||
const repo = primarySlug?.repo ?? null
|
||||
const hasPrimarySlug = popoverOpen && owner !== null && repo !== null
|
||||
@@ -117,14 +119,16 @@ export default function PRFilterDropdowns({
|
||||
secondary: currentUserLabel()
|
||||
})
|
||||
// Use visible authors because assignable-user metadata excludes outside contributors.
|
||||
for (const login of authorLogins) {
|
||||
for (const login of [...authorLoginsAtOpen, ...authorLogins]) {
|
||||
options.set(login.toLowerCase(), { key: login, primary: login })
|
||||
}
|
||||
if (parsed.author && !options.has(parsed.author.toLowerCase())) {
|
||||
options.set(parsed.author.toLowerCase(), { key: parsed.author, primary: parsed.author })
|
||||
// Key options by the query's casing so the picker's selection matches them.
|
||||
for (const author of parsed.authors) {
|
||||
const lower = author.toLowerCase()
|
||||
options.set(lower, { ...(options.get(lower) ?? { primary: author }), key: author })
|
||||
}
|
||||
return [...options.values()]
|
||||
}, [authorLogins, parsed.author])
|
||||
}, [authorLoginsAtOpen, authorLogins, parsed.authors])
|
||||
const labelOpts = useMemo<PickerOption[]>(
|
||||
() => (hasPrimarySlug ? labelsState.data.map((name) => ({ key: name, primary: name })) : []),
|
||||
[hasPrimarySlug, labelsState.data]
|
||||
@@ -154,7 +158,7 @@ export default function PRFilterDropdowns({
|
||||
|
||||
const activeCount =
|
||||
(statusActive ? 1 : 0) +
|
||||
(parsed.author ? 1 : 0) +
|
||||
(parsed.authors.length > 0 ? 1 : 0) +
|
||||
(parsed.assignee ? 1 : 0) +
|
||||
(reviewerActive ? 1 : 0) +
|
||||
(parsed.labels.length > 0 ? 1 : 0)
|
||||
@@ -170,7 +174,9 @@ export default function PRFilterDropdowns({
|
||||
open={popoverOpen}
|
||||
onOpenChange={(next) => {
|
||||
setPopoverOpen(next)
|
||||
if (!next) {
|
||||
if (next) {
|
||||
setAuthorLoginsAtOpen(authorLogins)
|
||||
} else {
|
||||
setOpenSection(null)
|
||||
}
|
||||
}}
|
||||
@@ -212,7 +218,7 @@ export default function PRFilterDropdowns({
|
||||
activeCount > 0
|
||||
? () => {
|
||||
onChange({
|
||||
author: null,
|
||||
authors: [],
|
||||
assignee: null,
|
||||
reviewer: null,
|
||||
labels: [],
|
||||
@@ -252,11 +258,11 @@ export default function PRFilterDropdowns({
|
||||
onClear={() => onChange({ state: 'open', draft: false })}
|
||||
/>
|
||||
) : null}
|
||||
{parsed.author ? (
|
||||
{parsed.authors.length > 0 ? (
|
||||
<ActivePill
|
||||
label={t('auto.components.github.PRFilterDropdowns.01f3f3d161', 'Author')}
|
||||
value={parsed.author}
|
||||
onClear={() => onChange({ author: null })}
|
||||
value={filterAuthorsValue(parsed.authors, t) ?? ''}
|
||||
onClear={() => onChange({ authors: [] })}
|
||||
/>
|
||||
) : null}
|
||||
{parsed.labels.length > 0 ? (
|
||||
|
||||
@@ -54,11 +54,13 @@ export function filterPullRequestPickerOptions(
|
||||
|
||||
function pickerFallbackText(
|
||||
{
|
||||
customValue,
|
||||
loading,
|
||||
queryTooLarge,
|
||||
error,
|
||||
emptyText
|
||||
}: {
|
||||
customValue: string | null
|
||||
loading: boolean
|
||||
queryTooLarge: boolean
|
||||
error: string | null
|
||||
@@ -66,6 +68,12 @@ function pickerFallbackText(
|
||||
},
|
||||
t: Translate = translate
|
||||
): string {
|
||||
if (customValue) {
|
||||
return t(
|
||||
'auto.components.github.PRFilterPickers.pressEnterToUseValue',
|
||||
'Press Enter to use the typed value.'
|
||||
)
|
||||
}
|
||||
if (loading) {
|
||||
return t('auto.components.github.PRFilterPickers.loading', 'Loading…')
|
||||
}
|
||||
@@ -78,6 +86,47 @@ function pickerFallbackText(
|
||||
return error ?? emptyText ?? t('auto.components.github.PRFilterPickers.noMatches', 'No matches')
|
||||
}
|
||||
|
||||
// Allow external authors/reviewers missing from the collaborator-only assignable-user list.
|
||||
function customPickerValue(
|
||||
filtered: PickerOption[],
|
||||
{ queryTooLarge, trimmedQuery }: ReturnType<typeof getPullRequestPickerQueryState>,
|
||||
allowCustomValue: boolean | undefined
|
||||
): string | null {
|
||||
const show =
|
||||
allowCustomValue &&
|
||||
trimmedQuery.length > 0 &&
|
||||
!queryTooLarge &&
|
||||
!filtered.some((o) => o.key.toLowerCase() === trimmedQuery.toLowerCase())
|
||||
return show ? trimmedQuery : null
|
||||
}
|
||||
|
||||
function CustomValueItem({
|
||||
value,
|
||||
onSelect
|
||||
}: {
|
||||
value: string
|
||||
onSelect: () => void
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
return (
|
||||
<CommandItem
|
||||
value={`__custom__:${value}`}
|
||||
onSelect={onSelect}
|
||||
className="items-center gap-2 px-3 py-1.5 text-xs"
|
||||
>
|
||||
<span className="min-w-0 truncate text-muted-foreground">
|
||||
<Trans
|
||||
i18n={i18n}
|
||||
defaults={t('auto.components.github.PRFilterPickers.useTypedValue', 'Use <value/>')}
|
||||
components={{
|
||||
value: <span className="font-medium text-foreground">{value}</span>
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
</CommandItem>
|
||||
)
|
||||
}
|
||||
|
||||
export function SingleSelectList({
|
||||
options,
|
||||
activeValue,
|
||||
@@ -96,25 +145,16 @@ export function SingleSelectList({
|
||||
searchPlaceholder: string
|
||||
emptyText?: string
|
||||
renderOption?: (opt: PickerOption) => React.ReactNode
|
||||
// Allow external authors/reviewers missing from the collaborator-only assignable-user list.
|
||||
allowCustomValue?: boolean
|
||||
onSelect: (value: string | null) => void
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const [query, setQuery] = useState('')
|
||||
const filtered = useMemo(() => filterPullRequestPickerOptions(options, query), [options, query])
|
||||
const { queryTooLarge, trimmedQuery } = getPullRequestPickerQueryState(query)
|
||||
const showCustom =
|
||||
allowCustomValue &&
|
||||
trimmedQuery.length > 0 &&
|
||||
!queryTooLarge &&
|
||||
!filtered.some((o) => o.key.toLowerCase() === trimmedQuery.toLowerCase())
|
||||
const fallback = showCustom
|
||||
? t(
|
||||
'auto.components.github.PRFilterPickers.pressEnterToUseValue',
|
||||
'Press Enter to use the typed value.'
|
||||
)
|
||||
: pickerFallbackText({ loading, queryTooLarge, error, emptyText }, t)
|
||||
const queryState = getPullRequestPickerQueryState(query)
|
||||
const { queryTooLarge } = queryState
|
||||
const customValue = customPickerValue(filtered, queryState, allowCustomValue)
|
||||
const fallback = pickerFallbackText({ customValue, loading, queryTooLarge, error, emptyText }, t)
|
||||
|
||||
return (
|
||||
<Command shouldFilter={false}>
|
||||
@@ -126,22 +166,8 @@ export function SingleSelectList({
|
||||
/>
|
||||
<CommandList>
|
||||
<CommandEmpty>{fallback}</CommandEmpty>
|
||||
{showCustom ? (
|
||||
<CommandItem
|
||||
value={`__custom__:${trimmedQuery}`}
|
||||
onSelect={() => onSelect(trimmedQuery)}
|
||||
className="items-center gap-2 px-3 py-1.5 text-xs"
|
||||
>
|
||||
<span className="min-w-0 truncate text-muted-foreground">
|
||||
<Trans
|
||||
i18n={i18n}
|
||||
defaults={t('auto.components.github.PRFilterPickers.useTypedValue', 'Use <value/>')}
|
||||
components={{
|
||||
value: <span className="font-medium text-foreground">{trimmedQuery}</span>
|
||||
}}
|
||||
/>
|
||||
</span>
|
||||
</CommandItem>
|
||||
{customValue ? (
|
||||
<CustomValueItem value={customValue} onSelect={() => onSelect(customValue)} />
|
||||
) : null}
|
||||
{activeValue ? (
|
||||
<CommandItem
|
||||
@@ -183,6 +209,8 @@ export function MultiSelectList({
|
||||
error,
|
||||
searchPlaceholder,
|
||||
emptyText,
|
||||
renderOption,
|
||||
allowCustomValue,
|
||||
onChange
|
||||
}: {
|
||||
options: PickerOption[]
|
||||
@@ -191,22 +219,18 @@ export function MultiSelectList({
|
||||
error: string | null
|
||||
searchPlaceholder: string
|
||||
emptyText?: string
|
||||
renderOption?: (opt: PickerOption) => React.ReactNode
|
||||
allowCustomValue?: boolean
|
||||
onChange: (next: string[]) => void
|
||||
}): React.JSX.Element {
|
||||
const t = useTranslate()
|
||||
const [query, setQuery] = useState('')
|
||||
const filtered = useMemo(() => filterPullRequestPickerOptions(options, query), [options, query])
|
||||
const selectedSet = useMemo(() => new Set(selected), [selected])
|
||||
const { queryTooLarge } = getPullRequestPickerQueryState(query)
|
||||
const fallback = pickerFallbackText(
|
||||
{
|
||||
loading,
|
||||
queryTooLarge,
|
||||
error,
|
||||
emptyText
|
||||
},
|
||||
t
|
||||
)
|
||||
const queryState = getPullRequestPickerQueryState(query)
|
||||
const { queryTooLarge } = queryState
|
||||
const customValue = customPickerValue(filtered, queryState, allowCustomValue)
|
||||
const fallback = pickerFallbackText({ customValue, loading, queryTooLarge, error, emptyText }, t)
|
||||
|
||||
const toggle = (key: string): void => {
|
||||
const next = new Set(selectedSet)
|
||||
@@ -228,6 +252,9 @@ export function MultiSelectList({
|
||||
/>
|
||||
<CommandList>
|
||||
<CommandEmpty>{fallback}</CommandEmpty>
|
||||
{customValue ? (
|
||||
<CustomValueItem value={customValue} onSelect={() => toggle(customValue)} />
|
||||
) : null}
|
||||
{selected.length > 0 ? (
|
||||
<CommandItem
|
||||
value="__clear__"
|
||||
@@ -254,7 +281,7 @@ export function MultiSelectList({
|
||||
isActive ? 'opacity-70' : 'opacity-0'
|
||||
)}
|
||||
/>
|
||||
<span className="truncate">{opt.primary}</span>
|
||||
{renderOption ? renderOption(opt) : <span className="truncate">{opt.primary}</span>}
|
||||
</CommandItem>
|
||||
)
|
||||
})}
|
||||
|
||||
@@ -6,12 +6,13 @@ import {
|
||||
type PickerOption
|
||||
} from '@/components/github/PRFilterPickers'
|
||||
import { cn } from '@/lib/class-names'
|
||||
import { filterAuthorsValue, filterLabelsValue } from '@/components/github/pr-filter-value-summary'
|
||||
import type { ParsedTaskQuery } from '../../../../shared/work-items/task-query'
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import { useTranslate, type Translate } from '@/i18n/use-translate'
|
||||
|
||||
export type PRFilterChange = {
|
||||
author?: string | null
|
||||
authors?: string[]
|
||||
assignee?: string | null
|
||||
reviewer?: { kind: 'requested' | 'reviewed-by'; login: string } | null
|
||||
labels?: string[]
|
||||
@@ -38,19 +39,6 @@ export function filterDraftLabel(t: Translate = translate): string {
|
||||
return t('auto.components.github.PRFilterSections.draft', 'Draft')
|
||||
}
|
||||
|
||||
export function filterLabelsValue(labels: string[], t: Translate = translate): string | null {
|
||||
if (labels.length === 0) {
|
||||
return null
|
||||
}
|
||||
if (labels.length === 1) {
|
||||
return labels[0]
|
||||
}
|
||||
return t('auto.components.github.PRFilterSections.labelCount', '{{count}} labels', {
|
||||
count: labels.length,
|
||||
defaultValue_one: '{{count}} label'
|
||||
})
|
||||
}
|
||||
|
||||
function statusLabel(parsed: ParsedTaskQuery, t: Translate = translate): string {
|
||||
const parts: string[] = []
|
||||
if (parsed.state === 'all') {
|
||||
@@ -207,7 +195,7 @@ export function SectionMenu({
|
||||
{
|
||||
key: 'author',
|
||||
label: t('auto.components.github.PRFilterSections.24754c44ad', 'Author'),
|
||||
value: parsed.author
|
||||
value: filterAuthorsValue(parsed.authors, t)
|
||||
},
|
||||
{
|
||||
key: 'label',
|
||||
@@ -315,9 +303,9 @@ export function SectionDetail({
|
||||
<StatusSection parsed={parsed} kind={kind} onSelect={onSelect} />
|
||||
) : null}
|
||||
{section === 'author' ? (
|
||||
<SingleSelectList
|
||||
<MultiSelectList
|
||||
options={authorOpts}
|
||||
activeValue={parsed.author}
|
||||
selected={parsed.authors}
|
||||
loading={false}
|
||||
error={null}
|
||||
searchPlaceholder={t(
|
||||
@@ -327,7 +315,7 @@ export function SectionDetail({
|
||||
emptyText={t('auto.components.github.PRFilterSections.458ea3602b', 'No authors')}
|
||||
allowCustomValue
|
||||
renderOption={(opt) => <UserOptionRow option={opt} />}
|
||||
onSelect={(value) => onSelect({ author: value })}
|
||||
onChange={(next) => onSelect({ authors: next })}
|
||||
/>
|
||||
) : null}
|
||||
{section === 'assignee' ? (
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
import { translate } from '@/i18n/i18n'
|
||||
import type { Translate } from '@/i18n/use-translate'
|
||||
|
||||
function filterValuesSummary(
|
||||
values: string[],
|
||||
countText: (count: number) => string
|
||||
): string | null {
|
||||
return values.length > 1 ? countText(values.length) : (values[0] ?? null)
|
||||
}
|
||||
|
||||
export function filterLabelsValue(labels: string[], t: Translate = translate): string | null {
|
||||
return filterValuesSummary(labels, (count) =>
|
||||
t('auto.components.github.PRFilterSections.labelCount', '{{count}} labels', {
|
||||
count,
|
||||
defaultValue_one: '{{count}} label'
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
export function filterAuthorsValue(authors: string[], t: Translate = translate): string | null {
|
||||
return filterValuesSummary(authors, (count) =>
|
||||
t('auto.components.github.PRFilterSections.authorCount', '{{count}} authors', {
|
||||
count,
|
||||
defaultValue_one: '{{count}} author'
|
||||
})
|
||||
)
|
||||
}
|
||||
@@ -21,8 +21,8 @@ const PR_PRESET_BY_WHO: Record<GitHubPRWhoChip, TaskViewPresetId> = {
|
||||
/** Patch the query's qualifiers, keeping every other filter and free text. */
|
||||
export function patchGitHubTaskQuery(query: string, change: PRFilterChange): string {
|
||||
let next = query
|
||||
if ('author' in change) {
|
||||
next = withQualifier(next, 'author', change.author ?? null)
|
||||
if ('authors' in change) {
|
||||
next = withQualifier(next, 'authors', change.authors ?? [])
|
||||
}
|
||||
if ('assignee' in change) {
|
||||
next = withQualifier(next, 'assignee', change.assignee ?? null)
|
||||
@@ -72,29 +72,36 @@ export function deriveGitHubPRStateChip(query: ParsedTaskQuery): GitHubPRStateCh
|
||||
return query.state === null ? 'all' : query.state
|
||||
}
|
||||
|
||||
function isMe(login: string | null): boolean {
|
||||
return login?.toLowerCase() === '@me'
|
||||
}
|
||||
|
||||
export function isOnlyMeAuthor(query: ParsedTaskQuery): boolean {
|
||||
return query.authors.length === 1 && isMe(query.authors[0])
|
||||
}
|
||||
|
||||
/** Who means author or reviewer, independent of assignee, labels and text; other people light no chip. */
|
||||
export function deriveGitHubPRWhoChip(query: ParsedTaskQuery): GitHubPRWhoChip | null {
|
||||
const isMe = (login: string | null): boolean => login?.toLowerCase() === '@me'
|
||||
if (query.reviewedBy !== null) {
|
||||
return null
|
||||
}
|
||||
if (query.author === null) {
|
||||
if (query.authors.length === 0) {
|
||||
if (query.reviewRequested === null) {
|
||||
return 'everyone'
|
||||
}
|
||||
return isMe(query.reviewRequested) ? 'reviewing' : null
|
||||
}
|
||||
return query.reviewRequested === null && isMe(query.author) ? 'mine' : null
|
||||
return query.reviewRequested === null && isOnlyMeAuthor(query) ? 'mine' : null
|
||||
}
|
||||
|
||||
export function gitHubPRWhoChange(who: GitHubPRWhoChip): PRFilterChange {
|
||||
if (who === 'mine') {
|
||||
return { author: '@me', reviewer: null }
|
||||
return { authors: ['@me'], reviewer: null }
|
||||
}
|
||||
if (who === 'reviewing') {
|
||||
return { author: null, reviewer: { kind: 'requested', login: '@me' } }
|
||||
return { authors: [], reviewer: { kind: 'requested', login: '@me' } }
|
||||
}
|
||||
return { author: null, reviewer: null }
|
||||
return { authors: [], reviewer: null }
|
||||
}
|
||||
|
||||
export function gitHubPRWhoPreset(who: GitHubPRWhoChip): TaskViewPresetId {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import type { ParsedTaskQuery } from '../../../../../../shared/work-items/task-query'
|
||||
import type { GitHubTaskKind } from '../../../../../../shared/work-items/task-github-search'
|
||||
import type { TaskViewPresetId } from '../../../../../../shared/ui-chrome-types'
|
||||
import { isOnlyMeAuthor } from './task-page-pr-chips'
|
||||
export function deriveGitHubTaskPreset(
|
||||
kind: GitHubTaskKind,
|
||||
query: ParsedTaskQuery
|
||||
@@ -9,7 +10,7 @@ export function deriveGitHubTaskPreset(
|
||||
return null
|
||||
}
|
||||
if (kind === 'prs') {
|
||||
if (query.author?.toLowerCase() === '@me') {
|
||||
if (isOnlyMeAuthor(query)) {
|
||||
return 'my-prs'
|
||||
}
|
||||
if (query.reviewRequested?.toLowerCase() === '@me') {
|
||||
@@ -18,7 +19,7 @@ export function deriveGitHubTaskPreset(
|
||||
} else if (query.assignee?.toLowerCase() === '@me') {
|
||||
return 'my-issues'
|
||||
}
|
||||
return query.author !== null ||
|
||||
return query.authors.length > 0 ||
|
||||
query.assignee !== null ||
|
||||
query.reviewRequested !== null ||
|
||||
query.reviewedBy !== null
|
||||
|
||||
+3
-1
@@ -331,7 +331,9 @@
|
||||
"github": {
|
||||
"PRFilterSections": {
|
||||
"labelCount_one": "{{count}} label",
|
||||
"labelCount_other": "{{count}} labels"
|
||||
"labelCount_other": "{{count}} labels",
|
||||
"authorCount_one": "{{count}} author",
|
||||
"authorCount_other": "{{count}} authors"
|
||||
},
|
||||
"project": {
|
||||
"ProjectPicker": {
|
||||
|
||||
@@ -3625,6 +3625,8 @@
|
||||
"draft": "Entwurf",
|
||||
"labelCount_one": "{{count}} Label",
|
||||
"labelCount_other": "{{count}} Labels",
|
||||
"authorCount_one": "{{count}} Autor",
|
||||
"authorCount_other": "{{count}} Autoren",
|
||||
"allStates": "Alle",
|
||||
"filterPullRequests": "Pull Requests filtern",
|
||||
"filterIssues": "Issues filtern",
|
||||
|
||||
@@ -4234,6 +4234,8 @@
|
||||
"draft": "Draft",
|
||||
"labelCount_one": "{{count}} label",
|
||||
"labelCount_other": "{{count}} labels",
|
||||
"authorCount_one": "{{count}} author",
|
||||
"authorCount_other": "{{count}} authors",
|
||||
"allStates": "All",
|
||||
"filterPullRequests": "Filter pull requests",
|
||||
"filterIssues": "Filter issues",
|
||||
|
||||
@@ -3113,6 +3113,9 @@
|
||||
"labelCount_one": "{{count}} etiqueta",
|
||||
"labelCount_other": "{{count}} etiquetas",
|
||||
"labelCount_many": "{{count}} etiquetas",
|
||||
"authorCount_one": "{{count}} autor",
|
||||
"authorCount_other": "{{count}} autores",
|
||||
"authorCount_many": "{{count}} autores",
|
||||
"allStates": "Todos",
|
||||
"filterPullRequests": "Filtrar pull requests",
|
||||
"filterIssues": "Filtrar issues",
|
||||
|
||||
@@ -3384,6 +3384,9 @@
|
||||
"labelCount_one": "{{count}} étiquette",
|
||||
"labelCount_other": "{{count}} étiquettes",
|
||||
"labelCount_many": "{{count}} étiquettes",
|
||||
"authorCount_one": "{{count}} auteur",
|
||||
"authorCount_other": "{{count}} auteurs",
|
||||
"authorCount_many": "{{count}} auteurs",
|
||||
"allStates": "Tous",
|
||||
"filterPullRequests": "Filtrer les pull requests",
|
||||
"filterIssues": "Filtrer les issues",
|
||||
|
||||
@@ -3059,6 +3059,7 @@
|
||||
"bd162b7d5a": "マージ済み",
|
||||
"draft": "下書き",
|
||||
"labelCount_other": "{{count}} 個のラベル",
|
||||
"authorCount_other": "{{count}} 人の著者",
|
||||
"allStates": "全て",
|
||||
"filterPullRequests": "PR を絞り込む",
|
||||
"filterIssues": "Issue を絞り込む",
|
||||
|
||||
@@ -3059,6 +3059,7 @@
|
||||
"bd162b7d5a": "병합됨",
|
||||
"draft": "초안",
|
||||
"labelCount_other": "라벨 {{count}}개",
|
||||
"authorCount_other": "작성자 {{count}}명",
|
||||
"allStates": "모두",
|
||||
"filterPullRequests": "PR 필터링",
|
||||
"filterIssues": "이슈 필터링",
|
||||
|
||||
@@ -16380,6 +16380,9 @@
|
||||
"labelCount_one": "{{count}} rótulo",
|
||||
"labelCount_other": "{{count}} rótulos",
|
||||
"labelCount_many": "{{count}} rótulos",
|
||||
"authorCount_one": "{{count}} autor",
|
||||
"authorCount_other": "{{count}} autores",
|
||||
"authorCount_many": "{{count}} autores",
|
||||
"allStates": "Todos",
|
||||
"filterPullRequests": "Filtrar pull requests",
|
||||
"filterIssues": "Filtrar issues",
|
||||
|
||||
@@ -3712,6 +3712,10 @@
|
||||
"labelCount_few": "{{count}} метки",
|
||||
"labelCount_many": "{{count}} меток",
|
||||
"labelCount_other": "{{count}} метки",
|
||||
"authorCount_one": "{{count}} автор",
|
||||
"authorCount_few": "{{count}} автора",
|
||||
"authorCount_many": "{{count}} авторов",
|
||||
"authorCount_other": "{{count}} автора",
|
||||
"allStates": "Все",
|
||||
"filterPullRequests": "Фильтр пул-реквестов",
|
||||
"filterIssues": "Фильтр задач",
|
||||
|
||||
@@ -3594,6 +3594,8 @@
|
||||
"draft": "Taslak",
|
||||
"labelCount_other": "{{count}} etiket",
|
||||
"labelCount_one": "{{count}} etiket",
|
||||
"authorCount_other": "{{count}} yazar",
|
||||
"authorCount_one": "{{count}} yazar",
|
||||
"allStates": "Tümü",
|
||||
"filterPullRequests": "Pull request'leri filtrele",
|
||||
"filterIssues": "Sorunları filtrele",
|
||||
|
||||
@@ -3552,6 +3552,7 @@
|
||||
"bd162b7d5a": "已合併",
|
||||
"draft": "草稿",
|
||||
"labelCount_other": "{{count}} 個標籤",
|
||||
"authorCount_other": "{{count}} 位作者",
|
||||
"allStates": "全部",
|
||||
"filterPullRequests": "篩選 PR",
|
||||
"filterIssues": "篩選議題",
|
||||
|
||||
@@ -3250,6 +3250,7 @@
|
||||
"bd162b7d5a": "合并",
|
||||
"draft": "草稿",
|
||||
"labelCount_other": "{{count}} 个标签",
|
||||
"authorCount_other": "{{count}} 位作者",
|
||||
"allStates": "全部",
|
||||
"filterPullRequests": "筛选 PR",
|
||||
"filterIssues": "筛选议题",
|
||||
|
||||
@@ -36,10 +36,10 @@ describe('parseTaskQuery', () => {
|
||||
|
||||
it('extracts assignee, author, label, and review qualifiers', () => {
|
||||
const parsed = parseTaskQuery(
|
||||
'assignee:@me author:alice review-requested:@me label:bug free text'
|
||||
'assignee:@me author:alice author:bob review-requested:@me label:bug free text'
|
||||
)
|
||||
expect(parsed.assignee).toBe('@me')
|
||||
expect(parsed.author).toBe('alice')
|
||||
expect(parsed.authors).toEqual(['alice', 'bob'])
|
||||
expect(parsed.reviewRequested).toBe('@me')
|
||||
expect(parsed.scope).toBe('pr') // review-requested forces pr
|
||||
expect(parsed.labels).toEqual(['bug'])
|
||||
|
||||
@@ -3,7 +3,7 @@ export type ParsedTaskQuery = {
|
||||
state: 'open' | 'closed' | 'all' | 'merged' | null
|
||||
draft: boolean
|
||||
assignee: string | null
|
||||
author: string | null
|
||||
authors: string[]
|
||||
reviewRequested: string | null
|
||||
reviewedBy: string | null
|
||||
labels: string[]
|
||||
@@ -66,7 +66,7 @@ export function parseTaskQuery(rawQuery: string): ParsedTaskQuery {
|
||||
state: null,
|
||||
draft: false,
|
||||
assignee: null,
|
||||
author: null,
|
||||
authors: [],
|
||||
reviewRequested: null,
|
||||
reviewedBy: null,
|
||||
labels: [],
|
||||
@@ -124,7 +124,7 @@ export function parseTaskQuery(rawQuery: string): ParsedTaskQuery {
|
||||
continue
|
||||
}
|
||||
if (key === 'author') {
|
||||
query.author = value
|
||||
query.authors.push(value)
|
||||
continue
|
||||
}
|
||||
if (key === 'review-requested') {
|
||||
@@ -195,8 +195,8 @@ export function serializeTaskQuery(q: ParsedTaskQuery): string {
|
||||
if (q.draft) {
|
||||
parts.push('is:draft')
|
||||
}
|
||||
if (q.author) {
|
||||
parts.push(`author:${quoteIfNeeded(q.author)}`)
|
||||
for (const author of q.authors) {
|
||||
parts.push(`author:${quoteIfNeeded(author)}`)
|
||||
}
|
||||
if (q.assignee) {
|
||||
parts.push(`assignee:${quoteIfNeeded(q.assignee)}`)
|
||||
@@ -217,7 +217,7 @@ export function serializeTaskQuery(q: ParsedTaskQuery): string {
|
||||
}
|
||||
|
||||
export type TaskQueryFilterKey =
|
||||
| 'author'
|
||||
| 'authors'
|
||||
| 'assignee'
|
||||
| 'reviewRequested'
|
||||
| 'reviewedBy'
|
||||
@@ -225,7 +225,7 @@ export type TaskQueryFilterKey =
|
||||
| 'state'
|
||||
| 'draft'
|
||||
|
||||
/** Single-value null clears the qualifier; labels replaces the full array (caller manages membership). */
|
||||
/** Single-value null clears the qualifier; authors and labels replace the full array (caller manages membership). */
|
||||
export function withQualifier(
|
||||
rawQuery: string,
|
||||
key: TaskQueryFilterKey,
|
||||
@@ -233,8 +233,8 @@ export function withQualifier(
|
||||
): string {
|
||||
const parsed = parseTaskQuery(rawQuery)
|
||||
switch (key) {
|
||||
case 'author':
|
||||
parsed.author = typeof value === 'string' ? value : null
|
||||
case 'authors':
|
||||
parsed.authors = Array.isArray(value) ? value : []
|
||||
break
|
||||
case 'assignee':
|
||||
parsed.assignee = typeof value === 'string' ? value : null
|
||||
|
||||
Reference in New Issue
Block a user