import { h, Component } from 'preact'; import { Router, route } from 'preact-router'; import WBBrowse from 'wb-browse'; import WBSignIn from 'wb-sign-in'; import WBLandingPage from 'wb-landing-page'; import WBProcessView from 'wb-process-view'; import arvadosTypeName from 'arvados-type-name'; class WBApp extends Component { constructor(...args) { super(...args); this.state.arvHost = window.localStorage['arvHost']; this.state.arvToken = window.localStorage['arvToken']; if ('currentUser' in window.localStorage) this.state.currentUser = JSON.parse(window.localStorage['currentUser']); this.appCallbacks = { 'navbarItemClicked': item => this.navbarItemClicked(item) }; this.appState = { 'arvHost': this.state.arvHost, 'arvToken': this.state.arvToken, 'currentUser': this.state.currentUser }; } navbarItemClicked(item) { if (item['id'] === 'sign-out') { delete window.localStorage['arvHost']; delete window.localStorage['arvToken']; delete window.localStorage['currentUser']; route('/sign-in'); } else if (item['id'] === 'home') { route('/browse/' + this.appState.currentUser.uuid); } else if (item['id'] === 'all-projects') { route('/browse'); } } breadcrumbClicked(item) { let objectType = arvadosTypeName(item.uuid.split('-')[1]); if (objectType === 'user') route('/browse/' + item.uuid) else if (objectType === 'group' && item.group_class === 'project') route('/browse/' + item.uuid); else if (objectType === 'container_request') route('/process/' + item.uuid) } render() { return ( ); } } export default WBApp;