-
Notifications
You must be signed in to change notification settings - Fork 523
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
fix: Replaced clear button with reset filters button #2703
Conversation
|
📝 Walkthrough📝 WalkthroughWalkthroughThe pull request introduces modifications to the Changes
Assessment against linked issues
Possibly related PRs
Suggested labels
Suggested reviewers
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
💤 Files with no reviewable changes (1)
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 (
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@BadriVishalPadhy 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 (1)
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx (1)
Line range hint
31-201
: Consider unifying filter state managementThe current implementation manages each filter's visibility and value separately, which could lead to maintenance challenges as more filters are added. Consider implementing a more unified approach to filter state management.
Some suggestions:
- Create a single filter configuration object
- Implement a generic filter visibility toggle
- Use a reducer pattern for filter state management
Example approach:
type FilterState = { identifier: { visible: boolean; value: string[] }; success: { visible: boolean; value: boolean | null }; timeRange: { visible: boolean; after: Date | null; before: Date | null }; }; type FilterAction = | { type: 'RESET_ALL' } | { type: 'TOGGLE_VISIBILITY'; filter: keyof FilterState } | { type: 'UPDATE_VALUE'; filter: keyof FilterState; value: any };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx
(1 hunks)apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/page.tsx
(1 hunks)
🔇 Additional comments (2)
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/page.tsx (1)
139-139
: LGTM: Removal of redirect link fixes issue #2394
The removal of the filter reset link resolves the incorrect redirection to "/audit" page and consolidates the reset functionality to the "Reset Filters" button, providing a more consistent user experience.
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx (1)
119-119
: LGTM: Button label accurately describes its action
The "Reset Filters" label better communicates the button's functionality of resetting all filters, improving user understanding.
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx
Outdated
Show resolved
Hide resolved
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx
Outdated
Show resolved
Hide resolved
Hey @chronark do check this |
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 (2)
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx (2)
Line range hint
149-149
: Remove unnecessary empty startTransition callsThere are still empty startTransition calls that serve no purpose and should be removed.
Apply these changes:
- Remove empty startTransition after setIdentifier:
setIdentifier(v); -startTransition(() => {});
- Remove empty startTransition after setSuccess:
setSuccess(v === "true"); -startTransition(() => {});
Also applies to: 182-182
111-119
: Extract reset logic into a reusable functionThe reset logic is duplicated across multiple button handlers. Consider extracting it into a reusable function for better maintainability and consistency.
Create a handler function like this:
const handleResetFilters = (filterType?: 'all' | 'success' | 'timeRange') => { startTransition(() => { if (filterType === 'all' || !filterType) { setIdentifierVisible(false); setSuccessVisible(false); setSuccess(null); setTimeRangeVisible(false); setIdentifier(null); setAfter(null); setBefore(null); setLocalTime(""); } else if (filterType === 'success') { setSuccessVisible(false); setSuccess(null); } else if (filterType === 'timeRange') { setTimeRangeVisible(false); setAfter(null); setBefore(null); setLocalTime(""); } }); };Then use it in the button handlers:
// Reset all filters onClick={() => handleResetFilters()} // Reset success filter onClick={() => handleResetFilters('success')} // Reset time range filter onClick={() => handleResetFilters('timeRange')}Also applies to: 182-186, 215-220
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx
(1 hunks)
🔇 Additional comments (2)
apps/dashboard/app/(app)/ratelimits/[namespaceId]/logs/filter.tsx (2)
111-122
: Implementation successfully addresses PR objectives
The changes effectively solve the original issue by:
- Preventing redirection to "/audit" page
- Providing comprehensive filter reset functionality
- Using clearer "Reset Filters" button text for better UX
111-119
:
Add missing localTime state reset
The reset functionality should also clear the localTime
state for complete consistency. While the implementation properly resets most states, it misses the localTime
state which is used to display the time range information.
Apply this diff to include the localTime reset:
startTransition(() => {
setIdentifierVisible(false);
setSuccessVisible(false);
setSuccess(null);
setTimeRangeVisible(false);
setIdentifier(null);
setAfter(null);
setBefore(null);
+ setLocalTime("");
});
Likely invalid or redundant comment.
@ogzhanolguncu check |
Looks and works great. |
What does this PR do?
replaced Clear-button with reset-filters-button because the clear button function and reset-filters-button function is same .Also clear button was only clearing one item but now resets all.
Fixes #2394
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
Screen.Recording.2024-12-04.at.19.36.04.mov
Summary by CodeRabbit