mirror of
https://github.com/desktop/desktop
synced 2024-10-31 11:07:25 +00:00
Show a not-logged-in view when you're not logged in.
This commit is contained in:
parent
356474a869
commit
cf9d3143f1
2 changed files with 22 additions and 20 deletions
28
src/app.tsx
28
src/app.tsx
|
@ -2,11 +2,12 @@ import * as React from 'react'
|
|||
import ThingList from './thing-list'
|
||||
import Info from './info'
|
||||
import UsersStore from './users-store'
|
||||
|
||||
const Octokat = require('octokat')
|
||||
import User from './user'
|
||||
import NotLoggedIn from './not-logged-in'
|
||||
|
||||
type AppState = {
|
||||
selectedRow: number
|
||||
selectedRow: number,
|
||||
user: User
|
||||
}
|
||||
|
||||
type AppProps = {
|
||||
|
@ -21,27 +22,14 @@ const AppStyle = {
|
|||
}
|
||||
|
||||
export default class App extends React.Component<AppProps, AppState> {
|
||||
private octo: any
|
||||
|
||||
public constructor(props: AppProps) {
|
||||
super(props)
|
||||
|
||||
this.octo = new Octokat({
|
||||
token: process.env.GITHUB_ACCESS_TOKEN
|
||||
})
|
||||
|
||||
props.usersStore.onUsersChanged(users => {
|
||||
console.log('users', users)
|
||||
this.setState({selectedRow: this.state.selectedRow, user: users[0]})
|
||||
})
|
||||
|
||||
console.log('users', props.usersStore.getUsers())
|
||||
|
||||
this.state = {selectedRow: -1}
|
||||
}
|
||||
|
||||
public async componentDidMount() {
|
||||
const zen = await this.octo.zen.read()
|
||||
console.log('zen', zen)
|
||||
this.state = {selectedRow: -1, user: props.usersStore.getUsers()[0]}
|
||||
}
|
||||
|
||||
public render() {
|
||||
|
@ -49,12 +37,12 @@ export default class App extends React.Component<AppProps, AppState> {
|
|||
return (
|
||||
<div style={completeStyle}>
|
||||
<ThingList selectedRow={this.state.selectedRow} onSelectionChanged={row => this.handleSelectionChanged(row)}/>
|
||||
<Info selectedRow={this.state.selectedRow}/>
|
||||
{this.state.user ? <Info selectedRow={this.state.selectedRow} user={this.state.user}/> : <NotLoggedIn/>}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
private handleSelectionChanged(row: number) {
|
||||
this.setState({selectedRow: row})
|
||||
this.setState({selectedRow: row, user: this.state.user})
|
||||
}
|
||||
}
|
||||
|
|
14
src/not-logged-in.tsx
Normal file
14
src/not-logged-in.tsx
Normal file
|
@ -0,0 +1,14 @@
|
|||
import * as React from 'react'
|
||||
|
||||
import {askUserToAuth} from './auth'
|
||||
|
||||
export default class NotLoggedIn extends React.Component<void, void> {
|
||||
public render() {
|
||||
return (
|
||||
<div>
|
||||
<div>You don't seem to be logged in.</div>
|
||||
<button onClick={() => askUserToAuth()}>Log In For Great Glory</button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue