-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
ui: style login page #26066
ui: style login page #26066
Changes from all commits
46c1b4f
a9f74ae
b966f7c
79b9dc4
4eaa236
9f6f519
f1ef286
8d20abc
31f60eb
6d064e0
ee1a743
de8d6f1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,29 @@ | ||
import React from "react"; | ||
import { Route } from "react-router"; | ||
import { Store } from "redux"; | ||
|
||
import { doLogout, selectLoginState } from "src/redux/login"; | ||
import { AdminUIState } from "src/redux/state"; | ||
import LoginPage from "src/views/login/loginPage"; | ||
|
||
export const LOGIN_PAGE = "/login"; | ||
export const LOGOUT_PAGE = "/logout"; | ||
|
||
export default function createLoginRoutes(store: Store<AdminUIState>): JSX.Element { | ||
function handleLogout(_nextState: any, replace: (route: string) => {}) { | ||
const loginState = selectLoginState(store.getState()); | ||
|
||
if (!loginState.loggedInUser()) { | ||
return replace(LOGIN_PAGE); | ||
} | ||
|
||
store.dispatch(doLogout()); | ||
} | ||
|
||
export default function(): JSX.Element { | ||
return ( | ||
<Route path={LOGIN_PAGE} component={ LoginPage } /> | ||
<React.Fragment> | ||
<Route path={LOGIN_PAGE} component={ LoginPage } /> | ||
<Route path={LOGOUT_PAGE} onEnter={ handleLogout } /> | ||
</React.Fragment> | ||
); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,13 +7,15 @@ import { Link } from "react-router"; | |
|
||
import { AdminUIState } from "src/redux/state"; | ||
import { selectLoginState, LoginState, doLogout } from "src/redux/login"; | ||
import { LOGOUT_PAGE } from "src/routes/login"; | ||
import { cockroachIcon } from "src/views/shared/components/icons"; | ||
import { trustIcon } from "src/util/trust"; | ||
|
||
import homeIcon from "!!raw-loader!assets/home.svg"; | ||
import metricsIcon from "!!raw-loader!assets/metrics.svg"; | ||
import databasesIcon from "!!raw-loader!assets/databases.svg"; | ||
import jobsIcon from "!!raw-loader!assets/jobs.svg"; | ||
import unlockedIcon from "!!raw-loader!assets/unlocked.svg"; | ||
|
||
interface IconLinkProps { | ||
icon: string; | ||
|
@@ -69,7 +71,13 @@ function LoginIndicator({ loginState, handleLogout }: LoginIndicatorProps) { | |
} | ||
|
||
if (!loginState.loginEnabled()) { | ||
return (<div className="login-indicator">Insecure mode</div>); | ||
return ( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't see this indicator when I start a cluster in insecure mode. Just blank space above the cockroach icon. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you sure you had the environment variable set? I am seeing it... |
||
<li className="login-indicator login-indicator--insecure"> | ||
<div className="image-container" | ||
dangerouslySetInnerHTML={trustIcon(unlockedIcon)}/> | ||
<div>Insecure mode</div> | ||
</li> | ||
); | ||
} | ||
|
||
const user = loginState.loggedInUser(); | ||
|
@@ -78,11 +86,15 @@ function LoginIndicator({ loginState, handleLogout }: LoginIndicatorProps) { | |
} | ||
|
||
return ( | ||
<div className="login-indicator"> | ||
Logged in as {user} | ||
<br /> | ||
<button onClick={handleLogout}>Logout</button> | ||
</div> | ||
<li className="login-indicator"> | ||
<div | ||
className="login-indicator__initial" | ||
title={`Signed in as ${user}`} | ||
> | ||
{ user[0] } | ||
</div> | ||
<Link to={LOGOUT_PAGE} onClick={handleLogout}>Sign Out</Link> | ||
</li> | ||
); | ||
} | ||
|
||
|
@@ -113,10 +125,8 @@ export default class Sidebar extends React.Component { | |
<IconLink to="/databases" icon={databasesIcon} title="Databases" activeFor="/database" /> | ||
<IconLink to="/jobs" icon={jobsIcon} title="Jobs" /> | ||
</ul> | ||
<div className="logged-in-user"> | ||
<LoginIndicatorConnected /> | ||
</div> | ||
<ul className="navigation-bar__list navigation-bar__list--bottom"> | ||
<LoginIndicatorConnected /> | ||
<IconLink to="/" icon={cockroachIcon} className="cockroach" /> | ||
</ul> | ||
</nav> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
@require "~styl/base/palette.styl" | ||
|
||
.login-page | ||
display flex | ||
align-items center | ||
justify-content center | ||
height 100% | ||
width 100% | ||
position absolute | ||
background-color white | ||
|
||
.content | ||
border thin solid $table-border-color | ||
position relative | ||
|
||
&__info.section | ||
width 486px | ||
display inline-block | ||
padding 24px | ||
|
||
&__form.section | ||
background-color $table-border-color | ||
width 486px | ||
display inline-block | ||
padding 108px 53px 138px | ||
|
||
.heading | ||
text-transform none | ||
letter-spacing 1px | ||
margin-bottom 24px | ||
|
||
.aside | ||
margin-top 12px | ||
line-height 24px | ||
letter-spacing 1px | ||
color $body-color | ||
width 350px | ||
|
||
.version | ||
color $body-color | ||
position absolute | ||
left 12px | ||
top 12px | ||
|
||
.version-tag | ||
color #54b30e | ||
|
||
.logo | ||
height 32px | ||
|
||
.docs-link | ||
display block | ||
margin-top 32px | ||
text-decoration none | ||
color $link-color | ||
|
||
&__icon | ||
position relative | ||
top 6px | ||
|
||
&__text | ||
font-size 17px | ||
line-height 30px | ||
margin-left 6px | ||
|
||
.input-text | ||
width 100% | ||
font-size 14px | ||
line-height 17px | ||
padding 12px 18px | ||
vertical-align middle | ||
border 1px solid $button-border-color | ||
border-radius 3px | ||
margin 12px 0 | ||
color $body-color | ||
display block | ||
|
||
&--error | ||
border-color $alert-color | ||
|
||
.submit-button | ||
width 100% | ||
text-transform uppercase | ||
font-size 14px | ||
letter-spacing 2px | ||
line-height 17px | ||
padding 12px 24px | ||
vertical-align middle | ||
border 0px none | ||
border-radius 3px | ||
margin 24px 0 | ||
color $background-color | ||
background-color $link-color | ||
cursor pointer | ||
display block | ||
|
||
&:disabled | ||
background-color #90b8ef | ||
|
||
&__error | ||
color $alert-color | ||
margin 12px 0 |
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 like this is what broke the
ServeIndexHTML
test in CI. It's pretty brittle — asserts the exact HTML that comes out. Not sure how to make that always pass, since the build tag will keep changing… Maybe can just sprintf it into the expected HTML.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.
Tests updated.