|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- 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 WBCollectionView from 'wb-collection-view';
- import WBCollectionBrowse from 'wb-collection-browse';
- 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 (
- <Router>
- <WBLandingPage path="/" />
-
- <WBSignIn path="/sign-in" appState={ this.appState } />
-
- <WBBrowse path="/browse/:ownerUuid?/:activePage?/:objTypeTab?/:collectionPage?/:processPage?/:workflowPage?"
- appCallbacks={ this.appCallbacks }
- appState={ this.appState }
- app={ this } />
-
- <WBProcessView path="/process/:uuid" app={ this } />
-
- <WBCollectionView path="/collection/:uuid" app={ this } />
-
- <WBCollectionBrowse path='/collection-browse/:uuid' app={ this } />
- </Router>
- );
- }
- }
-
- export default WBApp;
|