paths changed
[arvados-workbench2.git] / src / index.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from 'react';
6 import * as ReactDOM from 'react-dom';
7 import { Provider } from "react-redux";
8 import { Workbench } from './views/workbench/workbench';
9 import './index.css';
10 import { Route } from "react-router";
11 import createBrowserHistory from "history/createBrowserHistory";
12 import { configureStore } from "./store/store";
13 import { ConnectedRouter } from "react-router-redux";
14 import { ApiToken } from "./views-components/api-token/api-token";
15 import { initAuth } from "./store/auth/auth-action";
16 import { createServices } from "./services/services";
17 import { getProjectList } from "./store/project/project-action";
18 import { MuiThemeProvider } from '@material-ui/core/styles';
19 import { CustomTheme } from './common/custom-theme';
20 import { fetchConfig } from './common/config';
21 import { addMenuActionSet, ContextMenuKind } from "./views-components/context-menu/context-menu";
22 import { rootProjectActionSet } from "./views-components/context-menu/action-sets/root-project-action-set";
23 import { projectActionSet } from "./views-components/context-menu/action-sets/project-action-set";
24 import { resourceActionSet } from './views-components/context-menu/action-sets/resource-action-set';
25 import { favoriteActionSet } from "./views-components/context-menu/action-sets/favorite-action-set";
26 import { collectionFilesActionSet } from './views-components/context-menu/action-sets/collection-files-action-set';
27 import { collectionFilesItemActionSet } from './views-components/context-menu/action-sets/collection-files-item-action-set';
28 import { collectionActionSet } from './views-components/context-menu/action-sets/collection-action-set';
29 import { collectionResourceActionSet } from './views-components/context-menu/action-sets/collection-resource-action-set';
30 import { initPickerProjectTree } from './store/tree-picker/tree-picker-actions';
31
32 addMenuActionSet(ContextMenuKind.ROOT_PROJECT, rootProjectActionSet);
33 addMenuActionSet(ContextMenuKind.PROJECT, projectActionSet);
34 addMenuActionSet(ContextMenuKind.RESOURCE, resourceActionSet);
35 addMenuActionSet(ContextMenuKind.FAVORITE, favoriteActionSet);
36 addMenuActionSet(ContextMenuKind.COLLECTION_FILES, collectionFilesActionSet);
37 addMenuActionSet(ContextMenuKind.COLLECTION_FILES_ITEM, collectionFilesItemActionSet);
38 addMenuActionSet(ContextMenuKind.COLLECTION, collectionActionSet);
39 addMenuActionSet(ContextMenuKind.COLLECTION_RESOURCE, collectionResourceActionSet);
40
41 fetchConfig()
42     .then(config => {
43         const history = createBrowserHistory();
44         const services = createServices(config);
45         const store = configureStore(history, services);
46
47         store.dispatch(initAuth());
48         store.dispatch(getProjectList(services.authService.getUuid()));
49         store.dispatch(initPickerProjectTree());
50         
51         const TokenComponent = (props: any) => <ApiToken authService={services.authService} {...props}/>;
52         const WorkbenchComponent = (props: any) => <Workbench authService={services.authService} {...props}/>;
53
54         const App = () =>
55             <MuiThemeProvider theme={CustomTheme}>
56                 <Provider store={store}>
57                     <ConnectedRouter history={history}>
58                         <div>
59                             <Route path="/" component={WorkbenchComponent} />
60                             <Route path="/token" component={TokenComponent} />
61                         </div>
62                     </ConnectedRouter>
63                 </Provider>
64             </MuiThemeProvider>;
65
66         ReactDOM.render(
67             <App />,
68             document.getElementById('root') as HTMLElement
69         );
70     });
71
72