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

Fredhase/codeclimate refactor onboarding initializers 3739 #5809

Closed
wants to merge 9 commits into from
Closed

Fredhase/codeclimate refactor onboarding initializers 3739 #5809

wants to merge 9 commits into from

Conversation

fredhase
Copy link
Contributor

What type of PR is this? (check all applicable)

  • Refactor
  • Feature
  • Bug Fix
  • Optimization
  • Documentation Update

Description

Refactoring codes in app/assets/javascripts/initializers (DrawerSliders and SwipeGestures). Some minor refactoring and some repetitive blocks are now a function.
In app/javascript/onboarding/components just made minor refactoring.

Added to documentation?

  • docs.dev.to
  • readme
  • no documentation needed

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Jan 29, 2020
Copy link

@paulodiovani paulodiovani left a comment

Choose a reason for hiding this comment

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

Build is failing,
And also, refactor without unit tests can be dangerous. I suggest writing some in a separate PR prior to this one.

Comment on lines 8 to 13
const drawerSliders = [
{ selector: 'sidebar-bg-left', swipeState: 'middle', side: 'left', view: 'outOfView' },
{ selector: 'sidebar-bg-right', swipeState: 'middle', side: 'right', view: 'outOfView' },
{ selector: 'on-page-nav-butt-left', swipeState: 'left', side: 'left', view: 'intoView' },
{ selector: 'on-page-nav-butt-right', swipeState: 'right', side: 'right', view: 'intoView' },
];

Choose a reason for hiding this comment

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

This could be kept outside the function.

}
}
InstantClick.on('change', function() {
document.getElementsByTagName('body')[0].classList.remove('modal-open');

Choose a reason for hiding this comment

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

This classList.remove('modal-open') seems to be missed in the new code.

Comment on lines +81 to +83
} else {
swipeState = 'middle';
slideSidebar('left', 'outOfView');

Choose a reason for hiding this comment

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

you can avoid using else at all

  if (!document.getElementById('on-page-nav-controls')) {
    return;
  }

  if (swipeState == 'middle') {
    swipeState = 'right';
    return slideSidebar('right', 'intoView');
  }

  swipeState = 'middle';
  slideSidebar('left', 'outOfView');

@@ -125,42 +138,10 @@ class ClosingSlide extends Component {
</div>
);
}
return (
return(

Choose a reason for hiding this comment

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

Missing a blank space

}

whatsNext() {
const properties = [

Choose a reason for hiding this comment

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

please, rename this to something like whatsNextLinks,

or just return the array (see next comment)

Comment on lines 19 to 30
return(
properties.map((element, index) =>
<a key={ index } href={ element.href } data-no-instant={(index === 0) ? true : null }>
{ element.text }
<p className="whatnext-emoji">
<span role="img" aria-label="tada">
{ element.emoji }
</span>
</p>
</a>
)
);

Choose a reason for hiding this comment

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

Doesn't add much to have a method return a small piece of component here.
As a suggestion:

  1. make whatsNext() method return just the array of objects.
  2. .map it in render() method

@fredhase
Copy link
Contributor Author

@paulodiovani
Thanks for the review and tips. Unfortunattely, I'm still studying unit tests, so, for now, I can't do much about that. But I fixed everything pointed out :)

Copy link
Contributor

@nickytonline nickytonline left a comment

Choose a reason for hiding this comment

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

@fredhase, is this PR still being worked on, or has it been superceded by #5650? If so, consider closing this one.

@fredhase
Copy link
Contributor Author

fredhase commented Feb 7, 2020

@nickytonline
Hi, sorry. I'm still learning about PRs and branches and I may have forgotten to make the checkout to the master before starting a new branch. So, i'm not sure how my branchs are right now 🤔
Really sorry about the mess

@nickytonline
Copy link
Contributor

nickytonline commented Feb 7, 2020

@nickytonline
Hi, sorry. I'm still learning about PRs and branches and I may have forgotten to make the checkout to the master before starting a new branch. So, i'm not sure how my branchs are right now 🤔
Really sorry about the mess

No worries @fredhase. And no pressure to get this done. If you need some assistance with branches and git, happy to help. This post from one of our community members may be of help to you, https://dev.to/unseenwizzard/learn-git-concepts-not-commands-4gjc

@fredhase
Copy link
Contributor Author

Closing this PR for some branche mistakes that caused conflict

@fredhase fredhase closed this Feb 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: unreviewed bot applied label for PR's with no review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants