My Account adjustments
authorPawel Kromplewski <pawel.kromplewski@contractors.roche.com>
Thu, 6 Dec 2018 13:07:30 +0000 (14:07 +0100)
committerPawel Kromplewski <pawel.kromplewski@contractors.roche.com>
Thu, 6 Dec 2018 13:07:30 +0000 (14:07 +0100)
Feature #14452

Arvados-DCO-1.1-Signed-off-by: Pawel Kromplewski <pawel.kromplewski@contractors.roche.com>

src/models/user.ts
src/services/auth-service/auth-service.ts
src/store/my-account/my-account-panel-actions.ts
src/store/workbench/workbench-actions.ts
src/validators/validators.tsx
src/views/my-account-panel/my-account-panel-root.tsx
src/views/my-account-panel/my-account-panel.tsx

index dfb418892ef363192b73c5e8f6983c887910603b..60d598d57bd637c0728476f6b6b5f18a77909270 100644 (file)
@@ -4,7 +4,7 @@
 
 import { Resource, ResourceKind } from '~/models/resource';
 
-export type userPrefs = {
+export type UserPrefs = {
     profile?: {
         organization?: string,
         organization_email?: string,
@@ -21,7 +21,7 @@ export interface User {
     uuid: string;
     ownerUuid: string;
     identityUrl: string;
-    prefs: userPrefs;
+    prefs: UserPrefs;
     isAdmin: boolean;
 }
 
index 8c2ad5caf3065c7d1779c8eae13b01b934b95581..22c9dcd6ae3e36e495f25a9e152f9a489506efdc 100644 (file)
@@ -2,7 +2,7 @@
 //
 // SPDX-License-Identifier: AGPL-3.0
 
-import { User, userPrefs } from "~/models/user";
+import { User, UserPrefs } from "~/models/user";
 import { AxiosInstance } from "axios";
 import { ApiActions } from "~/services/api/api-actions";
 import * as uuid from "uuid/v4";
@@ -25,7 +25,7 @@ export interface UserDetailsResponse {
     owner_uuid: string;
     is_admin: boolean;
     identity_url: string;
-    prefs: userPrefs;
+    prefs: UserPrefs;
 }
 
 export class AuthService {
@@ -114,7 +114,6 @@ export class AuthService {
             .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,
index 93c6a3c5ecaa4876e93f6a345d94d8095b54f3b7..34bb2693dbb7b55796767cce66efdd93a5b93403 100644 (file)
@@ -8,16 +8,13 @@ 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 } from "~/store/snackbar/snackbar-actions";
-import { MY_ACCOUNT_FORM } from "~/views/my-account-panel/my-account-panel-root";
+import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
+
+export const MY_ACCOUNT_FORM = 'myAccountForm';
 
 export const loadMyAccountPanel = () =>
-    async (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
-        try {
-            dispatch(setBreadcrumbs([{ label: 'User profile'}]));
-        } catch (e) {
-            return;
-        }
+    (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        dispatch(setBreadcrumbs([{ label: 'User profile'}]));
     };
 
 export const saveEditedUser = (resource: any) =>
@@ -27,7 +24,7 @@ export const saveEditedUser = (resource: any) =>
             services.authService.saveUser(resource);
             dispatch(authActions.USER_DETAILS_SUCCESS(resource));
             dispatch(initialize(MY_ACCOUNT_FORM, resource));
-            dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Profile has been updated." }));
+            dispatch(snackbarActions.OPEN_SNACKBAR({ message: "Profile has been updated.", hideDuration: 2000, kind: SnackbarKind.SUCCESS }));
         } catch(e) {
             return;
         }
index 9d0140f33ca8eb736cea4d798d970b7b2c7181b8..49c50f288982c2140243948b2ccc17dcda46aa3b 100644 (file)
@@ -414,8 +414,8 @@ export const loadSshKeys = handleFirstTimeLoad(
     });
 
 export const loadMyAccount = handleFirstTimeLoad(
-    async (dispatch: Dispatch<any>) => {
-        await dispatch(loadMyAccountPanel());
+    (dispatch: Dispatch<any>) => {
+        dispatch(loadMyAccountPanel());
     });
 
 export const loadKeepServices = handleFirstTimeLoad(
index c601df17416d8711be048d51144684703fa4fe8c..a3f5df2e22d24df4f0c5eb7892298994451432c4 100644 (file)
@@ -26,3 +26,5 @@ export const REPOSITORY_NAME_VALIDATION = [require, maxLength(255)];
 
 export const SSH_KEY_PUBLIC_VALIDATION = [require, isRsaKey, maxLength(1024)];
 export const SSH_KEY_NAME_VALIDATION = [require, maxLength(255)];
+
+export const MY_ACCOUNT_VALIDATION = [require];
index 994a7819adaad8bd0ff14f95abd0e296bcf33c54..c92c48df29bb25322f1f831e9bcdcdfbedbc2493 100644 (file)
@@ -19,7 +19,7 @@ import {
 } from '@material-ui/core';
 import { ArvadosTheme } from '~/common/custom-theme';
 import { User } from "~/models/user";
-import { require } from "~/validators/require";
+import { MY_ACCOUNT_VALIDATION} from "~/validators/validators";
 
 type CssRules = 'root' | 'gridItem' | 'label' | 'title' | 'actions';
 
@@ -53,9 +53,15 @@ export interface MyAccountPanelRootDataProps {
     initialValues?: User;
 }
 
-export const MY_ACCOUNT_FORM = 'myAccountForm';
-
-const FILES_FIELD_VALIDATION = [require];
+const RoleTypes = [
+    {key: 'Bio-informatician', value: 'Bio-informatician'},
+    {key: 'Data Scientist', value: 'Data Scientist'},
+    {key: 'Analyst', value: 'Analyst'},
+    {key: 'Researcher', value: 'Researcher'},
+    {key: 'Software Developer', value: 'Software Developer'},
+    {key: 'System Administrator', value: 'System Administrator'},
+    {key: 'Other', value: 'Other'}
+];
 
 type MyAccountPanelRootProps = InjectedFormProps<MyAccountPanelRootActionProps> & MyAccountPanelRootDataProps & WithStyles<CssRules>;
 
@@ -96,7 +102,7 @@ export const MyAccountPanelRoot = withStyles(styles)(
                                     label="*Organization"
                                     name="prefs.profile.organization"
                                     component={TextField}
-                                    validate={FILES_FIELD_VALIDATION}
+                                    validate={MY_ACCOUNT_VALIDATION}
                                 />
                             </Grid>
                             <Grid item className={classes.gridItem}>
@@ -112,15 +118,7 @@ export const MyAccountPanelRoot = withStyles(styles)(
                                     id="prefs.profile.role"
                                     name="prefs.profile.role"
                                     component={NativeSelectField}
-                                    items={[
-                                        {key: 'Bio-informatician', value: 'Bio-informatician'},
-                                        {key: 'Data Scientist', value: 'Data Scientist'},
-                                        {key: 'Analyst', value: 'Analyst'},
-                                        {key: 'Researcher', value: 'Researcher'},
-                                        {key: 'Software Developer', value: 'Software Developer'},
-                                        {key: 'System Administrator', value: 'System Administrator'},
-                                        {key: 'Other', value: 'Other'}
-                                    ]}
+                                    items={RoleTypes}
                                 />
                             </Grid>
                         </Grid>
@@ -140,13 +138,19 @@ export const MyAccountPanelRoot = withStyles(styles)(
                                     label="*E-mail at Organization"
                                     name="prefs.profile.organization_email"
                                     component={TextField}
-                                    validate={FILES_FIELD_VALIDATION}
+                                    validate={MY_ACCOUNT_VALIDATION}
                                 />
                             </Grid>
                         </Grid>
                         <Grid item xs={12} className={classes.actions}>
                             <Button color="primary" onClick={reset} disabled={isPristine}>Discard changes</Button>
-                            <Button color="primary" variant="contained" type="submit" disabled={isPristine || invalid || submitting}>Save changes</Button>
+                            <Button
+                                color="primary"
+                                variant="contained"
+                                type="submit"
+                                disabled={isPristine || invalid || submitting}>
+                                    Save changes
+                            </Button>
                         </Grid>
                     </Grid>
                 </form>
index 03caa887a1466bac4402bcf1bd8f73167d420bee..5c2c5317dddf7104a29d4b950f835cc4a36e06f7 100644 (file)
@@ -7,7 +7,8 @@ import { compose } from 'redux';
 import { reduxForm, isPristine, isValid } from 'redux-form';
 import { connect } from 'react-redux';
 import { saveEditedUser } from '~/store/my-account/my-account-panel-actions';
-import { MyAccountPanelRoot, MyAccountPanelRootDataProps, MY_ACCOUNT_FORM } from '~/views/my-account-panel/my-account-panel-root';
+import { MyAccountPanelRoot, MyAccountPanelRootDataProps } from '~/views/my-account-panel/my-account-panel-root';
+import { MY_ACCOUNT_FORM } from "~/store/my-account/my-account-panel-actions";
 
 const mapStateToProps = (state: RootState): MyAccountPanelRootDataProps => ({
     isPristine: isPristine(MY_ACCOUNT_FORM)(state),