Merge pull request #9741 from strapi/i18n/cm-post-locales

[I18n] Post single locale
This commit is contained in:
cyril lopez 2021-03-17 09:40:21 +01:00 committed by GitHub
commit df66ea8a4d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 9 additions and 8 deletions

View File

@ -20,7 +20,7 @@ const Wrapper = styled.div`
`
: `
border: 1px solid #A5D5FF;
background-color: ${({ theme }) => theme.main.colors.lightestBlue};
background-color: ${theme.main.colors.lightestBlue};
${Text} {
color: ${theme.main.colors.mediumBlue};
}

View File

@ -1,7 +1,7 @@
import { memo, useCallback, useEffect, useMemo, useRef } from 'react';
import { useHistory } from 'react-router-dom';
import { get } from 'lodash';
import { request, useGlobalContext } from 'strapi-helper-plugin';
import { request, useGlobalContext, useQueryParams } from 'strapi-helper-plugin';
import { useSelector, useDispatch } from 'react-redux';
import PropTypes from 'prop-types';
import {
@ -28,6 +28,7 @@ import { getRequestUrl } from './utils';
const CollectionTypeFormWrapper = ({ allLayoutData, children, from, slug, id, origin }) => {
const { emitEvent } = useGlobalContext();
const { push, replace } = useHistory();
const [{ rawQuery }] = useQueryParams();
const dispatch = useDispatch();
const {
componentsDataStructure,
@ -212,7 +213,7 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, from, slug, id, or
const onPost = useCallback(
async (body, trackerProperty) => {
const endPoint = getRequestUrl(slug);
const endPoint = `${getRequestUrl(slug)}${rawQuery}`;
try {
// Show a loading button in the EditView/Header.js && lock the app => no navigation
@ -230,14 +231,14 @@ const CollectionTypeFormWrapper = ({ allLayoutData, children, from, slug, id, or
// Enable navigation and remove loaders
dispatch(setStatus('resolved'));
replace(`/plugins/${pluginId}/collectionType/${slug}/${response.id}`);
replace(`/plugins/${pluginId}/collectionType/${slug}/${response.id}${rawQuery}`);
} catch (err) {
emitEventRef.current('didNotCreateEntry', { error: err, trackerProperty });
displayErrors(err);
dispatch(setStatus('resolved'));
}
},
[cleanReceivedData, displayErrors, replace, slug, dispatch]
[cleanReceivedData, displayErrors, replace, slug, dispatch, rawQuery]
);
const onPublish = useCallback(async () => {

View File

@ -21,7 +21,7 @@ const EditViewLayoutManager = ({ layout, ...rest }) => {
};
}, [layout, dispatch, query]);
if (!currentLayout) {
if (!currentLayout || !permissions) {
return <LoadingIndicatorPage />;
}

View File

@ -11,8 +11,8 @@ const useSyncRbac = (query, collectionTypeUID, containerName = 'listView') => {
const relatedPermissions = collectionTypesRelatedPermissions[collectionTypeUID];
useEffect(() => {
if (query && relatedPermissions) {
dispatch(setPermissions(relatedPermissions, query.plugins, containerName));
if (relatedPermissions) {
dispatch(setPermissions(relatedPermissions, query ? query.plugins : null, containerName));
return () => {
dispatch(resetPermissions());