merge conflicts
[arvados-workbench2.git] / src / views-components / api-token / api-token.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { Redirect, RouteProps } from "react-router";
6 import * as React from "react";
7 import { connect, DispatchProp } from "react-redux";
8 import { authActions, getUserDetails } from "../../store/auth/auth-action";
9 import { authService } from "../../services/services";
10 import { getProjectList } from "../../store/project/project-action";
11 import { getUrlParameter } from "../../common/url";
12
13 interface ApiTokenProps {
14 }
15
16 export const ApiToken = connect()(
17     class extends React.Component<ApiTokenProps & RouteProps & DispatchProp<any>, {}> {
18         componentDidMount() {
19             const search = this.props.location ? this.props.location.search : "";
20             const apiToken = getUrlParameter(search, 'api_token');
21             this.props.dispatch(authActions.SAVE_API_TOKEN(apiToken));
22             this.props.dispatch<any>(getUserDetails()).then(() => {
23                 const rootUuid = authService.getRootUuid();
24                 this.props.dispatch(getProjectList(rootUuid));
25             });
26         }
27         render() {
28             return <Redirect to="/"/>;
29         }
30     }
31 );