Skip to content
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

Allow marking transactions as Transfers on mobile devices #4511

Merged
merged 16 commits into from
Mar 4, 2025

Conversation

rugulous
Copy link
Contributor

@rugulous rugulous commented Mar 2, 2025

Adds the functionality to mark transactions as Transfers on mobile devices. This involves moving the existing functionality into an existing shared object and updating the menu styling to make it clear when the option is disabled. I also spotted some messages that were not marked for translation so wrapped them in the t() function

@actual-github-bot actual-github-bot bot changed the title Allow marking transactions as Transfers on mobile devices [WIP] Allow marking transactions as Transfers on mobile devices Mar 2, 2025
Copy link

netlify bot commented Mar 2, 2025

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 3acbce3
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67c6fbeab5c27f000876fe73
😎 Deploy Preview https://deploy-preview-4511.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

github-actions bot commented Mar 2, 2025

Bundle Stats — desktop-client

Hey 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

Files count Total bundle size % Changed
18 8.07 MB → 8.08 MB (+1.48 kB) +0.02%
Changeset
File Δ Size
src/hooks/useTransactionBatchActions.ts 📈 +1.07 kB (+13.84%) 7.74 kB → 8.81 kB
src/components/mobile/transactions/TransactionList.tsx 📈 +1.24 kB (+7.66%) 16.15 kB → 17.39 kB
src/components/mobile/budget/CategoryTransactions.tsx 📈 +25 B (+0.83%) 2.93 kB → 2.96 kB
src/components/mobile/transactions/TransactionListWithBalances.tsx 📈 +30 B (+0.51%) 5.79 kB → 5.82 kB
src/components/mobile/accounts/AccountTransactions.tsx 📈 +13 B (+0.16%) 7.9 kB → 7.91 kB
src/components/reports/reports/Calendar.tsx 📈 +41 B (+0.15%) 26.07 kB → 26.11 kB
src/components/accounts/Account.tsx 📉 -957 B (-1.99%) 46.93 kB → 45.99 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 5.34 MB → 5.34 MB (+2.81 kB) +0.05%
static/js/ReportRouter.js 1.59 MB → 1.59 MB (+41 B) +0.00%
static/js/narrow.js 86.26 kB → 86.27 kB (+13 B) +0.01%

Smaller

Asset File Size % Changed
static/js/wide.js 103.68 kB → 102.3 kB (-1.38 kB) -1.33%

Unchanged

Asset File Size % Changed
static/js/es.js 58.26 kB 0%
static/js/fr.js 116.48 kB 0%
static/js/de.js 115.52 kB 0%
static/js/en-GB.js 96.66 kB 0%
static/js/nl.js 95.51 kB 0%
static/js/en.js 103.78 kB 0%
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/workbox-window.prod.es5.js 5.69 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/pt-BR.js 110.52 kB 0%
static/js/uk.js 111.06 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/useAccountPreviewTransactions.js 1.69 kB 0%
static/js/AppliedFilters.js 10.8 kB 0%

Copy link
Contributor

github-actions bot commented Mar 2, 2025

Bundle Stats — loot-core

Hey 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

Files count Total bundle size % Changed
1 1.34 MB 0%

Changeset

No files were changed

View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

No assets were bigger

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
kcab.worker.js 1.34 MB 0%

@rugulous rugulous changed the title [WIP] Allow marking transactions as Transfers on mobile devices Allow marking transactions as Transfers on mobile devices Mar 3, 2025
Copy link
Contributor

coderabbitai bot commented Mar 3, 2025

Walkthrough

The pull request introduces significant updates across multiple components related to transaction transfer management. In the Account.tsx file, the onSetTransfer method is refactored to remove its internal confirmation logic, delegating transfer processing to a higher-level function. The AccountInternalProps type is updated to include the new onSetTransfer property. Several mobile components, including AccountTransactions, CategoryTransactions, and TransactionList, add a new account property, affecting how transactions are displayed and handled. Additionally, the useTransactionBatchActions hook now includes an asynchronous onSetTransfer function that retrieves transactions, validates them, and performs batch updates via a server call. These changes collectively centralize and streamline transfer-related functionalities across desktop and mobile platforms.

