-
Notifications
You must be signed in to change notification settings - Fork 245
feat: add status filtering to OSS programs #355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
pulkitporwal
wants to merge
3
commits into
apsinghdev:main
Choose a base branch
from
pulkitporwal:feature/gsoc-status-filter
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,139 @@ | ||
| "use client"; | ||
|
|
||
| import { useState, useRef, useEffect, useMemo } from "react"; | ||
| import { X, ChevronDown, Filter } from "lucide-react"; | ||
|
|
||
| interface StatusFilterProps { | ||
| statuses: string[]; | ||
| selectedStatuses: string[]; | ||
| onStatusesChange: (statuses: string[]) => void; | ||
| } | ||
|
|
||
| export default function StatusFilter({ | ||
| statuses, | ||
| selectedStatuses, | ||
| onStatusesChange, | ||
| }: StatusFilterProps) { | ||
| const [filterInput, setFilterInput] = useState(""); | ||
| const [isDropdownOpen, setIsDropdownOpen] = useState(false); | ||
| const dropdownRef = useRef<HTMLDivElement>(null); | ||
| const inputRef = useRef<HTMLInputElement>(null); | ||
|
|
||
| useEffect(() => { | ||
| if (!isDropdownOpen) return; // Only attach listener when open | ||
|
|
||
| function handleClickOutside(event: MouseEvent) { | ||
| if ( | ||
| dropdownRef.current && | ||
| !dropdownRef.current.contains(event.target as Node) | ||
| ) { | ||
| setIsDropdownOpen(false); | ||
| } | ||
| } | ||
|
|
||
| // Use passive listener for better scroll performance | ||
| document.addEventListener("mousedown", handleClickOutside, { | ||
| passive: true, | ||
| }); | ||
| return () => document.removeEventListener("mousedown", handleClickOutside); | ||
| }, [isDropdownOpen]); | ||
|
|
||
| const availableTags = useMemo(() => { | ||
| return statuses.filter( | ||
| (status) => | ||
| !selectedStatuses.includes(status) && | ||
| status.toLowerCase().includes(filterInput.toLowerCase()) | ||
| ); | ||
| }, [statuses, selectedStatuses, filterInput]); | ||
|
|
||
| const addTag = (tag: string) => { | ||
| onStatusesChange([...selectedStatuses, tag]); | ||
| setFilterInput(""); | ||
| setIsDropdownOpen(true); | ||
| inputRef.current?.focus(); | ||
| }; | ||
|
|
||
| const removeTag = (tagToRemove: string) => { | ||
| onStatusesChange(selectedStatuses.filter((status) => status !== tagToRemove)); | ||
| }; | ||
|
|
||
| const handleKeyDown = (e: React.KeyboardEvent) => { | ||
| if ( | ||
| e.key === "Backspace" && | ||
| filterInput === "" && | ||
| selectedStatuses.length > 0 | ||
| ) { | ||
| removeTag(selectedStatuses[selectedStatuses.length - 1]); | ||
| } | ||
| }; | ||
|
|
||
| return ( | ||
| <div className="relative flex-1 min-w-0" ref={dropdownRef}> | ||
| <div | ||
| className="flex items-center gap-2 bg-dash-surface border border-dash-border rounded-xl p-2 min-h-[50px] focus-within:border-brand-purple transition-colors cursor-text min-w-0" | ||
| onClick={() => { | ||
| inputRef.current?.focus(); | ||
| setIsDropdownOpen(true); | ||
| }} | ||
| > | ||
| <div className="flex flex-wrap items-center gap-2 flex-1 min-w-0"> | ||
| <Filter className="w-4 h-4 text-text-secondary" /> | ||
| {selectedStatuses.map((status) => ( | ||
| <span | ||
| key={status} | ||
| className="flex items-center gap-1 bg-brand-purple/20 text-brand-purple-light px-3 py-1 rounded-full text-sm flex-shrink-0" | ||
| > | ||
| {status} | ||
| <button | ||
| onClick={(e) => { | ||
| e.stopPropagation(); | ||
| removeTag(status); | ||
| }} | ||
| aria-label={`Remove ${status}`} | ||
| className="hover:text-white" | ||
| > | ||
| <X className="w-3 h-3" /> | ||
| </button> | ||
| </span> | ||
| ))} | ||
| <input | ||
| ref={inputRef} | ||
| type="text" | ||
| placeholder={selectedStatuses.length === 0 ? "Status..." : ""} | ||
| value={filterInput} | ||
| onChange={(e) => { | ||
| setFilterInput(e.target.value); | ||
| setIsDropdownOpen(true); | ||
| }} | ||
| onKeyDown={handleKeyDown} | ||
| onFocus={() => setIsDropdownOpen(true)} | ||
| className="bg-transparent text-white placeholder-gray-500 focus:outline-none flex-1 min-w-0" | ||
| /> | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| </div> | ||
| <ChevronDown className="w-5 h-5 text-gray-400 flex-shrink-0" /> | ||
| </div> | ||
|
|
||
| {/* Replaced Framer Motion with CSS transitions for better performance */} | ||
| {isDropdownOpen && ( | ||
| <div className="absolute z-20 top-full left-0 right-0 mt-2 bg-dash-surface border border-dash-border rounded-xl shadow-xl max-h-60 overflow-y-auto animate-in fade-in slide-in-from-top-2 duration-150"> | ||
| {availableTags.length === 0 ? ( | ||
| <div className="p-4 text-gray-500 text-center"> | ||
| No matching statuses found | ||
| </div> | ||
| ) : ( | ||
| availableTags.map((status) => ( | ||
| <button | ||
| key={status} | ||
| onClick={() => addTag(status)} | ||
| aria-label={`Add status ${status}`} | ||
| className="w-full text-left px-4 py-3 hover:bg-dash-hover text-gray-300 hover:text-white transition-colors flex items-center justify-between" | ||
| > | ||
| {status} | ||
| </button> | ||
| )) | ||
| )} | ||
| </div> | ||
| )} | ||
| </div> | ||
| ); | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,12 @@ | ||
| packages: | ||
| - 'apps/*' | ||
| - 'packages/*' | ||
| - apps/* | ||
| - packages/* | ||
| onlyBuiltDependencies: | ||
| - '@prisma/client' | ||
| - '@prisma/engines' | ||
| - core-js | ||
| - core-js-pure | ||
| - esbuild | ||
| - prisma | ||
| - sharp | ||
| - unrs-resolver |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: apsinghdev/opensox
Length of output: 121
🏁 Script executed:
Repository: apsinghdev/opensox
Length of output: 44
🏁 Script executed:
Repository: apsinghdev/opensox
Length of output: 3391
🏁 Script executed:
Repository: apsinghdev/opensox
Length of output: 89
🏁 Script executed:
Repository: apsinghdev/opensox
Length of output: 44
Status filtering has timezone-sensitive boundary date logic affecting multiple components.
The date comparisons use ISO date strings parsed as UTC but compare against
new Date()in local timezone, causing programs to be misclassified on boundary dates depending on timezone offset. This same pattern exists identically inapps/web/src/components/oss-programs/ProgramCard.tsx(lines 11-25), suggesting a systemic issue.recommended fix
Extract a shared date normalization function to handle both locations consistently:
Apply the same
getDerivedStatusfunction toProgramCard.tsxto eliminate the duplicate logic.🤖 Prompt for AI Agents