Partial fix for 1830 (#1863)

* Remove door icon from log in button
* Move log in and info buttons from the top bar to in line with the cellxgene icon and dataset name
* Hover over on login button should say "Log in to cellxgene"
* Show email

closes #1830
This commit is contained in:
Colin Megill
2020-09-30 11:45:10 -07:00
committed by GitHub
parent 998fa4762d
commit 04a3c3c6b6
6 changed files with 107 additions and 57 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ class Categories extends React.Component {
{allCategoryNames.map((catName) => {allCategoryNames.map((catName) =>
!schema.annotations.obsByName[catName].writable && !schema.annotations.obsByName[catName].writable &&
(schema.annotations.obsByName[catName].categories?.length > 1 || (schema.annotations.obsByName[catName].categories?.length > 1 ||
!schema.annotations.obsByName[catName].categories) ? ( !schema.annotations.obsByName[catName].categories) ? (
<Category <Category
key={catName} key={catName}
metadataField={catName} metadataField={catName}
@@ -7,11 +7,19 @@ import * as globals from "../../globals";
import Logo from "../framework/logo"; import Logo from "../framework/logo";
import Truncate from "../util/truncate"; import Truncate from "../util/truncate";
import InfoDrawer from "../infoDrawer/infoDrawer"; import InfoDrawer from "../infoDrawer/infoDrawer";
import AuthButtons from "../menubar/authButtons";
import InformationMenu from "../menubar/infoMenu";
const DATASET_TITLE_FONT_SIZE = 14; const DATASET_TITLE_FONT_SIZE = 14;
@connect((state) => ({ @connect((state) => ({
datasetTitle: state.config?.displayNames?.dataset ?? "", datasetTitle: state.config?.displayNames?.dataset ?? "",
auth: state.config?.authentication,
userinfo: state.userinfo,
libraryVersions: state.config?.["library_versions"],
aboutLink: state.config?.links?.["about-dataset"],
tosURL: state.config?.parameters?.["about_legal_tos"],
privacyURL: state.config?.parameters?.["about_legal_privacy"],
})) }))
class LeftSideBar extends React.Component { class LeftSideBar extends React.Component {
handleClick = () => { handleClick = () => {
@@ -20,7 +28,16 @@ class LeftSideBar extends React.Component {
}; };
render() { render() {
const { datasetTitle } = this.props; const {
datasetTitle,
auth,
userinfo,
libraryVersions,
aboutLink,
privacyURL,
tosURL,
dispatch,
} = this.props;
return ( return (
<div <div
@@ -30,49 +47,70 @@ class LeftSideBar extends React.Component {
width: globals.leftSidebarWidth, width: globals.leftSidebarWidth,
zIndex: 1, zIndex: 1,
borderBottom: `1px solid ${globals.lighterGrey}`, borderBottom: `1px solid ${globals.lighterGrey}`,
display: "flex",
justifyContent: "space-between",
alignItems: "center",
}} }}
> >
<Logo size={30} /> <div>
<span <Logo size={28} />
style={{
fontSize: 28,
position: "relative",
top: -6,
fontWeight: "bold",
marginLeft: 5,
color: globals.logoColor,
userSelect: "none",
}}
>
cell
<span <span
style={{ style={{
position: "relative",
top: 1,
fontWeight: 300,
fontSize: 24, fontSize: 24,
position: "relative",
top: -6,
fontWeight: "bold",
marginLeft: 5,
color: globals.logoColor,
userSelect: "none",
}} }}
> >
× cell
</span> <span
gene style={{
</span> position: "relative",
<Button top: 1,
minimal fontWeight: 300,
style={{ fontSize: 24,
fontSize: DATASET_TITLE_FONT_SIZE, }}
position: "absolute", >
right: 10, ×
}}
onClick={this.handleClick}
>
<Truncate>
<span style={{ maxWidth: 155 }} data-testid="header">
{datasetTitle}
</span> </span>
</Truncate> gene
</Button> </span>
<InfoDrawer /> </div>
<div style={{ marginRight: 5, position: "relative", top: -7 }}>
<Button
minimal
style={{
fontSize: DATASET_TITLE_FONT_SIZE,
position: "relative",
top: -1,
}}
onClick={this.handleClick}
>
<Truncate>
<span style={{ maxWidth: 155 }} data-testid="header">
{datasetTitle}
</span>
</Truncate>
</Button>
<InfoDrawer />
<InformationMenu
{...{
libraryVersions,
aboutLink,
tosURL,
privacyURL,
auth,
dispatch,
userinfo,
}}
/>
{!userinfo.is_authenticated ? (
<AuthButtons auth={auth} userinfo={userinfo} />
) : null}
</div>
</div> </div>
); );
} }
+1 -2
View File
@@ -11,7 +11,7 @@ const Auth = React.memo((props) => {
return ( return (
<ButtonGroup className={styles.menubarButton}> <ButtonGroup className={styles.menubarButton}>
<Tooltip <Tooltip
content="Log in or log out of cellxgene" content="Log in to cellxgene"
position="bottom" position="bottom"
hoverOpenDelay={globals.tooltipHoverOpenDelay} hoverOpenDelay={globals.tooltipHoverOpenDelay}
> >
@@ -19,7 +19,6 @@ const Auth = React.memo((props) => {
type="button" type="button"
data-testid="auth-button" data-testid="auth-button"
disabled={false} disabled={false}
icon={!userinfo.is_authenticated ? "log-in" : "log-out"}
href={!userinfo.is_authenticated ? auth.login : auth.logout} href={!userinfo.is_authenticated ? auth.login : auth.logout}
> >
{!userinfo.is_authenticated ? "Log In" : "Log Out"} {!userinfo.is_authenticated ? "Log In" : "Log Out"}
+1 -12
View File
@@ -6,8 +6,7 @@ import * as globals from "../../globals";
import styles from "./menubar.css"; import styles from "./menubar.css";
import actions from "../../actions"; import actions from "../../actions";
import Clip from "./clip"; import Clip from "./clip";
import AuthButtons from "./authButtons";
import InformationMenu from "./infoMenu";
import Subset from "./subset"; import Subset from "./subset";
import UndoRedoReset from "./undoRedo"; import UndoRedoReset from "./undoRedo";
import DiffexpButtons from "./diffexpButtons"; import DiffexpButtons from "./diffexpButtons";
@@ -204,7 +203,6 @@ class MenuBar extends React.PureComponent {
render() { render() {
const { const {
dispatch, dispatch,
libraryVersions,
disableDiffexp, disableDiffexp,
undoDisabled, undoDisabled,
redoDisabled, redoDisabled,
@@ -212,17 +210,12 @@ class MenuBar extends React.PureComponent {
clipPercentileMin, clipPercentileMin,
clipPercentileMax, clipPercentileMax,
graphInteractionMode, graphInteractionMode,
aboutLink,
showCentroidLabels, showCentroidLabels,
privacyURL,
tosURL,
categoricalSelection, categoricalSelection,
colorAccessor, colorAccessor,
subsetPossible, subsetPossible,
subsetResetPossible, subsetResetPossible,
enableReembedding, enableReembedding,
auth,
userinfo,
} = this.props; } = this.props;
const { pendingClipPercentiles } = this.state; const { pendingClipPercentiles } = this.state;
@@ -248,10 +241,6 @@ class MenuBar extends React.PureComponent {
zIndex: 3, zIndex: 3,
}} }}
> >
<AuthButtons auth={auth} userinfo={userinfo} />
<InformationMenu
{...{ libraryVersions, aboutLink, tosURL, privacyURL, dispatch }}
/>
<UndoRedoReset <UndoRedoReset
dispatch={dispatch} dispatch={dispatch}
undoDisabled={undoDisabled} undoDisabled={undoDisabled}
+29 -6
View File
@@ -3,12 +3,12 @@ import React from "react";
import { import {
Button, Button,
ButtonGroup, ButtonGroup,
Classes,
Menu, Menu,
MenuItem, MenuItem,
Popover, Popover,
Position, Position,
} from "@blueprintjs/core"; } from "@blueprintjs/core";
import { IconNames } from "@blueprintjs/icons";
import styles from "./menubar.css"; import styles from "./menubar.css";
const handleClick = (dispatch) => { const handleClick = (dispatch) => {
@@ -16,7 +16,14 @@ const handleClick = (dispatch) => {
}; };
const InformationMenu = React.memo((props) => { const InformationMenu = React.memo((props) => {
const { libraryVersions, tosURL, privacyURL, dispatch } = props; const {
libraryVersions,
tosURL,
privacyURL,
auth,
userinfo,
dispatch,
} = props;
return ( return (
<ButtonGroup className={`${styles.menubarButton}`}> <ButtonGroup className={`${styles.menubarButton}`}>
<Popover <Popover
@@ -24,27 +31,30 @@ const InformationMenu = React.memo((props) => {
<Menu> <Menu>
<MenuItem <MenuItem
onClick={() => handleClick(dispatch)} onClick={() => handleClick(dispatch)}
icon={IconNames.INFO_SIGN} icon="info-sign"
text="Dataset Overview" text="Dataset Overview"
/> />
<MenuItem <MenuItem
href="https://chanzuckerberg.github.io/cellxgene/" href="https://chanzuckerberg.github.io/cellxgene/"
target="_blank" target="_blank"
icon="help" icon="book"
text="Help" text="Documentation"
rel="noopener"
/> />
<MenuItem <MenuItem
href="https://join-cellxgene-users.herokuapp.com/" href="https://join-cellxgene-users.herokuapp.com/"
target="_blank" target="_blank"
icon="chat" icon="chat"
text="Chat" text="Chat"
rel="noopener"
/> />
<MenuItem <MenuItem
href="https://github.com/chanzuckerberg/cellxgene" href="https://github.com/chanzuckerberg/cellxgene"
target="_blank" target="_blank"
icon="git-branch" icon="git-branch"
text="Github" text="Github"
rel="noopener"
/> />
<MenuItem <MenuItem
target="_blank" target="_blank"
@@ -63,15 +73,28 @@ const InformationMenu = React.memo((props) => {
href={privacyURL} href={privacyURL}
target="_blank" target="_blank"
text="Privacy Policy" text="Privacy Policy"
rel="noopener"
/> />
) : null} ) : null}
{auth?.["requires_client_login"] &&
userinfo?.["is_authenticated"] ? (
<>
<MenuItem text={`Logged in as: ${userinfo.email}`} />
<MenuItem text="Log Out" href={auth.logout} />
</>
) : null}
</Menu> </Menu>
} }
position={Position.BOTTOM_RIGHT} position={Position.BOTTOM_RIGHT}
modifiers={{
preventOverflow: { enabled: false },
hide: { enabled: false },
}}
> >
<Button <Button
type="button" type="button"
icon={IconNames.INFO_SIGN} className={`${Classes.BUTTON} bp3-icon-info-sign`}
style={{ style={{
cursor: "pointer", cursor: "pointer",
}} }}
+1
View File
@@ -47,6 +47,7 @@ class AuthTypeTest(AuthTypeClientBase):
return_to = args.get("dataset", "/") return_to = args.get("dataset", "/")
session[self.CXGUID] = args.get("userid", self.user_id) session[self.CXGUID] = args.get("userid", self.user_id)
session[self.CXGUNAME] = args.get("username", self.user_name) session[self.CXGUNAME] = args.get("username", self.user_name)
session[self.CXGUEMAIL] = args.get("email", self.user_email)
return redirect(return_to) return redirect(return_to)
def logout(self): def logout(self):