18559: Fix user profile form initialization & cleanup
authorStephen Smith <stephen@curii.com>
Wed, 2 Mar 2022 22:21:31 +0000 (17:21 -0500)
committerStephen Smith <stephen@curii.com>
Wed, 2 Mar 2022 22:21:31 +0000 (17:21 -0500)
Arvados-DCO-1.1-Signed-off-by: Stephen Smith <stephen@curii.com>

src/store/user-profile/user-profile-actions.ts
src/views/user-panel/user-panel.tsx
src/views/user-profile-panel/user-profile-panel-root.tsx

index 103456f3ea8dd766930dd53ac84845bf449e1d43..82e90a2bc46eec16f0387bdef534e4f856e14ede 100644 (file)
@@ -3,7 +3,7 @@
 // SPDX-License-Identifier: AGPL-3.0
 import { RootState } from "store/store";
 import { Dispatch } from 'redux';
-import { reset } from "redux-form";
+import { initialize, reset } from "redux-form";
 import { ServiceRepository } from "services/services";
 import { bindDataExplorerActions } from "store/data-explorer/data-explorer-action";
 import { propertiesActions } from 'store/properties/properties-actions';
@@ -25,9 +25,10 @@ export const loadUserProfilePanel = (userUuid?: string) =>
     // Get user uuid from route or use current user uuid
     const uuid = userUuid || getState().auth.user?.uuid;
     if (uuid) {
+      await dispatch(propertiesActions.SET_PROPERTY({ key: USER_PROFILE_PANEL_ID, value: uuid }));
       const user = await services.userService.get(uuid);
+      dispatch(initialize(USER_PROFILE_FORM, user));
       dispatch(updateResources([user]));
-      await dispatch(propertiesActions.SET_PROPERTY({ key: USER_PROFILE_PANEL_ID, value: uuid }));
       dispatch(UserProfileGroupsActions.REQUEST_ITEMS());
     }
   }
index be8ef6812cce0b38c040e44b458fc08b69c0eaa1..9f4d4ce4f692bde552e88bf7f44aaeb70e89efe3 100644 (file)
@@ -157,7 +157,7 @@ export const UserPanel = compose(
             render() {
                 const { value } = this.state;
                 return <Paper className={this.props.classes.root}>
-                    <Tabs value={value} onChange={this.handleChange} fullWidth>
+                    <Tabs value={value} onChange={this.handleChange} variant={"fullWidth"}>
                         <Tab label="USERS" />
                         <Tab label="ACTIVITY" disabled />
                     </Tabs>
index c0c80e3cdffc369f2166043d526fd0140c06997b..a725333d1b1712673a498be0597f77f4a9de6147 100644 (file)
@@ -89,11 +89,6 @@ const RoleTypes = [
 
 type UserProfilePanelRootProps = InjectedFormProps<{}> & UserProfilePanelRootActionProps & UserProfilePanelRootDataProps & WithStyles<CssRules>;
 
-// type LocalClusterProp = { localCluster: string };
-// const renderField: React.ComponentType<WrappedFieldProps & LocalClusterProp> = ({ input, localCluster }) => (
-//     <span>{localCluster === input.value.substring(0, 5) ? "" : "federated"} user {input.value}</span>
-// );
-
 export enum UserProfileGroupsColumnNames {
     NAME = "Name",
     PERMISSION = "Permission",
@@ -152,10 +147,7 @@ export const UserProfilePanelRoot = withStyles(styles)(
 
         render() {
             return <Paper className={this.props.classes.root}>
-                {/* <Typography variant="title" className={this.props.classes.title}>
-                    Logged in as <Field name="uuid" component={renderField} localCluster={this.props.localCluster} />
-                </Typography> */}
-                <Tabs value={this.state.value} onChange={this.handleChange} fullWidth>
+                <Tabs value={this.state.value} onChange={this.handleChange} variant={"fullWidth"}>
                     <Tab label="PROFILE" />
                     <Tab label="GROUPS" />
                     <Tab label="ADMIN" />
@@ -254,7 +246,6 @@ export const UserProfilePanelRoot = withStyles(styles)(
                                 id={USER_PROFILE_PANEL_ID}
                                 onRowClick={noop}
                                 onRowDoubleClick={noop}
-                                // onContextMenu={this.handleContextMenu}
                                 contextMenuColumn={false}
                                 hideColumnSelector
                                 hideSearchInput
@@ -352,17 +343,5 @@ export const UserProfilePanelRoot = withStyles(styles)(
             this.setState({ value });
         }
 
-        handleContextMenu = (event: React.MouseEvent<HTMLElement>, resourceUuid: string) => {
-            // const resource = getResource<UserResource>(resourceUuid)(this.props.resources);
-            // if (resource) {
-            //     this.props.onContextMenu(event, {
-            //         name: '',
-            //         uuid: resource.uuid,
-            //         ownerUuid: resource.ownerUuid,
-            //         kind: resource.kind,
-            //         menuKind: ContextMenuKind.USER
-            //     });
-            // }
-        }
     }
 );