Update bindDataExplorerActions to use middleware service
[arvados.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 import { MuiThemeProvider } from '@material-ui/core/styles';
19 import { CustomTheme } from './common/custom-theme';
20 import { fetchConfig } from './common/config';
21 import { setBaseUrl } from './common/api/server-api';
22 import { addMenuActionSet, ContextMenuKind } from "./views-components/context-menu/context-menu";
23 import { rootProjectActionSet } from "./views-components/context-menu/action-sets/root-project-action-set";
24 import { projectActionSet } from "./views-components/context-menu/action-sets/project-action-set";
25 import { resourceActionSet } from './views-components/context-menu/action-sets/resource-action-set';
26 import { favoriteActionSet } from "./views-components/context-menu/action-sets/favorite-action-set";
27
28 addMenuActionSet(ContextMenuKind.ROOT_PROJECT, rootProjectActionSet);
29 addMenuActionSet(ContextMenuKind.PROJECT, projectActionSet);
30 addMenuActionSet(ContextMenuKind.RESOURCE, resourceActionSet);
31 addMenuActionSet(ContextMenuKind.FAVORITE, favoriteActionSet);
32
33 fetchConfig()
34     .then(config => {
35
36         setBaseUrl(config.API_HOST);
37
38         const history = createBrowserHistory();
39         const store = configureStore(history);
40
41         store.dispatch(authActions.INIT());
42         store.dispatch<any>(getProjectList(authService.getUuid()));
43
44         const App = () =>
45             <MuiThemeProvider theme={CustomTheme}>
46                 <Provider store={store}>
47                     <ConnectedRouter history={history}>
48                         <div>
49                             <Route path="/" component={Workbench} />
50                             <Route path="/token" component={ApiToken} />
51                         </div>
52                     </ConnectedRouter>
53                 </Provider>
54             </MuiThemeProvider>;
55
56         ReactDOM.render(
57             <App />,
58             document.getElementById('root') as HTMLElement
59         );
60     });
61
62