Reuse ResourcePropertiesForm as ProjectPropertiesForm
[arvados.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 { RouteProps } from "react-router";
6 import * as React from "react";
7 import { connect, DispatchProp } from "react-redux";
8 import { getUserDetails, saveApiToken } from "~/store/auth/auth-action";
9 import { getUrlParameter } from "~/common/url";
10 import { AuthService } from "~/services/auth-service/auth-service";
11 import { navigateToRootProject } from "~/store/navigation/navigation-action";
12
13 interface ApiTokenProps {
14     authService: AuthService;
15 }
16
17 export const ApiToken = connect()(
18     class extends React.Component<ApiTokenProps & RouteProps & DispatchProp<any>, {}> {
19         componentDidMount() {
20             const search = this.props.location ? this.props.location.search : "";
21             const apiToken = getUrlParameter(search, 'api_token');
22             this.props.dispatch(saveApiToken(apiToken));
23             this.props.dispatch<any>(getUserDetails()).finally(() => {
24                 this.props.dispatch(navigateToRootProject);
25             });
26         }
27         render() {
28             return <div/>;
29         }
30     }
31 );