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

:electron: Migrations out of sync modal #3600

Merged

Conversation

MikesGlitch
Copy link
Contributor

@MikesGlitch MikesGlitch commented Oct 7, 2024

When will this display?

When you have multiple clients using one server. One client has been updated, the other hasn't. The updated client runs on the budget and migrates the data to the latest. Then the out-of-date client opens the budget.

We shouldn't let the user continue using the client in case they end up with bad data. It's not worth the risk. We should warn the user about it, prompt them to update their client, and let them know it's possible to use the web app from app.actualbudget.org.

image

Original intention

This was intended to be a warning for when server is a different version from client. I couldn't do it because

  • we'd need to force the user to be online and connect to the server to get the version info.
  • the user would have to wait until the server responds before loading the budget.

I don't think we should do that so I had to bin the idea.

@MikesGlitch MikesGlitch changed the title [WIP] :electron: migrations out of sync modal [WIP] :electron: Migrations out of sync modal Oct 7, 2024
Copy link

netlify bot commented Oct 7, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit a478899
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/67081c8e6121b40008ea2042
😎 Deploy Preview https://deploy-preview-3600.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 7, 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.31 MB → 5.32 MB (+2.84 kB) +0.05%
Changeset
File Δ Size
src/components/modals/OutOfSyncMigrationsModal.tsx 🆕 +2.86 kB 0 B → 2.86 kB
home/runner/work/actual/actual/packages/loot-core/src/client/actions/budgets.ts 📈 +72 B (+1.31%) 5.38 kB → 5.45 kB
src/components/Modals.tsx 📉 -97 B (-0.62%) 15.35 kB → 15.26 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.33 MB → 3.34 MB (+2.84 kB) +0.08%

Smaller

No assets were smaller

Unchanged

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

Copy link
Contributor

github-actions bot commented Oct 7, 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%

