-
Notifications
You must be signed in to change notification settings - Fork 529
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
feat: Added the use case category in templates page #2314
base: main
Are you sure you want to change the base?
feat: Added the use case category in templates page #2314
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
📝 WalkthroughWalkthroughThe changes introduce a new property Changes
Assessment against linked issues
Suggested labels
Suggested reviewers
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 (
|
@bitbrief is attempting to deploy a commit to the Unkey Team on Vercel. A member of the Team first needs to authorize it. |
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: 2
🧹 Outside diff range and nitpick comments (6)
apps/dashboard/lib/templates-form.ts (2)
11-11
: LGTM! Consider adding a comment for clarity.The addition of
usecases
to the schema is consistent with the existing structure and aligns with the PR objective.Consider adding a brief comment explaining the purpose of the
usecases
field, similar to the existing comments for other fields. For example:/** Array of use case identifiers */ usecases: z.array(z.string()),
67-75
: LGTM! Minor formatting suggestion.The implementation of
usecases
handling in theupdateUrl
function is correct and consistent with other form values.There's a minor indentation issue on line 67. Consider removing the extra space to maintain consistent formatting:
-
apps/www/app/templates/data.ts (3)
20-21
: LGTM! Consider adding a comment for theusecases
constant.The addition of the
usecases
constant andUsecase
type is a good approach for maintaining type safety and consistency across the codebase. This will help prevent typos and ensure that only valid use cases are used.Consider adding a brief comment above the
usecases
constant to explain its purpose and how it relates to the templates. For example:// Defines the available use case categories for templates export const usecases = ["Boilerplate", "Route protection", "RABC"] as const;
Line range hint
67-343
: LGTM! Consider fixing the capitalization of "RABC".The addition of the
usecase
property to all template objects is consistent with the changes made to theTemplate
type and aligns with the PR objectives. This will allow for proper categorization and filtering of templates based on their use cases.There's a minor inconsistency in the capitalization of "RABC" throughout the file. It should be "RBAC" (Role-Based Access Control). Please update the following lines:
- Line 20: Change "RABC" to "RBAC" in the
usecases
constant- Lines 79, 103, 139, 151, and 330: Change "RABC" to "RBAC" in the respective template objects
This will ensure consistency and correctness in the use case terminology.
Action Required: Correct "RABC" to "RBAC" in
data.ts
The verification script identified several instances where "RABC" is still used instead of "RBAC". Please update the following lines in
apps/www/app/templates/data.ts
:
- Replace all occurrences of
usecase: "RABC"
withusecase: "RBAC"
.- Ensure that the
usecases
array no longer includes "RABC" but uses "RBAC" where appropriate.This correction will align the terminology with the standard "Role-Based Access Control" acronym, improving code clarity and consistency.
🔗 Analysis chain
Line range hint
1-343
: Overall, the changes successfully implement the new "use case" category.The modifications to this file align well with the PR objectives of adding a new "use case" category to the templates page. The implementation includes:
- A new
usecases
constant andUsecase
type for type-safe use of the defined categories.- An updated
Template
type that includes the newusecase
property.- Addition of the
usecase
property to all template objects in thetemplates
constant.These changes provide a solid foundation for categorizing and filtering templates based on their use cases, enhancing the user experience as intended.
To ensure that all templates have been properly updated with the new
usecase
property, please run the following verification script:This script will help ensure that all templates have been properly updated and that the "RABC" to "RBAC" correction has been applied consistently.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify that all templates have the usecase property # Test: Check if any template is missing the usecase property missing_usecase=$(rg -U 'title:.*\n(?:(?!usecase:).)*?},' apps/www/app/templates/data.ts) if [ -n "$missing_usecase" ]; then echo "The following templates are missing the usecase property:" echo "$missing_usecase" else echo "All templates have the usecase property." fi # Test: Check for any remaining "RABC" occurrences that should be "RBAC" rabc_occurrences=$(rg 'RABC' apps/www/app/templates/data.ts) if [ -n "$rabc_occurrences" ]; then echo "The following lines still contain 'RABC' instead of 'RBAC':" echo "$rabc_occurrences" else echo "No 'RABC' occurrences found. All have been correctly changed to 'RBAC'." fiLength of output: 1391
apps/www/app/templates/client.tsx (1)
Line range hint
499-514
: Refactor template tag rendering to avoid duplicationThe code for rendering template tags for
framework
,language
, andusecase
repeats similar patterns. Consider refactoring this into a reusable component or a function to render tags dynamically, which will make the code cleaner and easier to maintain.Here's how you might refactor it:
function renderTemplateTags(template: Template) { const tags = [ template.framework, template.language, template.usecase, ].filter((tag): tag is string => tag !== undefined); return tags.map((tag) => ( <div key={tag} className="px-2 py-1 text-xs rounded-md bg-[rgb(26,26,26)] text-white/60" > {tag} </div> )); }Then use it in your component:
<div className="flex flex-row flex-wrap justify-start w-full h-full gap-3"> {renderTemplateTags(template)} </div>
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (4)
- apps/dashboard/lib/templates-form.ts (4 hunks)
- apps/www/app/templates/client.tsx (9 hunks)
- apps/www/app/templates/data.ts (26 hunks)
- apps/www/lib/templates-form.ts (5 hunks)
🧰 Additional context used
🔇 Additional comments (9)
apps/dashboard/lib/templates-form.ts (2)
28-28
: LGTM! Consistent implementation ofusecases
initialization.The changes correctly handle the initialization of
usecases
for both browser and non-browser contexts. The implementation is consistent with how other form values are managed.Also applies to: 37-37, 43-43
Line range hint
1-105
: Overall implementation looks good and aligns with PR objectives.The changes consistently implement the new
usecases
property across the file, including schema definition, default value initialization, and URL parameter handling. This implementation successfully adds support for the new "use case" category in the templates page, as outlined in the PR objectives.The code follows existing patterns and integrates well with the current structure. No significant issues were found in the logic or functionality.
apps/www/lib/templates-form.ts (6)
3-3
: LGTM: Import statement for usecases added correctly.The import statement for
usecases
is correctly added and uses a relative path consistent with the project structure.
12-12
: LGTM: Usecases property added to schema correctly.The
usecases
property is correctly added to the schema object usingz.array(z.string())
. This is consistent with the existing schema structure and appropriate for storing multiple use cases.
29-29
: LGTM: Usecases added to default form values correctly.The
usecases
property is correctly added to the default form values, initialized as an empty array when not in a browser environment. This is consistent with the existing function structure and ensures that the default form values include the new usecases property.
38-38
: LGTM: Usecases added to URL parameter handling correctly.The
usecases
property is correctly added to the URL parameter handling logic. It's retrieved from the URL parameters and included in the returned object, consistent with the handling of other properties. The logic correctly handles both the presence and absence of usecases in the URL.Also applies to: 44-44
60-67
: LGTM: Usecases handling added to updateUrl function correctly.The
usecases
property is correctly added to theupdateUrl
function. The logic is consistent with the handling of other properties and correctly manages multiple usecases in the URL. It properly clears existing usecase parameters before adding new ones, ensuring accurate URL representation of the form state.
Line range hint
1-105
: Summary: Implementation of "use case" category is complete and aligns with PR objectives.The changes in this file successfully implement the new "use case" category for the templates page. The modifications include:
- Adding
usecases
to the schema- Updating default form values
- Handling
usecases
in URL parameters- Updating the URL with
usecases
valuesThese changes are consistent with the existing code structure and patterns, and they fully align with the PR objectives outlined in issue #2289. The implementation allows for proper management of use cases in form values, URL parameters, and schema validation, enhancing the templates page functionality as intended.
apps/www/app/templates/data.ts (1)
51-51
: LGTM! TheTemplate
type has been correctly updated.The addition of the
usecase: Usecase;
property to theTemplate
type is consistent with the newly definedUsecase
type. This ensures type safety and enforces the inclusion of a valid use case for each template.
/assign |
You already have an open issue assigned to you here. Once that's closed or unassigned, only then we recommend you to take up more. |
/assign |
You already have an open issue assigned to you here. Once that's closed or unassigned, only then we recommend you to take up more. |
Hi @perkinsjr, when you have a moment, could you take a look at this PR? I'd love your feedback. |
@bitbrief I am not the maintainer of this repo. But it should be RBAC (role-based access control) and not RABC |
Yeah I was wondering about the order. |
Hi maintainers, I hope this message finds you well. I wanted to follow up regarding my pull request. I understand that everyone is busy, but I would appreciate any updates on its status. If there’s anything further I need to do or if there are any concerns regarding the PR, please let me know. Thank you for your time and help! |
I don't think the current 3 usecases are what we really want in the end. I also think a template may have multiple usecases, not just a single one wdyt @perkinsjr? |
What does this PR do?
Added the use case category in the templates page with all the working features of other categories like language and framework.
Fixes #2289
If there is not an issue for this, please create one first. This is used to tracking purposes and also helps use understand why this PR exists
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
Bug Fixes
Documentation