Possibly related PRs

Suggested labels

:white_check_mark: Approved, :sparkles: Merged

Suggested reviewers

  • joel-jeremy
  • matt-fidd

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d2f98d6 and 3acbce3.

📒 Files selected for processing (1)
  • packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (17 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (7)
  • GitHub Check: web
  • GitHub Check: Wait for Netlify build to finish
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Analyze
  • GitHub Check: compare
🔇 Additional comments (8)
packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (8)

81-81: Type definition looks good for account property

The optional account property is correctly defined in the TransactionListProps type.


218-218: Logic for showing transfer option is correctly implemented

The condition showMakeTransfer={!account} matches the desktop client behavior as mentioned in the PR objectives, allowing transfers to be shown when not in an account view.


228-228: Props type definition properly updated

The showMakeTransfer boolean property is correctly added to the SelectedTransactionsFloatingActionBarProps type.


307-325: Transfer validation logic looks good

The canBeTransfer implementation correctly checks:

  1. If exactly two transactions are selected
  2. If both transactions exist in the current list
  3. If they are valid for transfer using the imported validation function

The useMemo usage is appropriate for performance optimization.


327-350: Menu item construction looks good

The "Make transfer" menu item is correctly added to the menu items array when showMakeTransfer is true, and properly disabled when the transactions can't be transferred.

The updated styling for disabled menu items (line 245) enhances clarity as mentioned in the PR objectives.


585-596: Transfer functionality implementation looks correct

The implementation for marking transactions as transfers calls the onSetTransfer function with the selected transaction IDs, payees, and a callback for the success notification.

The notification message is properly translated using the t function with appropriate pluralization.


539-543: Excellent internationalization of notification messages

All notification messages are now properly internationalized using the t function with the count parameter for pluralization, which supports the PR objective of preparing messages for localization.

Also applies to: 553-557, 565-569, 578-582, 588-594


481-503: Proper translation of menu item texts

All menu item texts are now correctly using the translation function, fulfilling the PR objective of preparing messages for localization.

✨ Finishing Touches
  • 📝 Generate Docstrings

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?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 (4)
packages/desktop-client/src/hooks/useTransactionBatchActions.ts (1)

426-427:

❓ Verification inconclusive

Consider adding translation for potential error messages.

Since part of this PR's objective is to ensure messages are properly translated, you might want to ensure any error messages that could be displayed if the transactions aren't valid for transfer are wrapped in the translation function t().


🏁 Script executed:

#!/bin/bash
# Check if the validForTransfer function returns any error messages that might need translation

rg "validForTransfer" -A 10 -B 5

Length of output: 14812


Action: Confirm Localization of Any User-Facing Error Messaging

After reviewing the surrounding code and the implementation of validForTransfer, it appears that this block is solely using the function’s boolean result and does not directly display any error messages. Since there aren’t any message strings generated in this branch, no translation wrapping (using t()) is needed here right now.

That said, if you later implement user notifications or error dialogs when a transfer is invalid, please ensure those messages are processed through the translation function to meet the PR’s localization goals.

packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (3)

22-22: Avoid importing t directly from “i18next” when already using useTranslation.
Since useTranslation() provides the t function, the direct import from “i18next” may cause confusion or conflicts. Consider removing the direct import if not strictly needed.


545-548: Duplicating transactions success message.
Using placeholders in t() is correct. Optional: consider advanced pluralization if needed.


592-601: Consider error handling for onSetTransfer.
While the success callback is defined, it may help to show an error message if the transfer fails.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7650eed and f9567d2.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4511.md is excluded by !**/*.md
📒 Files selected for processing (7)
  • packages/desktop-client/src/components/accounts/Account.tsx (5 hunks)
  • packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (17 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx (3 hunks)
  • packages/desktop-client/src/components/reports/reports/Calendar.tsx (1 hunks)
  • packages/desktop-client/src/hooks/useTransactionBatchActions.ts (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/desktop-client/src/components/reports/reports/Calendar.tsx
🧰 Additional context used
🧠 Learnings (1)
packages/desktop-client/src/components/accounts/Account.tsx (1)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Analyze
🔇 Additional comments (30)
packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx (1)

131-131: New feature added: Enable marking transfers in category transactions.

The showMakeTransfer property has been added to enable the transfer functionality in the category transactions view.

packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx (2)

94-94: Type definition added for the transfer functionality control.

The showMakeTransfer boolean property has been properly added to the component props interface.


109-109: Correctly propagated the transfer control property.

The showMakeTransfer property is now destructured from props and properly passed down to the child TransactionList component.

Also applies to: 153-153

packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx (1)

350-350: Conditional transfer functionality for uncategorized transactions only.

The showMakeTransfer property is conditionally set to true only when viewing uncategorized transactions. This is a logical choice as transfers are typically only relevant in that context.

packages/desktop-client/src/hooks/useTransactionBatchActions.ts (3)

3-3: Essential imports added for transfer functionality.

The validForTransfer helper and PayeeEntity type have been properly imported to support the new transfer capability.

Also applies to: 16-16


413-458: Well-structured implementation of transfer functionality.

The new onSetTransfer function properly follows the pattern established by other batch actions in this file:

  1. It uses the reconciled transaction check pattern
  2. It validates that exactly two transactions are selected and valid for transfer
  3. It properly updates both transactions with their respective transfer details

The implementation is clean and maintains consistency with the codebase patterns.


466-466: Correctly exported the new functionality.

The onSetTransfer function is now available as part of the hook's returned object, making it accessible to components that use this hook.

packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (18)

13-17: Use named types from “@actual-app/components/menu”.
The newly imported MenuItem and MenuItemObject are properly typed.


25-25: Import of validForTransfer recommended.
Good job leveraging the shared validation function from “loot-core/client/transfer”.


81-81: New prop showMakeTransfer in TransactionListProps.
A clear boolean prop to toggle transfer-related UI elements.


90-90: Pass showMakeTransfer to the TransactionList component.
Ensuring we propagate the new prop to align with the intended conditional display logic.


216-219: Forward showMakeTransfer to SelectedTransactionsFloatingActionBar.
This correctly ensures the floating action bar is aware of transfer feature availability.


225-234: Added showMakeTransfer to SelectedTransactionsFloatingActionBarProps.
Extends the component to conditionally render “Make transfer” in the options menu.


244-244: Set disabled color for menu items.
Using theme.buttonBareDisabledText for disabled items improves visual feedback for users.


285-285: Expose onSetTransfer from batch actions.
Introducing onSetTransfer to the selection bar ensures a unified approach to transaction transfer logic.


306-324: canBeTransfer hook.
The memoized logic correctly ensures only two selected transactions are validated for transfers.


326-351: Conditional “Make transfer” menu item.
Properly disabled unless canBeTransfer is true. Aligns with the new prop showMakeTransfer.


405-405: Better accessibility with i18n for aria-label.
Internationalizing “Edit fields” is a good practice.


427-427: Local variable declaration for displayValue.
Straightforward approach to handle updated field display logic.


486-508: Drive i18n for edit menu items.
Setting text: t(...) for “Account”, “Payee”, “Notes”, “Category”, and “Cleared” enhances translation coverage.


517-517: Internationalized aria-label for more options.
Good accessibility improvement for screen readers.


559-562: Link schedule success message.
Properly handles placeholders for count and schedule references.


571-574: Unlink schedule success message.
The i18n placeholders for count are correctly applied.


585-587: Deletion success message.
Accurately parameterizes the count in translations.


605-605: Updated assignments of menu items.
Using moreOptionsMenuItems ensures the new “Make transfer” item is included in the final menu.

packages/desktop-client/src/components/accounts/Account.tsx (5)

310-310: Extend AccountInternalProps with onSetTransfer.
This property properly delegates the transfer logic to batch actions.


1339-1344: Add onSetTransfer method to AccountInternal.
Indicates a busy state before calling this.props.onSetTransfer. Consider adding fallback handling on failures.


1888-1888: Include onSetTransfer in omitted props.
Ensures that properties are fully consistent when forwarding props to AccountHack.


1900-1901: Destructure onSetTransfer from hook.
Extracting it alongside other batch actions promotes uniform code style.


1912-1912: Prop forwarding to AccountInternal.
Passing onSetTransfer so that the internal component can manage workflow around transfers.

Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

Just a few nits but the implementation looks good.

@tempiz
Copy link

tempiz commented Mar 3, 2025

I was actually just working on this same implementation last night, but you beat my to the punch. You can accomplish Matt's request fairly easy by using showMakeTransfer = !account; This is the same implementation that the desktop client uses, and essentially allows make transfer within on budget, off budget, and uncategorized.

Really looking forward to this feature in mobile!

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (1)

28-28: Use import type for type-only imports

The AccountEntity import is only used as a type, so it should use the import type syntax to follow TypeScript best practices.

- import { AccountEntity } from 'loot-core/types/models';
+ import type { AccountEntity } from 'loot-core/types/models';

This helps distinguish between values and types at compile time and can improve build performance.

🧰 Tools
🪛 GitHub Check: lint

[warning] 28-28:
All imports in the declaration are only used as types. Use import type

🪛 GitHub Actions: Test

[warning] 28-28: All imports in the declaration are only used as types. Use import type @typescript-eslint/consistent-type-imports

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f9567d2 and e7e4934.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/4511.md is excluded by !**/*.md
📒 Files selected for processing (6)
  • packages/desktop-client/src/components/accounts/Account.tsx (5 hunks)
  • packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (17 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx (4 hunks)
  • packages/desktop-client/src/components/reports/reports/Calendar.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx
🧰 Additional context used
🧠 Learnings (2)
packages/desktop-client/src/components/accounts/Account.tsx (1)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx (2)
Learnt from: joel-jeremy
PR: actualbudget/actual#3685
File: packages/desktop-client/src/components/accounts/Account.tsx:655-665
Timestamp: 2024-11-10T16:45:31.225Z
Learning: The Account component in 'packages/desktop-client/src/components/accounts/Account.tsx' is being rewritten in a separate PR.
Learnt from: jfdoming
PR: actualbudget/actual#3402
File: packages/desktop-client/src/components/accounts/Account.tsx:8-8
Timestamp: 2024-11-10T16:45:25.627Z
Learning: In the `AllTransactions` component of `Account.tsx`, the `useLayoutEffect` hook is appropriately used to dispatch an action that closes splits for parent transactions when `prependTransactions` changes, ensuring this occurs synchronously before the component is painted.
🪛 GitHub Check: lint
packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx

[warning] 28-28:
All imports in the declaration are only used as types. Use import type

🪛 GitHub Actions: Test
packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx

[warning] 28-28: All imports in the declaration are only used as types. Use import type @typescript-eslint/consistent-type-imports

packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx

[error] 131-131: Type 'null' is not assignable to type 'AccountEntity'.

🪛 GitHub Check: typecheck
packages/desktop-client/src/components/mobile/accounts/AccountTransactions.tsx

[failure] 350-350:
Type 'AccountEntity | undefined' is not assignable to type 'AccountEntity'.

packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx

[failure] 131-131:
Type 'null' is not assignable to type 'AccountEntity'.

packages/desktop-client/src/components/reports/reports/Calendar.tsx

[failure] 698-698:
Type 'null' is not assignable to type 'AccountEntity'.

⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: build (ubuntu-latest)
  • GitHub Check: Wait for Netlify build to finish
🔇 Additional comments (12)
packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (6)

217-219: LGTM! Using account existence to control transfer visibility

The implementation correctly uses the presence of an account to determine when the transfer option should be shown. This matches the PR objective to allow marking transactions as transfers on mobile devices.


307-325: Good implementation of transfer validation logic

The implementation correctly verifies that:

  1. Exactly two transactions are selected
  2. Both transactions exist in the current list
  3. The transactions are valid for transfer according to the imported validForTransfer function

327-348: Well-structured menu item conditional logic

The implementation properly:

  1. Defines the base menu items
  2. Conditionally inserts the transfer option when appropriate
  3. Correctly handles the disabled state based on the validation result

583-594: Proper implementation of transfer action

The transfer handler is well-implemented:

  1. Uses the onSetTransfer function from the transaction batch actions hook
  2. Passes the selected transaction IDs
  3. Provides properly translated success notification
  4. Uses the appropriate format for the success callback

236-236: Good internationalization practice

Adding the translation hook and applying it consistently to user-facing strings follows best practices for internationalization.


245-245: Improved visual feedback for disabled menu items

Adding specific styling for disabled menu items enhances the user experience by providing clearer visual feedback when an option is unavailable.

packages/desktop-client/src/components/accounts/Account.tsx (6)

310-310: Added property correctly typed and defined.

Adding the onSetTransfer property to the AccountInternalProps interface correctly defines the dependency on the function from the useTransactionBatchActions hook.


1353-1358: Refactored onSetTransfer method to use the shared implementation.

The method has been simplified to delegate transfer processing to the shared implementation from useTransactionBatchActions. This improves code maintainability and ensures consistent behavior between desktop and mobile clients.


1902-1902: Type definition updated to match implementation changes.

The onSetTransfer property has been properly added to the exclusion list in the AccountHackProps type, which correctly reflects that this property will be explicitly provided.


1914-1915: Successfully extracted onSetTransfer from hook.

The function is correctly destructured from the useTransactionBatchActions hook, making it available for passing to the inner component.


1926-1927: Properly passed onSetTransfer to component.

The onSetTransfer function is correctly passed to the AccountInternal component, ensuring it has access to the shared implementation.


1352-1359:

❓ Verification inconclusive

Verify function's integration across the codebase.

The implementation now relies on an external onSetTransfer function from useTransactionBatchActions. Let's verify this implementation is fully compatible with how it's being used here.


🏁 Script executed:

#!/bin/bash
# Description: Locate the implementation of onSetTransfer in useTransactionBatchActions hook

# Find the hook implementation
echo "Looking for useTransactionBatchActions implementation..."
find packages -name "useTransactionBatchActions.ts" -o -name "useTransactionBatchActions.tsx" | xargs cat

# Look for references to onSetTransfer in other files to ensure compatibility
echo "Looking for other usages of onSetTransfer..."
rg "onSetTransfer" --type tsx --type ts

Length of output: 14148


Action: Verify onSetTransfer Integration Consistency

After reviewing the implementation of the onSetTransfer method in the useTransactionBatchActions hook and its usage in packages/desktop-client/src/components/accounts/Account.tsx, the integration appears to match the expected API—Account.tsx calls it with an array of IDs, a list of payees, and a callback for refetching transactions, which is consistent with the hook’s signature.

However, our initial search for additional references to onSetTransfer using the rg command yielded an error regarding TSX file types. This low-quality inference means we should verify manually (or re-run an alternative search) to confirm that no legacy or conflicting usages exist elsewhere in the codebase.

Verification Points:

  • Ensure that the parameters expected by the hook’s onSetTransfer match the ones passed by Account.tsx.
  • Double-check that no other components are still relying on an older version of this function.

I recommend performing a further search using a glob-based approach. For example:

#!/bin/bash
# Re-run search for onSetTransfer references in .ts and .tsx files using find and grep
echo "Searching for onSetTransfer references using find and grep..."
find packages -type f \( -iname "*.ts" -o -iname "*.tsx" \) -exec grep -H "onSetTransfer" {} \;

Once you’ve confirmed that the usage is consistent across the codebase, please update this review with your findings.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 comments (1)
packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (1)

403-403: 🛠️ Refactor suggestion

Missing translation for "Edit" button

The "Edit" button text is still hardcoded while surrounding elements use the translation function.

Add translation to the Edit button text:

- Edit
+ {t('Edit')}
🧹 Nitpick comments (2)
packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (2)

81-81: Consider making the account property nullable instead of optional

The account property is defined as optional here, but I'm seeing in the code it's used for conditional rendering where its existence is important.

Consider updating the type to be more specific about nullability:

- account?: AccountEntity;
+ account: AccountEntity | null;

This would make it clear that account can be explicitly null rather than potentially undefined.


327-348: Consider simplifying the menu items construction

The current implementation uses array splicing to conditionally insert the transfer option, which works but is less readable than alternatives.

Consider using the spread operator for a more declarative approach:

- const moreOptionsMenuItems: MenuItem<string>[] = [
-   {
-     name: 'duplicate',
-     text: t('Duplicate'),
-   },
-   {
-     name: allTransactionsAreLinked ? 'unlink-schedule' : 'link-schedule',
-     text: t((allTransactionsAreLinked ? 'Unlink' : 'Link') + ' schedule'),
-   },
-   {
-     name: 'delete',
-     text: t('Delete'),
-   },
- ];
-
- if (showMakeTransfer) {
-   moreOptionsMenuItems.splice(2, 0, {
-     name: 'transfer',
-     text: t('Make transfer'),
-     disabled: !canBeTransfer,
-   });
- }

+ const moreOptionsMenuItems: MenuItem<string>[] = [
+   {
+     name: 'duplicate',
+     text: t('Duplicate'),
+   },
+   {
+     name: allTransactionsAreLinked ? 'unlink-schedule' : 'link-schedule',
+     text: t((allTransactionsAreLinked ? 'Unlink' : 'Link') + ' schedule'),
+   },
+   ...(showMakeTransfer
+     ? [
+         {
+           name: 'transfer',
+           text: t('Make transfer'),
+           disabled: !canBeTransfer,
+         },
+       ]
+     : []),
+   {
+     name: 'delete',
+     text: t('Delete'),
+   },
+ ];

This maintains the same order but makes the conditional inclusion more explicit.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e7e4934 and a26cf53.

📒 Files selected for processing (4)
  • packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx (1 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (17 hunks)
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx (4 hunks)
  • packages/desktop-client/src/components/reports/reports/Calendar.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/desktop-client/src/components/mobile/budget/CategoryTransactions.tsx
  • packages/desktop-client/src/components/mobile/transactions/TransactionListWithBalances.tsx
  • packages/desktop-client/src/components/reports/reports/Calendar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: Visual regression
  • GitHub Check: Functional
  • GitHub Check: build (macos-latest)
  • GitHub Check: build (windows-latest)
  • GitHub Check: Analyze
  • GitHub Check: build (ubuntu-latest)
🔇 Additional comments (10)
packages/desktop-client/src/components/mobile/transactions/TransactionList.tsx (10)

13-17: Improved import structure

The import statement has been refined to clearly import both the Menu component and its associated types, which enhances code clarity and TypeScript type safety.


24-24: Good use of shared functionality

Moving the transfer validation logic to a shared module is excellent - this aligns with the PR objective of relocating existing functionality into a shared object that's already in use within the application.


28-28: Proper type import added

Adding the explicit import for the AccountEntity type improves type safety throughout the component.


217-219: Clearly implementing the transfer availability logic

The implementation correctly passes the showMakeTransfer property based on the absence of an account, which aligns with the implementation mentioned in the PR comments where user tempiz suggested using showMakeTransfer = !account.


228-228: Well-defined prop type

Adding the showMakeTransfer boolean to the props type ensures type safety and makes the component's API explicit.


236-236: Good internationalization practice

Using the useTranslation hook at the component level is the right approach for i18n.


245-245: Improved visual feedback for disabled state

The styling update for disabled menu items provides better visual feedback to users, which enhances the UI clarity mentioned in the PR objectives.


307-325: Well-implemented transfer validation logic

The canBeTransfer memoized function is implemented correctly and handles all edge cases:

  1. Checks if exactly two transactions are selected
  2. Ensures both transactions exist in the current list
  3. Validates if they can form a transfer using the shared validation function

583-594: Well-implemented transfer handler

The transfer action handler is implemented correctly, using the onSetTransfer function from useTransactionBatchActions and showing an appropriate success notification.


537-541: Good internationalization with pluralization

Excellent use of the translation function with count parameter for proper pluralization across languages.

Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One last nit, <Trans> is preferred when using text in a component

Co-authored-by: Matt Fiddaman <github@m.fiddaman.uk>
Copy link
Contributor

@matt-fidd matt-fidd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks for this

@matt-fidd matt-fidd merged commit 98e4ece into actualbudget:master Mar 4, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants