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

[KED-1450] Move visibleNav/navWidth calculations into redux store #124

Merged
merged 13 commits into from
Mar 13, 2020

Conversation

richardwestenra
Copy link
Contributor

@richardwestenra richardwestenra commented Mar 4, 2020

Description

The visibleNav calculation affects the flowchart width and is currently a class method used in multiple places, which is getting difficult to maintain. It's handled in this way because the boolean flag is stored in the Wrapper component state, so it can only be passed down as a prop. Moving this prop to the redux store and using selectors to manage the navWidth calculations will save time and make things more maintainable.

Development notes

I've also added/changed some of the tests to improve coverage and make them more flexible, and done some slight sidebar refactoring.

QA notes

No functionality changes

Checklist

  • Read the contributing guidelines
  • Opened this PR as a 'Draft Pull Request' if it is work-in-progress
  • Updated the documentation to reflect the code changes
  • Added new entries to the RELEASE.md file
  • Added tests to cover my changes

Legal notice

  • I acknowledge and agree that, by checking this box and clicking "Submit Pull Request":

  • I submit this contribution under the Apache 2.0 license and represent that I am entitled to do so on behalf of myself, my employer, or relevant third parties, as applicable.

  • I certify that (a) this contribution is my original creation and / or (b) to the extent it is not my original creation, I am authorised to submit this contribution on behalf of the original creator(s) or their licensees.

  • I certify that the use of this contribution as authorised by the Apache 2.0 license does not violate the intellectual property rights of anyone else.

@richardwestenra richardwestenra marked this pull request as ready for review March 5, 2020 17:12
Better to pass an explicitly empty object when values have not been received (and handle the response down the ), than pass false values
@921kiyo
Copy link
Contributor

921kiyo commented Mar 6, 2020

I think it's best for the front-end engineers to review the changes, so I will leave it to them.

@richardwestenra richardwestenra changed the title Move visibleNav/navWidth calculations into redux store [KED1450] Move visibleNav/navWidth calculations into redux store Mar 6, 2020
@richardwestenra richardwestenra changed the title [KED1450] Move visibleNav/navWidth calculations into redux store [KED-1450] Move visibleNav/navWidth calculations into redux store Mar 11, 2020
Copy link
Collaborator

@limdauto limdauto left a comment

Choose a reason for hiding this comment

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

There is one potential logical issue I could spot. The rest looks great to me, although it's probably a good idea to ask another pair of 👀 on it.

className={classnames(
'pipeline-sidebar__show-menu pipeline-sidebar__icon-button',
{
'pipeline-sidebar__icon-button--visible': !visible
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have to pass visible in here? onToggle is already hard-coded to true right. The same applies to HideMenuButton. The reason I'm asking is because 'pipeline-sidebar__icon-button--visible': !visible is a bit hard to parse for my brain, but it's not a biggie.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's a really tricky one - I'm using 'visible' to refer to two different things - the visibility of the sidebar, and the visibility of the Show Menu button, which is only visible when the other is hidden. I think renaming the prop to be more specific will help - I'll do that. Thanks!

top,
outerWidth: width,
outerHeight: height,
width: width ? width - sidebarWidth : width,
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be sidebarWidth ? width - sidebarWidth : width (probably)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ahhhh this is a leftover relic from before I added the check for if (!width || !height) { on line 91. I can now remove the ternary check completely.

"'pipeline-sidebar__icon-button--visible': !visible" was confusing
There is now a guard against width being undefined earlier in the function
Copy link
Collaborator

@limdauto limdauto left a comment

Choose a reason for hiding this comment

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

Nice one!

@richardwestenra richardwestenra merged commit 4d6f05c into develop Mar 13, 2020
@richardwestenra richardwestenra deleted the refactor/nav-offset branch March 13, 2020 12:13
richardwestenra added a commit that referenced this pull request Mar 18, 2020
@richardwestenra richardwestenra mentioned this pull request May 26, 2020
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