Files
orca/src/shared/task-preset-query.ts
T
Jinjing 383665ebb8 Taskpage pure extract (#13367)
* refactor(task-page): extract pure task-kind, jira, and pagination helpers

Moves seven closed sets of pure helpers out of TaskPage.tsx (13485 -> 13308
lines) into domain-named sibling modules. Function bodies are byte-identical
cut/paste; the only production edits in TaskPage.tsx are the removed blocks
and the new import statements.

- task-page-github-task-kind.ts: isPRFocusedTaskView, normalizeGitHubTaskPreset,
  getGitHubTaskKind, getDefaultPresetForGitHubTaskKind, scopeGitHubTaskSearch
- task-page-jira-create-fields.ts: the Jira create-field visibility, allowed-value,
  and payload builders
- task-page-jira-project-selection.ts: getJiraProjectSelectionKey,
  compareJiraProjectsByDisplayLabel
- task-page-jira-status-tone.ts: getJiraStatusTone
- task-page-pr-delta-summary.ts: formatPRDelta
- task-page-pagination-page-numbers.ts: getPageNumbers
- task-page-string-set-equality.ts: areStringSetsEqual

Each module gets a characterization test suite that pins current behavior,
including the quirks (case-sensitive matching, truthiness-based option payload
fallbacks, allowedValues winning over schema type). Quirks are documented, not
fixed.

github-enterprise-slug-routing-boundary.test.ts anchored its source-text
sections on `function formatPRDelta` and `function getPageNumbers`; both moved,
so the sentinels advance to the next declarations. The bounded sections and
their assertions are unchanged.

No intentional behavior change.

* refactor(task-page): clarify helper logic and consolidate tests

- Add comment explaining quoted-form parsing in GitHub task scope
- Refine test descriptions and characterization comments for clarity
- Add test case for quoted `is:"issue"` form in task scoping
- Consolidate test files as part of pure-function extraction

* improvements

* Remove obvious comment from getPageNumbers

The function name and implementation are self-documenting; the comment restates what the code already expresses clearly.
2026-08-09 14:45:34 -07:00

24 lines
680 B
TypeScript

import type { TaskViewPresetId } from './types'
/**
* Why: TaskPage presets, blank-search fallbacks, and openTaskPage prefetch must
* share one preset→query map so cache keys stay aligned across entry points.
*/
export function getTaskPresetQuery(presetId: TaskViewPresetId | null): string {
switch (presetId) {
case 'all':
case 'issues':
return 'is:issue is:open'
case 'my-issues':
return 'assignee:@me is:issue is:open'
case 'prs':
return 'is:pr is:open'
case 'my-prs':
return 'author:@me is:pr is:open'
case 'review':
return 'review-requested:@me is:pr is:open'
case null:
return 'is:issue is:open'
}
}