import { Resource, ResourceKind } from '~/models/resource';
+export type userPrefs = {
+ profile?: {
+ organization?: string,
+ organization_email?: string,
+ lab?: string,
+ website_url?: string,
+ role?: string
+ }
+};
+
export interface User {
email: string;
firstName: string;
lastName: string;
uuid: string;
ownerUuid: string;
+ identityUrl: string;
+ prefs: userPrefs;
isAdmin: boolean;
}
import { History, Location } from 'history';
import { RootStore } from '~/store/store';
+import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchMyAccountRoute } from './routes';
+import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories, loadMyAccount } from '~/store/workbench/workbench-actions';
import { matchProcessRoute, matchProcessLogRoute, matchProjectRoute, matchCollectionRoute, matchFavoritesRoute, matchTrashRoute, matchRootRoute, matchSharedWithMeRoute, matchRunProcessRoute, matchWorkflowRoute, matchSearchResultsRoute, matchSshKeysRoute, matchRepositoriesRoute, matchVirtualMachineRoute } from './routes';
import { loadProject, loadCollection, loadFavorites, loadTrash, loadProcess, loadProcessLog, loadSshKeys, loadRepositories, loadVirtualMachines } from '~/store/workbench/workbench-actions';
import { navigateToRootProject } from '~/store/navigation/navigation-action';
const virtualMachineMatch = matchVirtualMachineRoute(pathname);
const workflowMatch = matchWorkflowRoute(pathname);
const sshKeysMatch = matchSshKeysRoute(pathname);
+ const myAccountMatch = matchMyAccountRoute(pathname);
if (projectMatch) {
store.dispatch(loadProject(projectMatch.params.id));
store.dispatch(loadRepositories);
} else if (sshKeysMatch) {
store.dispatch(loadSshKeys);
+ } else if (myAccountMatch) {
+ store.dispatch(loadMyAccount);
}
};
VIRTUAL_MACHINES: '/virtual-machines',
WORKFLOWS: '/workflows',
SEARCH_RESULTS: '/search-results',
- SSH_KEYS: `/ssh-keys`
+ SSH_KEYS: `/ssh-keys`,
+ MY_ACCOUNT: '/my-account'
};
export const getResourceUrl = (uuid: string) => {
export const matchSshKeysRoute = (route: string) =>
matchPath(route, { path: Routes.SSH_KEYS });
+
+export const matchMyAccountRoute = (route: string) =>
+ matchPath(route, { path: Routes.MY_ACCOUNT });
//
// SPDX-License-Identifier: AGPL-3.0
-import { User } from "~/models/user";
+import { User, userPrefs } from "~/models/user";
import { AxiosInstance } from "axios";
import { ApiActions, ProgressFn } from "~/services/api/api-actions";
import * as uuid from "uuid/v4";
export const USER_UUID_KEY = 'userUuid';
export const USER_OWNER_UUID_KEY = 'userOwnerUuid';
export const USER_IS_ADMIN = 'isAdmin';
+export const USER_IDENTITY_URL = 'identityUrl';
+export const USER_PREFS = 'prefs';
export interface UserDetailsResponse {
email: string;
uuid: string;
owner_uuid: string;
is_admin: boolean;
+ identity_url: string;
+ prefs: userPrefs;
}
export class AuthService {
const uuid = this.getUuid();
const ownerUuid = this.getOwnerUuid();
const isAdmin = this.getIsAdmin();
+ const identityUrl = localStorage.getItem(USER_IDENTITY_URL);
+ const prefs = JSON.parse(localStorage.getItem(USER_PREFS) || '{"profile": {}}');
- return email && firstName && lastName && uuid && ownerUuid
- ? { email, firstName, lastName, uuid, ownerUuid, isAdmin }
+ return email && firstName && lastName && uuid && ownerUuid && identityUrl && prefs
+ ? { email, firstName, lastName, uuid, ownerUuid, isAdmin, identityUrl, prefs }
: undefined;
}
localStorage.setItem(USER_UUID_KEY, user.uuid);
localStorage.setItem(USER_OWNER_UUID_KEY, user.ownerUuid);
localStorage.setItem(USER_IS_ADMIN, JSON.stringify(user.isAdmin));
+ localStorage.setItem(USER_IDENTITY_URL, user.identityUrl);
+ localStorage.setItem(USER_PREFS, JSON.stringify(user.prefs));
}
public removeUser() {
localStorage.removeItem(USER_UUID_KEY);
localStorage.removeItem(USER_OWNER_UUID_KEY);
localStorage.removeItem(USER_IS_ADMIN);
+ localStorage.removeItem(USER_IDENTITY_URL);
+ localStorage.removeItem(USER_PREFS);
}
public login() {
.get<UserDetailsResponse>('/users/current')
.then(resp => {
this.actions.progressFn(reqId, false);
+ const prefs = resp.data.prefs.profile ? resp.data.prefs : { profile: {}};
+ console.log(resp.data);
return {
email: resp.data.email,
firstName: resp.data.first_name,
lastName: resp.data.last_name,
uuid: resp.data.uuid,
ownerUuid: resp.data.owner_uuid,
- isAdmin: resp.data.is_admin
+ isAdmin: resp.data.is_admin,
+ identityUrl: resp.data.identity_url,
+ prefs
};
})
.catch(e => {
}
};
-
export type AuthAction = UnionOf<typeof authActions>;
lastName: "Doe",
uuid: "uuid",
ownerUuid: "ownerUuid",
+ identityUrl: "identityUrl",
+ prefs: {},
isAdmin: false
};
const state = reducer(initialState, authActions.INIT({ user, token: "token" }));
lastName: "Doe",
uuid: "uuid",
ownerUuid: "ownerUuid",
+ identityUrl: "identityUrl",
+ prefs: {},
isAdmin: false
};
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { Dispatch } from "redux";
+import { RootState } from "~/store/store";
+import { ServiceRepository } from "~/services/services";
+import { setBreadcrumbs } from "~/store/breadcrumbs/breadcrumbs-actions";
+
+export const loadMyAccountPanel = () =>
+ async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+ try {
+ dispatch(setBreadcrumbs([{ label: 'User profile'}]));
+ } catch (e) {
+ return;
+ }
+ };
\ No newline at end of file
export const navigateToRepositories = push(Routes.REPOSITORIES);
export const navigateToSshKeys= push(Routes.SSH_KEYS);
+
+export const navigateToMyAccount = push(Routes.MY_ACCOUNT);
import { CopyFormDialogData } from '~/store/copy-dialog/copy-dialog';
import { loadWorkflowPanel, workflowPanelActions } from '~/store/workflow-panel/workflow-panel-actions';
import { loadSshKeysPanel } from '~/store/auth/auth-action';
+import { loadMyAccountPanel } from '~/store/my-account/my-account-panel-actions';
import { workflowPanelColumns } from '~/views/workflow-panel/workflow-panel-view';
import { progressIndicatorActions } from '~/store/progress-indicator/progress-indicator-actions';
import { getProgressIndicator } from '~/store/progress-indicator/progress-indicator-reducer';
await dispatch(loadSshKeysPanel());
});
+export const loadMyAccount = handleFirstTimeLoad(
+ async (dispatch: Dispatch<any>) => {
+ await dispatch(loadMyAccountPanel());
+ });
+
const finishLoadingProject = (project: GroupContentsResource | string) =>
async (dispatch: Dispatch<any>) => {
const uuid = typeof project === 'string' ? project : project.uuid;
import { RootState } from "~/store/store";
import { openCurrentTokenDialog } from '~/store/current-token-dialog/current-token-dialog-actions';
import { openRepositoriesPanel } from "~/store/repositories/repositories-actions";
-import { navigateToSshKeys } from '~/store/navigation/navigation-action';
+import { navigateToSshKeys, navigateToMyAccount } from '~/store/navigation/navigation-action';
import { openVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
interface AccountMenuProps {
<MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
<MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
<MenuItem onClick={() => dispatch(navigateToSshKeys)}>Ssh Keys</MenuItem>
- <MenuItem>My account</MenuItem>
+ <MenuItem onClick={() => dispatch(navigateToMyAccount)}>My account</MenuItem>
<MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
</DropdownMenu>
: null);
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from 'react';
+import { StyleRulesCallback, WithStyles, withStyles, Card, CardContent, TextField, Button, Typography, Grid, Table, TableHead, TableRow, TableCell, TableBody, Tooltip, IconButton } from '@material-ui/core';
+import { ArvadosTheme } from '~/common/custom-theme';
+import { User } from "~/models/user";
+
+type CssRules = 'root' | 'gridItem' | 'title';
+
+const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
+ root: {
+ width: '100%',
+ overflow: 'auto'
+ },
+ gridItem: {
+ minHeight: 45,
+ marginBottom: 20
+ },
+ title: {
+ marginBottom: theme.spacing.unit * 3,
+ color: theme.palette.grey["600"]
+ }
+});
+
+export interface MyAccountPanelRootActionProps {}
+
+export interface MyAccountPanelRootDataProps {
+ user?: User;
+}
+
+type MyAccountPanelRootProps = MyAccountPanelRootActionProps & MyAccountPanelRootDataProps & WithStyles<CssRules>;
+
+export const MyAccountPanelRoot = withStyles(styles)(
+ ({ classes, user }: MyAccountPanelRootProps) => {
+ console.log(user);
+ return <Card className={classes.root}>
+ <CardContent>
+ <Typography variant="title" className={classes.title}>User profile</Typography>
+ <Grid container direction="row" spacing={24}>
+ <Grid item xs={6}>
+ <Grid item className={classes.gridItem}>
+ <TextField
+ label="E-mail"
+ name="email"
+ fullWidth
+ value={user!.email}
+ disabled
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <TextField
+ label="First name"
+ name="firstName"
+ fullWidth
+ value={user!.firstName}
+ disabled
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <TextField
+ label="Identity URL"
+ name="identityUrl"
+ fullWidth
+ value={user!.identityUrl}
+ disabled
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <TextField
+ label="Organization"
+ name="organization"
+ value={user!.prefs.profile!.organization}
+ fullWidth
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <TextField
+ label="Website"
+ name="website"
+ value={user!.prefs.profile!.website_url}
+ fullWidth
+ />
+ </Grid>
+ <Grid item className={classes.gridItem}>
+ <TextField
+ label="Role"
+ name="role"
+ value={user!.prefs.profile!.role}
+ fullWidth
+ />
+ </Grid>
+ </Grid>
+ <Grid item xs={6}>
+ <Grid item className={classes.gridItem} />
+ <Grid item className={classes.gridItem}>
+ <TextField
+ label="Last name"
+ name="lastName"
+ fullWidth
+ value={user!.lastName}
+ disabled
+ />
+ </Grid>
+ <Grid item className={classes.gridItem} />
+ <Grid item className={classes.gridItem}>
+ <TextField
+ label="E-mail at Organization"
+ name="organizationEmail"
+ value={user!.prefs.profile!.organization_email}
+ fullWidth
+ />
+ </Grid>
+ </Grid>
+ </Grid>
+ </CardContent>
+ </Card>;}
+);
\ No newline at end of file
--- /dev/null
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import { RootState } from '~/store/store';
+import { Dispatch } from 'redux';
+import { connect } from 'react-redux';
+import { MyAccountPanelRoot, MyAccountPanelRootDataProps, MyAccountPanelRootActionProps } from '~/views/my-account-panel/my-account-panel-root';
+
+const mapStateToProps = (state: RootState): MyAccountPanelRootDataProps => ({
+ user: state.auth.user
+});
+
+const mapDispatchToProps = (dispatch: Dispatch): MyAccountPanelRootActionProps => ({
+
+});
+
+export const MyAccountPanel = connect(mapStateToProps, mapDispatchToProps)(MyAccountPanelRoot);
\ No newline at end of file
import { WorkflowPanel } from '~/views/workflow-panel/workflow-panel';
import { SearchResultsPanel } from '~/views/search-results-panel/search-results-panel';
import { SshKeyPanel } from '~/views/ssh-key-panel/ssh-key-panel';
+import { MyAccountPanel } from '~/views/my-account-panel/my-account-panel';
import { SharingDialog } from '~/views-components/sharing-dialog/sharing-dialog';
import { AdvancedTabDialog } from '~/views-components/advanced-tab-dialog/advanced-tab-dialog';
import { ProcessInputDialog } from '~/views-components/process-input-dialog/process-input-dialog';
<Route path={Routes.VIRTUAL_MACHINES} component={VirtualMachinePanel} />
<Route path={Routes.REPOSITORIES} component={RepositoriesPanel} />
<Route path={Routes.SSH_KEYS} component={SshKeyPanel} />
+ <Route path={Routes.MY_ACCOUNT} component={MyAccountPanel} />
</Switch>
</Grid>
</Grid>