From a9ae91c0c134e69b9484599f71ed954905a4bb3c Mon Sep 17 00:00:00 2001 From: malexsan <alexandru.munt@gmail.com> Date: Fri, 14 Dec 2018 15:54:39 +0200 Subject: [PATCH] fix(component-user): changes after code review --- .../app/components/AdminUserForm.js | 48 ++++++++++--------- .../component-user/app/pages/AdminUsers.js | 7 +-- packages/component-user/package.json | 15 ++---- .../server/notifications/notification.js | 2 +- 4 files changed, 33 insertions(+), 39 deletions(-) diff --git a/packages/component-user/app/components/AdminUserForm.js b/packages/component-user/app/components/AdminUserForm.js index 272798dba..50a314f42 100644 --- a/packages/component-user/app/components/AdminUserForm.js +++ b/packages/component-user/app/components/AdminUserForm.js @@ -26,6 +26,31 @@ import { withCountries, } from 'pubsweet-component-faraday-ui' +// #region helpers +const setInitialRole = a => { + if (get(a, 'admin', false)) { + return 'admin' + } + if (get(a, 'handlingEditor', false)) { + return 'handlingEditor' + } + if (get(a, 'editorInChief', false)) { + return 'editorInChief' + } + return 'author' +} + +const validate = values => { + const errors = {} + + if (get(values, 'email', '') === '') { + errors.email = 'Required' + } + + return errors +} +// #endregion + const FormModal = ({ edit, roles, @@ -53,15 +78,7 @@ const FormModal = ({ <Formik initialValues={initialValues} onSubmit={onSubmit} - validate={values => { - const errors = {} - - if (get(values, 'email', '') === '') { - errors.email = 'Required' - } - - return errors - }} + validate={validate} > {({ handleSubmit, ...rest }) => ( <Fragment> @@ -152,19 +169,6 @@ const FormModal = ({ </Root> ) -const setInitialRole = a => { - if (get(a, 'admin', false)) { - return 'admin' - } - if (get(a, 'handlingEditor', false)) { - return 'handlingEditor' - } - if (get(a, 'editorInChief', false)) { - return 'editorInChief' - } - return 'author' -} - export default compose( withRoles, withFetching, diff --git a/packages/component-user/app/pages/AdminUsers.js b/packages/component-user/app/pages/AdminUsers.js index 8249f2d45..25e7b6e07 100644 --- a/packages/component-user/app/pages/AdminUsers.js +++ b/packages/component-user/app/pages/AdminUsers.js @@ -44,9 +44,9 @@ const Users = ({ <ActionLink data-test-id="go-to-dashboard" fontIcon="arrowLeft" - paddingBottom={1.2} mr={2} onClick={history.goBack} + paddingBottom={1.2} > Admin Dashboard </ActionLink> @@ -258,8 +258,3 @@ const UserRow = styled.tr` } } ` -// #endregion - -// withHandlers({ - -// }), diff --git a/packages/component-user/package.json b/packages/component-user/package.json index 63cc0e68a..fe634328d 100644 --- a/packages/component-user/package.json +++ b/packages/component-user/package.json @@ -4,13 +4,12 @@ "description": "User component for Hindawi peer review app.", "license": "MIT", "author": "Collaborative Knowledge Foundation", - "files": [ - "src" - ], + "files": ["src"], "main": "index.js", "scripts": { "test": "jest", - "docs": "./node_modules/.bin/apidoc -e \"(node_modules|public)\" -o public/apidoc", + "docs": + "./node_modules/.bin/apidoc -e \"(node_modules|public)\" -o public/apidoc", "open-docs": "open public/apidoc/index.html" }, "repository": { @@ -26,6 +25,8 @@ "graphql-tag": "^2.10.0", "lodash": "^4.17.11", "pubsweet-client": "^7.0.0", + "pubsweet-server": "^10.0.0", + "pubsweet-component-helper-service": "0.0.1", "react": "^16.6.0", "react-apollo": "^2.3.2", "react-dom": "^16.6.0", @@ -35,12 +36,6 @@ "styled-components": "^4.1.2", "xpub-validators": "^0.0.6" }, - "peerDependencies": { - "@pubsweet/component-send-email": "0.2.4", - "@pubsweet/logger": "^0.0.1", - "pubsweet-component-helper-service": "0.0.1", - "pubsweet-server": "^10.0.0" - }, "devDependencies": { "apidoc": "^0.17.6", "jest": "^23.6.0", diff --git a/packages/component-user/server/notifications/notification.js b/packages/component-user/server/notifications/notification.js index ddf2aeaa3..c32282a6e 100644 --- a/packages/component-user/server/notifications/notification.js +++ b/packages/component-user/server/notifications/notification.js @@ -15,7 +15,7 @@ class Notification { async notifyUserAddedByAdmin(role) { const resetPath = config.get('invite-reset-password.url') const { user } = this - const baseUrl = config.get('hostname') + const baseUrl = config.get('pubsweet-client.baseUrl') const emailType = role === 'Handling Editor' ? 'he-added-by-admin' : 'user-added-by-admin' -- GitLab