Merge pull request #7716 from strapi/fix/7699

Fixes Admin bugs
This commit is contained in:
Alexandre BODIN 2020-09-24 14:41:10 +02:00 committed by GitHub
commit c97f33bf53
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 26 additions and 10 deletions

View File

@ -20,6 +20,7 @@ const Register = ({
formErrors, formErrors,
inputsPrefix, inputsPrefix,
modifiedData, modifiedData,
noSignin,
onChange, onChange,
onSubmit, onSubmit,
requestError, requestError,
@ -135,6 +136,7 @@ const Register = ({
</Box> </Box>
</Padded> </Padded>
</Section> </Section>
{!noSignin && (
<AuthLink label="Auth.link.signin" to="/auth/login"> <AuthLink label="Auth.link.signin" to="/auth/login">
<Text fontSize="md"> <Text fontSize="md">
{formatMessage({ id: 'Auth.link.signin.account' })} {formatMessage({ id: 'Auth.link.signin.account' })}
@ -144,6 +146,7 @@ const Register = ({
</Text> </Text>
</Text> </Text>
</AuthLink> </AuthLink>
)}
</> </>
); );
}; };
@ -151,6 +154,7 @@ const Register = ({
Register.defaultProps = { Register.defaultProps = {
fieldsToDisable: [], fieldsToDisable: [],
inputsPrefix: '', inputsPrefix: '',
noSignin: false,
onSubmit: e => e.preventDefault(), onSubmit: e => e.preventDefault(),
requestError: null, requestError: null,
}; };
@ -160,6 +164,7 @@ Register.propTypes = {
formErrors: PropTypes.object.isRequired, formErrors: PropTypes.object.isRequired,
inputsPrefix: PropTypes.string, inputsPrefix: PropTypes.string,
modifiedData: PropTypes.object.isRequired, modifiedData: PropTypes.object.isRequired,
noSignin: PropTypes.bool,
onChange: PropTypes.func.isRequired, onChange: PropTypes.func.isRequired,
onSubmit: PropTypes.func, onSubmit: PropTypes.func,
requestError: PropTypes.object, requestError: PropTypes.object,

View File

@ -22,7 +22,7 @@ const AuthPage = ({ hasAdmin }) => {
} = useRouteMatch('/auth/:authType'); } = useRouteMatch('/auth/:authType');
const query = useQuery(); const query = useQuery();
const registrationToken = query.get('registrationToken'); const registrationToken = query.get('registrationToken');
const { Component, endPoint, fieldsToDisable, fieldsToOmit, inputsPrefix, schema } = get( const { Component, endPoint, fieldsToDisable, fieldsToOmit, inputsPrefix, schema, ...rest } = get(
forms, forms,
authType, authType,
{} {}
@ -285,6 +285,7 @@ const AuthPage = ({ hasAdmin }) => {
</NavTopRightWrapper> </NavTopRightWrapper>
<BaselineAlignment top size="78px"> <BaselineAlignment top size="78px">
<Component <Component
{...rest}
fieldsToDisable={fieldsToDisable} fieldsToDisable={fieldsToDisable}
formErrors={formErrors} formErrors={formErrors}
inputsPrefix={inputsPrefix} inputsPrefix={inputsPrefix}

View File

@ -80,6 +80,7 @@ const forms = {
'register-admin': { 'register-admin': {
Component: Register, Component: Register,
endPoint: 'register-admin', endPoint: 'register-admin',
noSignin: true,
fieldsToDisable: [], fieldsToDisable: [],
fieldsToOmit: ['confirmPassword', 'news'], fieldsToOmit: ['confirmPassword', 'news'],
schema: yup.object().shape({ schema: yup.object().shape({

View File

@ -21,6 +21,7 @@ const CustomTable = ({ canUpdate, canDelete, data, headers, isBulkable, showLoad
emitEvent('willEditEntryFromList'); emitEvent('willEditEntryFromList');
push({ push({
pathname: `${pathname}/${id}`, pathname: `${pathname}/${id}`,
state: { from: pathname },
}); });
}; };

View File

@ -159,6 +159,14 @@ const EditViewDataManagerProvider = ({
console.log(err); console.log(err);
const status = get(err, 'response.status', null); const status = get(err, 'response.status', null);
// The record does not exists
// Redirect the user to the previous page
if (id && status === 404) {
push(from);
return;
}
if (id && status === 403) { if (id && status === 403) {
strapi.notification.info(getTrad('permissions.not-allowed.update')); strapi.notification.info(getTrad('permissions.not-allowed.update'));

View File

@ -53,7 +53,7 @@ const HomePageSettings = ({
placeholder={formatMessage({ id: getTrad('search.placeholder') })} placeholder={formatMessage({ id: getTrad('search.placeholder') })}
name="_q" name="_q"
value={searchValue} value={searchValue}
autoFocus="true" autoFocus
/> />
{isLoading ? ( {isLoading ? (
<> <>