import { Resource, ResourceKind } from '~/models/resource';
-export type userPrefs = {
+export type UserPrefs = {
profile?: {
organization?: string,
organization_email?: string,
uuid: string;
ownerUuid: string;
identityUrl: string;
- prefs: userPrefs;
+ prefs: UserPrefs;
isAdmin: boolean;
}
//
// 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";
owner_uuid: string;
is_admin: boolean;
identity_url: string;
- prefs: userPrefs;
+ prefs: UserPrefs;
}
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,
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) =>
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;
}
});
export const loadMyAccount = handleFirstTimeLoad(
- async (dispatch: Dispatch<any>) => {
- await dispatch(loadMyAccountPanel());
+ (dispatch: Dispatch<any>) => {
+ dispatch(loadMyAccountPanel());
});
export const loadKeepServices = handleFirstTimeLoad(
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];
} 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';
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>;
label="*Organization"
name="prefs.profile.organization"
component={TextField}
- validate={FILES_FIELD_VALIDATION}
+ validate={MY_ACCOUNT_VALIDATION}
/>
</Grid>
<Grid item className={classes.gridItem}>
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>
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>
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),