@@ -591,15 +592,8 @@ export function Modals() {
return <ImportYNAB5Modal key={name} />;
case 'import-actual':
return <ImportActualModal key={name} />;
case 'manager-load-backup':
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This isn't used anywhere, cleaning it up

@MikesGlitch MikesGlitch marked this pull request as ready for review October 9, 2024 21:34
@actual-github-bot actual-github-bot bot changed the title [WIP] :electron: Migrations out of sync modal :electron: Migrations out of sync modal Oct 9, 2024
Copy link
Contributor

coderabbitai bot commented Oct 9, 2024

Walkthrough

The pull request introduces a new modal component, OutOfSyncMigrationsModal, into the Modals function of the Modals.tsx file. This component informs users that they are using an outdated version of the Actual application, which impacts their budget data. It is integrated into the existing modal rendering logic, replacing the previous case for manager-load-backup with a new case for out-of-sync-migrations. The OutOfSyncMigrationsModal component is created in a separate file, utilizing React and Redux hooks for state management and user interaction. The loadBudget function in budgets.ts is modified to simplify error handling by removing the handling for the 'out-of-sync-data' error, while still allowing the 'out-of-sync-migrations' error to trigger the new modal. Additionally, a new modal type is added to the FinanceModals type definition to accommodate the new modal.

Possibly related PRs

Suggested labels

sparkles: Merged

Suggested reviewers

  • joel-jeremy

📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between dc2881d and a478899.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3600.md is excluded by !**/*.md
📒 Files selected for processing (1)
  • packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx (1 hunks)
🧰 Additional context used
🔇 Additional comments (7)
packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx (7)

1-17: LGTM: Imports and function declaration are well-structured.

The imports are appropriate for the component's functionality, and the use of hooks (useDispatch, useTranslation) follows React best practices.


19-22: LGTM: closeBudgetAndModal function is concise and effective.

The function correctly dispatches the closeBudget action and then closes the modal, ensuring proper cleanup.


28-30: Simplify the modal header title structure.

Consider simplifying the modal header title structure as suggested in a previous review:

          <ModalHeader title={<ModalTitle title={t('Please update Actual!')} />} />

This change removes the unnecessary nesting of the ModalTitle component.


43-48: LGTM: Proper use of Trans component for translations.

The Trans component is correctly used for handling translations with embedded JSX elements, which is a best practice for i18n in React applications.

Also applies to: 57-64


67-89: LGTM: Modal footer with close button is well-implemented.

The "Close Budget" button is correctly implemented with appropriate styling and functionality. The use of closeBudgetAndModal ensures proper cleanup when closing the modal.


1-91: Overall, the OutOfSyncMigrationsModal implementation is well-structured and follows best practices.

The component effectively informs users about an outdated client version and provides clear instructions. The use of React hooks, Redux, and i18n is appropriate. With the suggested minor improvements, this implementation will be excellent.


41-49: ⚠️ Potential issue

Fix text and correct typo in the modal content.

  1. Change "version of the Actual client" to either "version of Actual" or "version of the Actual client" for better clarity.
  2. Correct the typo "verison" to "version" on line 46.

Here's the suggested change:

                  It looks like you're using an outdated version of Actual. Your budget data has been updated by another
                  client, but this client is still on the old version. For the
                  best experience, please update Actual to the latest version.

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
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 (4)
packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx (2)

22-83: LGTM: Modal structure and content are well-implemented, with a suggestion for improvement.

The modal structure is well-organized, using appropriate components for layout and styling. The content effectively communicates the out-of-sync issue to the user and provides a solution. The use of the Trans component suggests good internationalization support.

Consider adding an aria-label to the "Close Budget" button to improve accessibility. For example:

 <Button
   variant="primary"
   style={{
     padding: '10px 30px',
   }}
   onPress={() => closeBudgetAndModal(close)}
+  aria-label="Close Budget and return to budget selection"
 >
   <Trans>Close Budget</Trans>
 </Button>

1-85: LGTM: Well-implemented component with suggestions for enhancements.

The OutOfSyncMigrationsModal component is well-structured, following React best practices and effectively utilizing Redux for state management. It handles the specific use case of out-of-sync migrations clearly and concisely.

Consider the following enhancements to improve user experience and error handling:

  1. Add an option for users to attempt to sync their local data with the server, if possible.
  2. Implement error logging to track occurrences of out-of-sync migrations.
  3. Provide more detailed information about the nature of the out-of-sync issue, if available.

Example implementation for point 1:

<Button
  variant="secondary"
  onPress={() => attemptSync()}
  style={{ marginRight: 10 }}
>
  <Trans>Attempt Sync</Trans>
</Button>

These suggestions could provide users with more options and help in diagnosing and resolving sync issues.

packages/loot-core/src/client/actions/budgets.ts (1)

62-62: Add a comment explaining the removal of 'out-of-sync-data' handling.

To improve code maintainability and provide context for future developers, consider adding a comment explaining why the 'out-of-sync-data' error handling was removed.

Here's a suggested comment:

// 'out-of-sync-data' handling removed as part of the migration warning system update.
// Users will now be notified via a general error alert instead of the specific backup loading prompt.
packages/loot-core/src/client/state-types/modals.d.ts (1)

89-90: LGTM! Consider adding a comment for clarity.

The addition of the 'out-of-sync-migrations' modal type is appropriate and aligns with the PR objectives. It follows the existing pattern for modals without options.

For consistency and clarity, consider adding a brief comment explaining the purpose of this modal, similar to other modal definitions in the file. For example:

// Modal to warn users about out-of-sync migrations
'out-of-sync-migrations': null;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f786bdc and dc2881d.

⛔ Files ignored due to path filters (1)
  • upcoming-release-notes/3600.md is excluded by !**/*.md
📒 Files selected for processing (4)
  • packages/desktop-client/src/components/Modals.tsx (2 hunks)
  • packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx (1 hunks)
  • packages/loot-core/src/client/actions/budgets.ts (1 hunks)
  • packages/loot-core/src/client/state-types/modals.d.ts (1 hunks)
🧰 Additional context used
🔇 Additional comments (7)
packages/desktop-client/src/components/modals/OutOfSyncMigrationsModal.tsx (2)

1-12: LGTM: Imports are well-organized and appropriate.

The imports cover all necessary dependencies for the component, including React hooks, Redux dispatch, and various UI components. The import of closeBudget action from 'loot-core/client/actions' is particularly noteworthy as it indicates integration with the core application logic.


14-20: LGTM: Component structure and hook usage are well-implemented.

The OutOfSyncMigrationsModal is correctly implemented as a functional component. The use of useDispatch hook is appropriate for managing state actions. The closeBudgetAndModal function effectively combines closing the budget and the modal, ensuring a smooth user experience.

packages/loot-core/src/client/actions/budgets.ts (1)

60-61: LGTM: Handling of 'out-of-sync-migrations' error.

The handling of the 'out-of-sync-migrations' error remains unchanged and aligns with the PR objectives of introducing a warning modal for this scenario.

packages/desktop-client/src/components/Modals.tsx (4)

54-54: LGTM: New modal component imported correctly.

The OutOfSyncMigrationsModal component is imported correctly, following the existing import style in the file.


595-596: LGTM: New modal case added correctly.

The out-of-sync-migrations case has been added correctly to the switch statement, rendering the OutOfSyncMigrationsModal component with a unique key prop.

Please verify if the OutOfSyncMigrationsModal component requires any additional props. If it does, consider passing relevant data from the options object:

-          return <OutOfSyncMigrationsModal key={name} />;
+          return <OutOfSyncMigrationsModal key={name} {...options} />;

Line range hint 1-605: Summary: Changes align with PR objectives

The modifications to the Modals.tsx file successfully implement the new OutOfSyncMigrationsModal to address the scenario where a user's budget has been migrated using an up-to-date client, but the current client is outdated. This aligns well with the PR objectives of preventing users from continuing to use an outdated client to avoid potential data issues.

Key changes:

  1. Import of the new OutOfSyncMigrationsModal component.
  2. Addition of the out-of-sync-migrations case in the switch statement.
  3. Removal of the manager-load-backup case (to be verified).

These changes contribute to the implementation of the warning modal described in the PR objectives, informing users about the out-of-date client and suggesting the use of the web application as an alternative.


594-594: Verify the intentional removal of the manager-load-backup case.

The manager-load-backup case has been removed from the switch statement. Please confirm if this removal is intentional and if the functionality for loading backups is now handled differently or no longer needed.

To check for any remaining references to the removed case, run the following script:

✅ Verification successful

Removal of manager-load-backup case verified.

All references to manager-load-backup have been successfully removed from the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for any remaining references to 'manager-load-backup'
rg --type typescript --type javascript 'manager-load-backup'

Length of output: 95


Script:

#!/bin/bash
# Search for any remaining references to 'manager-load-backup'
rg --type ts --type js 'manager-load-backup'

Length of output: 44

MatissJanis
MatissJanis previously approved these changes Oct 10, 2024
Copy link
Member

@MatissJanis MatissJanis 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! I hope I didn't put you in a Trans 🤯 😄

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