Added central action for navigation
[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 authActions from "./store/auth/auth-action";
16 import { authService } from "./services/services";
17 import { getProjectList } from "./store/project/project-action";
18
19 const history = createBrowserHistory();
20
21 const store = configureStore({
22     projects: {
23         items: [],
24         currentItemId: ""
25     },
26     collections: [
27     ],
28     router: {
29         location: null
30     },
31     auth: {
32         user: undefined
33     }
34 }, history);
35
36 store.dispatch(authActions.INIT());
37 const rootUuid = authService.getRootUuid();
38 store.dispatch<any>(getProjectList(rootUuid));
39
40 const App = () =>
41     <Provider store={store}>
42         <ConnectedRouter history={history}>
43             <div>
44                 <Route path="/" component={Workbench}/>
45                 <Route path="/token" component={ApiToken}/>
46             </div>
47         </ConnectedRouter>
48     </Provider>;
49
50 ReactDOM.render(
51     <App/>,
52     document.getElementById('root') as HTMLElement
53 );