14720: "My account" page now explicitly when user is federated
authorPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 22 Feb 2019 19:59:50 +0000 (14:59 -0500)
committerPeter Amstutz <pamstutz@veritasgenetics.com>
Fri, 22 Feb 2019 20:03:41 +0000 (15:03 -0500)
Arvados-DCO-1.1-Signed-off-by: Peter Amstutz <pamstutz@veritasgenetics.com>

src/store/auth/auth-reducer.ts
src/views/my-account-panel/my-account-panel-root.tsx
src/views/my-account-panel/my-account-panel.tsx

index e7087b58a8c69984f607effae376c44270ab1394..0335752678c56421336751dfd79eaef11316db94 100644 (file)
@@ -37,7 +37,7 @@ export const authReducer = (services: ServiceRepository) => (state = initialStat
             return {
                 ...state,
                 localCluster: config.uuidPrefix,
-                remoteHosts: config.remoteHosts,
+                remoteHosts: { ...config.remoteHosts, [config.uuidPrefix]: new URL(config.rootUrl).host },
                 homeCluster: config.uuidPrefix
             };
         },
index e728c4ebd552e146efbcf072cb870c26da782045..e84b3b6484d8ba46f57e31c5e3ddc5222b164489 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import * as React from 'react';
-import { Field, InjectedFormProps } from "redux-form";
+import { Field, InjectedFormProps, WrappedFieldProps } from "redux-form";
 import { TextField } from "~/components/text-field/text-field";
 import { NativeSelectField } from "~/components/select-field/select-field";
 import {
@@ -51,6 +51,7 @@ export interface MyAccountPanelRootDataProps {
     isPristine: boolean;
     isValid: boolean;
     initialValues?: User;
+    localCluster: string;
 }
 
 const RoleTypes = [
@@ -65,21 +66,20 @@ const RoleTypes = [
 
 type MyAccountPanelRootProps = InjectedFormProps<MyAccountPanelRootActionProps> & MyAccountPanelRootDataProps & WithStyles<CssRules>;
 
+type LocalClusterProp = { localCluster: string };
+const renderField: React.ComponentType<WrappedFieldProps & LocalClusterProp> = ({ input, localCluster }) => (
+    <span>{localCluster === input.value.substr(0, 5) ? "" : "federated"} user {input.value}</span>
+);
+
 export const MyAccountPanelRoot = withStyles(styles)(
-    ({ classes, isValid, handleSubmit, reset, isPristine, invalid, submitting }: MyAccountPanelRootProps) => {
+    ({ classes, isValid, handleSubmit, reset, isPristine, invalid, submitting, localCluster }: MyAccountPanelRootProps) => {
         return <Card className={classes.root}>
             <CardContent>
+                <Typography variant="title" className={classes.title}>
+                    Logged in as <Field name="uuid" component={renderField} localCluster={localCluster} />
+                </Typography>
                 <form onSubmit={handleSubmit}>
                     <Grid container spacing={24}>
-                        <Grid item xs={6} />
-                        <Grid item className={classes.gridItem} sm={6} xs={12}>
-                            <Field
-                                label="UUID"
-                                name="uuid"
-                                component={TextField}
-                                disabled
-                            />
-                        </Grid>
                         <Grid item className={classes.gridItem} sm={6} xs={12}>
                             <Field
                                 label="First name"
@@ -154,7 +154,7 @@ export const MyAccountPanelRoot = withStyles(styles)(
                                 type="submit"
                                 disabled={isPristine || invalid || submitting}>
                                 Save changes
-                        </Button>
+                            </Button>
                         </Grid>
                     </Grid>
                 </form >
index 5c2c5317dddf7104a29d4b950f835cc4a36e06f7..bd1f58745724b9dbd0a87eb083d31c0dd48fe135 100644 (file)
@@ -13,14 +13,15 @@ import { MY_ACCOUNT_FORM } from "~/store/my-account/my-account-panel-actions";
 const mapStateToProps = (state: RootState): MyAccountPanelRootDataProps => ({
     isPristine: isPristine(MY_ACCOUNT_FORM)(state),
     isValid: isValid(MY_ACCOUNT_FORM)(state),
-    initialValues: state.auth.user
+    initialValues: state.auth.user,
+    localCluster: state.auth.localCluster
 });
 
 export const MyAccountPanel = compose(
     connect(mapStateToProps),
     reduxForm({
-    form: MY_ACCOUNT_FORM,
-    onSubmit: (data, dispatch) => {
-        dispatch(saveEditedUser(data));
-    }
-}))(MyAccountPanelRoot);
\ No newline at end of file
+        form: MY_ACCOUNT_FORM,
+        onSubmit: (data, dispatch) => {
+            dispatch(saveEditedUser(data));
+        }
+    }))(MyAccountPanelRoot);