mirror of
https://github.com/strapi/strapi.git
synced 2026-01-06 12:13:52 +00:00
Fix PR feedback
Signed-off-by: soupette <cyril.lpz@gmail.com>
This commit is contained in:
parent
f1f245448f
commit
63fa27e032
@ -9,7 +9,7 @@ import { getCheckboxState, removeConditionKeyFromData } from '../../utils';
|
||||
import ConditionsButton from '../../ConditionsButton';
|
||||
import ConditionsModal from '../../ConditionsModal';
|
||||
import HiddenAction from '../../HiddenAction';
|
||||
import RowLabel from '../../RowLabel';
|
||||
import RowLabelWithCheckbox from '../../RowLabelWithCheckbox';
|
||||
import Wrapper from './Wrapper';
|
||||
import generateCheckboxesActions from './utils/generateCheckboxesActions';
|
||||
|
||||
@ -29,10 +29,10 @@ const Collapse = ({ availableActions, isActive, isGrey, label, onClickToggle, pa
|
||||
setModalState(prevState => ({ ...prevState, isMounted: false }));
|
||||
};
|
||||
|
||||
// This corresponds to the data related to the CT left checkboxe
|
||||
// This corresponds to the data related to the CT left checkbox
|
||||
// modifiedData: { collectionTypes: { [ctuid]: {create: {fields: {f1: true}, update: {}, ... } } } }
|
||||
const mainData = get(modifiedData, pathToData.split('..'), {});
|
||||
// The utils we are using: getCheckboxState, retrieves if all the boolean values of an object in order
|
||||
// The utils we are using: getCheckboxState, retrieves all the boolean leafs of an object in order
|
||||
// to return the state of checkbox. Since the conditions are not related to the property we need to remove the key from the object.
|
||||
const dataWithoutCondition = useMemo(() => {
|
||||
return Object.keys(mainData).reduce((acc, current) => {
|
||||
@ -58,7 +58,7 @@ const Collapse = ({ availableActions, isActive, isGrey, label, onClickToggle, pa
|
||||
<Wrapper isActive={isActive} isGrey={isGrey}>
|
||||
<Flex style={{ flex: 1 }}>
|
||||
<Padded left size="sm" />
|
||||
<RowLabel
|
||||
<RowLabelWithCheckbox
|
||||
isCollapsable
|
||||
label={label}
|
||||
checkboxName={pathToData}
|
||||
@ -68,7 +68,7 @@ const Collapse = ({ availableActions, isActive, isGrey, label, onClickToggle, pa
|
||||
value={hasAllActionsSelected}
|
||||
>
|
||||
<Chevron icon={isActive ? 'chevron-up' : 'chevron-down'} />
|
||||
</RowLabel>
|
||||
</RowLabelWithCheckbox>
|
||||
|
||||
<Flex style={{ flex: 1 }}>
|
||||
{checkboxesActions.map(
|
||||
|
||||
@ -8,7 +8,7 @@ import CheckboxWithCondition from '../../../CheckboxWithCondition';
|
||||
import Chevron from '../../../Chevron';
|
||||
import HiddenAction from '../../../HiddenAction';
|
||||
import RequiredSign from '../../../RequiredSign';
|
||||
import RowLabel from '../../../RowLabel';
|
||||
import RowLabelWithCheckbox from '../../../RowLabelWithCheckbox';
|
||||
import SubActionRow from '../SubActionRow';
|
||||
import Wrapper from './Wrapper';
|
||||
import getRowLabelCheckboxeState from './utils/getRowLabelCheckboxeState';
|
||||
@ -67,7 +67,7 @@ const ActionRow = ({
|
||||
<Wrapper alignItems="center" isCollapsable={isCollapsable} isActive={isActive}>
|
||||
<Flex style={{ flex: 1 }}>
|
||||
<Padded left size="sm" />
|
||||
<RowLabel
|
||||
<RowLabelWithCheckbox
|
||||
width="15rem"
|
||||
onChange={handleChangeLeftRowCheckbox}
|
||||
onClick={handleClick}
|
||||
@ -78,7 +78,7 @@ const ActionRow = ({
|
||||
>
|
||||
{required && <RequiredSign />}
|
||||
<Chevron icon={isActive ? 'caret-up' : 'caret-down'} />
|
||||
</RowLabel>
|
||||
</RowLabelWithCheckbox>
|
||||
<Flex style={{ flex: 1 }}>
|
||||
{propertyActions.map(({ label, isActionRelatedToCurrentProperty, actionId }) => {
|
||||
if (!isActionRelatedToCurrentProperty) {
|
||||
|
||||
@ -90,7 +90,7 @@ const findLayouts = (allLayouts, subjects) => {
|
||||
* }
|
||||
*/
|
||||
const createDefaultCTFormFromLayout = ({ subjects }, actionArray, conditionArray) => {
|
||||
return actionArray.reduce((acc, current) => {
|
||||
return actionArray.reduce((defaultForm, current) => {
|
||||
const actionSubjects = current.subjects;
|
||||
|
||||
const subjectLayouts = findLayouts(subjects, actionSubjects);
|
||||
@ -99,18 +99,18 @@ const createDefaultCTFormFromLayout = ({ subjects }, actionArray, conditionArray
|
||||
// for instance the D&P permission is applied only with the cts that
|
||||
// have the D&P features enabled
|
||||
if (isEmpty(subjectLayouts)) {
|
||||
return acc;
|
||||
return defaultForm;
|
||||
}
|
||||
|
||||
// The object has the following shape: { [ctUID]: { [actionId]: { [property]: { enabled: false } } } }
|
||||
const contentTypesActions = Object.keys(subjectLayouts).reduce((acc2, currentCTUID) => {
|
||||
const contentTypesActions = Object.keys(subjectLayouts).reduce((acc, currentCTUID) => {
|
||||
const { actionId, applyToProperties } = current;
|
||||
const conditionsForm = createDefaultConditionsForm(conditionArray);
|
||||
|
||||
if (isEmpty(applyToProperties)) {
|
||||
set(acc2, [currentCTUID, actionId], { enabled: false, conditions: conditionsForm });
|
||||
set(acc, [currentCTUID, actionId], { enabled: false, conditions: conditionsForm });
|
||||
|
||||
return acc2;
|
||||
return acc;
|
||||
}
|
||||
|
||||
const propertiesForm = createDefaultPropertiesForm(
|
||||
@ -118,12 +118,12 @@ const createDefaultCTFormFromLayout = ({ subjects }, actionArray, conditionArray
|
||||
subjectLayouts[currentCTUID]
|
||||
);
|
||||
|
||||
set(acc2, [currentCTUID, actionId], { ...propertiesForm, conditions: conditionsForm });
|
||||
set(acc, [currentCTUID, actionId], { ...propertiesForm, conditions: conditionsForm });
|
||||
|
||||
return acc2;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
return merge(acc, contentTypesActions);
|
||||
return merge(defaultForm, contentTypesActions);
|
||||
}, {});
|
||||
};
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ import { Checkbox, Text } from '@buffetjs/core';
|
||||
import CollapseLabel from '../CollapseLabel';
|
||||
import Wrapper from './Wrapper';
|
||||
|
||||
const RowLabel = ({
|
||||
const RowLabelWithCheckbox = ({
|
||||
children,
|
||||
isCollapsable,
|
||||
label,
|
||||
@ -41,7 +41,7 @@ const RowLabel = ({
|
||||
);
|
||||
};
|
||||
|
||||
RowLabel.defaultProps = {
|
||||
RowLabelWithCheckbox.defaultProps = {
|
||||
children: null,
|
||||
checkboxName: '',
|
||||
onChange: () => {},
|
||||
@ -52,7 +52,7 @@ RowLabel.defaultProps = {
|
||||
width: '18rem',
|
||||
};
|
||||
|
||||
RowLabel.propTypes = {
|
||||
RowLabelWithCheckbox.propTypes = {
|
||||
checkboxName: PropTypes.string,
|
||||
children: PropTypes.node,
|
||||
label: PropTypes.string.isRequired,
|
||||
@ -65,4 +65,4 @@ RowLabel.propTypes = {
|
||||
width: PropTypes.string,
|
||||
};
|
||||
|
||||
export default memo(RowLabel);
|
||||
export default memo(RowLabelWithCheckbox);
|
||||
Loading…
x
Reference in New Issue
Block a user