--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+export enum LinkAccountType {
+ ADD_OTHER_LOGIN,
+ ACCESS_OTHER_ACCOUNT
+}
+
+export interface AccountToLink {
+ type: LinkAccountType;
+ userToken: string;
+}
import { Dispatch } from "redux";
import { RootState } from "~/store/store";
-import { initialize } from "redux-form";
import { ServiceRepository } from "~/services/services";
import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
-import { authActions } from "~/store/auth/auth-action";
-import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
+import { LinkAccountType, AccountToLink } from "~/models/link-account";
+import { logout } from "~/store/auth/auth-action";
export const loadLinkAccountPanel = () =>
- (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ (dispatch: Dispatch<any>) => {
dispatch(setBreadcrumbs([{ label: 'Link account'}]));
};
+
+export const saveAccountLinkData = (t: LinkAccountType) =>
+ (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ const accountToLink = {type: t, userToken: services.authService.getApiToken()} as AccountToLink;
+ sessionStorage.setItem("accountToLink", JSON.stringify(accountToLink));
+ dispatch(logout());
+ };
\ No newline at end of file
import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
import { loadSshKeysPanel } from '~/store/auth/auth-action-ssh';
import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
-import { loadLinkAccountPanel } from '~/store/link-account/link-account-panel-actions';
+import { loadLinkAccountPanel } from '~/store/link-account-panel/link-account-panel-actions';
import { loadSiteManagerPanel } from '~/store/auth/auth-action-session';
import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
} from '@material-ui/core';
import { ArvadosTheme } from '~/common/custom-theme';
import { User } from "~/models/user";
+import { LinkAccountType } from "~/models/link-account";
import { formatDate }from "~/common/formatters";
type CssRules = 'root';// | 'gridItem' | 'label' | 'title' | 'actions';
user?: User;
}
-export interface LinkAccountPanelRootActionProps { }
+export interface LinkAccountPanelRootActionProps {
+ saveAccountLinkData: (type: LinkAccountType) => void;
+}
type LinkAccountPanelRootProps = LinkAccountPanelRootDataProps & LinkAccountPanelRootActionProps & WithStyles<CssRules>;
export const LinkAccountPanelRoot = withStyles(styles) (
- ({classes, user}: LinkAccountPanelRootProps) => {
+ ({classes, user, saveAccountLinkData}: LinkAccountPanelRootProps) => {
return <Card className={classes.root}>
<CardContent>
<Grid container spacing={24}>
</Grid> }
<Grid container item direction="row" spacing={24}>
<Grid item>
- <Button color="primary" variant="contained">Add another login to this account</Button>
+ <Button color="primary" variant="contained" onClick={() => saveAccountLinkData(LinkAccountType.ADD_OTHER_LOGIN)}>
+ Add another login to this account
+ </Button>
</Grid>
<Grid item>
- <Button color="primary" variant="contained">Use this login to access another account</Button>
+ <Button color="primary" variant="contained" onClick={() => saveAccountLinkData(LinkAccountType.ACCESS_OTHER_ACCOUNT)}>
+ Use this login to access another account
+ </Button>
</Grid>
</Grid>
</Grid>
import { RootState } from '~/store/store';
import { Dispatch } from 'redux';
-import { compose } from 'redux';
-import { reduxForm } from 'redux-form';
import { connect } from 'react-redux';
-import { getResource, ResourcesState } from '~/store/resources/resources';
-import { Resource } from '~/models/resource';
-import { User, UserResource } from '~/models/user';
+import { saveAccountLinkData } from '~/store/link-account-panel/link-account-panel-actions';
+import { LinkAccountType } from '~/models/link-account';
import {
LinkAccountPanelRoot,
LinkAccountPanelRootDataProps,
};
};
-const mapDispatchToProps = (dispatch: Dispatch): LinkAccountPanelRootActionProps => ({});
+const mapDispatchToProps = (dispatch: Dispatch): LinkAccountPanelRootActionProps => ({
+ saveAccountLinkData: (type: LinkAccountType) => dispatch<any>(saveAccountLinkData(type))
+});
export const LinkAccountPanel = connect(mapStateToProps, mapDispatchToProps)(LinkAccountPanelRoot);