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

save csv inOutMode settings #3543

Merged
merged 2 commits into from
Oct 10, 2024
Merged

Conversation

matt-fidd
Copy link
Contributor

Fixes #3542

Copy link
Contributor

coderabbitai bot commented Oct 2, 2024

Walkthrough

The pull request introduces changes to the ImportTransactionsModal component to enhance its functionality by integrating user preferences for transaction imports. State variables inOutMode and outValue are initialized based on user settings retrieved from prefs. The savePrefs function is updated to store these preferences, ensuring they are remembered across sessions. Additionally, the SyncedPrefs type in prefs.d.ts is modified to include new string literal types, allowing for more flexible preference configurations related to CSV handling.

Assessment against linked issues

Objective Addressed Explanation
Remember the import setting for "Select column to specify if amount goes in/out" (#3542)

Possibly related PRs

Suggested labels

:sparkles: Merged

Suggested reviewers

  • joel-jeremy
  • MikesGlitch

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 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

netlify bot commented Oct 2, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 90a0654
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67068650c029f40008325d7d
😎 Deploy Preview https://deploy-preview-3543.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 Oct 2, 2024

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
9 5.32 MB → 5.32 MB (+263 B) +0.00%
Changeset
File Δ Size
src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx 📈 +263 B (+0.86%) 29.76 kB → 30.02 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 3.34 MB → 3.34 MB (+263 B) +0.01%

Smaller

No assets were smaller

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/narrow.js 82.55 kB 0%
static/js/usePreviewTransactions.js 1.64 kB 0%
static/js/AppliedFilters.js 20.96 kB 0%
static/js/wide.js 224.88 kB 0%
static/js/ReportRouter.js 1.51 MB 0%

Copy link
Contributor

github-actions bot commented Oct 2, 2024

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.26 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.26 MB 0%

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 and nitpick comments (1)
packages/desktop-client/src/components/modals/ImportTransactionsModal.jsx (1)

877-883: LGTM! Consider adding a default value for inOutMode.

The changes look good and align with the PR objectives. The new state variables inOutMode and outValue are correctly initialized using user preferences.

A minor suggestion:

  • Consider adding a default value for inOutMode in case prefs[\csv-in-out-mode-${accountId}`]` is undefined. This would ensure a consistent initial state.

Example:

const [inOutMode, setInOutMode] = useState(
  String(prefs[`csv-in-out-mode-${accountId}`] ?? true) !== 'false'
);
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 327887b and a423070.

📒 Files selected for processing (2)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal.jsx (2 hunks)
  • packages/loot-core/src/types/prefs.d.ts (1 hunks)
🔇 Additional comments (3)
packages/loot-core/src/types/prefs.d.ts (1)

Line range hint 1-67: Summary: Changes look good and address the PR objectives

The additions to the SyncedPrefs type in this file are appropriate and directly address the PR objectives of remembering the "Select column to specify if amount goes in/out" setting for CSV imports. The implementation is consistent with the existing preference structure and naming conventions.

Remember to update any relevant documentation or user guides to reflect these new preferences and their functionality.

packages/desktop-client/src/components/modals/ImportTransactionsModal.jsx (2)

1352-1353: LGTM! Preferences are correctly saved.

These changes ensure that the user's preferences for inOutMode and outValue are saved, which is consistent with the behavior of other import settings and aligns with the PR objectives.


877-883: Summary: Implementation successfully addresses the PR objectives.

The changes effectively implement the "Select column to specify if amount goes in/out" feature:

  1. New state variables inOutMode and outValue are introduced and initialized with user preferences.
  2. These preferences are correctly saved when importing transactions.

These modifications ensure that the setting is remembered between imports, aligning with the behavior of other import settings and addressing the issue described in #3542.

The implementation is consistent with the existing code style and patterns. Great job on improving the user experience for CSV imports!

Also applies to: 1352-1353

packages/loot-core/src/types/prefs.d.ts Show resolved Hide resolved
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

🧹 Outside diff range and nitpick comments (2)
packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx (2)

645-646: LGTM: Saving new CSV import preferences.

The addition of saving preferences for csv-in-out-mode and csv-out-value is correct and aligns with the PR objectives. This ensures that the user's choices for these settings are remembered for future imports.

For consistency with other preference saving lines, consider using template literals:

-savePrefs({ [`csv-in-out-mode-${accountId}`]: String(inOutMode) });
-savePrefs({ [`csv-out-value-${accountId}`]: String(outValue) });
+savePrefs({ [`csv-in-out-mode-${accountId}`]: `${inOutMode}` });
+savePrefs({ [`csv-out-value-${accountId}`]: `${outValue}` });

This change makes the code more consistent with other preference saving lines in the file.


Issues Found: Inconsistent Usage of inOutMode and outValue

The verification script identified instances where splitMode is used without the accompanying inOutMode and outValue parameters. This inconsistency may lead to inaccurate import previews.

  • packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx
    • Line: const isSplit = !splitMode;
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/FieldMappings.jsx
    • Line: splitMode,
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/utils.js
    • Lines:
      • splitMode,
      • if (splitMode) {
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/Transaction.jsx
    • Line: splitMode,

Please update these instances to include inOutMode and outValue where necessary to ensure consistency across the codebase.

🔗 Analysis chain

Line range hint 285-286: LGTM: Updated getImportPreview function.

The addition of inOutMode and outValue parameters to the getImportPreview function and their subsequent use in parseAmountFields ensures that the import preview accurately reflects the user's chosen CSV import settings.

To ensure that these changes are correctly propagated throughout the codebase, please run the following verification script:

This script will help identify any instances where inOutMode and outValue might need to be added for consistency.

Also applies to: 287-288

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that inOutMode and outValue are consistently used in relevant functions

# Check for usage in getImportPreview and parseAmountFields
echo "Checking usage in getImportPreview and parseAmountFields:"
rg --type javascript 'function (getImportPreview|parseAmountFields).*\{' -A 10 | rg '(inOutMode|outValue)'

# Check for any missed occurrences where these parameters should be added
echo "\nChecking for potential missed occurrences:"
rg --type javascript 'function .*\{' -A 10 | rg 'splitMode' | rg -v '(inOutMode|outValue)'

Length of output: 493


Script:

#!/bin/bash
# Description: Verify that inOutMode and outValue are consistently used in relevant functions

# Check for usage in getImportPreview and parseAmountFields
echo "Checking usage in getImportPreview and parseAmountFields:"
rg --type js 'function (getImportPreview|parseAmountFields)\s*\(' -A 10 | rg '(inOutMode|outValue)'

# Check for any missed occurrences where these parameters should be added
echo "\nChecking for potential missed occurrences:"
rg --type js 'function\s+\w+\s*\(' -A 10 | rg 'splitMode' | rg -v '(inOutMode|outValue)'

Length of output: 1117

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between c420fad and f0194e8.

📒 Files selected for processing (2)
  • packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx (2 hunks)
  • packages/loot-core/src/types/prefs.d.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/loot-core/src/types/prefs.d.ts
🧰 Additional context used
🔇 Additional comments (2)
packages/desktop-client/src/components/modals/ImportTransactionsModal/ImportTransactionsModal.jsx (2)

171-176: LGTM: New state variables for CSV import settings.

The addition of inOutMode and outValue state variables, initialized from prefs, aligns well with the PR objective of remembering the "Select column to specify if amount goes in/out" setting. This change will help maintain consistency in the user's import preferences across sessions.


Line range hint 1-1068: Overall assessment: Changes look good and address the PR objectives.

The implemented changes effectively address the issue of remembering the "Select column to specify if amount goes in/out" setting for CSV imports. The new state variables, preference saving, and updates to the import preview function are well-integrated into the existing codebase.

A few minor suggestions were made for consistency and verification, but overall, the changes are approved and ready for merging, pending the results of the verification script.

@matt-fidd matt-fidd changed the title [WIP] save csv inOutMode settings save csv inOutMode settings Oct 9, 2024
@MikesGlitch MikesGlitch self-assigned this Oct 10, 2024
@matt-fidd matt-fidd merged commit 9f27948 into actualbudget:master Oct 10, 2024
20 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.

[Feature] Import status for "Select column to specify if amount goes in/out" not remembered
2 participants