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

Modals and DashAlert state #737

Merged
merged 16 commits into from
Mar 5, 2017
Merged

Modals and DashAlert state #737

merged 16 commits into from
Mar 5, 2017

Conversation

ackernaut
Copy link
Member

@ackernaut ackernaut commented Feb 23, 2017

Fixes #724

Copy link
Member

@mattkrick mattkrick left a comment

Choose a reason for hiding this comment

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

well done! just 2 readability things & 1 slight performance thing & we'll be ready to rock

},

main: {
[ui.modalLayout[0]]: {
Copy link
Member

Choose a reason for hiding this comment

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

if we write the type out instead of referencing an array this would be easier to read

const {id: teamId, name: teamName, isPaid} = team;
const hasActiveMeeting = Boolean(team && team.meetingId);
const hasOverlay = hasActiveMeeting || !isPaid;
const isSettings = router.isActive(`/team/${teamId}/settings`, false);
initialValues.teamName = teamName;
const DashHeaderInfoTitle = isSettings ? <EditTeamName initialValues={initialValues} teamName={teamName} teamId={teamId}/> : teamName;
const modalLayout = hasNotificationBar ? ui.modalLayout[1] : ui.modalLayout[0];
Copy link
Member

Choose a reason for hiding this comment

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

referencing the array isn't very meaningful (i know i set a bad example with the notifications varList, but that's mainly for payload size). could we instead say something like `hasNotificationBar ? ui.main : ui.mainHasNotificaitonBar

if (activeMeetings.length > 0 || barType === TRIAL_EXPIRES_SOON || barType === TRIAL_EXPIRED) {
this.props.dispatch(notificationBarPresent(true));
} else {
this.props.dispatch(notificationBarPresent(false));
Copy link
Member

Choose a reason for hiding this comment

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

can we grab hasNotificationBar and ONLY call dispatch if nextProps.hasNotificationBar !== this.props.hasNotificationBar? Otherwise we'll be triggering a dispatch on every new prop that comes in

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! Very helpful, thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

@mattkrick Not sure how to set it the first time without next always equal to the current.

Copy link
Member

Choose a reason for hiding this comment

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

@ackernaut here's the pattern i use:

  • factor this out into its own method
  • call that method from componentWillMount and componentWillReceiveProps
  • from cWRP, pass in this.props and nextProps
  • from cWM, pass in this.props as the nextProps param and {} for nextProps

Check out MeetingContainer for the pattern, i do this for handleRedirects.

@ackernaut ackernaut changed the base branch from add-orgs to master March 1, 2017 22:18
@ackernaut ackernaut changed the title Add orgs modals take2 Modals and notification bar state Mar 1, 2017
@codecov
Copy link

codecov bot commented Mar 1, 2017

Codecov Report

Merging #737 into master will increase coverage by 0.1%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master     #737     +/-   ##
=========================================
+ Coverage   56.66%   56.77%   +0.1%     
=========================================
  Files          97       97             
  Lines        1207     1210      +3     
=========================================
+ Hits          684      687      +3     
  Misses        523      523
Impacted Files Coverage Δ
src/universal/styles/ui.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a80343b...293fec7. Read the comment docs.

@codecov
Copy link

codecov bot commented Mar 1, 2017

Codecov Report

Merging #737 into master will increase coverage by 0.1%.
The diff coverage is 100%.

@@            Coverage Diff            @@
##           master     #737     +/-   ##
=========================================
+ Coverage   56.66%   56.77%   +0.1%     
=========================================
  Files          97       97             
  Lines        1207     1210      +3     
=========================================
+ Hits          684      687      +3     
  Misses        523      523
Impacted Files Coverage Δ
src/universal/styles/ui.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update bf3385a...abc13ca. Read the comment docs.

return (
<DashLayoutContainer>
<DashLayoutContainer dispatch={dispatch}>
Copy link
Member

Choose a reason for hiding this comment

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

dont pass dispatch to containers, mapStateToProps gives it to em anyways

Copy link
Member

Choose a reason for hiding this comment

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

@ackernaut is this necessary?

@@ -0,0 +1,23 @@
const NOTIFICATION_BAR_PRESENT = 'notifications/NOTIFICATION_BAR_PRESENT';
Copy link
Member

Choose a reason for hiding this comment

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

where does this bar appear? all dashboards? meeting? i think we may wanna refactor it into a dashboard duck. we already have an entity called notifications & having a notifications duck that doesnt pertain to it is gonna get confusing.

@ackernaut
Copy link
Member Author

Ok @mattkrick all changes have been made! This PR is ready.

const title = pathname === '/me' ? 'User Dashboard' : 'User Settings';
return (
<DashboardWrapper location={pathname} title={title}>
<DashboardWrapper dispatch={dispatch} location={pathname} title={title}>
Copy link
Member

Choose a reason for hiding this comment

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

necessary?

@@ -35,6 +36,7 @@ const appReducers = {
[DEFAULT_AUTH_REDUCER_NAME]: auth,
cashay: cashayReducer,
form: formReducer.plugin(formPlugin),
notifications: notificationReducer,
Copy link
Member

Choose a reason for hiding this comment

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

let's refactor to 'dashboard' or something similar so we don't confuse the notification bar with notifications

@ackernaut
Copy link
Member Author

@mattkrick what do you think about DashboardAlert instead of NotificationBar since the content is not really a notification at all, just a cousin sometimes (when pertaining to billing, but not active meetings)...

@ackernaut
Copy link
Member Author

ackernaut commented Mar 2, 2017

Ok @mattkrick third time’s the charm, eh?

  • Refactored Noti…Bar to DashAlert (including ducks)
  • Cleaned up unnecessary dispatch props
  • Improved the DashAlert presence helper method to ensure bool value

@ackernaut ackernaut changed the title Modals and notification bar state Modals and DashAlert state Mar 2, 2017
@@ -10,7 +10,7 @@ import HTML5Backend from 'react-dnd-html5-backend';
const NewTeam = (props) => {
const {dispatch, params: {newOrg}} = props;
return (
<DashboardWrapper title="User Dashboard">
<DashboardWrapper dispatch={dispatch} title="User Dashboard">
Copy link
Member

Choose a reason for hiding this comment

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

@ackernaut can we get rid of this?

Copy link
Member

@mattkrick mattkrick left a comment

Choose a reason for hiding this comment

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

just 1 itty bitty change!

@ackernaut
Copy link
Member Author

👍

@jordanh
Copy link
Contributor

jordanh commented Mar 5, 2017

Is this ready to merge now?

@mattkrick mattkrick merged commit 0da996b into master Mar 5, 2017
@jordanh jordanh removed the pr review label Mar 5, 2017
@ackernaut ackernaut deleted the add-orgs-modals-take2 branch March 8, 2017 04:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants