-
Notifications
You must be signed in to change notification settings - Fork 504
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
style: sort languages and frameworks alphabetically in the template filter #2502
Conversation
|
@ShreyasLakhani is attempting to deploy a commit to the Unkey Team on Vercel. A member of the Team first needs to authorize it. |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 Walkthrough📝 WalkthroughWalkthroughThe pull request modifies the Changes
Assessment against linked issues
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Thank you for following the naming conventions for pull request titles! 🙏 |
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.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (1)
apps/www/app/templates/client.tsx (1)
Line range hint
278-313
: LGTM: Alphabetical sorting of framework options implemented.The changes successfully implement the requested feature of sorting framework options alphabetically, consistent with the language filtering implementation. The functionality is preserved while improving the user experience.
Consider extracting the sorting logic into a reusable function to reduce code duplication:
const sortAlphabetically = (a: [string, any], b: [string, any]) => a[0].localeCompare(b[0]); // Then use it like this: Object.entries(languages).sort(sortAlphabetically).map(...) Object.entries(frameworks).sort(sortAlphabetically).map(...)This would make the code more DRY and easier to maintain.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- apps/www/app/templates/client.tsx (4 hunks)
🧰 Additional context used
🔇 Additional comments (2)
apps/www/app/templates/client.tsx (2)
Line range hint
218-254
: LGTM: Alphabetical sorting of language options implemented.The changes successfully implement the requested feature of sorting language options alphabetically. The use of
localeCompare
for sorting is appropriate and ensures correct alphabetical order. The existing functionality is preserved while improving the user experience.
Line range hint
218-313
: Summary: PR objectives successfully implementedThe changes in this PR effectively address the issue #2432 by implementing alphabetical sorting for both language and framework filter options. This enhancement improves the user experience by making it easier to locate specific options within the filters.
Key points:
- The sorting is consistently implemented for both languages and frameworks.
- The existing functionality of the component is preserved.
- The changes are focused and do not introduce any apparent issues.
These modifications align well with the PR objectives and should provide a noticeable improvement in usability for the templates page.
@perkinsjr @chronark please review my PR and give feedback. |
/assign |
The /assign command can only be used on issues, not on pull requests. |
@perkinsjr @chronark @MichaelUnkey @mcstepp Can anyone review my PR? |
@chronark tell me is it works or not? |
apps/www/app/templates/client.tsx
Outdated
@@ -37,6 +37,9 @@ import { useEffect, useMemo } from "react"; | |||
import { useForm } from "react-hook-form"; | |||
import { type Framework, type Language, templates } from "./data"; | |||
|
|||
// New reusable sorting function | |||
const sortAlphabetically = (a: [string, any], b: [string, any]) => a[0].localeCompare(b[0]); |
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.
don't use any
apps/www/app/templates/client.tsx
Outdated
render={({ field }) => { | ||
return ( | ||
{Object.entries(frameworks) | ||
.sort(sortAlphabetically) // Use the new sorting function |
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.
just use what you did in line 222
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.
@chronark done changes as per yours.
I hope this work.
Let me know if anything miss.
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.
Actionable comments posted: 1
🧹 Outside diff range and nitpick comments (1)
apps/www/app/templates/client.tsx (1)
281-283
: Fix misleading comment in frameworks sorting.
The comment incorrectly refers to "languages" instead of "frameworks".
- .sort(([langA], [langB]) => langA.localeCompare(langB)) // Sort languages alphabetically
+ .sort(([frameworkA], [frameworkB]) => frameworkA.localeCompare(frameworkB)) // Sort frameworks alphabetically
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- apps/www/app/templates/client.tsx (5 hunks)
🧰 Additional context used
🪛 Biome
apps/www/app/templates/client.tsx
[error] 41-41: This variable is unused.
Unused variables usually are result of incomplete refactoring, typos and other source of bugs.
Unsafe fix: If this is intentional, prepend sortAlphabetically with an underscore.
(lint/correctness/noUnusedVariables)
🔇 Additional comments (2)
apps/www/app/templates/client.tsx (2)
Line range hint 221-257
: LGTM! Languages sorting implementation is correct.
The implementation correctly sorts languages alphabetically using localeCompare
, maintaining type safety and readability.
Line range hint 221-316
: Verify sorting implementation across the codebase.
The implementation successfully adds alphabetical sorting to both languages and frameworks sections. Let's verify there are no other instances requiring similar sorting.
✅ Verification successful
Sorting implementation is correctly applied where needed
The verification shows that:
- The alphabetical sorting in the languages and frameworks sections is consistent with other sorting implementations in the codebase
- Other instances of sorting are appropriately implemented for their specific use cases (e.g., date sorting for blog posts, name sorting for projects)
- No other instances of language/framework listings were found that would require similar alphabetical sorting
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check for other potential locations that might need alphabetical sorting
# Look for similar patterns of Object.entries().sort() that might need consistent sorting
rg -A 2 "Object\.entries\([^)]+\)\.sort\(" --type tsx --type jsx
# Look for potential framework/language related code that might need sorting
rg -l "frameworks|languages" --type tsx --type jsx
Length of output: 175
Script:
#!/bin/bash
# Description: Check for other potential locations that might need alphabetical sorting
# Look for similar patterns of Object.entries().sort() that might need consistent sorting
rg -A 2 "Object\.entries\([^)]+\)\.sort\("
# Look for potential framework/language related code that might need sorting
rg -l "frameworks|languages"
# Look for other potential sorting implementations
rg "\.sort\(\([a-zA-Z]" -A 2
Length of output: 4061
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.
@chronark Rewrite the sorting logic.
✅ Actions performedReview triggered.
|
@coderabbitai full review |
✅ Actions performedFull review triggered. |
@ShreyasLakhani: I will redo the entire review of the PR as per your request. ✅ Actions performedFull review triggered. |
@chronark can you please review my changes before end of the hacktoberfest |
What does this PR do?
This PR implements a new feature that allows users to filter items by category, enhancing the user experience by making it easier to find relevant items. This change fixes issue #2432, which requested this functionality. No additional dependencies are required for this change.
Fixes #2432
Type of change
How should this be tested?
Checklist
Required
pnpm build
pnpm fmt
console.logs
git pull origin main
Appreciated
Summary by CodeRabbit
New Features
AccordionContent
.Bug Fixes