mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
fix: adress pr comments
This commit is contained in:
@@ -20,6 +20,11 @@ import { cn } from '@/lib/utils';
|
||||
import type { IssuesStateFilter } from '../types';
|
||||
import { ISSUES_STATE_FILTER_OPTIONS } from '../types';
|
||||
|
||||
/** Maximum number of labels to display before showing "+N more" in normal layout */
|
||||
const VISIBLE_LABELS_LIMIT = 3;
|
||||
/** Maximum number of labels to display before showing "+N more" in compact layout */
|
||||
const VISIBLE_LABELS_LIMIT_COMPACT = 2;
|
||||
|
||||
interface IssuesFilterControlsProps {
|
||||
/** Current state filter value */
|
||||
stateFilter: IssuesStateFilter;
|
||||
@@ -156,21 +161,27 @@ export function IssuesFilterControls({
|
||||
{/* Selected Labels Display - shown on separate row */}
|
||||
{hasSelectedLabels && (
|
||||
<div className="flex items-center gap-1 flex-wrap">
|
||||
{selectedLabels.slice(0, compact ? 2 : 3).map((label) => (
|
||||
<Badge
|
||||
key={label}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="gap-1 cursor-pointer hover:bg-destructive/10 hover:border-destructive/50"
|
||||
onClick={() => handleLabelToggle(label)}
|
||||
>
|
||||
{label}
|
||||
<X className="h-2.5 w-2.5" />
|
||||
</Badge>
|
||||
))}
|
||||
{selectedLabels.length > (compact ? 2 : 3) && (
|
||||
{selectedLabels
|
||||
.slice(0, compact ? VISIBLE_LABELS_LIMIT_COMPACT : VISIBLE_LABELS_LIMIT)
|
||||
.map((label) => (
|
||||
<Badge
|
||||
key={label}
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="gap-1 cursor-pointer hover:bg-destructive/10 hover:border-destructive/50"
|
||||
onClick={() => handleLabelToggle(label)}
|
||||
>
|
||||
{label}
|
||||
<X className="h-2.5 w-2.5" />
|
||||
</Badge>
|
||||
))}
|
||||
{selectedLabels.length >
|
||||
(compact ? VISIBLE_LABELS_LIMIT_COMPACT : VISIBLE_LABELS_LIMIT) && (
|
||||
<Badge variant="muted" size="sm">
|
||||
+{selectedLabels.length - (compact ? 2 : 3)} more
|
||||
+
|
||||
{selectedLabels.length -
|
||||
(compact ? VISIBLE_LABELS_LIMIT_COMPACT : VISIBLE_LABELS_LIMIT)}{' '}
|
||||
more
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -200,8 +200,9 @@ export function useIssuesFilter(
|
||||
// Normalize search query for case-insensitive matching
|
||||
const normalizedQuery = searchQuery.toLowerCase().trim();
|
||||
|
||||
// Filter issues based on all criteria
|
||||
const matchedIssueNumbers = new Set<number>();
|
||||
// Filter issues based on all criteria - return matched issues directly
|
||||
// This eliminates the redundant O(n) filtering operation in the consuming component
|
||||
const matchedIssues: GitHubIssue[] = [];
|
||||
|
||||
for (const issue of issues) {
|
||||
// All conditions must be true for a match
|
||||
@@ -214,17 +215,17 @@ export function useIssuesFilter(
|
||||
matchesValidationStatus(issue, validationStatusFilter, cachedValidations);
|
||||
|
||||
if (matchesAllFilters) {
|
||||
matchedIssueNumbers.add(issue.number);
|
||||
matchedIssues.push(issue);
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
matchedIssueNumbers,
|
||||
matchedIssues,
|
||||
availableLabels,
|
||||
availableAssignees,
|
||||
availableMilestones,
|
||||
hasActiveFilter,
|
||||
matchedCount: matchedIssueNumbers.size,
|
||||
matchedCount: matchedIssues.length,
|
||||
};
|
||||
}, [
|
||||
issues,
|
||||
|
||||
@@ -72,8 +72,8 @@ export interface IssuesFilterState {
|
||||
* Result of applying filters to the issues list
|
||||
*/
|
||||
export interface IssuesFilterResult {
|
||||
/** Set of issue numbers that match the current filters */
|
||||
matchedIssueNumbers: Set<number>;
|
||||
/** Array of GitHubIssue objects that match the current filters */
|
||||
matchedIssues: GitHubIssue[];
|
||||
/** Available labels from all issues (for filter dropdown population) */
|
||||
availableLabels: string[];
|
||||
/** Available assignees from all issues (for filter dropdown population) */
|
||||
|
||||
Reference in New Issue
Block a user