@@ -5,10 +5,15 @@ import fetchProjectParents from 'fetch-project-parents'; | |||||
class WBProjectCrumbs extends Component { | class WBProjectCrumbs extends Component { | ||||
constructor(...args) { | constructor(...args) { | ||||
super(...args); | super(...args); | ||||
this.state.items = []; | |||||
this.state.items = [ { 'name': 'All Projects' } ]; | |||||
} | } | ||||
fetchCrumbs() { | fetchCrumbs() { | ||||
if (!this.props.uuid) { | |||||
this.setState({ 'items': [ { 'name': 'All Projects' } ] }); | |||||
return; | |||||
} | |||||
let { arvHost, arvToken } = this.props.appState; | let { arvHost, arvToken } = this.props.appState; | ||||
let prom = fetchProjectParents(arvHost, arvToken, this.props.uuid); | let prom = fetchProjectParents(arvHost, arvToken, this.props.uuid); | ||||
prom = prom.then(parents => this.setState({ 'items': parents })); | prom = prom.then(parents => this.setState({ 'items': parents })); | ||||
@@ -9,12 +9,14 @@ class WBApp extends Component { | |||||
super(...args); | super(...args); | ||||
this.state.arvHost = window.localStorage['arvHost']; | this.state.arvHost = window.localStorage['arvHost']; | ||||
this.state.arvToken = window.localStorage['arvToken']; | this.state.arvToken = window.localStorage['arvToken']; | ||||
this.state.currentUser = JSON.parse(window.localStorage['currentUser']); | |||||
this.appCallbacks = { | this.appCallbacks = { | ||||
'navbarItemClicked': this.navbarItemClicked | |||||
'navbarItemClicked': item => this.navbarItemClicked(item) | |||||
}; | }; | ||||
this.appState = { | this.appState = { | ||||
'arvHost': this.state.arvHost, | 'arvHost': this.state.arvHost, | ||||
'arvToken': this.state.arvToken | |||||
'arvToken': this.state.arvToken, | |||||
'currentUser': this.state.currentUser | |||||
}; | }; | ||||
} | } | ||||
@@ -24,6 +26,13 @@ class WBApp extends Component { | |||||
delete window.localStorage['arvToken']; | delete window.localStorage['arvToken']; | ||||
delete window.localStorage['currentUser']; | delete window.localStorage['currentUser']; | ||||
route('/sign-in'); | route('/sign-in'); | ||||
} else if (item['id'] === 'home') { | |||||
route('/browse/' + this.appState.currentUser.uuid); | |||||
} else if (item['id'] === 'all-projects') { | |||||
route('/browse'); | |||||
} | } | ||||
} | } | ||||
@@ -32,7 +41,7 @@ class WBApp extends Component { | |||||
<Router> | <Router> | ||||
<WBLandingPage path="/" /> | <WBLandingPage path="/" /> | ||||
<WBSignIn path="/sign-in" /> | |||||
<WBSignIn path="/sign-in" appState={ this.appState } /> | |||||
<WBBrowse path="/browse/:ownerUuid?/:activePage?" | <WBBrowse path="/browse/:ownerUuid?/:activePage?" | ||||
appCallbacks={ this.appCallbacks } | appCallbacks={ this.appCallbacks } | ||||
@@ -10,7 +10,8 @@ class WBBrowse extends Component { | |||||
return ( | return ( | ||||
<div> | <div> | ||||
<WBNavbar items={ [ | <WBNavbar items={ [ | ||||
{ 'name': 'Browse', 'active': true }, | |||||
{ 'name': 'Home', 'id': 'home', 'active': (ownerUuid === appState.currentUser.uuid) }, | |||||
{ 'name': 'All Projects', 'id': 'all-projects', 'active': (!ownerUuid) }, | |||||
{ 'name': 'User', 'dropdown': [ { 'id': 'sign-out', 'name': 'Sign Out' } ]} | { 'name': 'User', 'dropdown': [ { 'id': 'sign-out', 'name': 'Sign Out' } ]} | ||||
] } rhs={ ( | ] } rhs={ ( | ||||
<WBInlineSearch /> | <WBInlineSearch /> | ||||
@@ -6,12 +6,16 @@ import makeArvadosRequest from 'make-arvados-request'; | |||||
class WBSignIn extends Component { | class WBSignIn extends Component { | ||||
onSubmit() { | onSubmit() { | ||||
let { appState } = this.props; | |||||
let { arvHost, arvToken } = this.state; | let { arvHost, arvToken } = this.state; | ||||
window.localStorage['arvHost'] = arvHost; | |||||
window.localStorage['arvToken'] = arvToken; | |||||
let prom = makeArvadosRequest(arvHost, arvToken, '/arvados/v1/users/current'); | let prom = makeArvadosRequest(arvHost, arvToken, '/arvados/v1/users/current'); | ||||
prom = prom.then(xhr => { | prom = prom.then(xhr => { | ||||
window.localStorage['arvHost'] = arvHost; | |||||
window.localStorage['arvToken'] = arvToken; | |||||
window.localStorage['currentUser'] = JSON.stringify(xhr.response); | window.localStorage['currentUser'] = JSON.stringify(xhr.response); | ||||
appState.arvHost = arvHost; | |||||
appState.arvToken = arvToken; | |||||
appState.currentUser = xhr.response; | |||||
route('/browse/' + xhr.response['uuid']); | route('/browse/' + xhr.response['uuid']); | ||||
}); | }); | ||||
prom = prom.catch(() => { | prom = prom.catch(() => { | ||||