|                                            | 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 | import { h, Component } from 'preact';
import { Router, route } from 'preact-router';
import WBBrowse from 'wb-browse';
import WBSignIn from 'wb-sign-in';
import WBSignOut from 'wb-sign-out';
import WBLandingPage from 'wb-landing-page';
import WBProcessView from 'wb-process-view';
import WBContainerView from 'wb-container-view';
import WBCollectionView from 'wb-collection-view';
import WBCollectionBrowse from 'wb-collection-browse';
import WBUsersPage from 'wb-users-page';
import WBWorkflowView from 'wb-workflow-view';
import WBLaunchWorkflowPage from 'wb-launch-workflow-page';
import WBDownloadPage from 'wb-download-page';
import WBImageViewerPage from 'wb-image-viewer-page';
import WBSharingPage from 'wb-sharing-page';
import WBProjectView from 'wb-project-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.loadToolbox();
  }
  navbarItemUrl(item) {
    if (item['id'] === 'sign-out') {
      return ('/sign-out');
    } else if (item['id'] === 'home') {
      return ('/browse/' + this.state.currentUser.uuid);
    } else if (item['id'] === 'all-projects') {
      return ('/browse');
    } else if (item['id'] === 'all-users') {
      return ('/users');
    } else if (item['id'] === 'shared-with-me') {
      return ('/shared-with-me');
    }
  }
  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)
  }
  addToToolbox(uuid) {
    this.state.toolboxItems.push(uuid);
    window.localStorage['toolboxItems'] =
      JSON.stringify(this.state.toolboxItems);
  }
  clearToolbox() {
    this.state.toolboxItems = [];
    delete window.localStorage['toolboxItems'];
  }
  loadToolbox() {
    this.state.toolboxItems = ('toolboxItems' in window.localStorage) ?
      JSON.parse(window.localStorage['toolboxItems']) : [];
  }
  render() {
    return (
      <Router>
        <WBLandingPage path="/" />
        <WBSignIn path="/sign-in/:mode?" appState={ this.state } />
        <WBSignOut path='/sign-out' app={ this } />
        <WBBrowse path="/browse/:ownerUuid?/:activePage?/:objTypeTab?/:collectionPage?/:processPage?/:workflowPage?/:textSearch?"
          app={ this } mode="browse" />
        <WBBrowse path="/shared-with-me/:activePage?/:textSearch?"
          app={ this } mode="shared-with-me" />
        <WBProcessView path="/process/:uuid/:page?" app={ this } />
        <WBContainerView path="/container/:uuid" app={ this } />
        <WBCollectionView path="/collection/:uuid" app={ this } />
        <WBCollectionBrowse path='/collection-browse/:uuid/:collectionPath?/:page?' app={ this } />
        <WBUsersPage path='/users/:page?/:textSearch?' app={ this } />
        <WBWorkflowView path="/workflow/:uuid" app={ this } />
        <WBLaunchWorkflowPage path="/workflow-launch/:workflowUuid" app={ this } />
        <WBDownloadPage path="/download/:blocksBlobUrl/:inline?" app={ this } />
        <WBImageViewerPage path="/image-viewer/:blobUrl" app={ this } />
        <WBSharingPage path="/sharing/:uuid" app={ this } />
        <WBProjectView path="/project/:uuid" app={ this } />
      </Router>
    );
  }
}
export default WBApp;
 |