import { unionize, ofType, UnionOf } from '~/common/unionize';
export const linkAccountPanelActions = unionize({
- LOAD_LINKING: ofType<AccountToLink>()
+ LOAD_LINKING: ofType<AccountToLink>(),
+ REMOVE_LINKING: {}
});
export type LinkAccountPanelAction = UnionOf<typeof linkAccountPanelActions>;
export const getAccountLinkData = () =>
(dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
return services.linkAccountService.getLinkAccount();
+ };
+
+export const removeAccountLinkData = () =>
+ (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ services.linkAccountService.removeLinkAccount();
+ dispatch(linkAccountPanelActions.REMOVE_LINKING());
};
\ No newline at end of file
linkAccountPanelActions.match(action, {
default: () => state,
LOAD_LINKING: (accountToLink) => ({ ...state, accountToLink }),
+ REMOVE_LINKING: () => ({...state, accountToLink: undefined})
});
\ No newline at end of file
import { authActions, getUserDetails, saveApiToken } from "~/store/auth/auth-action";
import { getUrlParameter } from "~/common/url";
import { AuthService } from "~/services/auth-service/auth-service";
-import { navigateToRootProject } from "~/store/navigation/navigation-action";
+import { navigateToRootProject, navigateToLinkAccount } from "~/store/navigation/navigation-action";
import { User } from "~/models/user";
import { Config } from "~/common/config";
import { initSessions } from "~/store/auth/auth-action-session";
+import { getAccountLinkData } from "~/store/link-account-panel/link-account-panel-actions";
interface ApiTokenProps {
authService: AuthService;
this.props.dispatch<any>(getUserDetails()).then((user: User) => {
this.props.dispatch(initSessions(this.props.authService, this.props.config, user));
}).finally(() => {
- this.props.dispatch(navigateToRootProject);
+ if (this.props.dispatch(getAccountLinkData())) {
+ this.props.dispatch(navigateToLinkAccount);
+ }
+ else {
+ this.props.dispatch(navigateToRootProject);
+ }
});
}
render() {
export interface LinkAccountPanelRootActionProps {
saveAccountLinkData: (type: LinkAccountType) => void;
+ removeAccountLinkData: () => void;
}
type LinkAccountPanelRootProps = LinkAccountPanelRootDataProps & LinkAccountPanelRootActionProps & WithStyles<CssRules>;
export const LinkAccountPanelRoot = withStyles(styles) (
- ({classes, user, saveAccountLinkData}: LinkAccountPanelRootProps) => {
+ ({classes, user, accountToLink, saveAccountLinkData, removeAccountLinkData}: LinkAccountPanelRootProps) => {
return <Card className={classes.root}>
<CardContent>
- <Grid container spacing={24}>
- { user && <Grid container item direction="column" spacing={24}>
- <Grid item>
- You are currently logged in as <b>{user.email}</b> ({user.username}, {user.uuid}) created on <b>{formatDate(user.createdAt)}</b>
+ { user && accountToLink===undefined && <Grid container spacing={24}>
+ <Grid container item direction="column" spacing={24}>
+ <Grid item>
+ You are currently logged in as <b>{user.email}</b> ({user.username}, {user.uuid}) created on <b>{formatDate(user.createdAt)}</b>
+ </Grid>
+ <Grid item>
+ You can link Arvados accounts. After linking, either login will take you to the same account.
+ </Grid>
</Grid>
- <Grid item>
- You can link Arvados accounts. After linking, either login will take you to the same account.
+ <Grid container item direction="row" spacing={24}>
+ <Grid item>
+ <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" onClick={() => saveAccountLinkData(LinkAccountType.ACCESS_OTHER_ACCOUNT)}>
+ Use this login to access another account
+ </Button>
+ </Grid>
</Grid>
- </Grid> }
- <Grid container item direction="row" spacing={24}>
- <Grid item>
- <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" onClick={() => saveAccountLinkData(LinkAccountType.ACCESS_OTHER_ACCOUNT)}>
- Use this login to access another account
- </Button>
+ </Grid>}
+ { accountToLink && <Grid container spacing={24}>
+ <Grid container item direction="row" spacing={24}>
+ <Grid item>
+ <Button variant="contained" onClick={() => removeAccountLinkData()}>
+ Cancel
+ </Button>
+ </Grid>
+ <Grid item>
+ <Button color="primary" variant="contained" onClick={() => {}}>
+ Link accounts
+ </Button>
+ </Grid>
</Grid>
- </Grid>
- </Grid>
+ </Grid> }
</CardContent>
</Card>;
});
\ No newline at end of file
import { RootState } from '~/store/store';
import { Dispatch } from 'redux';
import { connect } from 'react-redux';
-import { saveAccountLinkData } from '~/store/link-account-panel/link-account-panel-actions';
+import { saveAccountLinkData, removeAccountLinkData } from '~/store/link-account-panel/link-account-panel-actions';
import { LinkAccountType } from '~/models/link-account';
import {
LinkAccountPanelRoot,
};
const mapDispatchToProps = (dispatch: Dispatch): LinkAccountPanelRootActionProps => ({
- saveAccountLinkData: (type: LinkAccountType) => dispatch<any>(saveAccountLinkData(type))
+ saveAccountLinkData: (type: LinkAccountType) => dispatch<any>(saveAccountLinkData(type)),
+ removeAccountLinkData: () => dispatch<any>(removeAccountLinkData())
});
export const LinkAccountPanel = connect(mapStateToProps, mapDispatchToProps)(LinkAccountPanelRoot);