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
thuang-1840-authn-prompt #1911
Conversation
data-testid="auth-button" | ||
disabled={false} | ||
href={!userinfo.is_authenticated ? auth.login : auth.logout} | ||
<div style={{ position: "relative" }}> |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 :)
There was a problem hiding this comment.
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!
Codecov Report
@@ Coverage Diff @@
## main #1911 +/- ##
=======================================
Coverage 65.65% 65.65%
=======================================
Files 52 52
Lines 4234 4234
=======================================
Hits 2780 2780
Misses 1454 1454
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report at Codecov.
|
There was a problem hiding this 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 .
Thanks so much for the quick review, Brian!! PTAL for styling and cellxgene code best practices @pdugan20 @colinmegill @seve 😄 🙏 Thank you! |
There was a problem hiding this 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} |
There was a problem hiding this comment.
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:
href={!userinfo?.is_authenticated ? auth.login : auth.logout} | |
href={!userinfo?.["is_authenticated"] ? auth.login : auth.logout} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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" }}> |
There was a problem hiding this comment.
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 :)
35e5786
to
c94120d
Compare
@@ -107,9 +107,9 @@ class LeftSideBar extends React.Component { | |||
userinfo, | |||
}} | |||
/> | |||
{!userinfo.is_authenticated ? ( | |||
{!userinfo.is_authenticated && ( |
There was a problem hiding this comment.
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 ()
{!userinfo.is_authenticated && ( | |
{!userinfo.is_authenticated && <AuthButtons auth={auth} userinfo={userinfo} />} |
There was a problem hiding this comment.
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} />
)}
There was a problem hiding this comment.
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} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point! Done 😆
How about: "Log in to create your own annotations. Please note, logging in later will refresh this page and you may lose progress." |
There was a problem hiding this 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? 🙏
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! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Timmy!
Thanks Leslie! I think we're close to being able to merge. Last bit on the buttons, pending decision in Slack thread 😆 |
5b351ad
to
340c69f
Compare
340c69f
to
6fb5982
Compare
6fb5982
to
e0cfc1a
Compare
https://app.zenhub.com/workspaces/single-cell-5e2a191dad828d52cc78b028/issues/chanzuckerberg/cellxgene/1840undefined
/* eslint-disable camelcase -- Allowing snake_case from BE */
inclient/src/components/menubar/authButtons.js
<--- NO LONGER NEEDED!LocalStorage
helper functions into its own fileclient/src/components/util/localStorage.js
, and reuse it in both cookie prompt and login promptPopover
for login promptNOTE:
<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:
<AuthButtons />
to show by changing the following inclient/src/components/leftSidebar/topLeftLogoAndTitle.js
:BEFORE
AFTER
Expected behaviors:
Check the checkbox and click "OK" button, refresh the page, and you should no longer see the prompt if you're not logged in
Any other conditions should still show the prompt after refreshing the page
Prompt should only show if authN is on, not logged in, and prompt LocalStorage
cxg.LOGIN_PROMPT
value is not"off"
UPDATE: NEW COPY
PTAL! Thank you!