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

thuang-1840-authn-prompt #1911

Merged
merged 1 commit into from Oct 8, 2020
Merged

thuang-1840-authn-prompt #1911

merged 1 commit into from Oct 8, 2020

Conversation

tihuan
Copy link
Contributor

@tihuan tihuan commented Oct 7, 2020

https://app.zenhub.com/workspaces/single-cell-5e2a191dad828d52cc78b028/issues/chanzuckerberg/cellxgene/1840undefined

  1. Adds /* eslint-disable camelcase -- Allowing snake_case from BE */ in client/src/components/menubar/authButtons.js <--- NO LONGER NEEDED!
  2. Extracts LocalStorage helper functions into its own file client/src/components/util/localStorage.js, and reuse it in both cookie prompt and login prompt
  3. Adds Popover for login prompt
  4. Adds checkbox option to stop showing the login prompt next time the user visits the app

NOTE:

  1. I did a slight variation of what the ticket describes, because now we're showing the <Popover /> over the Login button, so I thought adding another <Login /> button inside the <Popover /> would look weird. But please let me know what you think. Thank you!

QA steps:

  1. Get <AuthButtons /> to show by changing the following in client/src/components/leftSidebar/topLeftLogoAndTitle.js:

BEFORE

{!userinfo.is_authenticated ? (
    <AuthButtons auth={auth} userinfo={userinfo} />
  ) : null}

AFTER

{true? (
    <AuthButtons auth={auth} userinfo={userinfo} />
  ) : null}
  1. Play with the prompt!

Expected behaviors:

  1. Check the checkbox and click "OK" button, refresh the page, and you should no longer see the prompt if you're not logged in

  2. Any other conditions should still show the prompt after refreshing the page

  3. Prompt should only show if authN is on, not logged in, and prompt LocalStorage cxg.LOGIN_PROMPT value is not "off"

UPDATE: NEW COPY

Screen Shot 2020-10-08 at 4 40 47 PM

gif

PTAL! Thank you!

data-testid="auth-button"
disabled={false}
href={!userinfo.is_authenticated ? auth.login : auth.logout}
<div style={{ position: "relative" }}>
Copy link
Contributor Author

@tihuan tihuan Oct 7, 2020

Choose a reason for hiding this comment

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

Add a relative parent to wrap siblings <AuthButton /> and <div style={{ position: "absolute" }} />, so the "absolute" sibling can overlap with <AuthButton /> and position <Popover /> correctly

We can't just wrap Popover > Tooltip > AuthButton, because that disables <AuthButton />, which means clicking on the <AuthButton /> will only trigger the <Popover /> instead of navigating to the login/logout link

Copy link
Member

Choose a reason for hiding this comment

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

which means clicking on the will only trigger the instead of navigating to the login/logout link

typo :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah thank you! Missing the closing ` 😆 Corrected!

@tihuan tihuan requested a review from pdugan20 October 7, 2020 03:50
@codecov-io
Copy link

codecov-io commented Oct 7, 2020

Codecov Report

Merging #1911 into main will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #1911   +/-   ##
=======================================
  Coverage   65.65%   65.65%           
=======================================
  Files          52       52           
  Lines        4234     4234           
=======================================
  Hits         2780     2780           
  Misses       1454     1454           
Flag Coverage Δ
#frontend 100.00% <ø> (ø)
#javascript 100.00% <ø> (ø)
#smokeTestAnnotations 100.00% <ø> (?)
#unitTest 100.00% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


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 6677d0d...e0cfc1a. Read the comment docs.

Copy link
Contributor

@bmccandless bmccandless left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thanks @tihuan .

@tihuan
Copy link
Contributor Author

tihuan commented Oct 7, 2020

Thanks so much for the quick review, Brian!!

PTAL for styling and cellxgene code best practices @pdugan20 @colinmegill @seve 😄 🙏

Thank you!

@colinmegill
Copy link
Contributor

I think we need to clarify the copy.

Does this mean:

  1. Log in now to save your annotations, but regardless of whether you do they'll be here when you come back
  2. Log in now to save your annotations, so that they are here when you come back

image

Copy link
Member

@seve seve left a comment

Choose a reason for hiding this comment

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

Local Storage, exciting! One small nit about ESLint. LGTM otherwise!

type="button"
data-testid="auth-button"
disabled={false}
href={!userinfo?.is_authenticated ? auth.login : auth.logout}
Copy link
Member

Choose a reason for hiding this comment

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

There is currently a bug in ESLint that's causing these lines to get errored. Instead of disabling ESLint, our current workaround is:

Suggested change
href={!userinfo?.is_authenticated ? auth.login : auth.logout}
href={!userinfo?.["is_authenticated"] ? auth.login : auth.logout}

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh thank you! TIL! Will update!

data-testid="auth-button"
disabled={false}
href={!userinfo.is_authenticated ? auth.login : auth.logout}
<div style={{ position: "relative" }}>
Copy link
Member

Choose a reason for hiding this comment

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

which means clicking on the will only trigger the instead of navigating to the login/logout link

typo :)

@@ -107,9 +107,9 @@ class LeftSideBar extends React.Component {
userinfo,
}}
/>
{!userinfo.is_authenticated ? (
{!userinfo.is_authenticated && (
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉 I think we can even get rid of the ()

Suggested change
{!userinfo.is_authenticated && (
{!userinfo.is_authenticated && <AuthButtons auth={auth} userinfo={userinfo} />}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah good point! In this case, since prettier wraps code when the line is too long, it automatically does the following instead!

{!userinfo.is_authenticated && (
  <AuthButtons auth={auth} userinfo={userinfo} />
)}

Copy link
Contributor

Choose a reason for hiding this comment

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

ooh nvm then!

<AnchorButton
type="button"
data-testid="auth-button"
disabled={false}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think we could just omit this if it's false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point! Done 😆

@bmccandless
Copy link
Contributor

I think we need to clarify the copy.

Does this mean:

  1. Log in now to save your annotations, but regardless of whether you do they'll be here when you come back
  2. Log in now to save your annotations, so that they are here when you come back

image

How about: "Log in to create your own annotations. Please note, logging in later will refresh this page and you may lose progress."

Copy link
Contributor

@lesliecodes lesliecodes left a comment

Choose a reason for hiding this comment

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

Looks great! Can we add a unit test for this? 🙏

@tihuan
Copy link
Contributor Author

tihuan commented Oct 7, 2020

Thanks @lesliecodes ! cellxgene doesn't have unit test, but we can add an integration test after Seve's #1907 is merged, since it has the infrastructure code for running AuthN features locally!

Copy link
Contributor

@lesliecodes lesliecodes left a comment

Choose a reason for hiding this comment

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

Thanks Timmy!

@tihuan
Copy link
Contributor Author

tihuan commented Oct 7, 2020

Thanks Leslie!

I think we're close to being able to merge. Last bit on the buttons, pending decision in Slack thread 😆

@tihuan tihuan force-pushed the thuang-1840-authn-prompt branch 2 times, most recently from 5b351ad to 340c69f Compare October 8, 2020 02:22
@tihuan
Copy link
Contributor Author

tihuan commented Oct 8, 2020

Latest iteration!

Screen Shot 2020-10-07 at 7 09 09 PM

gif

@tihuan tihuan merged commit c01a2c7 into main Oct 8, 2020
@tihuan tihuan deleted the thuang-1840-authn-prompt branch October 8, 2020 23:57
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.

None yet

6 participants