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

Dynamic user splash page #71

Merged
merged 12 commits into from
Jan 8, 2020
Merged

Dynamic user splash page #71

merged 12 commits into from
Jan 8, 2020

Conversation

joverlee521
Copy link
Contributor

This PR builds on top of #69

If a user is signed in, the splash page has a groups section that dynamically creates tiles for the user's groups. These tiles are empty images with a background color from theme.titleColors.

In order to pass the user data to the index page, I created a UserDataWrapper that fetches user data from /whoami and passes the user state to each child element through the user prop. I'm not entirely sure how to manage a "global" user data store within gatsby when the authentication is handled on the server side.

@joverlee521 joverlee521 force-pushed the dynamic-user-splash-page branch from bc45f6a to 24c7437 Compare January 3, 2020 19:47
@tsibley tsibley temporarily deployed to nextstrain-s-dynamic-us-zirdqz January 3, 2020 19:47 Inactive
@jameshadfield jameshadfield temporarily deployed to nextstrain-dev January 5, 2020 20:28 Inactive
@jameshadfield
Copy link
Member

👍 I'm going to close #69 and review this PR instead, which is now up on https://nextstrain-dev.herokuapp.com

Copy link
Member

@jameshadfield jameshadfield left a comment

Choose a reason for hiding this comment

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

Thanks @joverlee521 and @kairstenfay -- this looks really good. See the line comments for things which need changing.

(i) When logged in /whoami redirects to /users/<userName> but /users doesn't redirect (in this case /users/<userName> looks identical to users. Is this intentional? Seems like it should redirect but this is a minor point & it may be intentional.

(ii) Your usage of <UserDataWrapper> seems like a good way to inject state into downstream components. Alternative solutions would be to use React's Context functionality to only inject it into components that need it, but I'm happy with your solution.

(iii) The usage of empty.png is nice as one day we'll hopefully have images to display for each group. Webpack inlines this into a small base64 string so there's no real performance penalty I can see.



const FourOhFour = () => {
// Workaround so 404 page doesn't flash when pages are redirecting
Copy link
Member

Choose a reason for hiding this comment

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

This is nice! It removes the flash for me when going straight to docs pages (with or without redirects) but the (this was a flash of the splash page, not the 404 page)

The 404 page still flashes when I click "login" or "logout". In particular, clicking logout causes 2-3 page flashes, including at least one 404. Can you replicate?

Copy link
Contributor

Choose a reason for hiding this comment

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

After logging in and logging out, I no longer see 404 flashes.

Copy link
Member

Choose a reason for hiding this comment

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

They're still there for me. This issue isn't blocking for this PR (the behavior's not introduced here) so i'm going to make an issue with GIFs so that you can see what i'm on about.

@trvrb trvrb temporarily deployed to nextstrain-s-dynamic-us-60jky6 January 6, 2020 21:07 Inactive
kairstenfay and others added 11 commits January 6, 2020 14:22
Co-authored-by: Jover Lee <joverlee521@gmail.com>
Redirects from `/whoami` to `/users/<username>` is a user is signed in.
Redirects to `/users` if there is no user signed in.
Used a workaround found on github
(gatsbyjs/gatsby#5329 (comment))
to prevent the index or 404 page from flashing during page
redirects.
`user.groups` provides all groups that users are a part of on AWS,
but we only care about groups that match our Nextstrain sources.
Assumes that all group urls follows the format `/group/<group-name>`.
Provides a wrapper that fetches user data from the API endpoint
"/whoami". Passes the user state to all children through the prop `user`
Refactor pages to use userDataWrapper.
Refactor NavBar to use `user` prop instead of having its own user state.
If a user is signed in, they can see a "groups" section on the splash
page that lists all of their groups.

Currently the group tiles use an "empty" image with a background color.
The background colors rotate through the titleColors listed in theme.js.
@kairstenfay kairstenfay force-pushed the dynamic-user-splash-page branch 2 times, most recently from 736e51c to 390b32a Compare January 8, 2020 01:49
@kairstenfay
Copy link
Contributor

@jameshadfield I've incorporated your requested changes except for:

  • adding a padlock icon to Nextstrain groups header on the splash page (to further encode the concept of "private" datasets)
  • using Context over Jover's dataWrapper component to pass state to the new user components

@jameshadfield jameshadfield marked this pull request as ready for review January 8, 2020 05:16
@jameshadfield jameshadfield self-requested a review January 8, 2020 05:16
@jameshadfield jameshadfield temporarily deployed to nextstrain-dev January 8, 2020 05:17 Inactive
Minor font size changes
@jameshadfield jameshadfield temporarily deployed to nextstrain-dev January 8, 2020 05:47 Inactive
@jameshadfield
Copy link
Member

Thanks @kairstenfay i've retested and it's working well. This is a nice step forward for the website!

Note that because cognito groups are now filtered against those specified in sources.js at authentication time, if you're already logged in from a previous deployment of nextstrain.org then you may get tiles when you shouldn't (see screenshot below, blab isn't a valid nextstrain group (yet)). Looking through the cognito groups we have this should only impact users with blab or seattleflu cognito groups. It's resolved by logging-out & logging in.

image

I've incorporated your requested changes except for ... [padlock icon & using Context]

I never requested those two changes! I only mentioned Context as an alternate solution (and specifically said that I was happy with the current solution) in response to Jover saying she wasn't sure if this was the way to do it.

@jameshadfield jameshadfield merged commit a5dc052 into master Jan 8, 2020
@jameshadfield jameshadfield deleted the dynamic-user-splash-page branch January 8, 2020 06:05
@kairstenfay
Copy link
Contributor

I never requested those two changes! I only mentioned Context as an alternate solution (and specifically said that I was happy with the current solution) in response to Jover saying she wasn't sure if this was the way to do it.

Understood. I simply wanted to raise the two remaining potential changes in a single comment.

Additionally, it just occurred to me that we never implemented a redirect from /users to /users/{username}.

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.

5 participants