From 63fa27e0324bab08a28a4e1ceacecbc1e395e2f7 Mon Sep 17 00:00:00 2001 From: soupette Date: Thu, 18 Feb 2021 13:48:14 +0100 Subject: [PATCH] Fix PR feedback Signed-off-by: soupette --- .../ContentTypeCollapse/Collapse/index.js | 10 +++++----- .../CollapsePropertyMatrix/ActionRow/index.js | 6 +++--- .../utils/createDefaultCTFormFromLayout.js | 16 ++++++++-------- .../Wrapper.js | 0 .../{RowLabel => RowLabelWithCheckbox}/index.js | 8 ++++---- 5 files changed, 20 insertions(+), 20 deletions(-) rename packages/strapi-admin/ee/admin/containers/Roles/CreatePage/{RowLabel => RowLabelWithCheckbox}/Wrapper.js (100%) rename packages/strapi-admin/ee/admin/containers/Roles/CreatePage/{RowLabel => RowLabelWithCheckbox}/index.js (90%) diff --git a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/ContentTypeCollapse/Collapse/index.js b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/ContentTypeCollapse/Collapse/index.js index d1e5f923ab..c02a8f4d8d 100644 --- a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/ContentTypeCollapse/Collapse/index.js +++ b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/ContentTypeCollapse/Collapse/index.js @@ -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 - - + {checkboxesActions.map( diff --git a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/index.js b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/index.js index ffc03cfdf1..0e7cdb0935 100644 --- a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/index.js +++ b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/index.js @@ -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 = ({ - {required && } - + {propertyActions.map(({ label, isActionRelatedToCurrentProperty, actionId }) => { if (!isActionRelatedToCurrentProperty) { diff --git a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/Permissions/utils/createDefaultCTFormFromLayout.js b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/Permissions/utils/createDefaultCTFormFromLayout.js index 4ec52c69ca..794e95705d 100644 --- a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/Permissions/utils/createDefaultCTFormFromLayout.js +++ b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/Permissions/utils/createDefaultCTFormFromLayout.js @@ -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); }, {}); }; diff --git a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabel/Wrapper.js b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabelWithCheckbox/Wrapper.js similarity index 100% rename from packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabel/Wrapper.js rename to packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabelWithCheckbox/Wrapper.js diff --git a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabel/index.js b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabelWithCheckbox/index.js similarity index 90% rename from packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabel/index.js rename to packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabelWithCheckbox/index.js index 6297cd8510..1a68b8c8f3 100644 --- a/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabel/index.js +++ b/packages/strapi-admin/ee/admin/containers/Roles/CreatePage/RowLabelWithCheckbox/index.js @@ -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);