mirror of
https://github.com/strapi/strapi.git
synced 2025-12-27 07:03:38 +00:00
Fix PR feedback
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
6e13c3f2a5
commit
5718540247
@ -67,6 +67,14 @@ const DynamicZone = ({
|
||||
[addComponentToDynamicZone, hasError, name]
|
||||
);
|
||||
|
||||
const handleClickOpenPicker = () => {
|
||||
if (dynamicDisplayedComponentsLength < max) {
|
||||
setIsOpen(prev => !prev);
|
||||
} else {
|
||||
strapi.notification.info(`${pluginId}.components.notification.info.maximum-requirement`);
|
||||
}
|
||||
};
|
||||
|
||||
if (!isFieldAllowed && isCreatingEntry) {
|
||||
return (
|
||||
<BaselineAlignement>
|
||||
@ -123,15 +131,7 @@ const DynamicZone = ({
|
||||
type="button"
|
||||
hasError={hasError}
|
||||
className={isOpen && 'isOpen'}
|
||||
onClick={() => {
|
||||
if (dynamicDisplayedComponentsLength < max) {
|
||||
setIsOpen(prev => !prev);
|
||||
} else {
|
||||
strapi.notification.info(
|
||||
`${pluginId}.components.notification.info.maximum-requirement`
|
||||
);
|
||||
}
|
||||
}}
|
||||
onClick={handleClickOpenPicker}
|
||||
/>
|
||||
{hasRequiredError && !isOpen && !hasMaxError && (
|
||||
<div className="error-label">
|
||||
|
||||
@ -62,9 +62,7 @@ function SelectWrapper({
|
||||
});
|
||||
}, [options, value]);
|
||||
|
||||
const endPoint = useMemo(() => queryInfos.endPoint, [queryInfos]);
|
||||
const containsKey = useMemo(() => queryInfos.containsKey, [queryInfos]);
|
||||
const defaultParams = useMemo(() => queryInfos.defaultParams, [queryInfos]);
|
||||
const { endPoint, containsKey, defaultParams, shouldDisplayRelationLink } = queryInfos;
|
||||
|
||||
const getData = useCallback(
|
||||
async signal => {
|
||||
@ -162,7 +160,7 @@ function SelectWrapper({
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!queryInfos.shouldDisplayRelationLink) {
|
||||
if (!shouldDisplayRelationLink) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -173,7 +171,7 @@ function SelectWrapper({
|
||||
</FormattedMessage>
|
||||
</Link>
|
||||
);
|
||||
}, [queryInfos.shouldDisplayRelationLink, pathname, to, value]);
|
||||
}, [shouldDisplayRelationLink, pathname, to, value]);
|
||||
|
||||
const Component = isSingle ? SelectOne : SelectMany;
|
||||
const associationsLength = isArray(value) ? value.length : 0;
|
||||
@ -224,7 +222,7 @@ function SelectWrapper({
|
||||
addRelation({ target: { name, value } });
|
||||
}}
|
||||
components={{ ClearIndicator, DropdownIndicator, IndicatorSeparator, Option }}
|
||||
displayNavigationLink={queryInfos.shouldDisplayRelationLink}
|
||||
displayNavigationLink={shouldDisplayRelationLink}
|
||||
id={name}
|
||||
isDisabled={isDisabled}
|
||||
isLoading={isLoading}
|
||||
|
||||
@ -15,7 +15,7 @@ import { crudInitialState, crudReducer } from '../../sharedReducers';
|
||||
import { getRequestUrl } from './utils';
|
||||
|
||||
// This container is used to handle the CRUD
|
||||
const CollectionTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
const CollectionTypeFormWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
const { emitEvent } = useGlobalContext();
|
||||
const { push, replace } = useHistory();
|
||||
|
||||
@ -28,7 +28,7 @@ const CollectionTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
|
||||
const isCreatingEntry = id === 'create';
|
||||
|
||||
const fetchURL = useMemo(() => {
|
||||
const requestURL = useMemo(() => {
|
||||
if (isCreatingEntry && !origin) {
|
||||
return null;
|
||||
}
|
||||
@ -109,7 +109,7 @@ const CollectionTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
dispatch({ type: 'GET_DATA' });
|
||||
|
||||
try {
|
||||
const data = await request(fetchURL, { method: 'GET', signal });
|
||||
const data = await request(requestURL, { method: 'GET', signal });
|
||||
|
||||
dispatch({
|
||||
type: 'GET_DATA_SUCCEEDED',
|
||||
@ -139,7 +139,7 @@ const CollectionTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
}
|
||||
};
|
||||
|
||||
if (fetchURL && shouldFetch.current) {
|
||||
if (requestURL && shouldFetch.current) {
|
||||
getData(signal);
|
||||
} else {
|
||||
dispatch({ type: 'INIT_FORM' });
|
||||
@ -147,9 +147,9 @@ const CollectionTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
|
||||
return () => {
|
||||
abortController.abort();
|
||||
shouldFetch.current = fetchURL === null;
|
||||
shouldFetch.current = requestURL === null;
|
||||
};
|
||||
}, [fetchURL, push, from, cleanReceivedData, cleanClonedData]);
|
||||
}, [requestURL, push, from, cleanReceivedData, cleanClonedData]);
|
||||
|
||||
const displayErrors = useCallback(err => {
|
||||
const errorPayload = err.response.payload;
|
||||
@ -303,11 +303,11 @@ const CollectionTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
});
|
||||
};
|
||||
|
||||
CollectionTypeWrapper.defaultProps = {
|
||||
CollectionTypeFormWrapper.defaultProps = {
|
||||
from: '/',
|
||||
};
|
||||
|
||||
CollectionTypeWrapper.propTypes = {
|
||||
CollectionTypeFormWrapper.propTypes = {
|
||||
allLayoutData: PropTypes.exact({
|
||||
components: PropTypes.object.isRequired,
|
||||
contentType: PropTypes.exact({
|
||||
@ -328,4 +328,4 @@ CollectionTypeWrapper.propTypes = {
|
||||
slug: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default memo(CollectionTypeWrapper);
|
||||
export default memo(CollectionTypeFormWrapper);
|
||||
@ -21,9 +21,9 @@ import FieldComponent from '../../components/FieldComponent';
|
||||
import Inputs from '../../components/Inputs';
|
||||
import SelectWrapper from '../../components/SelectWrapper';
|
||||
import { generatePermissionsObject, getInjectedComponents } from '../../utils';
|
||||
import CollectionTypeWrapper from '../CollectionTypeWrapper';
|
||||
import CollectionTypeFormWrapper from '../CollectionTypeFormWrapper';
|
||||
import EditViewDataManagerProvider from '../EditViewDataManagerProvider';
|
||||
import SingleTypeWrapper from '../SingleTypeWrapper';
|
||||
import SingleTypeFormWrapper from '../SingleTypeFormWrapper';
|
||||
import Header from './Header';
|
||||
import { createAttributesLayout, getFieldsActionMatchingPermissions } from './utils';
|
||||
import { LinkWrapper, SubWrapper } from './components';
|
||||
@ -63,7 +63,7 @@ const EditView = ({ isSingleType, layout, slug }) => {
|
||||
const currentContentTypeLayoutData = useMemo(() => get(layout, ['contentType'], {}), [layout]);
|
||||
|
||||
const DataManagementWrapper = useMemo(
|
||||
() => (isSingleType ? SingleTypeWrapper : CollectionTypeWrapper),
|
||||
() => (isSingleType ? SingleTypeFormWrapper : CollectionTypeFormWrapper),
|
||||
[isSingleType]
|
||||
);
|
||||
|
||||
|
||||
@ -13,7 +13,7 @@ import { crudInitialState, crudReducer } from '../../sharedReducers';
|
||||
import { getRequestUrl } from './utils';
|
||||
|
||||
// This container is used to handle the CRUD
|
||||
const SingleTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
const SingleTypeFormWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
const { emitEvent } = useGlobalContext();
|
||||
const { push } = useHistory();
|
||||
const emitEventRef = useRef(emitEvent);
|
||||
@ -91,6 +91,10 @@ const SingleTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
});
|
||||
setIsCreatingEntry(false);
|
||||
} catch (err) {
|
||||
if (err.name === 'AbortError') {
|
||||
return;
|
||||
}
|
||||
|
||||
const responseStatus = get(err, 'response.status', null);
|
||||
|
||||
// Creating a single type
|
||||
@ -262,11 +266,11 @@ const SingleTypeWrapper = ({ allLayoutData, children, from, slug }) => {
|
||||
});
|
||||
};
|
||||
|
||||
SingleTypeWrapper.defaultProps = {
|
||||
SingleTypeFormWrapper.defaultProps = {
|
||||
from: '/',
|
||||
};
|
||||
|
||||
SingleTypeWrapper.propTypes = {
|
||||
SingleTypeFormWrapper.propTypes = {
|
||||
allLayoutData: PropTypes.shape({
|
||||
components: PropTypes.object.isRequired,
|
||||
contentType: PropTypes.object.isRequired,
|
||||
@ -276,4 +280,4 @@ SingleTypeWrapper.propTypes = {
|
||||
slug: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default memo(SingleTypeWrapper);
|
||||
export default memo(SingleTypeFormWrapper);
|
||||
@ -25,4 +25,12 @@ describe('CONTENT MANAGER | utils | checkIfAttributeIsDisplayable', () => {
|
||||
|
||||
expect(checkIfAttributeIsDisplayable(attribute)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should return true if the type is a text', () => {
|
||||
const attribute = {
|
||||
type: 'text',
|
||||
};
|
||||
|
||||
expect(checkIfAttributeIsDisplayable(attribute)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user