-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 deleting rules considering the applied filters #4224
base: master
Are you sure you want to change the base?
fix deleting rules considering the applied filters #4224
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Bundle Stats — desktop-clientHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset
View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger
Smaller No assets were smaller Unchanged
|
Bundle Stats — loot-coreHey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle. As this PR is updated, I'll keep you updated on how the bundle size is impacted. Total
Changeset No files were changed View detailed bundle breakdownAdded No assets were added Removed No assets were removed Bigger No assets were bigger Smaller No assets were smaller Unchanged
|
10e7a8a
to
79d606e
Compare
79d606e
to
f998baa
Compare
WalkthroughThe pull request modifies the Assessment against linked issues
Possibly related PRs
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 (
|
Would you also prefer to reset the filter after the deletion is complete? |
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
🧹 Nitpick comments (1)
packages/desktop-client/src/components/ManageRules.tsx (1)
203-210
: Consider removing ts-ignore and improving type safety.While the intersection logic is correct, there are opportunities to improve the type safety:
- The
@ts-ignore
comment seems unnecessary as Set operations are well-supported in TypeScript.- Consider using type parameters for the Set to avoid type assertion.
- // @ts-ignore `intersection` is fully compatible with browser versions - selectedInst.items.intersection( - new Set(filteredRules.map(r => r.id)), - ) as Set<string> + const filteredIds = new Set<string>(filteredRules.map(r => r.id)); + new Set([...selectedInst.items].filter(x => filteredIds.has(x)))
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
upcoming-release-notes/4224.md
is excluded by!**/*.md
📒 Files selected for processing (1)
packages/desktop-client/src/components/ManageRules.tsx
(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Functional
- GitHub Check: Visual regression
- GitHub Check: build (ubuntu-latest)
🔇 Additional comments (4)
packages/desktop-client/src/components/ManageRules.tsx (4)
21-24
: LGTM! Type imports improve type safety.The addition of explicit type imports enhances type checking and code maintainability.
116-116
: LGTM! Explicit state typing.The explicit typing of
allRules
asRuleEntity[]
improves type safety and code clarity.
Line range hint
212-228
: LGTM! Robust delete handler implementation.The delete handler correctly:
- Uses the filtered set of rules
- Handles errors gracefully with user feedback
- Cleans up selection state
354-357
: LGTM! Accurate UI feedback.The delete button correctly reflects the number of rules that can actually be deleted, considering the applied filters.
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
🧹 Nitpick comments (1)
packages/desktop-client/src/components/ManageRules.tsx (1)
Line range hint
210-226
: Consider enhancing error feedback.The implementation correctly uses
rulesToDelete
and handles the deletion process well. However, the error message could be more specific about which rules failed to delete.Consider enhancing the error message to include the names or IDs of rules that couldn't be deleted:
- alert( - t('Some rules were not deleted because they are linked to schedules'), - ); + alert( + t('The following rules could not be deleted because they are linked to schedules: ') + + Array.from(rulesToDelete) + .filter(id => /* check which rules failed */) + .map(id => allRules.find(r => r.id === id)?.name || id) + .join(', ') + );
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/desktop-client/src/components/ManageRules.tsx
(5 hunks)
🔇 Additional comments (5)
packages/desktop-client/src/components/ManageRules.tsx (5)
21-24
: LGTM! Type safety improvement.The addition of the
RuleEntity
type import enhances type safety and provides better type checking for rule entities.
116-116
: LGTM! Proper type annotation for state.The explicit type annotation
RuleEntity[]
forallRules
state ensures type safety throughout the component.
203-208
: LGTM! Core fix for rule deletion.The
rulesToDelete
implementation correctly ensures that only rules visible in the current filter can be deleted. The use ofSet
for efficient lookups and proper memoization with correct dependencies makes this a robust solution.
352-355
: LGTM! Accurate delete button state.The delete button correctly reflects the number of rules that can be deleted based on the current filter.
203-208
: Verify edge cases in rule deletion.Let's verify the robustness of the rule deletion implementation.
Also applies to: 352-355
✅ Verification successful
Rule deletion implementation is robust and handles edge cases properly
The implementation correctly handles:
- Filtered rule selection
- Both single and batch deletions
- Failed deletion scenarios
- Loading states and concurrency
- Type safety through proper interfaces
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for potential edge cases in rule deletion handling # Test 1: Check for proper cleanup of rule references echo "Checking for proper cleanup of rule references..." rg -l "rule\." --type ts # Test 2: Check for proper error handling patterns echo "Checking for consistent error handling patterns in rule deletion..." ast-grep --pattern 'await send("rule-delete", $_)' # Test 3: Check for proper loading state management echo "Checking for consistent loading state management..." ast-grep --pattern 'setLoading($_)'Length of output: 6000
Script:
#!/bin/bash # Check rule deletion implementation and error handling # Look for rule deletion implementation echo "Checking rule deletion implementation..." rg -A 5 "rule-delete" --type ts # Look for error handling patterns around rule deletion echo "Checking error handling patterns..." rg -A 5 "catch.*rule.*delete" --type ts rg -A 5 "try.*rule.*delete" --type tsLength of output: 3697
Fixes #3366