From 289e867737e25255c2953497dcaa4faff18cf118 Mon Sep 17 00:00:00 2001 From: Victor Vlasenko Date: Mon, 10 Sep 2018 12:23:44 +0300 Subject: [PATCH] Fix Prop 't' is undefined in UserEdit component Fixes: #843 --- .../native/ui-antd-mobile/components/Select.jsx | 6 +++--- .../native/ui-antd-mobile/components/Switch.jsx | 5 ++--- .../containers/PaginationDemo.native.jsx | 2 +- .../src/modules/user/components/UserAddView.jsx | 4 ++-- .../modules/user/components/UserAddView.web.jsx | 4 ++-- .../src/modules/user/components/UserEditView.jsx | 4 ++-- .../modules/user/components/UserEditView.web.jsx | 4 ++-- .../src/modules/user/components/UserForm.jsx | 14 +++++++------- .../src/modules/user/components/UserForm.web.jsx | 10 +++++----- .../modules/user/components/UsersFilterView.jsx | 4 ++-- .../src/modules/user/containers/UserEdit.jsx | 2 ++ packages/server/src/middleware/website.tsx | 2 +- 12 files changed, 31 insertions(+), 30 deletions(-) diff --git a/packages/client/src/modules/common/components/native/ui-antd-mobile/components/Select.jsx b/packages/client/src/modules/common/components/native/ui-antd-mobile/components/Select.jsx index 81e4ac51f9..b8da3e6edb 100644 --- a/packages/client/src/modules/common/components/native/ui-antd-mobile/components/Select.jsx +++ b/packages/client/src/modules/common/components/native/ui-antd-mobile/components/Select.jsx @@ -5,12 +5,12 @@ import { FontAwesome } from '@expo/vector-icons'; import { View, StyleSheet } from 'react-native'; import SelectStyles from '../styles/Select'; -const Select = ({ icon, iconName, iconColor, iconSize, onValueChange, cols, selectedValue, value, ...props }) => { +const Select = ({ icon, iconName, iconColor, iconSize, onChange, cols, selectedValue, value, ...props }) => { return ( onValueChange(cols === 1 ? val[0] : val)} + onChange={val => onChange(cols === 1 ? val[0] : val)} value={[selectedValue || value]} cols={cols || 1} {...props} @@ -31,7 +31,7 @@ const Select = ({ icon, iconName, iconColor, iconSize, onValueChange, cols, sele }; Select.propTypes = { - onValueChange: PropTypes.func, + onChange: PropTypes.func, cols: PropTypes.number, value: PropTypes.string, selectedValue: PropTypes.string, diff --git a/packages/client/src/modules/common/components/native/ui-antd-mobile/components/Switch.jsx b/packages/client/src/modules/common/components/native/ui-antd-mobile/components/Switch.jsx index b5337e1aec..1d42bcf754 100644 --- a/packages/client/src/modules/common/components/native/ui-antd-mobile/components/Switch.jsx +++ b/packages/client/src/modules/common/components/native/ui-antd-mobile/components/Switch.jsx @@ -2,14 +2,13 @@ import React from 'react'; import { Switch as ADSwitch } from 'antd-mobile-rn'; import PropTypes from 'prop-types'; -const Switch = ({ checked, value, onValueChange, onChange, ...props }) => { - return ; +const Switch = ({ checked, value, onChange, ...props }) => { + return ; }; Switch.propTypes = { checked: PropTypes.bool, value: PropTypes.bool, - onValueChange: PropTypes.func, onChange: PropTypes.func }; diff --git a/packages/client/src/modules/pagination/containers/PaginationDemo.native.jsx b/packages/client/src/modules/pagination/containers/PaginationDemo.native.jsx index 00508d0748..abe2457699 100644 --- a/packages/client/src/modules/pagination/containers/PaginationDemo.native.jsx +++ b/packages/client/src/modules/pagination/containers/PaginationDemo.native.jsx @@ -61,7 +61,7 @@ class PaginationDemo extends React.Component { mode="dropdown" data={options} selectedValue={pagination} - onValueChange={this.onPaginationTypeChange} + onChange={this.onPaginationTypeChange} okText={t('list.select.ok')} dismissText={t('list.select.dismiss')} cols={1} diff --git a/packages/client/src/modules/user/components/UserAddView.jsx b/packages/client/src/modules/user/components/UserAddView.jsx index 64612ee557..90974c79ba 100644 --- a/packages/client/src/modules/user/components/UserAddView.jsx +++ b/packages/client/src/modules/user/components/UserAddView.jsx @@ -19,8 +19,8 @@ class UserAddView extends React.PureComponent { ); diff --git a/packages/client/src/modules/user/components/UserAddView.web.jsx b/packages/client/src/modules/user/components/UserAddView.web.jsx index f8b7eec645..ef23f037cf 100644 --- a/packages/client/src/modules/user/components/UserAddView.web.jsx +++ b/packages/client/src/modules/user/components/UserAddView.web.jsx @@ -58,8 +58,8 @@ class UserAddView extends React.PureComponent { ); diff --git a/packages/client/src/modules/user/components/UserEditView.jsx b/packages/client/src/modules/user/components/UserEditView.jsx index 184597d7ed..8af35be46e 100644 --- a/packages/client/src/modules/user/components/UserEditView.jsx +++ b/packages/client/src/modules/user/components/UserEditView.jsx @@ -28,8 +28,8 @@ class UserEditView extends React.PureComponent { diff --git a/packages/client/src/modules/user/components/UserEditView.web.jsx b/packages/client/src/modules/user/components/UserEditView.web.jsx index 0d027b56b5..3ea9e68105 100644 --- a/packages/client/src/modules/user/components/UserEditView.web.jsx +++ b/packages/client/src/modules/user/components/UserEditView.web.jsx @@ -64,8 +64,8 @@ class UserEditView extends React.PureComponent { diff --git a/packages/client/src/modules/user/components/UserForm.jsx b/packages/client/src/modules/user/components/UserForm.jsx index 883cac3238..84dedd30d6 100644 --- a/packages/client/src/modules/user/components/UserForm.jsx +++ b/packages/client/src/modules/user/components/UserForm.jsx @@ -25,7 +25,7 @@ const handleRoleChange = (type, value, setFieldValue) => { const validate = values => validateForm(values, userFormSchema); -const UserForm = ({ values, handleSubmit, setFieldValue, t, shouldRoleDisplay, shouldActiveDisplay }) => { +const UserForm = ({ values, handleSubmit, setFieldValue, t, shouldDisplayRole, shouldDisplayActive }) => { const options = [ { value: 'user', @@ -57,7 +57,7 @@ const UserForm = ({ values, handleSubmit, setFieldValue, t, shouldRoleDisplay, s keyboardType="email-address" placeholderTextColor={placeholderColor} /> - {shouldRoleDisplay && ( + {shouldDisplayRole && ( handleRoleChange('role', value, setFieldValue)} + onChange={value => handleRoleChange('role', value, setFieldValue)} cols={1} data={options} /> )} - {shouldActiveDisplay && ( + {shouldDisplayActive && ( setFieldValue('isActive', !isActive)} + onChange={() => setFieldValue('isActive', !isActive)} component={RenderSwitch} placeholder={t('userEdit.form.field.active')} checked={isActive} @@ -146,8 +146,8 @@ UserForm.propTypes = { setTouched: PropTypes.func, isValid: PropTypes.bool, error: PropTypes.string, - shouldRoleDisplay: PropTypes.bool, - shouldActiveDisplay: PropTypes.bool, + shouldDisplayRole: PropTypes.bool, + shouldDisplayActive: PropTypes.bool, values: PropTypes.object, errors: PropTypes.object, initialValues: PropTypes.object.isRequired, diff --git a/packages/client/src/modules/user/components/UserForm.web.jsx b/packages/client/src/modules/user/components/UserForm.web.jsx index 50baab5dfd..83445d9343 100644 --- a/packages/client/src/modules/user/components/UserForm.web.jsx +++ b/packages/client/src/modules/user/components/UserForm.web.jsx @@ -29,7 +29,7 @@ const updateUserFormSchema = { const validate = (values, createNew) => validateForm(values, createNew ? createUserFormSchema : updateUserFormSchema); -const UserForm = ({ values, handleSubmit, error, setFieldValue, t, shouldRoleDisplay, shouldActiveDisplay }) => { +const UserForm = ({ values, handleSubmit, error, setFieldValue, t, shouldDisplayRole, shouldDisplayActive }) => { const { username, email, role, isActive, profile, auth, password, passwordConfirmation } = values; return ( @@ -42,7 +42,7 @@ const UserForm = ({ values, handleSubmit, error, setFieldValue, t, shouldRoleDis value={username} /> - {shouldRoleDisplay && ( + {shouldDisplayRole && ( {t('userEdit.form.field.role.admin')} )} - {shouldActiveDisplay && ( + {shouldDisplayActive && ( this.handleRole(value)} + onChange={value => this.handleRole(value)} okText={t('users.select.okText')} dismissText={t('users.select.dismissText')} cols={1} @@ -189,7 +189,7 @@ class UsersFilterView extends React.PureComponent { {t('users.column.active')} - + this.setState({ showModal: true })}> diff --git a/packages/client/src/modules/user/containers/UserEdit.jsx b/packages/client/src/modules/user/containers/UserEdit.jsx index 7a85ca1135..e794750000 100644 --- a/packages/client/src/modules/user/containers/UserEdit.jsx +++ b/packages/client/src/modules/user/containers/UserEdit.jsx @@ -7,6 +7,7 @@ import UserEditView from '../components/UserEditView'; import USER_QUERY from '../graphql/UserQuery.graphql'; import EDIT_USER from '../graphql/EditUser.graphql'; import settings from '../../../../../../settings'; +import translate from '../../../i18n'; import UserFormatter from '../helpers/UserFormatter'; class UserEdit extends React.Component { @@ -42,6 +43,7 @@ class UserEdit extends React.Component { } export default compose( + translate('user'), graphql(USER_QUERY, { options: props => { let id = 0; diff --git a/packages/server/src/middleware/website.tsx b/packages/server/src/middleware/website.tsx index 43717fb387..6aefee9b38 100644 --- a/packages/server/src/middleware/website.tsx +++ b/packages/server/src/middleware/website.tsx @@ -77,7 +77,7 @@ const Html = ({ content, state, css, clientModules, helmet }: HtmlProps) => ( const renderServerSide = async (req: any, res: any) => { const clientModules = require('../../../client/src/modules').default; - const schemaLink = new SchemaLink({ schema, context: await modules.createContext(req, res) }); + const schemaLink = new SchemaLink({ schema, context: { ...(await modules.createContext(req, res)), req, res } }); const client = createApolloClient({ apiUrl, createNetLink: !isApiExternal ? () => schemaLink : undefined,