@akemona-org/strapi-admin 3.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -0
- package/README.md +41 -0
- package/admin/src/app.js +242 -0
- package/admin/src/assets/icons/icon_auth-permissions.svg +1 -0
- package/admin/src/assets/icons/icon_content-manager.svg +1 -0
- package/admin/src/assets/icons/icon_content-type-builder.svg +1 -0
- package/admin/src/assets/icons/icon_settings-manager.svg +1 -0
- package/admin/src/assets/icons/icon_success.svg +19 -0
- package/admin/src/assets/images/background_empty.svg +1 -0
- package/admin/src/assets/images/background_welcome_homepage.png +0 -0
- package/admin/src/assets/images/banner_strapi-rocket.png +0 -0
- package/admin/src/assets/images/banner_t-shirt.png +0 -0
- package/admin/src/assets/images/bg_hp_tee_shirt.png +0 -0
- package/admin/src/assets/images/logo-strapi.png +0 -0
- package/admin/src/assets/images/logo-t-shirt.svg +1 -0
- package/admin/src/assets/images/logo_github.png +0 -0
- package/admin/src/assets/images/logo_slack.png +0 -0
- package/admin/src/assets/images/logo_stack_overflow.png +0 -0
- package/admin/src/assets/images/logo_strapi.png +0 -0
- package/admin/src/assets/images/oops.png +0 -0
- package/admin/src/assets/images/social_discord.png +0 -0
- package/admin/src/assets/images/social_gh.png +0 -0
- package/admin/src/assets/images/social_reddit.png +0 -0
- package/admin/src/assets/images/social_strapi.png +0 -0
- package/admin/src/assets/images/social_twitter.png +0 -0
- package/admin/src/components/BaselineAlignement/index.js +33 -0
- package/admin/src/components/Bloc/index.js +9 -0
- package/admin/src/components/ContainerFluid/index.js +13 -0
- package/admin/src/components/Fonts/index.js +76 -0
- package/admin/src/components/FormBloc/index.js +60 -0
- package/admin/src/components/FullWidthButton/index.js +15 -0
- package/admin/src/components/GlobalStyle/index.js +175 -0
- package/admin/src/components/Header/index.js +40 -0
- package/admin/src/components/HeaderSearch/HeaderSearch.js +8 -0
- package/admin/src/components/HeaderSearch/index.js +99 -0
- package/admin/src/components/IntlInput/index.js +38 -0
- package/admin/src/components/LeftMenu/LeftMenuFooter/Wrapper.js +51 -0
- package/admin/src/components/LeftMenu/LeftMenuFooter/index.js +44 -0
- package/admin/src/components/LeftMenu/LeftMenuHeader/Wrapper.js +50 -0
- package/admin/src/components/LeftMenu/LeftMenuHeader/index.js +14 -0
- package/admin/src/components/LeftMenu/LeftMenuLink/A.js +39 -0
- package/admin/src/components/LeftMenu/LeftMenuLink/LeftMenuIcon.js +23 -0
- package/admin/src/components/LeftMenu/LeftMenuLink/LeftMenuLinkContent.js +97 -0
- package/admin/src/components/LeftMenu/LeftMenuLink/NotificationCount.js +32 -0
- package/admin/src/components/LeftMenu/LeftMenuLink/index.js +41 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkHeader/Search.js +11 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkHeader/SearchButton.js +11 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkHeader/SearchWrapper.js +11 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkHeader/Title.js +30 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkHeader/index.js +81 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkHeader/messages.json +38 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkSection/EmptyLinksList.js +21 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkSection/EmptyLinksListWrapper.js +9 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkSection/LeftMenuListLink.js +10 -0
- package/admin/src/components/LeftMenu/LeftMenuLinkSection/index.js +84 -0
- package/admin/src/components/LeftMenu/LinksContainer/index.js +31 -0
- package/admin/src/components/LeftMenu/index.js +4 -0
- package/admin/src/components/NavTopRightWrapper/index.js +11 -0
- package/admin/src/components/Notifications/Notification/Li.js +168 -0
- package/admin/src/components/Notifications/Notification/index.js +104 -0
- package/admin/src/components/Notifications/NotificationsContainer/Wrapper.js +17 -0
- package/admin/src/components/Notifications/NotificationsContainer/index.js +56 -0
- package/admin/src/components/Notifications/index.js +2 -0
- package/admin/src/components/PageTitle/index.js +15 -0
- package/admin/src/components/Roles/ButtonWithNumber/NumberCard.js +10 -0
- package/admin/src/components/Roles/ButtonWithNumber/index.js +42 -0
- package/admin/src/components/Roles/CheckboxWithCondition/index.js +41 -0
- package/admin/src/components/Roles/Chevron/index.js +11 -0
- package/admin/src/components/Roles/CollapseLabel/index.js +11 -0
- package/admin/src/components/Roles/ConditionsButton/Wrapper.js +28 -0
- package/admin/src/components/Roles/ConditionsButton/index.js +49 -0
- package/admin/src/components/Roles/ConditionsModal/ActionRow/Wrapper.js +12 -0
- package/admin/src/components/Roles/ConditionsModal/ActionRow/index.js +88 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/ClearIndicator.js +15 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/CustomDropdownIndicator.js +39 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/IndicatorSeparator.js +3 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/MenuList/SubUl.js +48 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/MenuList/Ul.js +80 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/MenuList/UpperFirst.js +6 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/MenuList/index.js +140 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/MenuList/utils/constants.js +3 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/MenuList/utils/createCollapsesObject.js +14 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/SingleValue.js +46 -0
- package/admin/src/components/Roles/ConditionsModal/ConditionsSelect/index.js +67 -0
- package/admin/src/components/Roles/ConditionsModal/Separator.js +9 -0
- package/admin/src/components/Roles/ConditionsModal/index.js +150 -0
- package/admin/src/components/Roles/ConditionsModal/utils/createDefaultConditionsForm.js +47 -0
- package/admin/src/components/Roles/ConditionsModal/utils/selectStyle.js +95 -0
- package/admin/src/components/Roles/ContentTypeCollapse/Collapse/Wrapper.js +38 -0
- package/admin/src/components/Roles/ContentTypeCollapse/Collapse/index.js +156 -0
- package/admin/src/components/Roles/ContentTypeCollapse/Collapse/utils/constants.js +3 -0
- package/admin/src/components/Roles/ContentTypeCollapse/Collapse/utils/generateCheckboxesActions.js +55 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/Wrapper.js +28 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/index.js +162 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/utils/constants.js +3 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/ActionRow/utils/getRowLabelCheckboxeState.js +59 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/Header/index.js +65 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/SubActionRow/Wrapper.js +8 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/SubActionRow/index.js +176 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/SubActionRow/row.js +37 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/SubActionRow/timeline.js +15 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/SubActionRow/utils/constants.js +3 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/Wrapper.js +21 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/index.js +55 -0
- package/admin/src/components/Roles/ContentTypeCollapse/CollapsePropertyMatrix/utils/generateHeadersFromActions.js +12 -0
- package/admin/src/components/Roles/ContentTypeCollapse/Wrapper.js +17 -0
- package/admin/src/components/Roles/ContentTypeCollapse/index.js +72 -0
- package/admin/src/components/Roles/ContentTypeCollapse/utils/activeStyle.js +15 -0
- package/admin/src/components/Roles/ContentTypeCollapse/utils/getAvailableActions.js +10 -0
- package/admin/src/components/Roles/ContentTypeCollapse/utils/index.js +2 -0
- package/admin/src/components/Roles/ContentTypeCollapses/index.js +50 -0
- package/admin/src/components/Roles/ContentTypes/Wrapper.js +13 -0
- package/admin/src/components/Roles/ContentTypes/index.js +39 -0
- package/admin/src/components/Roles/Curve/index.js +35 -0
- package/admin/src/components/Roles/EmptyRole/index.js +31 -0
- package/admin/src/components/Roles/GlobalActions/Wrapper.js +18 -0
- package/admin/src/components/Roles/GlobalActions/index.js +66 -0
- package/admin/src/components/Roles/GlobalActions/utils/constants.js +3 -0
- package/admin/src/components/Roles/GlobalActions/utils/findDisplayedActions.js +4 -0
- package/admin/src/components/Roles/GlobalActions/utils/getRowLabelCheckboxesState.js +38 -0
- package/admin/src/components/Roles/GlobalActions/utils/index.js +2 -0
- package/admin/src/components/Roles/HiddenAction/index.js +9 -0
- package/admin/src/components/Roles/Permissions/README.md +372 -0
- package/admin/src/components/Roles/Permissions/index.js +155 -0
- package/admin/src/components/Roles/Permissions/init.js +41 -0
- package/admin/src/components/Roles/Permissions/reducer.js +177 -0
- package/admin/src/components/Roles/Permissions/utils/createDefaultCTFormFromLayout.js +178 -0
- package/admin/src/components/Roles/Permissions/utils/createDefaultPluginsFormFromLayout.js +49 -0
- package/admin/src/components/Roles/Permissions/utils/findMatchingPermissions.js +4 -0
- package/admin/src/components/Roles/Permissions/utils/formatContentTypesPermissionToAPI.js +122 -0
- package/admin/src/components/Roles/Permissions/utils/formatLayoutForSettingsAndPlugins.js +23 -0
- package/admin/src/components/Roles/Permissions/utils/formatPermissionsToAPI.js +21 -0
- package/admin/src/components/Roles/Permissions/utils/formatSettingsPermissionsToAPI.js +59 -0
- package/admin/src/components/Roles/Permissions/utils/tabLabels.js +24 -0
- package/admin/src/components/Roles/Permissions/utils/updateConditionsToFalse.js +39 -0
- package/admin/src/components/Roles/Permissions/utils/updateValues.js +31 -0
- package/admin/src/components/Roles/PermissionsDataManagerProvider/index.js +26 -0
- package/admin/src/components/Roles/PluginsAndSettings/ListWrapper.js +10 -0
- package/admin/src/components/Roles/PluginsAndSettings/Row/Wrapper.js +28 -0
- package/admin/src/components/Roles/PluginsAndSettings/Row/index.js +82 -0
- package/admin/src/components/Roles/PluginsAndSettings/SubCategory/CheckboxWrapper.js +22 -0
- package/admin/src/components/Roles/PluginsAndSettings/SubCategory/ConditionsButtonWrapper.js +13 -0
- package/admin/src/components/Roles/PluginsAndSettings/SubCategory/Wrapper.js +26 -0
- package/admin/src/components/Roles/PluginsAndSettings/SubCategory/index.js +136 -0
- package/admin/src/components/Roles/PluginsAndSettings/SubCategory/utils/constants.js +3 -0
- package/admin/src/components/Roles/PluginsAndSettings/SubCategory/utils/formatActions.js +32 -0
- package/admin/src/components/Roles/PluginsAndSettings/SubCategory/utils/getConditionsButtonState.js +17 -0
- package/admin/src/components/Roles/PluginsAndSettings/SubCategory/utils/index.js +2 -0
- package/admin/src/components/Roles/PluginsAndSettings/index.js +53 -0
- package/admin/src/components/Roles/RequiredSign/index.js +11 -0
- package/admin/src/components/Roles/RoleForm/NameInput.js +6 -0
- package/admin/src/components/Roles/RoleForm/RoleForm.js +94 -0
- package/admin/src/components/Roles/RoleForm/index.js +2 -0
- package/admin/src/components/Roles/RoleList/RoleDescription.js +9 -0
- package/admin/src/components/Roles/RoleList/RoleListWrapper.js +17 -0
- package/admin/src/components/Roles/RoleList/RoleRow.js +48 -0
- package/admin/src/components/Roles/RoleList/index.js +3 -0
- package/admin/src/components/Roles/RowLabelWithCheckbox/Wrapper.js +29 -0
- package/admin/src/components/Roles/RowLabelWithCheckbox/index.js +76 -0
- package/admin/src/components/Roles/Tabs/Tab.js +22 -0
- package/admin/src/components/Roles/Tabs/TabsWrapper.js +17 -0
- package/admin/src/components/Roles/Tabs/index.js +65 -0
- package/admin/src/components/Roles/index.js +6 -0
- package/admin/src/components/Roles/utils/createArrayOfValues.js +19 -0
- package/admin/src/components/Roles/utils/getCheckboxState.js +19 -0
- package/admin/src/components/Roles/utils/index.js +3 -0
- package/admin/src/components/Roles/utils/removeConditionKeyFromData.js +15 -0
- package/admin/src/components/Settings/Header/index.js +73 -0
- package/admin/src/components/Settings/index.js +2 -0
- package/admin/src/components/SettingsPageTitle/index.js +17 -0
- package/admin/src/components/SizedInput/index.js +25 -0
- package/admin/src/components/UpgradePlanModal/components/Arrow/arrow.png +0 -0
- package/admin/src/components/UpgradePlanModal/components/Arrow/index.js +16 -0
- package/admin/src/components/UpgradePlanModal/components/Download/index.js +13 -0
- package/admin/src/components/UpgradePlanModal/components/Option/Wrapper.js +12 -0
- package/admin/src/components/UpgradePlanModal/components/Option/index.js +18 -0
- package/admin/src/components/UpgradePlanModal/components/Wrapper/balloon.png +0 -0
- package/admin/src/components/UpgradePlanModal/components/Wrapper/index.js +14 -0
- package/admin/src/components/UpgradePlanModal/components/index.js +4 -0
- package/admin/src/components/UpgradePlanModal/index.js +76 -0
- package/admin/src/components/Users/Filter/index.js +41 -0
- package/admin/src/components/Users/FilterPicker/Button.js +14 -0
- package/admin/src/components/Users/FilterPicker/Card/Input.js +35 -0
- package/admin/src/components/Users/FilterPicker/Card/Wrapper.js +8 -0
- package/admin/src/components/Users/FilterPicker/Card/index.js +91 -0
- package/admin/src/components/Users/FilterPicker/Card/init.js +5 -0
- package/admin/src/components/Users/FilterPicker/Card/reducer.js +39 -0
- package/admin/src/components/Users/FilterPicker/Card/utils/form.js +57 -0
- package/admin/src/components/Users/FilterPicker/Card/utils/formatInputValue.js +9 -0
- package/admin/src/components/Users/FilterPicker/Card/utils/getInputValue.js +9 -0
- package/admin/src/components/Users/FilterPicker/Card/utils/index.js +3 -0
- package/admin/src/components/Users/FilterPicker/index.js +35 -0
- package/admin/src/components/Users/Footer/Wrapper.js +7 -0
- package/admin/src/components/Users/Footer/index.js +40 -0
- package/admin/src/components/Users/LinkNotification/Envelope.js +20 -0
- package/admin/src/components/Users/LinkNotification/IconWrapper.js +15 -0
- package/admin/src/components/Users/LinkNotification/Wrapper.js +26 -0
- package/admin/src/components/Users/LinkNotification/index.js +47 -0
- package/admin/src/components/Users/List/ActiveStatus.js +20 -0
- package/admin/src/components/Users/List/Wrapper.js +34 -0
- package/admin/src/components/Users/List/index.js +151 -0
- package/admin/src/components/Users/List/init.js +5 -0
- package/admin/src/components/Users/List/reducer.js +56 -0
- package/admin/src/components/Users/List/utils/checkIfAllEntriesAreSelected.js +3 -0
- package/admin/src/components/Users/List/utils/getSelectedIds.js +19 -0
- package/admin/src/components/Users/List/utils/headers.js +42 -0
- package/admin/src/components/Users/List/utils/index.js +4 -0
- package/admin/src/components/Users/List/utils/updateRows.js +6 -0
- package/admin/src/components/Users/MagicLink/index.js +27 -0
- package/admin/src/components/Users/ModalCreateBody/Wrapper.js +12 -0
- package/admin/src/components/Users/ModalCreateBody/index.js +153 -0
- package/admin/src/components/Users/ModalCreateBody/init.js +5 -0
- package/admin/src/components/Users/ModalCreateBody/reducer.js +27 -0
- package/admin/src/components/Users/ModalCreateBody/utils/form.js +29 -0
- package/admin/src/components/Users/ModalCreateBody/utils/formDataModel.js +8 -0
- package/admin/src/components/Users/ModalCreateBody/utils/roleSettingsForm.js +10 -0
- package/admin/src/components/Users/ModalCreateBody/utils/schema.js +17 -0
- package/admin/src/components/Users/RoleSettingsModalSection/RolesSelectComponent.js +53 -0
- package/admin/src/components/Users/RoleSettingsModalSection/index.js +76 -0
- package/admin/src/components/Users/SelectRoles/ClearIndicator.js +15 -0
- package/admin/src/components/Users/SelectRoles/DropdownIndicator.js +39 -0
- package/admin/src/components/Users/SelectRoles/ErrorMessage.js +10 -0
- package/admin/src/components/Users/SelectRoles/IndicatorSeparator.js +3 -0
- package/admin/src/components/Users/SelectRoles/MultiValueContainer.js +43 -0
- package/admin/src/components/Users/SelectRoles/StyledOption.js +11 -0
- package/admin/src/components/Users/SelectRoles/index.js +68 -0
- package/admin/src/components/Users/SelectRoles/utils/styles.js +99 -0
- package/admin/src/components/Users/SortPicker/Button.js +14 -0
- package/admin/src/components/Users/SortPicker/List.js +46 -0
- package/admin/src/components/Users/SortPicker/ListItem.js +37 -0
- package/admin/src/components/Users/SortPicker/ListWrapper.js +18 -0
- package/admin/src/components/Users/SortPicker/StyledListItem.js +30 -0
- package/admin/src/components/Users/SortPicker/index.js +34 -0
- package/admin/src/components/Users/index.js +8 -0
- package/admin/src/components/Webhooks/EventInput/EventRow.js +66 -0
- package/admin/src/components/Webhooks/EventInput/Wrapper.js +77 -0
- package/admin/src/components/Webhooks/EventInput/index.js +128 -0
- package/admin/src/components/Webhooks/EventInput/utils/formatValue.js +13 -0
- package/admin/src/components/Webhooks/HeadersInput/Wrapper.js +102 -0
- package/admin/src/components/Webhooks/HeadersInput/index.js +143 -0
- package/admin/src/components/Webhooks/HeadersInput/keys.js +39 -0
- package/admin/src/components/Webhooks/HeadersInput/utils/getBorderColor.js +12 -0
- package/admin/src/components/Webhooks/Inputs/Wrapper.js +34 -0
- package/admin/src/components/Webhooks/Inputs/index.js +110 -0
- package/admin/src/components/Webhooks/ListRow/StyledListRow.js +49 -0
- package/admin/src/components/Webhooks/ListRow/index.js +113 -0
- package/admin/src/components/Webhooks/Switch/Toggle.js +30 -0
- package/admin/src/components/Webhooks/Switch/Wrapper.js +67 -0
- package/admin/src/components/Webhooks/Switch/index.js +51 -0
- package/admin/src/components/Webhooks/TriggerContainer/Wrapper.js +64 -0
- package/admin/src/components/Webhooks/TriggerContainer/index.js +103 -0
- package/admin/src/components/Webhooks/index.js +4 -0
- package/admin/src/config.js +13 -0
- package/admin/src/configureStore.js +60 -0
- package/admin/src/containers/Admin/Content.js +30 -0
- package/admin/src/containers/Admin/Logout/components.js +128 -0
- package/admin/src/containers/Admin/Logout/index.js +60 -0
- package/admin/src/containers/Admin/Wrapper.js +27 -0
- package/admin/src/containers/Admin/actions.js +21 -0
- package/admin/src/containers/Admin/constants.js +9 -0
- package/admin/src/containers/Admin/index.js +364 -0
- package/admin/src/containers/Admin/reducer.js +39 -0
- package/admin/src/containers/Admin/selectors.js +22 -0
- package/admin/src/containers/App/actions.js +87 -0
- package/admin/src/containers/App/components.js +15 -0
- package/admin/src/containers/App/constants.js +18 -0
- package/admin/src/containers/App/index.js +157 -0
- package/admin/src/containers/App/reducer.js +86 -0
- package/admin/src/containers/App/selectors.js +38 -0
- package/admin/src/containers/App/styles/website.css +25 -0
- package/admin/src/containers/App/utils/customRoutes.js +3 -0
- package/admin/src/containers/App/utils/defaultRoutes.js +3 -0
- package/admin/src/containers/App/utils/index.js +3 -0
- package/admin/src/containers/App/utils/routes.js +4 -0
- package/admin/src/containers/App/utils/unique-identifier.js +10 -0
- package/admin/src/containers/ApplicationInfosPage/components/Detail/index.js +30 -0
- package/admin/src/containers/ApplicationInfosPage/components/InfoText/index.js +19 -0
- package/admin/src/containers/ApplicationInfosPage/components/Link/components.js +22 -0
- package/admin/src/containers/ApplicationInfosPage/components/Link/index.js +26 -0
- package/admin/src/containers/ApplicationInfosPage/components/Wrapper/index.js +7 -0
- package/admin/src/containers/ApplicationInfosPage/components/index.js +4 -0
- package/admin/src/containers/ApplicationInfosPage/index.js +89 -0
- package/admin/src/containers/AuthPage/components/AuthLink/Link.js +13 -0
- package/admin/src/containers/AuthPage/components/AuthLink/Wrapper.js +8 -0
- package/admin/src/containers/AuthPage/components/AuthLink/index.js +35 -0
- package/admin/src/containers/AuthPage/components/Box/Wrapper.js +13 -0
- package/admin/src/containers/AuthPage/components/Box/index.js +28 -0
- package/admin/src/containers/AuthPage/components/ForgotPassword/index.js +65 -0
- package/admin/src/containers/AuthPage/components/ForgotPasswordSuccess/Envelope.js +20 -0
- package/admin/src/containers/AuthPage/components/ForgotPasswordSuccess/index.js +77 -0
- package/admin/src/containers/AuthPage/components/Input/index.js +32 -0
- package/admin/src/containers/AuthPage/components/Login/BaseLogin.js +84 -0
- package/admin/src/containers/AuthPage/components/Login/index.js +23 -0
- package/admin/src/containers/AuthPage/components/Logo/Img.js +7 -0
- package/admin/src/containers/AuthPage/components/Logo/index.js +7 -0
- package/admin/src/containers/AuthPage/components/Oops/Img.js +7 -0
- package/admin/src/containers/AuthPage/components/Oops/index.js +63 -0
- package/admin/src/containers/AuthPage/components/Register/CustomLabel.js +28 -0
- package/admin/src/containers/AuthPage/components/Register/InputWrapper.js +8 -0
- package/admin/src/containers/AuthPage/components/Register/Span.js +13 -0
- package/admin/src/containers/AuthPage/components/Register/index.js +173 -0
- package/admin/src/containers/AuthPage/components/ResetPassword/index.js +73 -0
- package/admin/src/containers/AuthPage/components/Section/index.js +22 -0
- package/admin/src/containers/AuthPage/index.js +321 -0
- package/admin/src/containers/AuthPage/init.js +5 -0
- package/admin/src/containers/AuthPage/reducer.js +41 -0
- package/admin/src/containers/AuthPage/utils/forms.js +124 -0
- package/admin/src/containers/AuthPage/utils/index.js +2 -0
- package/admin/src/containers/HomePage/BlogPost.js +48 -0
- package/admin/src/containers/HomePage/SocialLink.js +52 -0
- package/admin/src/containers/HomePage/components.js +260 -0
- package/admin/src/containers/HomePage/hooks.js +54 -0
- package/admin/src/containers/HomePage/index.js +239 -0
- package/admin/src/containers/InstalledPluginsPage/ListWrapper.js +7 -0
- package/admin/src/containers/InstalledPluginsPage/Logo.js +36 -0
- package/admin/src/containers/InstalledPluginsPage/Row.js +98 -0
- package/admin/src/containers/InstalledPluginsPage/index.js +73 -0
- package/admin/src/containers/InstalledPluginsPage/utils/generateRows.js +19 -0
- package/admin/src/containers/LanguageProvider/actions.js +16 -0
- package/admin/src/containers/LanguageProvider/constants.js +8 -0
- package/admin/src/containers/LanguageProvider/hooks/useChangeLanguage.js +14 -0
- package/admin/src/containers/LanguageProvider/index.js +49 -0
- package/admin/src/containers/LanguageProvider/reducer.js +52 -0
- package/admin/src/containers/LanguageProvider/selectors.js +25 -0
- package/admin/src/containers/LeftMenu/Loader.js +34 -0
- package/admin/src/containers/LeftMenu/LoaderWrapper.js +13 -0
- package/admin/src/containers/LeftMenu/Wrapper.js +61 -0
- package/admin/src/containers/LeftMenu/actions.js +24 -0
- package/admin/src/containers/LeftMenu/constants.js +4 -0
- package/admin/src/containers/LeftMenu/index.js +101 -0
- package/admin/src/containers/LeftMenu/reducer.js +79 -0
- package/admin/src/containers/LeftMenu/selectors.js +3 -0
- package/admin/src/containers/LeftMenu/useMenuSections.js +62 -0
- package/admin/src/containers/LeftMenu/utils/checkPermissions.js +13 -0
- package/admin/src/containers/LeftMenu/utils/generateModelsLinks.js +61 -0
- package/admin/src/containers/LeftMenu/utils/getCtOrStLinks.js +49 -0
- package/admin/src/containers/LeftMenu/utils/getGeneralLinks.js +42 -0
- package/admin/src/containers/LeftMenu/utils/getPluginSectionLinks.js +17 -0
- package/admin/src/containers/LeftMenu/utils/getSettingsMenuLinksPermissions.js +20 -0
- package/admin/src/containers/LeftMenu/utils/index.js +2 -0
- package/admin/src/containers/LeftMenu/utils/toPluginLinks.js +19 -0
- package/admin/src/containers/LocaleToggle/Wrapper.js +147 -0
- package/admin/src/containers/LocaleToggle/actions.js +19 -0
- package/admin/src/containers/LocaleToggle/constants.js +8 -0
- package/admin/src/containers/LocaleToggle/index.js +84 -0
- package/admin/src/containers/LocaleToggle/reducer.js +25 -0
- package/admin/src/containers/LocaleToggle/selectors.js +25 -0
- package/admin/src/containers/MarketplacePage/MarketplaceBanner/Wrapper.js +29 -0
- package/admin/src/containers/MarketplacePage/MarketplaceBanner/index.js +37 -0
- package/admin/src/containers/MarketplacePage/PluginCard/Wrapper.js +148 -0
- package/admin/src/containers/MarketplacePage/PluginCard/index.js +184 -0
- package/admin/src/containers/MarketplacePage/Wrapper.js +10 -0
- package/admin/src/containers/MarketplacePage/index.js +103 -0
- package/admin/src/containers/NewNotification/Notification/index.js +181 -0
- package/admin/src/containers/NewNotification/Notification/styledComponents.js +66 -0
- package/admin/src/containers/NewNotification/Wrapper.js +19 -0
- package/admin/src/containers/NewNotification/actions.js +9 -0
- package/admin/src/containers/NewNotification/constants.js +2 -0
- package/admin/src/containers/NewNotification/index.js +35 -0
- package/admin/src/containers/NewNotification/reducer.js +49 -0
- package/admin/src/containers/NotFoundPage/index.js +24 -0
- package/admin/src/containers/NotificationProvider/actions.js +37 -0
- package/admin/src/containers/NotificationProvider/constants.js +8 -0
- package/admin/src/containers/NotificationProvider/index.js +45 -0
- package/admin/src/containers/NotificationProvider/reducer.js +48 -0
- package/admin/src/containers/NotificationProvider/selectors.js +27 -0
- package/admin/src/containers/Onboarding/Li.js +150 -0
- package/admin/src/containers/Onboarding/StaticLinks/StyledLink.js +23 -0
- package/admin/src/containers/Onboarding/StaticLinks/index.js +45 -0
- package/admin/src/containers/Onboarding/Video.js +180 -0
- package/admin/src/containers/Onboarding/Wrapper.js +131 -0
- package/admin/src/containers/Onboarding/index.js +134 -0
- package/admin/src/containers/Onboarding/init.js +5 -0
- package/admin/src/containers/Onboarding/reducer.js +62 -0
- package/admin/src/containers/Onboarding/utils/formatAndStoreVideoArray.js +27 -0
- package/admin/src/containers/PermissionsManager/actions.js +25 -0
- package/admin/src/containers/PermissionsManager/constants.js +5 -0
- package/admin/src/containers/PermissionsManager/index.js +49 -0
- package/admin/src/containers/PermissionsManager/reducer.js +66 -0
- package/admin/src/containers/PluginDispatcher/index.js +69 -0
- package/admin/src/containers/PrivateRoute/index.js +39 -0
- package/admin/src/containers/ProfilePage/components.js +9 -0
- package/admin/src/containers/ProfilePage/index.js +170 -0
- package/admin/src/containers/ProfilePage/utils/form.js +36 -0
- package/admin/src/containers/ProfilePage/utils/index.js +2 -0
- package/admin/src/containers/ProfilePage/utils/schema.js +16 -0
- package/admin/src/containers/Roles/CreatePage/index.js +8 -0
- package/admin/src/containers/Roles/EditPage/index.js +172 -0
- package/admin/src/containers/Roles/EditPage/utils/schema.js +8 -0
- package/admin/src/containers/Roles/ListPage/BaselineAlignment.js +8 -0
- package/admin/src/containers/Roles/ListPage/index.js +149 -0
- package/admin/src/containers/Roles/ProtectedEditPage/index.js +31 -0
- package/admin/src/containers/Roles/ProtectedListPage/index.js +12 -0
- package/admin/src/containers/SettingsHeaderSearchContextProvider/index.js +17 -0
- package/admin/src/containers/SettingsPage/components/ApplicationDetailLink/Icon.js +13 -0
- package/admin/src/containers/SettingsPage/components/ApplicationDetailLink/Link.js +25 -0
- package/admin/src/containers/SettingsPage/components/ApplicationDetailLink/Notif.js +17 -0
- package/admin/src/containers/SettingsPage/components/ApplicationDetailLink/Wrapper.js +9 -0
- package/admin/src/containers/SettingsPage/components/ApplicationDetailLink/index.js +26 -0
- package/admin/src/containers/SettingsPage/components/MenuWrapper/index.js +9 -0
- package/admin/src/containers/SettingsPage/components/SettingDispatcher/index.js +27 -0
- package/admin/src/containers/SettingsPage/components/StyledLeftMenu/index.js +13 -0
- package/admin/src/containers/SettingsPage/components/Wrapper/index.js +19 -0
- package/admin/src/containers/SettingsPage/components/index.js +5 -0
- package/admin/src/containers/SettingsPage/index.js +132 -0
- package/admin/src/containers/SettingsPage/utils/createPluginsLinksRoutes.js +23 -0
- package/admin/src/containers/SettingsPage/utils/createRoute.js +8 -0
- package/admin/src/containers/SettingsPage/utils/customRoutes.js +3 -0
- package/admin/src/containers/SettingsPage/utils/defaultRoutes.js +65 -0
- package/admin/src/containers/SettingsPage/utils/findFirstAllowedEndpoint.js +14 -0
- package/admin/src/containers/SettingsPage/utils/getSectionsToDisplay.js +5 -0
- package/admin/src/containers/SettingsPage/utils/index.js +6 -0
- package/admin/src/containers/SettingsPage/utils/makeUniqueRoutes.js +6 -0
- package/admin/src/containers/SettingsPage/utils/routes.js +4 -0
- package/admin/src/containers/Theme/index.js +14 -0
- package/admin/src/containers/Users/EditPage/index.js +137 -0
- package/admin/src/containers/Users/EditPage/utils/form.js +52 -0
- package/admin/src/containers/Users/ListPage/Header.js +78 -0
- package/admin/src/containers/Users/ListPage/ModalForm.js +101 -0
- package/admin/src/containers/Users/ListPage/index.js +289 -0
- package/admin/src/containers/Users/ListPage/init.js +3 -0
- package/admin/src/containers/Users/ListPage/reducer.js +57 -0
- package/admin/src/containers/Users/ListPage/stepper.js +18 -0
- package/admin/src/containers/Users/ListPage/utils/getFilters.js +30 -0
- package/admin/src/containers/Users/ProtectedEditPage/index.js +45 -0
- package/admin/src/containers/Users/ProtectedListPage/index.js +12 -0
- package/admin/src/containers/Webhooks/EditView/Wrapper.js +61 -0
- package/admin/src/containers/Webhooks/EditView/index.js +448 -0
- package/admin/src/containers/Webhooks/EditView/reducer.js +76 -0
- package/admin/src/containers/Webhooks/EditView/utils/fieldsRegex.js +4 -0
- package/admin/src/containers/Webhooks/EditView/utils/form.js +38 -0
- package/admin/src/containers/Webhooks/EditView/utils/formatData.js +26 -0
- package/admin/src/containers/Webhooks/EditView/utils/index.js +3 -0
- package/admin/src/containers/Webhooks/EditView/utils/schema.js +35 -0
- package/admin/src/containers/Webhooks/ListView/Wrapper.js +31 -0
- package/admin/src/containers/Webhooks/ListView/index.js +320 -0
- package/admin/src/containers/Webhooks/ListView/reducer.js +43 -0
- package/admin/src/containers/Webhooks/ProtectedCreateView/index.js +12 -0
- package/admin/src/containers/Webhooks/ProtectedEditView/index.js +12 -0
- package/admin/src/containers/Webhooks/ProtectedListView/index.js +12 -0
- package/admin/src/contexts/MarketPlace/index.js +25 -0
- package/admin/src/contexts/PermisssionsDataManagerContext/index.js +5 -0
- package/admin/src/contexts/SettingsHeaderSearchContext/index.js +5 -0
- package/admin/src/contexts/index.js +2 -0
- package/admin/src/favicon.png +0 -0
- package/admin/src/hooks/index.js +9 -0
- package/admin/src/hooks/useFetchPermissionsLayout/index.js +32 -0
- package/admin/src/hooks/useFetchPermissionsLayout/reducer.js +35 -0
- package/admin/src/hooks/useFetchPluginsFromMarketPlace/index.js +49 -0
- package/admin/src/hooks/useFetchRole/index.js +58 -0
- package/admin/src/hooks/useFetchRole/reducer.js +33 -0
- package/admin/src/hooks/useModels/index.js +47 -0
- package/admin/src/hooks/useModels/reducer.js +45 -0
- package/admin/src/hooks/usePermissionsDataManager/index.js +6 -0
- package/admin/src/hooks/useRolesList/index.js +49 -0
- package/admin/src/hooks/useRolesList/init.js +5 -0
- package/admin/src/hooks/useRolesList/reducer.js +31 -0
- package/admin/src/hooks/useSettingsForm/index.js +136 -0
- package/admin/src/hooks/useSettingsForm/init.js +5 -0
- package/admin/src/hooks/useSettingsForm/reducer.js +60 -0
- package/admin/src/hooks/useSettingsHeaderSearchContext/index.js +6 -0
- package/admin/src/hooks/useSettingsMenu/index.js +56 -0
- package/admin/src/hooks/useSettingsMenu/init.js +49 -0
- package/admin/src/hooks/useSettingsMenu/reducer.js +41 -0
- package/admin/src/hooks/useSettingsMenu/utils/customGlobalLinks.js +1 -0
- package/admin/src/hooks/useSettingsMenu/utils/defaultGlobalLinks.js +14 -0
- package/admin/src/hooks/useSettingsMenu/utils/formatLinks.js +12 -0
- package/admin/src/hooks/useSettingsMenu/utils/globalLinks.js +4 -0
- package/admin/src/i18n.js +17 -0
- package/admin/src/index.html +16 -0
- package/admin/src/permissions/customPermissions.js +1 -0
- package/admin/src/permissions/defaultPermissions.js +60 -0
- package/admin/src/permissions/index.js +7 -0
- package/admin/src/plugins.js +37 -0
- package/admin/src/public-path.js +40 -0
- package/admin/src/reducers.js +28 -0
- package/admin/src/themes/colors.js +51 -0
- package/admin/src/themes/fontWeights.js +8 -0
- package/admin/src/themes/index.js +13 -0
- package/admin/src/themes/sizes.js +31 -0
- package/admin/src/translations/ar.json +146 -0
- package/admin/src/translations/cs.json +183 -0
- package/admin/src/translations/de.json +371 -0
- package/admin/src/translations/dk.json +348 -0
- package/admin/src/translations/en.json +375 -0
- package/admin/src/translations/es.json +338 -0
- package/admin/src/translations/fr.json +232 -0
- package/admin/src/translations/he.json +364 -0
- package/admin/src/translations/id.json +337 -0
- package/admin/src/translations/index.js +86 -0
- package/admin/src/translations/it.json +347 -0
- package/admin/src/translations/ja.json +288 -0
- package/admin/src/translations/ko.json +179 -0
- package/admin/src/translations/ms.json +223 -0
- package/admin/src/translations/nl.json +221 -0
- package/admin/src/translations/no.json +349 -0
- package/admin/src/translations/pl.json +372 -0
- package/admin/src/translations/pt-BR.json +228 -0
- package/admin/src/translations/pt.json +225 -0
- package/admin/src/translations/ru.json +368 -0
- package/admin/src/translations/sk.json +337 -0
- package/admin/src/translations/sv.json +127 -0
- package/admin/src/translations/th.json +332 -0
- package/admin/src/translations/tr.json +371 -0
- package/admin/src/translations/uk.json +223 -0
- package/admin/src/translations/vi.json +179 -0
- package/admin/src/translations/zh-Hans.json +372 -0
- package/admin/src/translations/zh.json +152 -0
- package/admin/src/utils/ComponentApi.js +42 -0
- package/admin/src/utils/FieldApi.js +48 -0
- package/admin/src/utils/MiddlewareApi.js +15 -0
- package/admin/src/utils/Plugin.js +50 -0
- package/admin/src/utils/Strapi.js +28 -0
- package/admin/src/utils/basename.js +3 -0
- package/admin/src/utils/checkFormValidity.js +15 -0
- package/admin/src/utils/checkLatestStrapiVersion.js +11 -0
- package/admin/src/utils/checkStore.js +24 -0
- package/admin/src/utils/constants.js +3 -0
- package/admin/src/utils/formatAPIErrors.js +17 -0
- package/admin/src/utils/getAttributesToDisplay.js +21 -0
- package/admin/src/utils/getExistingActions.js +34 -0
- package/admin/src/utils/getRequestUrl.js +3 -0
- package/admin/src/utils/history.js +6 -0
- package/admin/src/utils/index.js +9 -0
- package/admin/src/utils/injectReducer.js +56 -0
- package/admin/src/utils/injectSaga.js +76 -0
- package/admin/src/utils/reducerInjectors.js +38 -0
- package/admin/src/utils/retrieveGlobalLinks.js +17 -0
- package/admin/src/utils/retrievePluginsMenu.js +17 -0
- package/admin/src/utils/sagaInjectors.js +94 -0
- package/admin/src/utils/sortLinks.js +5 -0
- package/admin/src/validations/users/edit.js +11 -0
- package/admin/src/validations/users/index.js +3 -0
- package/admin/src/validations/users/profile.js +29 -0
- package/admin/src/validations/users/roles.js +11 -0
- package/config/admin-actions.js +122 -0
- package/config/admin-conditions.js +26 -0
- package/config/email-templates/forgot-password.js +25 -0
- package/config/functions/bootstrap.js +67 -0
- package/config/functions/register.js +7 -0
- package/config/layout.js +10 -0
- package/config/migrations/permissions-fields-to-properties.js +104 -0
- package/config/policies/hasPermissions.js +51 -0
- package/config/policies/isAuthenticatedAdmin.js +9 -0
- package/config/routes.json +320 -0
- package/config/settings.js +9 -0
- package/controllers/Webhooks.js +150 -0
- package/controllers/admin.js +101 -0
- package/controllers/authenticated-user.js +56 -0
- package/controllers/authentication.js +181 -0
- package/controllers/formatters/conditions.js +12 -0
- package/controllers/formatters/format-actions-by-sections.js +37 -0
- package/controllers/formatters/index.js +9 -0
- package/controllers/permission.js +51 -0
- package/controllers/role.js +148 -0
- package/controllers/user.js +136 -0
- package/doc/change-the-login-page-logo.md +28 -0
- package/doc/customize-menu.md +17 -0
- package/doc/disable-tracking.md +16 -0
- package/domain/action/index.js +142 -0
- package/domain/action/provider.js +83 -0
- package/domain/condition/index.js +92 -0
- package/domain/condition/provider.js +42 -0
- package/domain/permission/index.js +140 -0
- package/domain/role.js +29 -0
- package/domain/user.js +25 -0
- package/index.html +16 -0
- package/index.js +374 -0
- package/middlewares/auth/defaults.json +5 -0
- package/middlewares/auth/index.js +39 -0
- package/models/Permission.js +7 -0
- package/models/Permission.settings.json +49 -0
- package/models/Role.js +7 -0
- package/models/Role.settings.json +50 -0
- package/models/User.config.js +12 -0
- package/models/User.js +7 -0
- package/models/User.settings.json +88 -0
- package/package.json +129 -0
- package/services/action.js +34 -0
- package/services/auth.js +113 -0
- package/services/condition.js +14 -0
- package/services/constants.js +12 -0
- package/services/content-type.js +208 -0
- package/services/metrics.js +18 -0
- package/services/passport/local-strategy.js +21 -0
- package/services/passport.js +47 -0
- package/services/permission/engine-hooks.js +82 -0
- package/services/permission/engine.js +275 -0
- package/services/permission/permissions-manager/index.js +87 -0
- package/services/permission/permissions-manager/query-builers.js +86 -0
- package/services/permission/queries.js +241 -0
- package/services/permission/sections-builder/builder.js +84 -0
- package/services/permission/sections-builder/handlers.js +156 -0
- package/services/permission/sections-builder/index.js +50 -0
- package/services/permission/sections-builder/section.js +71 -0
- package/services/permission/sections-builder/utils.js +26 -0
- package/services/permission.js +30 -0
- package/services/role.js +470 -0
- package/services/token.js +57 -0
- package/services/user.js +348 -0
- package/utils/index.js +11 -0
- package/validation/action-provider.js +79 -0
- package/validation/authentication/forgot-password.js +20 -0
- package/validation/authentication/index.js +17 -0
- package/validation/authentication/register.js +63 -0
- package/validation/authentication/reset-password.js +21 -0
- package/validation/common-functions/check-fields-are-correctly-nested.js +26 -0
- package/validation/common-functions/check-fields-dont-have-duplicates.js +16 -0
- package/validation/common-functions/index.js +9 -0
- package/validation/common-validators.js +217 -0
- package/validation/permission.js +153 -0
- package/validation/policies/hasPermissions.js +33 -0
- package/validation/role.js +21 -0
- package/validation/user.js +85 -0
- package/webpack.alias.js +64 -0
- package/webpack.config.js +212 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import createDefaultCTFormFromLayout from './utils/createDefaultCTFormFromLayout';
|
|
2
|
+
import createDefaultPluginsFormFromLayout from './utils/createDefaultPluginsFormFromLayout';
|
|
3
|
+
import formatLayoutForSettingsAndPlugins from './utils/formatLayoutForSettingsAndPlugins';
|
|
4
|
+
|
|
5
|
+
const init = (layout, permissions) => {
|
|
6
|
+
const {
|
|
7
|
+
conditions,
|
|
8
|
+
sections: { collectionTypes, singleTypes, plugins, settings },
|
|
9
|
+
} = layout;
|
|
10
|
+
|
|
11
|
+
const layouts = {
|
|
12
|
+
collectionTypes,
|
|
13
|
+
singleTypes,
|
|
14
|
+
plugins: formatLayoutForSettingsAndPlugins(plugins, 'plugin'),
|
|
15
|
+
settings: formatLayoutForSettingsAndPlugins(settings, 'category'),
|
|
16
|
+
};
|
|
17
|
+
const defaultForm = {
|
|
18
|
+
collectionTypes: createDefaultCTFormFromLayout(
|
|
19
|
+
collectionTypes,
|
|
20
|
+
collectionTypes.actions || [],
|
|
21
|
+
conditions,
|
|
22
|
+
permissions
|
|
23
|
+
),
|
|
24
|
+
singleTypes: createDefaultCTFormFromLayout(
|
|
25
|
+
singleTypes,
|
|
26
|
+
singleTypes.actions || [],
|
|
27
|
+
conditions,
|
|
28
|
+
permissions
|
|
29
|
+
),
|
|
30
|
+
plugins: createDefaultPluginsFormFromLayout(layouts.plugins, conditions, permissions),
|
|
31
|
+
settings: createDefaultPluginsFormFromLayout(layouts.settings, conditions, permissions),
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
initialData: defaultForm,
|
|
36
|
+
modifiedData: defaultForm,
|
|
37
|
+
layouts,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default init;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import produce from 'immer';
|
|
2
|
+
import { cloneDeep, has, isObject, get, set } from 'lodash';
|
|
3
|
+
import updateConditionsToFalse from './utils/updateConditionsToFalse';
|
|
4
|
+
import updateValues from './utils/updateValues';
|
|
5
|
+
|
|
6
|
+
const initialState = {
|
|
7
|
+
initialData: {},
|
|
8
|
+
modifiedData: {},
|
|
9
|
+
layouts: {},
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
/* eslint-disable consistent-return */
|
|
13
|
+
const reducer = (state, action) =>
|
|
14
|
+
produce(state, draftState => {
|
|
15
|
+
switch (action.type) {
|
|
16
|
+
// This action is called when a checkbox in the <GlobalActions />
|
|
17
|
+
// changes
|
|
18
|
+
case 'ON_CHANGE_COLLECTION_TYPE_GLOBAL_ACTION_CHECKBOX': {
|
|
19
|
+
const { collectionTypeKind, actionId, value } = action;
|
|
20
|
+
const pathToData = ['modifiedData', collectionTypeKind];
|
|
21
|
+
|
|
22
|
+
Object.keys(get(state, pathToData)).forEach(collectionType => {
|
|
23
|
+
const collectionTypeActionData = get(
|
|
24
|
+
state,
|
|
25
|
+
[...pathToData, collectionType, actionId],
|
|
26
|
+
undefined
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
if (collectionTypeActionData) {
|
|
30
|
+
let updatedValues = updateValues(collectionTypeActionData, value);
|
|
31
|
+
|
|
32
|
+
// We need to remove the applied conditions
|
|
33
|
+
if (!value && updatedValues.conditions) {
|
|
34
|
+
const updatedConditions = updateValues(updatedValues.conditions, false);
|
|
35
|
+
|
|
36
|
+
updatedValues = { ...updatedValues, conditions: updatedConditions };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
set(draftState, [...pathToData, collectionType, actionId], updatedValues);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
case 'ON_CHANGE_COLLECTION_TYPE_ROW_LEFT_CHECKBOX': {
|
|
46
|
+
const { pathToCollectionType, propertyName, rowName, value } = action;
|
|
47
|
+
let nextModifiedDataState = cloneDeep(state.modifiedData);
|
|
48
|
+
const pathToModifiedDataCollectionType = pathToCollectionType.split('..');
|
|
49
|
+
|
|
50
|
+
const objToUpdate = get(nextModifiedDataState, pathToModifiedDataCollectionType, {});
|
|
51
|
+
|
|
52
|
+
Object.keys(objToUpdate).forEach(actionId => {
|
|
53
|
+
// When a ct has multiple properties (ex: locales, field)
|
|
54
|
+
// We need to make sure that we add any new property to the modifiedData
|
|
55
|
+
// object.
|
|
56
|
+
if (has(objToUpdate[actionId], `properties.${propertyName}`)) {
|
|
57
|
+
const objValue = get(objToUpdate, [actionId, 'properties', propertyName, rowName]);
|
|
58
|
+
const pathToDataToSet = [
|
|
59
|
+
...pathToModifiedDataCollectionType,
|
|
60
|
+
actionId,
|
|
61
|
+
'properties',
|
|
62
|
+
propertyName,
|
|
63
|
+
rowName,
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
if (!isObject(objValue)) {
|
|
67
|
+
set(nextModifiedDataState, pathToDataToSet, value);
|
|
68
|
+
} else {
|
|
69
|
+
const updatedValue = updateValues(objValue, value);
|
|
70
|
+
|
|
71
|
+
set(nextModifiedDataState, pathToDataToSet, updatedValue);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
// When we uncheck a row, we need to check if we also need to disable the conditions
|
|
77
|
+
if (!value) {
|
|
78
|
+
nextModifiedDataState = updateConditionsToFalse(nextModifiedDataState);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
set(draftState, 'modifiedData', nextModifiedDataState);
|
|
82
|
+
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
case 'ON_CHANGE_CONDITIONS': {
|
|
86
|
+
Object.entries(action.conditions).forEach(array => {
|
|
87
|
+
const [stringPathToData, conditionsToUpdate] = array;
|
|
88
|
+
|
|
89
|
+
set(
|
|
90
|
+
draftState,
|
|
91
|
+
['modifiedData', ...stringPathToData.split('..'), 'conditions'],
|
|
92
|
+
conditionsToUpdate
|
|
93
|
+
);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
case 'ON_CHANGE_SIMPLE_CHECKBOX': {
|
|
99
|
+
let nextModifiedDataState = cloneDeep(state.modifiedData);
|
|
100
|
+
|
|
101
|
+
set(nextModifiedDataState, [...action.keys.split('..')], action.value);
|
|
102
|
+
|
|
103
|
+
// When we uncheck a single checkbox we need to remove the conditions from the parent
|
|
104
|
+
if (!action.value) {
|
|
105
|
+
nextModifiedDataState = updateConditionsToFalse(nextModifiedDataState);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
set(draftState, 'modifiedData', nextModifiedDataState);
|
|
109
|
+
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
/*
|
|
113
|
+
* Here the idea is to retrieve a specific value of the modifiedObject
|
|
114
|
+
* then update all the boolean values of the retrieved one
|
|
115
|
+
* and update the drafState.
|
|
116
|
+
*
|
|
117
|
+
* For instance in order to enable create action for all the fields and locales
|
|
118
|
+
* of the restaurant content type we need to :
|
|
119
|
+
* 1. Retrieve the modifiedData.collectionTypes.restaurant.create object
|
|
120
|
+
* 2. Toggle all the end boolean values to the desired one
|
|
121
|
+
* 3. Update the draftState
|
|
122
|
+
*
|
|
123
|
+
* Since the case works well in order to update what we called "parent" checkbox. We can
|
|
124
|
+
* reuse the action when we need to toggle change all the values that depends on this one.
|
|
125
|
+
* A parent checkbox is a checkbox which value is not a boolean but depends on its children ones, therefore,
|
|
126
|
+
* a parent checkbox does not have a represented value in the draftState, they are just helpers.
|
|
127
|
+
*
|
|
128
|
+
* Given the following data:
|
|
129
|
+
*
|
|
130
|
+
* const data = {
|
|
131
|
+
* restaurant: {
|
|
132
|
+
* create: {
|
|
133
|
+
* fields: { name: true },
|
|
134
|
+
* locales: { en: false }
|
|
135
|
+
* }
|
|
136
|
+
* }
|
|
137
|
+
* }
|
|
138
|
+
*
|
|
139
|
+
* The value of the create checkbox for the restaurant will be ƒalse since not all its children have
|
|
140
|
+
* truthy values and in order to set its value to true when need to have all the values of its children set to true.
|
|
141
|
+
*
|
|
142
|
+
* Similarly, we can reuse the logic for the components attributes
|
|
143
|
+
*
|
|
144
|
+
*/
|
|
145
|
+
case 'ON_CHANGE_TOGGLE_PARENT_CHECKBOX': {
|
|
146
|
+
const { keys, value } = action;
|
|
147
|
+
const pathToValue = [...keys.split('..')];
|
|
148
|
+
let nextModifiedDataState = cloneDeep(state.modifiedData);
|
|
149
|
+
const oldValues = get(nextModifiedDataState, pathToValue, {});
|
|
150
|
+
|
|
151
|
+
const updatedValues = updateValues(oldValues, value);
|
|
152
|
+
set(nextModifiedDataState, pathToValue, updatedValues);
|
|
153
|
+
|
|
154
|
+
// When we uncheck a parent checkbox we need to remove the associated conditions
|
|
155
|
+
if (!value) {
|
|
156
|
+
nextModifiedDataState = updateConditionsToFalse(nextModifiedDataState);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
set(draftState, ['modifiedData'], nextModifiedDataState);
|
|
160
|
+
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
case 'RESET_FORM': {
|
|
164
|
+
draftState.modifiedData = state.initialData;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case 'SET_FORM_AFTER_SUBMIT': {
|
|
168
|
+
draftState.initialData = state.modifiedData;
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
default:
|
|
172
|
+
return draftState;
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
export default reducer;
|
|
177
|
+
export { initialState };
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { merge, get, isEmpty, set } from 'lodash';
|
|
2
|
+
import findMatchingPermission from './findMatchingPermissions';
|
|
3
|
+
/**
|
|
4
|
+
* Creates the default condition form: { [conditionId]: false }
|
|
5
|
+
* @param {object} conditions.id Id of the condition
|
|
6
|
+
* @returns {object}
|
|
7
|
+
*/
|
|
8
|
+
const createDefaultConditionsForm = (conditions, initialConditions = []) =>
|
|
9
|
+
conditions.reduce((acc, current) => {
|
|
10
|
+
acc[current.id] = initialConditions.indexOf(current.id) !== -1;
|
|
11
|
+
|
|
12
|
+
return acc;
|
|
13
|
+
}, {});
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Create the default form a property (fields, locales) with all the values
|
|
17
|
+
* set to false
|
|
18
|
+
* @param {object} property.children ex: {children: [{value: 'foo',}]}
|
|
19
|
+
* @param {array<string>} The found property values retrieved from the role associated permissions
|
|
20
|
+
* @returns {object} ex: { foo: false }
|
|
21
|
+
*
|
|
22
|
+
*/
|
|
23
|
+
const createDefaultPropertyForms = ({ children }, propertyValues, prefix = '') => {
|
|
24
|
+
return children.reduce((acc, current) => {
|
|
25
|
+
if (current.children) {
|
|
26
|
+
return {
|
|
27
|
+
...acc,
|
|
28
|
+
[current.value]: createDefaultPropertyForms(
|
|
29
|
+
current,
|
|
30
|
+
propertyValues,
|
|
31
|
+
`${prefix}${current.value}.`
|
|
32
|
+
),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const hasProperty = propertyValues.indexOf(`${prefix}${current.value}`) !== -1;
|
|
37
|
+
|
|
38
|
+
acc[current.value] = hasProperty;
|
|
39
|
+
|
|
40
|
+
return acc;
|
|
41
|
+
}, {});
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Creates the default form for all the properties found in a content type's layout
|
|
46
|
+
* @param {array<string>} propertiesArray ex; ['fields', 'locales']
|
|
47
|
+
* @param {object} ctLayout layout of the content type ex:
|
|
48
|
+
* ctLayout = {
|
|
49
|
+
* properties: [{
|
|
50
|
+
* value: 'fields',
|
|
51
|
+
* children: [{value: 'name'}]
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* @returns {object} In this case it will return { fields: { name: false } }
|
|
55
|
+
*/
|
|
56
|
+
const createDefaultPropertiesForm = (propertiesArray, ctLayout, matchingPermission) => {
|
|
57
|
+
return propertiesArray.reduce(
|
|
58
|
+
(acc, currentPropertyName) => {
|
|
59
|
+
const foundProperty = ctLayout.properties.find(({ value }) => value === currentPropertyName);
|
|
60
|
+
|
|
61
|
+
if (foundProperty) {
|
|
62
|
+
const matchingPermissionPropertyValues = get(
|
|
63
|
+
matchingPermission,
|
|
64
|
+
['properties', foundProperty.value],
|
|
65
|
+
[]
|
|
66
|
+
);
|
|
67
|
+
const propertyForm = createDefaultPropertyForms(
|
|
68
|
+
foundProperty,
|
|
69
|
+
matchingPermissionPropertyValues
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
acc.properties[currentPropertyName] = propertyForm;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return acc;
|
|
76
|
+
},
|
|
77
|
+
{ properties: {} }
|
|
78
|
+
);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Return an object of content types layout of an action's subject ex: { adress: {uid, label, properties } }
|
|
83
|
+
* @param {array<object>} allLayouts All the content types' layout
|
|
84
|
+
* @param {object} subjects
|
|
85
|
+
*/
|
|
86
|
+
const findLayouts = (allLayouts, subjects) => {
|
|
87
|
+
return subjects.reduce((acc, current) => {
|
|
88
|
+
const foundLayout = allLayouts.find(({ uid }) => uid === current) || null;
|
|
89
|
+
|
|
90
|
+
if (foundLayout) {
|
|
91
|
+
acc[current] = foundLayout;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return acc;
|
|
95
|
+
}, {});
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Creates the default for for a content type
|
|
100
|
+
* @param {object} layout.subjects All the content types to display
|
|
101
|
+
* @param {array<object>} actionArray An action has the following shape:
|
|
102
|
+
* action = {label: 'string', actionId: 'string', subjects: [object], applyToProperties: ['string]}
|
|
103
|
+
* @param {array<object>} conditionArray Ex: { id: 'string', category: 'string' }
|
|
104
|
+
* @returns {object} Ex:
|
|
105
|
+
* {
|
|
106
|
+
* ctUId: {
|
|
107
|
+
* [actionId]: {
|
|
108
|
+
* [propertyName]: { enabled: false, conditions: { [id]: false } }
|
|
109
|
+
* }
|
|
110
|
+
* }
|
|
111
|
+
* }
|
|
112
|
+
*/
|
|
113
|
+
const createDefaultCTFormFromLayout = (
|
|
114
|
+
{ subjects },
|
|
115
|
+
actionArray,
|
|
116
|
+
conditionArray,
|
|
117
|
+
initialPermissions = []
|
|
118
|
+
) => {
|
|
119
|
+
return actionArray.reduce((defaultForm, current) => {
|
|
120
|
+
const actionSubjects = current.subjects;
|
|
121
|
+
|
|
122
|
+
const subjectLayouts = findLayouts(subjects, actionSubjects);
|
|
123
|
+
|
|
124
|
+
// This can happen when an action is not related to a content type
|
|
125
|
+
// for instance the D&P permission is applied only with the cts that
|
|
126
|
+
// have the D&P features enabled
|
|
127
|
+
if (isEmpty(subjectLayouts)) {
|
|
128
|
+
return defaultForm;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// The object has the following shape: { [ctUID]: { [actionId]: { [property]: { enabled: false } } } }
|
|
132
|
+
const contentTypesActions = Object.keys(subjectLayouts).reduce((acc, currentCTUID) => {
|
|
133
|
+
const { actionId, applyToProperties } = current;
|
|
134
|
+
const currentSubjectLayout = subjectLayouts[currentCTUID];
|
|
135
|
+
const properties = currentSubjectLayout.properties.map(({ value }) => value);
|
|
136
|
+
const doesNothaveProperty = properties.every(
|
|
137
|
+
property => (applyToProperties || []).indexOf(property) === -1
|
|
138
|
+
);
|
|
139
|
+
|
|
140
|
+
const matchingPermission = findMatchingPermission(initialPermissions, actionId, currentCTUID);
|
|
141
|
+
const conditionsForm = createDefaultConditionsForm(
|
|
142
|
+
conditionArray,
|
|
143
|
+
get(matchingPermission, 'conditions', [])
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
if (isEmpty(applyToProperties) || doesNothaveProperty) {
|
|
147
|
+
set(acc, [currentCTUID, actionId], {
|
|
148
|
+
properties: {
|
|
149
|
+
enabled: matchingPermission !== undefined,
|
|
150
|
+
},
|
|
151
|
+
conditions: conditionsForm,
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
return acc;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
const propertiesForm = createDefaultPropertiesForm(
|
|
158
|
+
applyToProperties,
|
|
159
|
+
subjectLayouts[currentCTUID],
|
|
160
|
+
matchingPermission
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
set(acc, [currentCTUID, actionId], { ...propertiesForm, conditions: conditionsForm });
|
|
164
|
+
|
|
165
|
+
return acc;
|
|
166
|
+
}, {});
|
|
167
|
+
|
|
168
|
+
return merge(defaultForm, contentTypesActions);
|
|
169
|
+
}, {});
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
export default createDefaultCTFormFromLayout;
|
|
173
|
+
export {
|
|
174
|
+
createDefaultConditionsForm,
|
|
175
|
+
createDefaultPropertyForms,
|
|
176
|
+
createDefaultPropertiesForm,
|
|
177
|
+
findLayouts,
|
|
178
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { get } from 'lodash';
|
|
2
|
+
import { createDefaultConditionsForm } from './createDefaultCTFormFromLayout';
|
|
3
|
+
import findMatchingPermission from './findMatchingPermissions';
|
|
4
|
+
|
|
5
|
+
const createSubCategoryForm = (actions, conditions, permissions) => {
|
|
6
|
+
return actions.reduce((acc, current) => {
|
|
7
|
+
const foundMatchingPermission = findMatchingPermission(permissions, current.action, null);
|
|
8
|
+
|
|
9
|
+
acc[current.action] = {
|
|
10
|
+
properties: {
|
|
11
|
+
enabled: foundMatchingPermission !== undefined,
|
|
12
|
+
},
|
|
13
|
+
conditions: createDefaultConditionsForm(
|
|
14
|
+
conditions,
|
|
15
|
+
get(foundMatchingPermission, 'conditions', [])
|
|
16
|
+
),
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return acc;
|
|
20
|
+
}, {});
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
const createChildrenDefaultForm = (childrenForm, conditions, initialPermissions) => {
|
|
24
|
+
return childrenForm.reduce((acc, current) => {
|
|
25
|
+
acc[current.subCategoryId] = createSubCategoryForm(
|
|
26
|
+
current.actions,
|
|
27
|
+
conditions,
|
|
28
|
+
initialPermissions
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
return acc;
|
|
32
|
+
}, {});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const createDefaultPluginsFormFromLayout = (pluginsLayout, conditions, initialPermissions = []) => {
|
|
36
|
+
return pluginsLayout.reduce((acc, { categoryId, childrenForm }) => {
|
|
37
|
+
const childrenDefaultForm = createChildrenDefaultForm(
|
|
38
|
+
childrenForm,
|
|
39
|
+
conditions,
|
|
40
|
+
initialPermissions
|
|
41
|
+
);
|
|
42
|
+
acc[categoryId] = childrenDefaultForm;
|
|
43
|
+
|
|
44
|
+
return acc;
|
|
45
|
+
}, {});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export default createDefaultPluginsFormFromLayout;
|
|
49
|
+
export { createSubCategoryForm, createChildrenDefaultForm };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { has, isObject } from 'lodash';
|
|
2
|
+
import { createArrayOfValues } from '../../utils';
|
|
3
|
+
import { createConditionsArray } from './formatSettingsPermissionsToAPI';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Returns an array of property values
|
|
7
|
+
* @param {object} propertyValue
|
|
8
|
+
* @param {string} prefix
|
|
9
|
+
* @returns {array<string>}
|
|
10
|
+
*/
|
|
11
|
+
const createPropertyArray = (propertyValue, prefix = '') => {
|
|
12
|
+
return Object.entries(propertyValue).reduce((acc, current) => {
|
|
13
|
+
const [name, value] = current;
|
|
14
|
+
|
|
15
|
+
if (isObject(value)) {
|
|
16
|
+
return [...acc, ...createPropertyArray(value, `${prefix}${name}.`)];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (value && !isObject(value)) {
|
|
20
|
+
acc.push(`${prefix}${name}`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return acc;
|
|
24
|
+
}, []);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
*
|
|
29
|
+
* @param {string} action
|
|
30
|
+
* @param {string} subject
|
|
31
|
+
* @param {object} param2
|
|
32
|
+
* @config {object} conditions
|
|
33
|
+
* @config {object} the name of the properties array we need to fill
|
|
34
|
+
* @returns {object}
|
|
35
|
+
*/
|
|
36
|
+
const createPermissionWithProperties = (action, subject, { conditions, properties }) => {
|
|
37
|
+
return Object.entries(properties).reduce(
|
|
38
|
+
(acc, current) => {
|
|
39
|
+
const [propertyName, propertyValue] = current;
|
|
40
|
+
|
|
41
|
+
acc.properties[propertyName] = createPropertyArray(propertyValue);
|
|
42
|
+
|
|
43
|
+
return acc;
|
|
44
|
+
},
|
|
45
|
+
{ action, subject, conditions: createConditionsArray(conditions), properties: {} }
|
|
46
|
+
);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {string} action The name of the action
|
|
52
|
+
* @param {string} subject The name of the subject
|
|
53
|
+
* @param {object} param2
|
|
54
|
+
* @returns {object}
|
|
55
|
+
*/
|
|
56
|
+
const createPermissionWithoutProperties = (action, subject, { conditions }) => {
|
|
57
|
+
return {
|
|
58
|
+
action,
|
|
59
|
+
subject,
|
|
60
|
+
properties: {},
|
|
61
|
+
conditions: createConditionsArray(conditions),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
*
|
|
67
|
+
* @param {string} subject The name of the subject
|
|
68
|
+
* @param {object} actions The subject's actions
|
|
69
|
+
* @returns {array<object>}
|
|
70
|
+
*/
|
|
71
|
+
const createSubjectPermissions = (subject, actions) => {
|
|
72
|
+
const permissions = Object.entries(actions).reduce((acc, current) => {
|
|
73
|
+
const [actionName, permissions] = current;
|
|
74
|
+
const shouldCreatePermission = createArrayOfValues(permissions).some(val => val);
|
|
75
|
+
|
|
76
|
+
if (!shouldCreatePermission) {
|
|
77
|
+
return acc;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (!has(permissions, 'properties.enabled')) {
|
|
81
|
+
const createdPermissionsArray = createPermissionWithProperties(
|
|
82
|
+
actionName,
|
|
83
|
+
subject,
|
|
84
|
+
permissions
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return [...acc, createdPermissionsArray];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (!permissions.properties.enabled) {
|
|
91
|
+
return acc;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const permission = createPermissionWithoutProperties(actionName, subject, permissions);
|
|
95
|
+
|
|
96
|
+
acc.push(permission);
|
|
97
|
+
|
|
98
|
+
return acc;
|
|
99
|
+
}, []);
|
|
100
|
+
|
|
101
|
+
return permissions;
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
*
|
|
106
|
+
* @param {object} contentTypesPermissions
|
|
107
|
+
* @returns {array<object>}
|
|
108
|
+
*/
|
|
109
|
+
const formatContentTypesPermissionToAPI = contentTypesPermissions => {
|
|
110
|
+
const permissions = Object.entries(contentTypesPermissions).reduce((allPermissions, current) => {
|
|
111
|
+
const [subject, currentSubjectActions] = current;
|
|
112
|
+
|
|
113
|
+
const permissions = createSubjectPermissions(subject, currentSubjectActions);
|
|
114
|
+
|
|
115
|
+
return [...allPermissions, ...permissions];
|
|
116
|
+
}, []);
|
|
117
|
+
|
|
118
|
+
return permissions;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
export default formatContentTypesPermissionToAPI;
|
|
122
|
+
export { createPropertyArray, createPermissionWithProperties };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { chain } from 'lodash';
|
|
2
|
+
|
|
3
|
+
const replaceName = name => name.split(' ').join('-');
|
|
4
|
+
|
|
5
|
+
const formatLayout = (layout, groupByKey) => {
|
|
6
|
+
return chain(layout)
|
|
7
|
+
.groupBy(groupByKey)
|
|
8
|
+
.map((item, itemName) => ({
|
|
9
|
+
category: itemName,
|
|
10
|
+
categoryId: replaceName(itemName),
|
|
11
|
+
childrenForm: chain(item)
|
|
12
|
+
.groupBy('subCategory')
|
|
13
|
+
.map((actions, subCategoryName) => ({
|
|
14
|
+
subCategoryName,
|
|
15
|
+
subCategoryId: replaceName(subCategoryName),
|
|
16
|
+
actions,
|
|
17
|
+
}))
|
|
18
|
+
.value(),
|
|
19
|
+
}))
|
|
20
|
+
.value();
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default formatLayout;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import formatContentTypesPermissionToAPI from './formatContentTypesPermissionToAPI';
|
|
2
|
+
import formatSettingsPermissionsToAPI from './formatSettingsPermissionsToAPI';
|
|
3
|
+
|
|
4
|
+
const formatPermissionsToAPI = modifiedData => {
|
|
5
|
+
const pluginsPermissions = formatSettingsPermissionsToAPI(modifiedData.plugins);
|
|
6
|
+
const settingsPermissions = formatSettingsPermissionsToAPI(modifiedData.settings);
|
|
7
|
+
const collectionTypesPermissions = formatContentTypesPermissionToAPI(
|
|
8
|
+
modifiedData.collectionTypes
|
|
9
|
+
);
|
|
10
|
+
|
|
11
|
+
const singleTypesPermissions = formatContentTypesPermissionToAPI(modifiedData.singleTypes);
|
|
12
|
+
|
|
13
|
+
return [
|
|
14
|
+
...pluginsPermissions,
|
|
15
|
+
...settingsPermissions,
|
|
16
|
+
...collectionTypesPermissions,
|
|
17
|
+
...singleTypesPermissions,
|
|
18
|
+
];
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default formatPermissionsToAPI;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns an array of condition names when a condition is enabled
|
|
3
|
+
* @param {object} conditions
|
|
4
|
+
* @config {boolean}
|
|
5
|
+
*/
|
|
6
|
+
const createConditionsArray = conditions => {
|
|
7
|
+
return Object.entries(conditions)
|
|
8
|
+
.filter(([, conditionValue]) => {
|
|
9
|
+
return conditionValue;
|
|
10
|
+
})
|
|
11
|
+
.map(([conditionName]) => conditionName);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const createPermission = array => {
|
|
15
|
+
const [actionName, { conditions }] = array;
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
action: actionName,
|
|
19
|
+
subject: null,
|
|
20
|
+
conditions: createConditionsArray(conditions),
|
|
21
|
+
properties: {},
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const createPermissionsArrayFromCategory = categoryPermissions => {
|
|
26
|
+
return Object.values(categoryPermissions).reduce((acc, current) => {
|
|
27
|
+
const permissions = Object.entries(current).reduce((acc1, current1) => {
|
|
28
|
+
const [
|
|
29
|
+
,
|
|
30
|
+
{
|
|
31
|
+
properties: { enabled },
|
|
32
|
+
},
|
|
33
|
+
] = current1;
|
|
34
|
+
|
|
35
|
+
if (!enabled) {
|
|
36
|
+
return acc1;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const permission = createPermission(current1);
|
|
40
|
+
|
|
41
|
+
acc1.push(permission);
|
|
42
|
+
|
|
43
|
+
return acc1;
|
|
44
|
+
}, []);
|
|
45
|
+
|
|
46
|
+
return [...acc, ...permissions];
|
|
47
|
+
}, []);
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
const formatSettingsPermissionsToAPI = settingsPermissionsObject => {
|
|
51
|
+
return Object.values(settingsPermissionsObject).reduce((acc, current) => {
|
|
52
|
+
const currentCategoryPermissions = createPermissionsArrayFromCategory(current);
|
|
53
|
+
|
|
54
|
+
return [...acc, ...currentCategoryPermissions];
|
|
55
|
+
}, []);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
export default formatSettingsPermissionsToAPI;
|
|
59
|
+
export { createConditionsArray, createPermission, createPermissionsArrayFromCategory };
|