-
-
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
Use a toggle on mobile transaction's Cleared flag #3622
Conversation
✅ Deploy Preview for actualbudget ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
WalkthroughThe pull request introduces several modifications across multiple components within the desktop client application. The 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 (
|
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 No assets were bigger 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
|
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 (9)
packages/desktop-client/src/components/common/Toggle.tsx (3)
12-14
: Approved: Enhanced ToggleProps with new properties.The addition of
disabled
andclassName
props, along with the updatedonToggle
signature, improves the component's flexibility and usability. These changes align well with common React patterns.Consider adding JSDoc comments for these new props to improve documentation:
/** Whether the toggle is disabled */ disabled?: boolean; /** Callback function when the toggle state changes */ onToggle?: (on: boolean) => void; /** Additional CSS class names */ className?: string;
41-42
: Approved: Enhanced label element with data attributes and theme-based styling.The addition of data attributes (
data-toggle-container
anddata-on
) and the use of theme variables for background color are good improvements. These changes enhance testability and maintain consistent styling.Consider extracting the background color logic to a separate variable for improved readability:
const backgroundColor = checked ? theme.checkboxToggleBackgroundSelected : theme.checkboxToggleBackground;Then use this variable in the style object:
background: backgroundColor,Also applies to: 53-55
60-61
: Approved: Improved span element with data attributes and conditional styling.The addition of data attributes (
data-toggle
anddata-on
) and the conditional background color based on thedisabled
state are good improvements. These changes enhance testability and provide better visual feedback.Consider extracting the background color logic to a separate variable for improved readability:
const toggleBackground = disabled ? theme.checkboxToggleDisabled : '#fff';Then use this variable in the style object:
background: toggleBackground,Also applies to: 64-64, 73-73
packages/desktop-client/src/components/common/Menu.tsx (1)
Line range hint
210-232
: Improved toggle item layout and accessibilityThe changes to the toggle item rendering enhance both the layout and accessibility:
- The new
View
component with flexbox properties (flexDirection
,flex
,justifyContent
,alignItems
) improves the alignment and spacing of the toggle item elements.- Wrapping the text in a
label
element and associating it with the toggle input using thehtmlFor
attribute enhances accessibility.- The
onToggle
function now uses a boolean callback, which is more idiomatic for toggle components.However, there are a couple of points to consider:
- The removal of the
onColor
prop from theToggle
component might affect its visual representation. Ensure that the toggle still has appropriate styling for its active state.- The
marginLeft: 5
on theToggle
component seems arbitrary. Consider using a design system variable or a more flexible spacing approach.Consider the following improvements:
- Replace the hardcoded
marginLeft: 5
with a design system spacing variable.- Verify that the
Toggle
component still has appropriate styling for its active state after removing theonColor
prop.packages/desktop-client/src/style/themes/development.ts (1)
178-180
: LGTM! Consider grouping toggle-related constants.The new constants for checkbox toggle styling are well-named and use appropriate colors from the existing palette. They align with the PR objective of adding a toggle functionality.
For improved organization, consider grouping all toggle-related constants together. You could move the new constants right after the existing checkbox constants (around line 177) for better readability and maintenance.
packages/desktop-client/src/style/themes/light.ts (1)
181-182
: Summary: New checkbox toggle constants addedThe additions of
checkboxToggleBackgroundSelected
andcheckboxToggleDisabled
are appropriate and consistent with the existing theme structure. These changes support the implementation of a toggle for the Cleared flag on mobile transactions.Suggestions for next steps:
- Ensure these constants are added to all other theme files (dark, development, midnight) for consistency.
- Consider adding a brief comment explaining the usage of these constants in the relevant UI components.
- Update the PR description with more details about the implementation and the rationale behind these changes.
To maintain consistency and improve maintainability, consider creating a shared interface for theme files. This would help ensure that all required constants are present in each theme file and make it easier to add new themes in the future.
packages/desktop-client/src/style/themes/midnight.ts (2)
180-182
: LGTM! Consider grouping related constants.The new constants
checkboxToggleBackgroundSelected
andcheckboxToggleDisabled
are well-named and use appropriate colors from thecolorPalette
. They enhance the styling options for checkbox toggles, providing distinct visual cues for selected and disabled states.For improved readability and maintainability, consider grouping all checkbox-related constants together. You could move the existing
checkboxToggleBackground
constant (if it's defined elsewhere in this file) next to these new constants.Here's a suggested grouping:
export const checkboxToggleBackground = colorPalette.gray400; export const checkboxToggleBackgroundSelected = colorPalette.purple300; export const checkboxToggleDisabled = colorPalette.gray700;This grouping will make it easier for developers to find and modify all checkbox toggle-related styles in one place.
Line range hint
1-182
: Summary: Enhancing checkbox toggle styling in the midnight themeThe changes to this file are part of a larger effort to improve the styling of checkbox toggles across the application. The new constants
checkboxToggleBackgroundSelected
andcheckboxToggleDisabled
provide additional styling options for selected and disabled states of checkbox toggles.These additions enhance the visual feedback for users interacting with checkbox toggles in the midnight theme, improving overall user experience and accessibility. The chosen colors align well with the existing color scheme, maintaining consistency with the midnight theme's dark and purple-accented aesthetic.
To further improve the theme system:
- Consider creating a separate file for checkbox-related styles if they become more complex in the future.
- Ensure that these new styles are applied consistently across all components that use checkbox toggles.
- Document the purpose and usage of these new constants in a central theme guide or style documentation to help other developers understand and correctly use these new styling options.
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (1)
Line range hint
1077-1110
: Renameunmounted
flag toisMounted
for better readabilityUsing
isMounted
initialized totrue
and setting it tofalse
upon unmount enhances clarity when checking the component's mount status. It makes the conditionals more intuitive.Apply this diff to rename the flag:
- let unmounted = false; + let isMounted = true; async function fetchTransaction() { // ... - if (!unmounted) { + if (isMounted) { // Update state } } // ... return () => { - unmounted = true; + isMounted = false; };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
upcoming-release-notes/3622.md
is excluded by!**/*.md
📒 Files selected for processing (7)
- packages/desktop-client/src/components/common/Menu.tsx (2 hunks)
- packages/desktop-client/src/components/common/Toggle.tsx (4 hunks)
- packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (6 hunks)
- packages/desktop-client/src/style/themes/dark.ts (1 hunks)
- packages/desktop-client/src/style/themes/development.ts (1 hunks)
- packages/desktop-client/src/style/themes/light.ts (1 hunks)
- packages/desktop-client/src/style/themes/midnight.ts (1 hunks)
🧰 Additional context used
📓 Learnings (1)
packages/desktop-client/src/style/themes/light.ts (2)
Learnt from: psybers PR: actualbudget/actual#3298 File: packages/desktop-client/src/style/themes/light.ts:212-214 Timestamp: 2024-09-20T03:54:11.640Z Learning: The tooltip styling constants `tooltipText`, `tooltipBackground`, and `tooltipBorder` have been added to all theme files, including `dark.ts`, `development.ts`, and `midnight.ts`.
Learnt from: psybers PR: actualbudget/actual#3298 File: packages/desktop-client/src/style/themes/light.ts:212-214 Timestamp: 2024-10-08T15:46:15.739Z Learning: The tooltip styling constants `tooltipText`, `tooltipBackground`, and `tooltipBorder` have been added to all theme files, including `dark.ts`, `development.ts`, and `midnight.ts`.
🔇 Additional comments (10)
packages/desktop-client/src/components/common/Toggle.tsx (5)
5-5
: LGTM: Import order change.The reordering of imports doesn't affect functionality and may align with coding standards.
21-21
: LGTM: Updated props destructuring.The destructuring of
disabled
andclassName
props is consistent with theToggleProps
type updates and allows for their use within the component.Also applies to: 23-23
31-32
: LGTM: Improved input element functionality.The addition of the
disabled
attribute and the updatedonChange
handler improves the component's functionality and accessibility. TheonToggle
callback now provides more useful information to the parent component.
Line range hint
1-84
: Overall improvements to the Toggle componentThe changes made to this file have significantly enhanced the Toggle component:
- Added new props (
disabled
andclassName
) for improved flexibility.- Updated the
onToggle
callback to provide more information.- Improved accessibility with the
disabled
attribute.- Enhanced styling options with theme variables and data attributes.
- Improved maintainability and testability.
These changes align well with React best practices and should improve the overall quality of the codebase.
27-27
: Approved: Replaced div with View component.The replacement of the outer
div
with aView
component and the addition of theclassName
prop improves the component's flexibility. This change allows for better customization from parent components.Could you provide more information about the
View
component? Let's verify its implementation:Also applies to: 82-82
✅ Verification successful
Further Verification Needed: Unable to locate the
View
component definition.To better understand the
View
component, let's perform a broader search to identify its definition or import.
Further Verification Needed: rg command failed to recognize the 'typescript' file type.
Let's adjust the search to use specific file extensions and try again.
Verified: Replacement of
div
withView
component is correct.The
View
component is properly defined and serves as a flexible wrapper around adiv
, ensuring enhanced customization and ref forwarding. Replacing thediv
withView
inToggle.tsx
aligns with our component architecture and maintains functionality.
- Confirmed the definition of
View
inpackages/desktop-client/src/components/common/View.tsx
.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for the View component definition ast-grep --lang typescript --pattern $'export const View = $_'Length of output: 63
Script:
#!/bin/bash # Search for any export or import of the View component rg --type typescript 'export\s+(const|function|class)\s+View\b' || rg --type typescript 'import\s+\{\s*View\s*\}'Length of output: 184
Script:
#!/bin/bash # Search for any export or import of the View component using TypeScript file extensions rg 'export\s+(const|function|class)\s+View\b' --glob '*.ts' --glob '*.tsx' || rg 'import\s+\{\s*View\s*\}' --glob '*.ts' --glob '*.tsx'Length of output: 207
packages/desktop-client/src/style/themes/dark.ts (2)
Line range hint
1-180
: Summary of changes to the dark themeThe additions to this file enhance the dark theme by introducing two new checkbox toggle states:
checkboxToggleBackgroundSelected
: For the selected state of a checkbox toggle.checkboxToggleDisabled
: For the disabled state of a checkbox toggle.These changes are consistent with the existing theme and follow the established naming conventions. They provide more granular control over checkbox toggle appearances, which aligns with the PR objective of using a toggle for the Cleared flag on mobile transactions.
The changes look good and are ready for integration, pending verification of their usage in the components.
179-180
: New checkbox toggle styles addedThe new exports
checkboxToggleBackgroundSelected
andcheckboxToggleDisabled
have been added to support additional states for checkbox toggles. These additions enhance the theme's flexibility for checkbox styling.A few observations:
- The selected state uses
purple300
, which is consistent with other selected states in the theme (e.g.,checkboxBackgroundSelected
).- The disabled state uses
gray400
, which is appropriate for indicating a non-interactive state.These additions look good and are consistent with the existing theme. However, to ensure proper integration:
Let's verify if these new exports are used correctly in the codebase:
This will help us confirm that the new exports are being utilized as intended in the components.
✅ Verification successful
Checkbox Toggle Styles Integration Verified
The new exports
checkboxToggleBackgroundSelected
andcheckboxToggleDisabled
are correctly defined in the theme files and properly utilized withinToggle.tsx
. No issues detected.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usage of the new exports echo "Searching for checkboxToggleBackgroundSelected usage:" rg "checkboxToggleBackgroundSelected" --type ts --type tsx echo "\nSearching for checkboxToggleDisabled usage:" rg "checkboxToggleDisabled" --type ts --type tsxLength of output: 381
Script:
#!/bin/bash # Search for usage of the new exports in .ts and .tsx files echo "Searching for checkboxToggleBackgroundSelected usage:" rg "checkboxToggleBackgroundSelected" --glob "*.ts" --glob "*.tsx" echo "\nSearching for checkboxToggleDisabled usage:" rg "checkboxToggleDisabled" --glob "*.ts" --glob "*.tsx"Length of output: 1524
packages/desktop-client/src/style/themes/light.ts (2)
182-182
: LGTM! Verify consistency across theme files.The addition of
checkboxToggleDisabled
is consistent with the existing theme structure and naming conventions. It appropriately uses a color from thecolorPalette
.To ensure consistency across all theme files, please run the following script:
✅ Verification successful
Action Required: Retry consistency check with corrected file type.
The previous script failed due to an unrecognized file type. Please use the updated script below to verify the presence of
checkboxToggleDisabled
in all TypeScript theme files:
Consistency Verified Across All Theme Files
The
checkboxToggleDisabled
constant is present in all theme files with appropriate color assignments:
packages/desktop-client/src/style/themes/midnight.ts
packages/desktop-client/src/style/themes/development.ts
packages/desktop-client/src/style/themes/dark.ts
packages/desktop-client/src/style/themes/light.ts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if checkboxToggleDisabled is present in all theme files # Test: Search for checkboxToggleDisabled in all theme files rg --type typescript 'export const checkboxToggleDisabled' packages/desktop-client/src/style/themes/Length of output: 137
Script:
# #!/bin/bash # Description: Check if checkboxToggleDisabled is present in all theme files # Test: Search for checkboxToggleDisabled in all `.ts` theme files rg --type-add 'ts:*.ts' --type ts 'export const checkboxToggleDisabled' packages/desktop-client/src/style/themes/Length of output: 563
181-181
: LGTM! Verify consistency across theme files.The addition of
checkboxToggleBackgroundSelected
is consistent with the existing theme structure and naming conventions. It appropriately uses a color from thecolorPalette
.To ensure consistency across all theme files, please run the following script:
✅ Verification successful
The previous script failed due to an unrecognized file type. Please use the corrected script below to verify consistency across theme files:
The previous script failed due to unrecognized
ts
andtsx
file types. Please use the corrected script below to verify consistency across theme files:
Verification Complete: Consistency Across Theme Files Confirmed
The
checkboxToggleBackgroundSelected
constant is present and appropriately defined in all theme files:
packages/desktop-client/src/style/themes/midnight.ts
packages/desktop-client/src/style/themes/development.ts
packages/desktop-client/src/style/themes/dark.ts
packages/desktop-client/src/style/themes/light.ts
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check if checkboxToggleBackgroundSelected is present in all theme files # Test: Search for checkboxToggleBackgroundSelected in all theme files rg --type typescript 'export const checkboxToggleBackgroundSelected' packages/desktop-client/src/style/themes/Length of output: 147
Script:
# Description: Check if checkboxToggleBackgroundSelected is present in all theme files # Test: Search for checkboxToggleBackgroundSelected in all TypeScript theme files rg --type ts --type tsx 'export const checkboxToggleBackgroundSelected' packages/desktop-client/src/style/themes/Length of output: 143
Script:
#!/bin/bash # Description: Check if checkboxToggleBackgroundSelected is present in all TypeScript theme files # Test: Search for checkboxToggleBackgroundSelected in all .ts and .tsx files within the specified directory rg 'export const checkboxToggleBackgroundSelected' packages/desktop-client/src/style/themes/ --glob '*.ts' --glob '*.tsx'Length of output: 615
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (1)
1125-1179
:⚠️ Potential issueInclude all dependencies in the
useCallback
dependency arrayIn the
onUpdate
function, you're usingonClearActiveEdit
, which should be included in the dependency array of theuseCallback
hook. Omitting dependencies can lead to stale closures and unexpected behavior.Apply this diff to include
onClearActiveEdit
in the dependency array:[dateFormat, transactions], + [dateFormat, transactions, onClearActiveEdit],
Likely invalid or redundant comment.
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx
Outdated
Show resolved
Hide resolved
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 (7)
packages/desktop-client/src/components/common/Toggle.tsx (4)
11-14
: LGTM! Consider adding JSDoc comments.The changes to
ToggleProps
improve the component's flexibility and clarity. The new properties and updated function signature enhance the component's usability.Consider adding JSDoc comments to describe each property, especially the new ones. This would improve the component's documentation and make it easier for other developers to use. For example:
type ToggleProps = { /** Unique identifier for the toggle */ id: string; /** Whether the toggle is on or off */ isOn: boolean; /** Whether the toggle is disabled */ isDisabled?: boolean; /** Callback function called when the toggle state changes */ onToggle?: (isOn: boolean) => void; /** Additional CSS class names */ className?: string; /** Custom styles */ style?: CSSProperties; };
20-23
: Consider maintaining consistent prop names.The prop destructuring aligns with the
ToggleProps
changes, which is good. However, renamingisDisabled
todisabled
in the destructuring might lead to confusion.For consistency and clarity, consider using the same names in the destructuring as in the
ToggleProps
definition:export const Toggle = ({ id, isOn, isDisabled, onToggle, className, style, }: ToggleProps) => { // ... }This maintains consistency between the prop definition and usage, making the code easier to understand and maintain.
27-32
: LGTM! Consider using optional chaining for onToggle.The changes improve the component's functionality and align with the updated prop types. Using
View
instead ofdiv
, adding thedisabled
attribute, and updating theonChange
handler are all positive improvements.Consider using optional chaining for the
onToggle
call to make it more concise:onChange={e => onToggle?.(e.target.checked)}This achieves the same result but is slightly more readable.
60-73
: LGTM! Consider removing unnecessary content property.The changes to the span element, including the addition of data attributes and the conditional background color, are good improvements. They enhance the component's flexibility and visual feedback.
The empty string content property on line 64 appears to be unnecessary. Consider removing it:
- content: ' ',
This property doesn't affect the element's appearance or behavior and can be safely removed to keep the code cleaner.
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (3)
964-977
: Improved transaction status display with toggle functionalityThe addition of conditional rendering for "Reconciled" and "Cleared" statuses in the Footer component enhances the user interface. The use of a Toggle component for the "Cleared" status allows for easy updating of this field.
Consider adding a tooltip or brief explanation for users to understand the difference between "Reconciled" and "Cleared" statuses, as this might not be immediately clear to all users.
1113-1167
: Enhanced onUpdate function with improved handling of rules and split transactionsThe refactored onUpdate function now includes more robust handling of transaction updates, especially for split transactions and rule-based updates. This is a good improvement in functionality.
However, the increased complexity of this function might make it harder to maintain in the future. Consider breaking down this function into smaller, more focused functions to improve readability and maintainability. For example, you could extract the rule-running logic and the subtransaction updating logic into separate helper functions.
Also, consider adding comments to explain the purpose of complex logic blocks, especially around the handling of subtransactions and rule updates.
Line range hint
1-1252
: Consider refactoring for improved maintainabilityThis file is quite large and contains multiple components and complex logic. While it's functional, it could benefit from some refactoring to improve maintainability. Consider breaking it down into smaller, more focused components and files. This would make the code easier to understand, test, and maintain in the long run.
For example, you could:
- Move the ChildTransactionEdit component into its own file.
- Extract the complex logic in the onUpdate function into a custom hook or utility function.
- Consider using the React Context API for sharing state and callbacks between deeply nested components instead of prop drilling.
These changes would significantly improve the overall structure and maintainability of the code.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (9)
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-from-accounts-id-page-1-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-from-accounts-id-page-2-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-from-accounts-id-page-3-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-1-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-2-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-3-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-4-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-5-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-6-chromium-linux.png
is excluded by!**/*.png
📒 Files selected for processing (4)
- packages/desktop-client/src/components/common/Menu.tsx (2 hunks)
- packages/desktop-client/src/components/common/Toggle.tsx (4 hunks)
- packages/desktop-client/src/components/mobile/MobileForms.tsx (3 hunks)
- packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (6 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/desktop-client/src/components/common/Menu.tsx
🧰 Additional context used
🪛 GitHub Check: lint
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx
[warning] 19-19:
'css' is defined but never used. Allowed unused vars must match /^(_|React)/u
🔇 Additional comments (9)
packages/desktop-client/src/components/common/Toggle.tsx (3)
Line range hint
41-55
: LGTM! Good use of data attributes and theme values.The addition of data attributes to the label element and the use of theme values for background colors are positive changes. These improvements enhance the component's flexibility for styling and testing, while also ensuring consistency with the overall theme.
The use of
data-toggle-container
anddata-on
attributes provides useful hooks for styling or testing. The background color logic usingtheme.checkboxToggleBackgroundSelected
andtheme.checkboxToggleBackground
ensures consistency with the application's theme.
82-82
: LGTM! Consistent use of View component.The change of the closing tag to
</View>
is correct and consistent with the earlier modification of the opening tag.This change ensures that the
Toggle
component is properly wrapped with theView
component, maintaining consistency throughout the component structure.
5-7
: LGTM! Verify View component usage.The import changes look good. The
View
component is now imported, which is used later in the component implementation.Let's verify the usage of the
View
component:✅ Verification successful
Verified! The
View
component is correctly imported and utilized within theToggle.tsx
component.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of View component in Toggle.tsx # Test: Search for View usage in Toggle.tsx rg --type typescript 'View' packages/desktop-client/src/components/common/Toggle.tsxLength of output: 119
Script:
#!/bin/bash # Description: Verify the usage of View component in Toggle.tsx # Test: Search for View usage in Toggle.tsx with correct file types rg --type ts --type tsx 'View' packages/desktop-client/src/components/common/Toggle.tsxLength of output: 115
Script:
#!/bin/bash # Description: Verify the usage of View component in Toggle.tsx using grep # Test: Search for 'View' usage in Toggle.tsx grep 'View' packages/desktop-client/src/components/common/Toggle.tsxLength of output: 158
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (2)
61-61
: New import added for Toggle componentThe Toggle component has been imported from the common components. This is good as it suggests a move towards using a standardized UI component for toggle functionality.
971-974
: Consistent use of ToggleField for "Cleared" statusThe implementation of the ToggleField component for the "Cleared" status in the TransactionEditInner component is consistent with the changes in the Footer. This provides a unified way of handling the "Cleared" status throughout the component, improving the overall user experience and code consistency.
packages/desktop-client/src/components/mobile/MobileForms.tsx (4)
2-2
: Approved: Added necessary type importThe addition of
ComponentPropsWithoutRef
is appropriate for typing the new component without ref forwarding.
14-14
: Approved: Importing the Toggle componentImporting the
Toggle
component is necessary for the implementation ofToggleField
.
136-136
: Approved: Defining ToggleFieldPropsUsing
ComponentPropsWithoutRef<typeof Toggle>
to defineToggleFieldProps
ensures proper typing based on theToggle
component's props.
153-167
: Approved: Customizing Toggle component stylesThe use of
css
from Glamor to customize the styles of theToggle
component ensures consistent styling across the application.
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx
Outdated
Show resolved
Hide resolved
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)
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (1)
963-975
: LGTM: Implementation of toggle for Cleared and Reconciled flagsThe changes successfully implement a toggle for the "Cleared" flag and display a disabled toggle for the "Reconciled" flag. This is consistent with the PR objective of adding a toggle for the "Cleared" flag on mobile transactions.
A minor suggestion for consistency:
Consider using the same casing for the
id
prop in both Toggle components:- <Toggle id="Reconciled" isOn isDisabled /> + <Toggle id="reconciled" isOn isDisabled />This makes it consistent with the "cleared" id used in the ToggleField component.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (1)
- packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (5 hunks)
🧰 Additional context used
🔇 Additional comments (2)
packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (2)
60-60
: LGTM: New Toggle component importThe addition of the Toggle component import is consistent with the implementation of the toggle functionality for the "Cleared" flag in the component.
Line range hint
1064-1243
: LGTM: Improvements in TransactionEditUnconnected componentThe changes in the TransactionEditUnconnected component bring several improvements:
- Addition of a cleanup mechanism for the async fetchTransaction function (lines 1064-1097) to prevent state updates on unmounted components.
- Implementation of useCallback hooks for onUpdate, onSave, onDelete, onAddSplit, and onSplit functions (lines 1112-1243).
These changes help prevent memory leaks and improve performance through memoization. The code is now more robust and efficient.
52ec641
to
0e42e61
Compare
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)
packages/desktop-client/src/components/mobile/MobileForms.tsx (2)
147-167
: LGTM:Toggle
component usage is correct, with a minor suggestion for improvement.The
Toggle
component is used correctly with all necessary props passed. The custom styling using thecss
function is well-implemented and consistent with the project's styling approach.Consider extracting the custom styles into a separate constant for improved readability:
const toggleStyles = css({ '& [data-toggle-container]': { width: 50, height: 24, }, '& [data-toggle]': { width: 20, height: 20, }, }); // Then in the component: className={String(css([toggleStyles, className]))}This change would make the component's render function cleaner and easier to read.
136-167
: LGTM: Overall implementation ofToggleField
is well-done.The refactoring from
BooleanField
toToggleField
using theToggle
component is a good improvement. It likely enhances the user experience on mobile devices and maintains consistency with the rest of the application. The implementation adheres to React and TypeScript best practices.Consider adding a brief JSDoc comment to the
ToggleField
component to describe its purpose and usage. This would be helpful for other developers working on the project.Example:
/** * ToggleField component for rendering a toggle input in mobile forms. * It wraps the Toggle component with additional styling and mobile-specific behavior. */ export function ToggleField({ ... }: ToggleFieldProps) { // ... }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (2)
- packages/desktop-client/src/components/common/Toggle.tsx (3 hunks)
- packages/desktop-client/src/components/mobile/MobileForms.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
- packages/desktop-client/src/components/common/Toggle.tsx
🧰 Additional context used
🔇 Additional comments (3)
packages/desktop-client/src/components/mobile/MobileForms.tsx (3)
14-14
: LGTM: Import statement added correctly.The
Toggle
component import is appropriately placed with other component imports, which is consistent with the file's structure.
136-136
: LGTM: Type definition forToggleFieldProps
is well-defined.The
ToggleFieldProps
type correctly extends the props from theToggle
component usingComponentPropsWithoutRef
. This approach ensures type consistency and promotes reusability.
138-145
: LGTM:ToggleField
function declaration and props destructuring are well-implemented.The
ToggleField
function correctly destructures the necessary props fromToggleFieldProps
. TheisDisabled
prop with a default value offalse
addresses the past review comment about consistent naming, which is a good improvement.
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.
LGTM. Just vrt failing |
821d741
to
8e66005
Compare
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 (4)
packages/desktop-client/src/components/common/Toggle.tsx (3)
11-14
: Approved: ToggleProps type definition improvedThe changes to the
ToggleProps
type definition enhance the API of the Toggle component:
- Renaming
checked
toisOn
improves clarity.- Adding
isDisabled
andclassName
properties increases flexibility.- Updating
onToggle
to accept a boolean parameter allows for more explicit state management.These changes are well-thought-out and improve the component's usability.
Consider adding JSDoc comments to describe the purpose of each prop, especially the new ones, to improve code documentation.
41-58
: Approved: Label element styling and attributes improvedThe changes to the label element enhance its functionality and styling:
- Addition of
data-toggle-container
anddata-on
attributes improves testability and allows for more specific styling.- Use of theme variables for background colors improves consistency and maintainability.
- Conditional background color based on
isOn
state provides better visual feedback.These changes significantly improve the component's flexibility and user experience.
Consider extracting the CSS object into a separate constant or using a CSS-in-JS solution like styled-components for better organization and reusability.
62-85
: Approved: Span element styling and attributes enhancedThe changes to the span element (toggle knob) significantly improve its functionality and appearance:
- Addition of
data-toggle
anddata-on
attributes enhances testability and allows for more specific styling.- Conditional background color based on
isDisabled
state provides better visual feedback.- Additional styling for the "on" state improves the toggle's appearance and user experience.
These changes result in a more robust and visually appealing toggle component.
Consider extracting the CSS objects into separate constants or using a CSS-in-JS solution like styled-components. This would improve code organization and potentially allow for easier theming and customization.
packages/desktop-client/src/components/mobile/MobileForms.tsx (1)
147-167
: LGTM:Toggle
component usage is correct with appropriate styling.The
Toggle
component is used correctly with all necessary props passed down. The custom styling applied throughclassName
is appropriate for adjusting the toggle size. The use of thecss
function allows for dynamic styling based on the passedclassName
prop.Consider extracting the custom styles object into a separate constant for improved readability:
const toggleStyles = { '& [data-toggle-container]': { width: 50, height: 24, }, '& [data-toggle]': { width: 20, height: 20, }, }; // Then use it in the component: className={String(css([toggleStyles, className]))}This change would make the component more readable and easier to maintain.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (10)
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-from-accounts-id-page-1-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-from-accounts-id-page-2-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-from-accounts-id-page-3-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-1-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-2-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-3-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-4-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-5-chromium-linux.png
is excluded by!**/*.png
packages/desktop-client/e2e/transactions.mobile.test.js-snapshots/Mobile-Transactions-creates-a-transaction-via-footer-button-6-chromium-linux.png
is excluded by!**/*.png
upcoming-release-notes/3622.md
is excluded by!**/*.md
📒 Files selected for processing (8)
- packages/desktop-client/src/components/common/Menu.tsx (2 hunks)
- packages/desktop-client/src/components/common/Toggle.tsx (2 hunks)
- packages/desktop-client/src/components/mobile/MobileForms.tsx (3 hunks)
- packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (5 hunks)
- packages/desktop-client/src/style/themes/dark.ts (1 hunks)
- packages/desktop-client/src/style/themes/development.ts (1 hunks)
- packages/desktop-client/src/style/themes/light.ts (1 hunks)
- packages/desktop-client/src/style/themes/midnight.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (5)
- packages/desktop-client/src/components/common/Menu.tsx
- packages/desktop-client/src/style/themes/dark.ts
- packages/desktop-client/src/style/themes/development.ts
- packages/desktop-client/src/style/themes/light.ts
- packages/desktop-client/src/style/themes/midnight.ts
🧰 Additional context used
🔇 Additional comments (10)
packages/desktop-client/src/components/common/Toggle.tsx (4)
5-7
: LGTM: Import statements reorganized and updatedThe import statements have been reorganized and updated appropriately. The addition of the
View
import suggests an improvement in the component's structure.
20-23
: LGTM: Component props destructuring updatedThe changes in the component props destructuring align well with the updates made to the
ToggleProps
type. The addition of a default value forisDisabled
is a good practice, ensuring the component behaves predictably when the prop is not explicitly set.
88-88
: LGTM: Closing View component tag addedThe addition of the closing View component tag is consistent with the earlier changes and completes the component structure correctly.
27-32
: Approved: Component structure and behavior improvedThe changes in the component's return statement enhance its structure and behavior:
- Replacing
div
withView
component (likely for consistency or added functionality).- Renaming
checked
toisOn
in the input element.- Adding the
disabled
attribute to the input element.- Updating the
onChange
handler to pass the checked state toonToggle
.These changes align well with the updated props and improve the component's functionality.
Could you please clarify the purpose of using the
View
component instead of adiv
? Is this a custom component that adds specific functionality or styling?packages/desktop-client/src/components/mobile/MobileForms.tsx (4)
14-14
: LGTM: Import statement added correctly.The
Toggle
component import is appropriately placed with other component imports, which is consistent with the file's structure.
136-136
: LGTM: Type definition forToggleFieldProps
is well-defined.The
ToggleFieldProps
type correctly extendsComponentPropsWithoutRef<typeof Toggle>
, allowing theToggleField
component to inherit all props from theToggle
component. This approach follows React best practices for type definitions.
138-145
: LGTM:ToggleField
function declaration and props destructuring are correct.The
ToggleField
function is properly declared as a React functional component. The props destructuring is done correctly, and theisDisabled
prop has a default value offalse
. The naming ofisDisabled
is consistent with the previous review comment suggestion, which improves code clarity.
138-169
: LGTM:ToggleField
implementation is clean and follows best practices.The
ToggleField
component is well-implemented as a wrapper around theToggle
component. It provides a consistent interface for using toggles in mobile forms, following React best practices. The component is flexible, allowing for custom styling and behavior through props, which enhances its reusability across the application.packages/desktop-client/src/components/mobile/transactions/TransactionEdit.jsx (2)
Line range hint
1064-1097
: Improved error handling with cleanup mechanismThe addition of the cleanup mechanism in the useEffect hook is a good practice. It prevents potential memory leaks and race conditions by ensuring that state updates don't occur if the component unmounts before the asynchronous operation completes.
960-975
: Improved UI with Toggle component for transaction statusThe replacement of BooleanField with the Toggle component for "Cleared" and "Reconciled" statuses is a good improvement. It enhances the user interface and provides a more intuitive way for users to interact with these boolean fields. The implementation correctly handles the different states, using a disabled Toggle for reconciled transactions and an interactive ToggleField for cleared status.
No description provided.