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

Refactor: Route children for welcome screens #468

Merged
merged 11 commits into from
Jan 2, 2024

Conversation

tuliomir
Copy link
Collaborator

@tuliomir tuliomir commented Dec 26, 2023

Among the necessary steps to upgrade to React Router v6 are:

  • Using react hooks on every screen
  • Using the children prop instead of component or render on the <Route /> elements

There are many screens to update and the ones selected for the scope of this PR are only the screens that are accessed without any router wrappers on the App.js file ( Ex.: NavigationRoute or StartedRoute ).

Some other components that are easy to refactor were also included, such as the BackButton that no longer needs any props from its parent.

Acceptance Criteria

  • All routes that are not wrapped in other components should be refactored with these best practices
  • All screens that are called by these routes should be refactored to functional components
  • Components used by those screens that are easily refactored should be turned into functional components as well
  • Unreachable component files that used to interact with those screens should be removed

Notes

As the screens' translatable messages were moved around, the locale/texts.pot had to be updated. This file alone has over 1000 lines of changed code that are actually from other contexts too.

Security Checklist

  • Make sure you do not include new dependencies in the project unless strictly necessary and do not include dev-dependencies as production ones. More dependencies increase the possibility of one of them being hijacked and affecting us.

@tuliomir tuliomir self-assigned this Dec 26, 2023
Copy link

codecov bot commented Dec 27, 2023

Codecov Report

Attention: 84 lines in your changes are missing coverage. Please review.

Comparison is base (bdd3667) 9.33% compared to head (e744e0d) 9.34%.

Files Patch % Lines
src/components/RequestError.js 0.00% 29 Missing and 5 partials ⚠️
src/screens/LoadingAddresses.js 0.00% 14 Missing and 3 partials ⚠️
src/screens/SentryPermission.js 0.00% 12 Missing and 3 partials ⚠️
src/screens/Welcome.js 0.00% 12 Missing ⚠️
src/components/BackButton.js 0.00% 5 Missing ⚠️
src/screens/Page404.js 0.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             dev    #468      +/-   ##
========================================
+ Coverage   9.33%   9.34%   +0.01%     
========================================
  Files        114     112       -2     
  Lines       5172    5166       -6     
  Branches     699     698       -1     
========================================
  Hits         483     483              
+ Misses      4025    4020       -5     
+ Partials     664     663       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tuliomir tuliomir marked this pull request as ready for review December 27, 2023 02:39
@tuliomir tuliomir requested review from r4mmer and removed request for pedroferreira1 December 27, 2023 02:39
}

render() {
Copy link
Collaborator Author

@tuliomir tuliomir Dec 27, 2023

Choose a reason for hiding this comment

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

tip: To review these changes to the render() method I suggest using the "Hide whitespace" feature on GitHub, as it highlights only the words that were changed on this file, and not the indentation adjustments that were necessary:

Ignore Whitespace Diff

Copy link
Member

@r4mmer r4mmer left a comment

Choose a reason for hiding this comment

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

There are some problems to verify some screens since they only come up in special circunstances. For instance failing a request to the fullnode (or timing out) with the wallet locked should show the Server screen so the user can select another server with the wallet still locked, this is very hard to check without manually spoofing a request.

Maybe we should check these unlikely scenarios on this PR since we are changing the component that handles errors.

The state was not being fetched by
the modal "hide" event listener.
It was removed because it's no longer
necessary.
@tuliomir
Copy link
Collaborator Author

tuliomir commented Dec 28, 2023

@r4mmer : I had already tested turning off the internet connection and the RequestError.js modal had worked fine. However I tried to intercept the requests and test more throroughly as you suggested and found a bug on the retry button.

The solution for this was to remove the retry state altogether, as it no longer has a setState callback function as it had before. The logic was redone so that it no longer depends on DOM manipulation and it has worked fine on all my tests so far.

This fix was implemented on f2cd753.

@tuliomir tuliomir requested a review from r4mmer December 28, 2023 19:45
$('#requestErrorModal').modal('hide');
this.props.history.push('/server/');
const handleChangeServer = () => {
$(MODAL_DOM_ID).modal('hide');
Copy link
Contributor

Choose a reason for hiding this comment

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

We should create an issue to convert this to the GlobalModal syntax

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Opened this issue on #471

@@ -7,33 +7,33 @@

import React from 'react';
import { t } from 'ttag';
import { useHistory } from "react-router-dom";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { useHistory } from "react-router-dom";
import { useHistory } from 'react-router-dom';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed on e744e0d

import hathorLib from '@hathor/wallet-lib';
import wallet from '../utils/wallet';
import { useHistory } from "react-router-dom";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { useHistory } from "react-router-dom";
import { useHistory } from 'react-router-dom';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed on e744e0d

@@ -5,7 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import React from 'react';
import React, { useState, useEffect } from 'react';
import { useHistory } from "react-router-dom";
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
import { useHistory } from "react-router-dom";
import { useHistory } from 'react-router-dom';

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed on e744e0d

@tuliomir tuliomir merged commit cbecaf1 into dev Jan 2, 2024
3 checks passed
@tuliomir tuliomir deleted the refactor/route-children-welcome branch January 2, 2024 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants