@akemona-org/strapi-plugin-content-manager 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 +27 -0
- package/admin/src/InjectedComponents/ContentTypeBuilder/ConfigureViewButton/index.js +78 -0
- package/admin/src/assets/images/background_input.svg +1 -0
- package/admin/src/assets/images/icon-cross-blue.svg +1 -0
- package/admin/src/assets/images/icon_remove.svg +19 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/AddDropdown/components.js +113 -0
- package/admin/src/components/AddDropdown/index.js +76 -0
- package/admin/src/components/Block/components.js +28 -0
- package/admin/src/components/Block/index.js +45 -0
- package/admin/src/components/ComponentInitializer/P.js +9 -0
- package/admin/src/components/ComponentInitializer/index.js +43 -0
- package/admin/src/components/Container/index.js +7 -0
- package/admin/src/components/CustomInputCheckbox/components.js +77 -0
- package/admin/src/components/CustomInputCheckbox/index.js +53 -0
- package/admin/src/components/CustomTable/ActionCollapse/Delete.js +14 -0
- package/admin/src/components/CustomTable/ActionCollapse/DeleteAll.js +18 -0
- package/admin/src/components/CustomTable/ActionCollapse/Wrapper.js +20 -0
- package/admin/src/components/CustomTable/ActionCollapse/index.js +38 -0
- package/admin/src/components/CustomTable/Headers/Header.js +59 -0
- package/admin/src/components/CustomTable/Headers/Thead.js +35 -0
- package/admin/src/components/CustomTable/Headers/index.js +46 -0
- package/admin/src/components/CustomTable/Row/ActionContainer.js +19 -0
- package/admin/src/components/CustomTable/Row/Cell.js +55 -0
- package/admin/src/components/CustomTable/Row/index.js +112 -0
- package/admin/src/components/CustomTable/index.js +162 -0
- package/admin/src/components/CustomTable/styledComponents.js +85 -0
- package/admin/src/components/DragLayer/index.js +102 -0
- package/admin/src/components/DraggedField/Close/index.js +10 -0
- package/admin/src/components/DraggedField/GrabWrapper.js +38 -0
- package/admin/src/components/DraggedField/Link.js +17 -0
- package/admin/src/components/DraggedField/NameWrapper.js +29 -0
- package/admin/src/components/DraggedField/RemoveWrapper.js +32 -0
- package/admin/src/components/DraggedField/SubWrapper.js +36 -0
- package/admin/src/components/DraggedField/Wrapper.js +134 -0
- package/admin/src/components/DraggedField/index.js +196 -0
- package/admin/src/components/DraggedField/utils/getColor.js +12 -0
- package/admin/src/components/DraggedField/utils/getHeight.js +3 -0
- package/admin/src/components/DraggedFieldWithPreview/Carret.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicComponent.js +70 -0
- package/admin/src/components/DraggedFieldWithPreview/DynamicZoneWrapper.js +10 -0
- package/admin/src/components/DraggedFieldWithPreview/Tooltip.js +19 -0
- package/admin/src/components/DraggedFieldWithPreview/Wrapper.js +24 -0
- package/admin/src/components/DraggedFieldWithPreview/index.js +194 -0
- package/admin/src/components/DynamicComponentCard/Wrapper.js +63 -0
- package/admin/src/components/DynamicComponentCard/index.js +49 -0
- package/admin/src/components/DynamicZone/BaselineAlignement.js +11 -0
- package/admin/src/components/DynamicZone/Button.js +31 -0
- package/admin/src/components/DynamicZone/Component/RoundCTA.js +45 -0
- package/admin/src/components/DynamicZone/Component/index.js +79 -0
- package/admin/src/components/DynamicZone/ComponentWrapper.js +44 -0
- package/admin/src/components/DynamicZone/DynamicZoneWrapper.js +12 -0
- package/admin/src/components/DynamicZone/Label.js +42 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/Wrapper.js +78 -0
- package/admin/src/components/DynamicZone/Picker/Category/Banner/index.js +33 -0
- package/admin/src/components/DynamicZone/Picker/Category/index.js +53 -0
- package/admin/src/components/DynamicZone/Picker/Wrapper.js +32 -0
- package/admin/src/components/DynamicZone/Picker/index.js +88 -0
- package/admin/src/components/DynamicZone/Wrapper.js +34 -0
- package/admin/src/components/DynamicZone/index.js +238 -0
- package/admin/src/components/DynamicZone/utils/connect.js +12 -0
- package/admin/src/components/DynamicZone/utils/select.js +49 -0
- package/admin/src/components/FieldComponent/ComponentIcon.js +44 -0
- package/admin/src/components/FieldComponent/EmptyComponent.js +19 -0
- package/admin/src/components/FieldComponent/Label.js +10 -0
- package/admin/src/components/FieldComponent/ResetComponent.js +41 -0
- package/admin/src/components/FieldComponent/Wrapper.js +18 -0
- package/admin/src/components/FieldComponent/index.js +171 -0
- package/admin/src/components/FieldComponent/utils/connect.js +12 -0
- package/admin/src/components/FieldComponent/utils/select.js +123 -0
- package/admin/src/components/FieldsReorder/Item.js +249 -0
- package/admin/src/components/FieldsReorder/components.js +8 -0
- package/admin/src/components/FieldsReorder/index.js +102 -0
- package/admin/src/components/FilterOptionsCTA/index.js +14 -0
- package/admin/src/components/FilterPicker/components.js +56 -0
- package/admin/src/components/FilterPicker/index.js +258 -0
- package/admin/src/components/FilterPicker/init.js +25 -0
- package/admin/src/components/FilterPicker/reducer.js +58 -0
- package/admin/src/components/FilterPickerOption/Input.js +58 -0
- package/admin/src/components/FilterPickerOption/Option.js +18 -0
- package/admin/src/components/FilterPickerOption/components.js +60 -0
- package/admin/src/components/FilterPickerOption/index.js +101 -0
- package/admin/src/components/FormTitle/index.js +26 -0
- package/admin/src/components/FormWrapper/index.js +20 -0
- package/admin/src/components/InputJSON/components.js +30 -0
- package/admin/src/components/InputJSON/index.js +184 -0
- package/admin/src/components/InputJSON/jsonlint.js +424 -0
- package/admin/src/components/InputJSONWithErrors/Wrapper.js +32 -0
- package/admin/src/components/InputJSONWithErrors/index.js +168 -0
- package/admin/src/components/InputUID/InputUID.js +26 -0
- package/admin/src/components/InputUID/Options/Option.js +22 -0
- package/admin/src/components/InputUID/Options/OptionsTitle.js +12 -0
- package/admin/src/components/InputUID/Options/RightOptionLabel.js +10 -0
- package/admin/src/components/InputUID/Options/index.js +34 -0
- package/admin/src/components/InputUID/Options/wrapper.js +13 -0
- package/admin/src/components/InputUID/RegenerateButton.js +18 -0
- package/admin/src/components/InputUID/RightContent.js +14 -0
- package/admin/src/components/InputUID/RightContentLabel.js +10 -0
- package/admin/src/components/InputUID/RightLabel.js +42 -0
- package/admin/src/components/InputUID/SubLabel.js +9 -0
- package/admin/src/components/InputUID/Wrapper.js +8 -0
- package/admin/src/components/InputUID/index.js +325 -0
- package/admin/src/components/InputUID/regex.js +3 -0
- package/admin/src/components/Inputs/index.js +283 -0
- package/admin/src/components/Inputs/utils/VALIDATIONS_TO_OMIT.js +12 -0
- package/admin/src/components/Inputs/utils/connect.js +12 -0
- package/admin/src/components/Inputs/utils/generateOptions.js +19 -0
- package/admin/src/components/Inputs/utils/getInputType.js +44 -0
- package/admin/src/components/Inputs/utils/getStep.js +15 -0
- package/admin/src/components/Inputs/utils/index.js +6 -0
- package/admin/src/components/Inputs/utils/select.js +38 -0
- package/admin/src/components/LayoutTitle/index.js +19 -0
- package/admin/src/components/MediaPreviewList/StyledMediaPreviewList.js +171 -0
- package/admin/src/components/MediaPreviewList/index.js +110 -0
- package/admin/src/components/NonRepeatableComponent/index.js +73 -0
- package/admin/src/components/NonRepeatableWrapper/index.js +73 -0
- package/admin/src/components/PlusButton/index.js +52 -0
- package/admin/src/components/PopupForm/index.js +93 -0
- package/admin/src/components/PreviewCarret/components.js +27 -0
- package/admin/src/components/PreviewCarret/index.js +22 -0
- package/admin/src/components/PreviewWysiwyg/Wrapper.js +133 -0
- package/admin/src/components/PreviewWysiwyg/index.js +34 -0
- package/admin/src/components/PreviewWysiwyg/utils/mdRenderer.js +72 -0
- package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +16 -0
- package/admin/src/components/RelationPreviewList/CountWrapper.js +7 -0
- package/admin/src/components/RelationPreviewList/RelationPreviewTooltip.js +117 -0
- package/admin/src/components/RelationPreviewList/index.js +111 -0
- package/admin/src/components/RepeatableComponent/AddFieldButton.js +64 -0
- package/admin/src/components/RepeatableComponent/Banner.js +112 -0
- package/admin/src/components/RepeatableComponent/BannerWrapper.js +194 -0
- package/admin/src/components/RepeatableComponent/CarretTop.js +14 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/index.js +245 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/index.js +2 -0
- package/admin/src/components/RepeatableComponent/DraggedItem/utils/select.js +30 -0
- package/admin/src/components/RepeatableComponent/EmptyComponent.js +27 -0
- package/admin/src/components/RepeatableComponent/FormWrapper.js +27 -0
- package/admin/src/components/RepeatableComponent/index.js +187 -0
- package/admin/src/components/RepeatableComponent/reducer.js +73 -0
- package/admin/src/components/RepeatableComponent/utils/connect.js +11 -0
- package/admin/src/components/RepeatableComponent/utils/select.js +12 -0
- package/admin/src/components/Search/index.js +88 -0
- package/admin/src/components/SectionTitle/Title.js +11 -0
- package/admin/src/components/SectionTitle/index.js +29 -0
- package/admin/src/components/SelectMany/ListItem.js +107 -0
- package/admin/src/components/SelectMany/Relation.js +106 -0
- package/admin/src/components/SelectMany/components.js +153 -0
- package/admin/src/components/SelectMany/index.js +159 -0
- package/admin/src/components/SelectOne/SingleValue.js +58 -0
- package/admin/src/components/SelectOne/index.js +71 -0
- package/admin/src/components/SelectWrapper/ClearIndicator.js +15 -0
- package/admin/src/components/SelectWrapper/IndicatorSeparator.js +3 -0
- package/admin/src/components/SelectWrapper/Option.js +76 -0
- package/admin/src/components/SelectWrapper/components.js +14 -0
- package/admin/src/components/SelectWrapper/index.js +393 -0
- package/admin/src/components/SelectWrapper/utils/connect.js +12 -0
- package/admin/src/components/SelectWrapper/utils/index.js +3 -0
- package/admin/src/components/SelectWrapper/utils/select.js +45 -0
- package/admin/src/components/SelectWrapper/utils/styles.js +105 -0
- package/admin/src/components/Separator/index.js +9 -0
- package/admin/src/components/SettingFormWrapper/index.js +9 -0
- package/admin/src/components/SettingsViewWrapper/index.js +283 -0
- package/admin/src/components/SortWrapper/index.js +9 -0
- package/admin/src/components/SortableList/Item.js +126 -0
- package/admin/src/components/SortableList/index.js +60 -0
- package/admin/src/components/State/Wrapper.js +30 -0
- package/admin/src/components/State/index.js +26 -0
- package/admin/src/components/Truncate/index.js +5 -0
- package/admin/src/components/Truncated/index.js +10 -0
- package/admin/src/components/Wysiwyg/EditorWrapper.js +122 -0
- package/admin/src/components/Wysiwyg/MediaLib.js +71 -0
- package/admin/src/components/Wysiwyg/PreviewControlWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/SelectWrapper.js +24 -0
- package/admin/src/components/Wysiwyg/ToggleModeWrapper.js +30 -0
- package/admin/src/components/Wysiwyg/constants.js +98 -0
- package/admin/src/components/Wysiwyg/customSelect.js +39 -0
- package/admin/src/components/Wysiwyg/helpers.js +116 -0
- package/admin/src/components/Wysiwyg/index.js +819 -0
- package/admin/src/components/Wysiwyg/previewControl.js +29 -0
- package/admin/src/components/Wysiwyg/toggleMode.js +44 -0
- package/admin/src/components/Wysiwyg/utils.js +70 -0
- package/admin/src/components/WysiwygBottomControls/components.js +44 -0
- package/admin/src/components/WysiwygBottomControls/index.js +33 -0
- package/admin/src/components/WysiwygDropUpload/Label.js +16 -0
- package/admin/src/components/WysiwygDropUpload/index.js +18 -0
- package/admin/src/components/WysiwygEditor/index.js +26 -0
- package/admin/src/components/WysiwygInlineControls/Button.js +77 -0
- package/admin/src/components/WysiwygInlineControls/StyledButton.js +54 -0
- package/admin/src/components/WysiwygInlineControls/Wrapper.js +25 -0
- package/admin/src/components/WysiwygInlineControls/index.js +66 -0
- package/admin/src/components/WysiwygWithErrors/Wrapper.js +38 -0
- package/admin/src/components/WysiwygWithErrors/index.js +158 -0
- package/admin/src/containers/CollectionTypeFormWrapper/index.js +376 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/CollectionTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/CollectionTypeRecursivePath/index.js +125 -0
- package/admin/src/containers/ComponentSetttingsView/index.js +55 -0
- package/admin/src/containers/EditSettingsView/index.js +408 -0
- package/admin/src/containers/EditSettingsView/init.js +18 -0
- package/admin/src/containers/EditSettingsView/reducer.js +126 -0
- package/admin/src/containers/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +26 -0
- package/admin/src/containers/EditSettingsView/utils/getInputProps.js +30 -0
- package/admin/src/containers/EditSettingsView/utils/index.js +2 -0
- package/admin/src/containers/EditSettingsView/utils/layout.js +98 -0
- package/admin/src/containers/EditView/DeleteLink/index.js +94 -0
- package/admin/src/containers/EditView/DeleteLink/utils/connect.js +12 -0
- package/admin/src/containers/EditView/DeleteLink/utils/index.js +2 -0
- package/admin/src/containers/EditView/DeleteLink/utils/select.js +21 -0
- package/admin/src/containers/EditView/Header/index.js +258 -0
- package/admin/src/containers/EditView/Header/utils/connect.js +12 -0
- package/admin/src/containers/EditView/Header/utils/getDraftRelations.js +62 -0
- package/admin/src/containers/EditView/Header/utils/index.js +3 -0
- package/admin/src/containers/EditView/Header/utils/select.js +31 -0
- package/admin/src/containers/EditView/InformationCard.js +100 -0
- package/admin/src/containers/EditView/components.js +74 -0
- package/admin/src/containers/EditView/index.js +297 -0
- package/admin/src/containers/EditView/utils/createAttributesLayout.js +39 -0
- package/admin/src/containers/EditView/utils/getFieldsActionMatchingPermissions.js +23 -0
- package/admin/src/containers/EditView/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/index.js +519 -0
- package/admin/src/containers/EditViewDataManagerProvider/reducer.js +218 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/cleanData.js +88 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/getYupInnerErrors.js +17 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/index.js +3 -0
- package/admin/src/containers/EditViewDataManagerProvider/utils/schema.js +368 -0
- package/admin/src/containers/EditViewLayoutManager/Permissions.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/actions.js +9 -0
- package/admin/src/containers/EditViewLayoutManager/constants.js +2 -0
- package/admin/src/containers/EditViewLayoutManager/index.js +44 -0
- package/admin/src/containers/EditViewLayoutManager/reducer.js +30 -0
- package/admin/src/containers/EditViewLayoutManager/selectors.js +5 -0
- package/admin/src/containers/LayoutDndProvider/index.js +75 -0
- package/admin/src/containers/ListSettingsView/DragWrapper.js +21 -0
- package/admin/src/containers/ListSettingsView/DropdownButton.js +8 -0
- package/admin/src/containers/ListSettingsView/Label.js +91 -0
- package/admin/src/containers/ListSettingsView/MenuDropdown.js +41 -0
- package/admin/src/containers/ListSettingsView/Toggle.js +51 -0
- package/admin/src/containers/ListSettingsView/forms.json +64 -0
- package/admin/src/containers/ListSettingsView/index.js +298 -0
- package/admin/src/containers/ListSettingsView/init.js +11 -0
- package/admin/src/containers/ListSettingsView/reducer.js +77 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/StyledLink.js +28 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/Wrapper.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/ConfigureLink/index.js +29 -0
- package/admin/src/containers/ListView/FieldPicker/Field/Wrapper.js +15 -0
- package/admin/src/containers/ListView/FieldPicker/Field/index.js +24 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/Wrapper.js +18 -0
- package/admin/src/containers/ListView/FieldPicker/Fields/index.js +27 -0
- package/admin/src/containers/ListView/FieldPicker/Header/Reset.js +8 -0
- package/admin/src/containers/ListView/FieldPicker/Header/index.js +42 -0
- package/admin/src/containers/ListView/FieldPicker/Wrapper.js +9 -0
- package/admin/src/containers/ListView/FieldPicker/index.js +46 -0
- package/admin/src/containers/ListView/Filter.js +83 -0
- package/admin/src/containers/ListView/Footer.js +60 -0
- package/admin/src/containers/ListView/actions.js +91 -0
- package/admin/src/containers/ListView/components.js +138 -0
- package/admin/src/containers/ListView/constants.js +16 -0
- package/admin/src/containers/ListView/index.js +573 -0
- package/admin/src/containers/ListView/reducer.js +182 -0
- package/admin/src/containers/ListView/selectors.js +24 -0
- package/admin/src/containers/ListView/utils/buildQueryString.js +26 -0
- package/admin/src/containers/ListView/utils/createPluginsFilter.js +13 -0
- package/admin/src/containers/ListView/utils/getAllAllowedHeaders.js +17 -0
- package/admin/src/containers/ListView/utils/getFirstSortableHeader.js +14 -0
- package/admin/src/containers/ListView/utils/index.js +3 -0
- package/admin/src/containers/ListViewLayoutManager/Permissions.js +29 -0
- package/admin/src/containers/ListViewLayoutManager/index.js +60 -0
- package/admin/src/containers/ListViewProvider/index.js +16 -0
- package/admin/src/containers/Main/actions.js +13 -0
- package/admin/src/containers/Main/constants.js +3 -0
- package/admin/src/containers/Main/index.js +100 -0
- package/admin/src/containers/Main/reducer.js +37 -0
- package/admin/src/containers/Main/selectors.js +20 -0
- package/admin/src/containers/RBACManager/actions.js +14 -0
- package/admin/src/containers/RBACManager/constants.js +2 -0
- package/admin/src/containers/RBACManager/reducer.js +32 -0
- package/admin/src/containers/RBACManager/useSyncRbac.js +28 -0
- package/admin/src/containers/SingleTypeFormWrapper/index.js +317 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/getRequestUrl.js +5 -0
- package/admin/src/containers/SingleTypeFormWrapper/utils/index.js +2 -0
- package/admin/src/containers/SingleTypeRecursivePath/index.js +84 -0
- package/admin/src/containers/WysiwygProvider/index.js +16 -0
- package/admin/src/contexts/ContentTypeLayout.js +5 -0
- package/admin/src/contexts/LayoutDnd.js +5 -0
- package/admin/src/contexts/ListView.js +5 -0
- package/admin/src/contexts/Wysiwyg.js +5 -0
- package/admin/src/contexts/index.js +4 -0
- package/admin/src/hooks/index.js +6 -0
- package/admin/src/hooks/useContentTypeLayout/index.js +19 -0
- package/admin/src/hooks/useFetchContentTypeLayout/index.js +83 -0
- package/admin/src/hooks/useFetchContentTypeLayout/reducer.js +56 -0
- package/admin/src/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +235 -0
- package/admin/src/hooks/useFindRedirectionLink/index.js +14 -0
- package/admin/src/hooks/useFindRedirectionLink/selectors.js +7 -0
- package/admin/src/hooks/useFindRedirectionLink/utils/getRedirectionLink.js +45 -0
- package/admin/src/hooks/useLayoutDnd.js +6 -0
- package/admin/src/hooks/useListView.js +6 -0
- package/admin/src/hooks/useWysiwyg.js +6 -0
- package/admin/src/icons/Bold/index.js +22 -0
- package/admin/src/icons/Code/index.js +13 -0
- package/admin/src/icons/Cross/index.js +33 -0
- package/admin/src/icons/Italic/index.js +23 -0
- package/admin/src/icons/Link/index.js +21 -0
- package/admin/src/icons/Media/index.js +14 -0
- package/admin/src/icons/Na/index.js +58 -0
- package/admin/src/icons/Ol/index.js +13 -0
- package/admin/src/icons/Quote/index.js +13 -0
- package/admin/src/icons/Striked/index.js +24 -0
- package/admin/src/icons/Ul/index.js +15 -0
- package/admin/src/icons/Underline/index.js +22 -0
- package/admin/src/index.js +52 -0
- package/admin/src/lifecycles.js +19 -0
- package/admin/src/permissions.js +27 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/reducers.js +16 -0
- package/admin/src/selectors.js +6 -0
- package/admin/src/sharedReducers/crudReducer/actions.js +44 -0
- package/admin/src/sharedReducers/crudReducer/constants.js +7 -0
- package/admin/src/sharedReducers/crudReducer/reducer.js +75 -0
- package/admin/src/sharedReducers/crudReducer/selectors.js +5 -0
- package/admin/src/testUtils/data.js +305 -0
- package/admin/src/testUtils/index.js +4 -0
- package/admin/src/translations/ar.json +94 -0
- package/admin/src/translations/cs.json +130 -0
- package/admin/src/translations/de.json +177 -0
- package/admin/src/translations/dk.json +180 -0
- package/admin/src/translations/en.json +177 -0
- package/admin/src/translations/es.json +177 -0
- package/admin/src/translations/fr.json +162 -0
- package/admin/src/translations/id.json +175 -0
- package/admin/src/translations/index.js +53 -0
- package/admin/src/translations/it.json +177 -0
- package/admin/src/translations/ja.json +94 -0
- package/admin/src/translations/ko.json +110 -0
- package/admin/src/translations/ms.json +148 -0
- package/admin/src/translations/nl.json +94 -0
- package/admin/src/translations/pl.json +142 -0
- package/admin/src/translations/pt-BR.json +94 -0
- package/admin/src/translations/pt.json +94 -0
- package/admin/src/translations/ru.json +177 -0
- package/admin/src/translations/sk.json +172 -0
- package/admin/src/translations/th.json +155 -0
- package/admin/src/translations/tr.json +177 -0
- package/admin/src/translations/uk.json +148 -0
- package/admin/src/translations/vi.json +110 -0
- package/admin/src/translations/zh-Hans.json +177 -0
- package/admin/src/translations/zh.json +94 -0
- package/admin/src/utils/ItemTypes.js +7 -0
- package/admin/src/utils/checkIfAttributeIsDisplayable.js +13 -0
- package/admin/src/utils/createDefaultForm.js +50 -0
- package/admin/src/utils/dateFormats.js +18 -0
- package/admin/src/utils/formatFiltersFromQuery.js +55 -0
- package/admin/src/utils/formatFiltersToQuery.js +27 -0
- package/admin/src/utils/formatLayoutToApi.js +44 -0
- package/admin/src/utils/generatePermissionsObject.js +20 -0
- package/admin/src/utils/getComponents.js +50 -0
- package/admin/src/utils/getDisplayedValue.js +61 -0
- package/admin/src/utils/getFieldName.js +6 -0
- package/admin/src/utils/getMaxTempKey.js +12 -0
- package/admin/src/utils/getRequestUrl.js +5 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/index.js +17 -0
- package/admin/src/utils/mergeMetasWithSchema.js +20 -0
- package/admin/src/utils/removeKeyInObject.js +45 -0
- package/admin/src/utils/removePasswordFieldsFromData.js +54 -0
- package/config/admin.json +5 -0
- package/config/functions/bootstrap.js +9 -0
- package/config/policies/has-draft-and-publish.js +19 -0
- package/config/policies/hasPermissions.js +34 -0
- package/config/policies/routing.js +27 -0
- package/config/routes.json +275 -0
- package/controllers/collection-types.js +282 -0
- package/controllers/components.js +66 -0
- package/controllers/content-types.js +112 -0
- package/controllers/relations.js +63 -0
- package/controllers/single-types.js +170 -0
- package/controllers/uid.js +41 -0
- package/controllers/validation/index.js +104 -0
- package/controllers/validation/model-configuration.js +114 -0
- package/oas.yml +757 -0
- package/package.json +77 -0
- package/services/components.js +92 -0
- package/services/configuration.js +79 -0
- package/services/content-types.js +73 -0
- package/services/data-mapper.js +98 -0
- package/services/entity-manager.js +140 -0
- package/services/metrics.js +34 -0
- package/services/permission-checker.js +69 -0
- package/services/permission.js +95 -0
- package/services/uid.js +63 -0
- package/services/utils/configuration/attributes.js +175 -0
- package/services/utils/configuration/index.js +43 -0
- package/services/utils/configuration/layouts.js +185 -0
- package/services/utils/configuration/metadatas.js +142 -0
- package/services/utils/configuration/settings.js +52 -0
- package/services/utils/store.js +93 -0
- package/utils/index.js +16 -0
- package/utils/pick-writable-attributes.js +6 -0
- package/utils/wrap-bad-request.js +15 -0
- package/validation/policies/hasPermissions.js +17 -0
|
@@ -0,0 +1,408 @@
|
|
|
1
|
+
import React, { useCallback, useMemo, useReducer, useState } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { useHistory } from 'react-router-dom';
|
|
4
|
+
import { useSelector, shallowEqual } from 'react-redux';
|
|
5
|
+
import { cloneDeep, flatMap, get, set, pick } from 'lodash';
|
|
6
|
+
import { request, useGlobalContext } from 'strapi-helper-plugin';
|
|
7
|
+
import { Inputs as Input } from '@buffetjs/custom';
|
|
8
|
+
import { FormattedMessage } from 'react-intl';
|
|
9
|
+
import pluginId from '../../pluginId';
|
|
10
|
+
import { getInjectedComponents, getRequestUrl } from '../../utils';
|
|
11
|
+
import FieldsReorder from '../../components/FieldsReorder';
|
|
12
|
+
import FormTitle from '../../components/FormTitle';
|
|
13
|
+
import LayoutTitle from '../../components/LayoutTitle';
|
|
14
|
+
import PopupForm from '../../components/PopupForm';
|
|
15
|
+
import SettingsViewWrapper from '../../components/SettingsViewWrapper';
|
|
16
|
+
import SortableList from '../../components/SortableList';
|
|
17
|
+
import { makeSelectModelAndComponentSchemas } from '../Main/selectors';
|
|
18
|
+
import LayoutDndProvider from '../LayoutDndProvider';
|
|
19
|
+
import init from './init';
|
|
20
|
+
import reducer, { initialState } from './reducer';
|
|
21
|
+
import { createPossibleMainFieldsForModelsAndComponents, getInputProps } from './utils';
|
|
22
|
+
import { unformatLayout } from './utils/layout';
|
|
23
|
+
|
|
24
|
+
const EditSettingsView = ({ components, mainLayout, isContentTypeView, slug, updateLayout }) => {
|
|
25
|
+
const { push } = useHistory();
|
|
26
|
+
const { currentEnvironment, emitEvent, plugins } = useGlobalContext();
|
|
27
|
+
|
|
28
|
+
const [reducerState, dispatch] = useReducer(reducer, initialState, () =>
|
|
29
|
+
init(initialState, mainLayout, components)
|
|
30
|
+
);
|
|
31
|
+
const [isModalFormOpen, setIsModalFormOpen] = useState(false);
|
|
32
|
+
const [isDraggingSibling, setIsDraggingSibling] = useState(false);
|
|
33
|
+
|
|
34
|
+
const schemasSelector = useMemo(makeSelectModelAndComponentSchemas, []);
|
|
35
|
+
const { schemas } = useSelector(state => schemasSelector(state), shallowEqual);
|
|
36
|
+
|
|
37
|
+
const { componentLayouts, initialData, metaToEdit, modifiedData, metaForm } = reducerState.toJS();
|
|
38
|
+
|
|
39
|
+
const componentsAndModelsPossibleMainFields = useMemo(() => {
|
|
40
|
+
return createPossibleMainFieldsForModelsAndComponents(schemas);
|
|
41
|
+
}, [schemas]);
|
|
42
|
+
|
|
43
|
+
const fieldsReorderClassName = isContentTypeView ? 'col-8' : 'col-12';
|
|
44
|
+
|
|
45
|
+
const attributes = useMemo(() => get(modifiedData, 'attributes', {}), [modifiedData]);
|
|
46
|
+
const editLayout = modifiedData.layouts.edit;
|
|
47
|
+
const relationsLayout = modifiedData.layouts.editRelations;
|
|
48
|
+
const editRelationsLayoutRemainingFields = useMemo(() => {
|
|
49
|
+
return Object.keys(attributes)
|
|
50
|
+
.filter(attr => attributes[attr].type === 'relation')
|
|
51
|
+
.filter(attr => relationsLayout.indexOf(attr) === -1);
|
|
52
|
+
}, [attributes, relationsLayout]);
|
|
53
|
+
|
|
54
|
+
const formToDisplay = useMemo(() => {
|
|
55
|
+
if (!metaToEdit) {
|
|
56
|
+
return [];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const associatedMetas = get(modifiedData, ['metadatas', metaToEdit, 'edit'], {});
|
|
60
|
+
|
|
61
|
+
return Object.keys(associatedMetas).filter(meta => meta !== 'visible');
|
|
62
|
+
}, [metaToEdit, modifiedData]);
|
|
63
|
+
|
|
64
|
+
const editLayoutRemainingFields = useMemo(() => {
|
|
65
|
+
const displayedFields = flatMap(modifiedData.layouts.edit, 'rowContent');
|
|
66
|
+
|
|
67
|
+
return Object.keys(modifiedData.attributes)
|
|
68
|
+
.filter(attr => {
|
|
69
|
+
if (!isContentTypeView) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return get(modifiedData, ['attributes', attr, 'type'], '') !== 'relation';
|
|
74
|
+
})
|
|
75
|
+
.filter(attr => get(modifiedData, ['metadatas', attr, 'edit', 'visible'], false) === true)
|
|
76
|
+
.filter(attr => {
|
|
77
|
+
return displayedFields.findIndex(el => el.name === attr) === -1;
|
|
78
|
+
})
|
|
79
|
+
.sort();
|
|
80
|
+
}, [isContentTypeView, modifiedData]);
|
|
81
|
+
|
|
82
|
+
const getSelectedItemSelectOptions = useCallback(
|
|
83
|
+
formType => {
|
|
84
|
+
if (formType !== 'relation' && formType !== 'component') {
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const targetKey = formType === 'component' ? 'component' : 'targetModel';
|
|
89
|
+
const key = get(modifiedData, ['attributes', metaToEdit, targetKey], '');
|
|
90
|
+
|
|
91
|
+
return get(componentsAndModelsPossibleMainFields, [key], []);
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
[metaToEdit, componentsAndModelsPossibleMainFields, modifiedData]
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
const handleChange = ({ target: { name, value } }) => {
|
|
98
|
+
dispatch({
|
|
99
|
+
type: 'ON_CHANGE',
|
|
100
|
+
keys: name.split('.'),
|
|
101
|
+
value,
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const handleChangeMeta = ({ target: { name, value } }) => {
|
|
106
|
+
dispatch({
|
|
107
|
+
type: 'ON_CHANGE_META',
|
|
108
|
+
keys: name.split('.'),
|
|
109
|
+
value,
|
|
110
|
+
});
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const handleConfirm = async () => {
|
|
114
|
+
try {
|
|
115
|
+
const body = pick(cloneDeep(modifiedData), ['layouts', 'metadatas', 'settings']);
|
|
116
|
+
|
|
117
|
+
// We need to send the unformated edit layout
|
|
118
|
+
set(body, 'layouts.edit', unformatLayout(body.layouts.edit));
|
|
119
|
+
|
|
120
|
+
const requestURL = isContentTypeView
|
|
121
|
+
? getRequestUrl(`content-types/${slug}/configuration`)
|
|
122
|
+
: getRequestUrl(`components/${slug}/configuration`);
|
|
123
|
+
|
|
124
|
+
const response = await request(requestURL, { method: 'PUT', body });
|
|
125
|
+
|
|
126
|
+
if (updateLayout) {
|
|
127
|
+
updateLayout(response.data);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
dispatch({
|
|
131
|
+
type: 'SUBMIT_SUCCEEDED',
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
emitEvent('didEditEditSettings');
|
|
135
|
+
} catch (err) {
|
|
136
|
+
strapi.notification.error('notification.error');
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const handleSubmitMetaForm = e => {
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
dispatch({
|
|
143
|
+
type: 'SUBMIT_META_FORM',
|
|
144
|
+
});
|
|
145
|
+
toggleModalForm();
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const moveItem = (dragIndex, hoverIndex, dragRowIndex, hoverRowIndex) => {
|
|
149
|
+
// Same row = just reorder
|
|
150
|
+
if (dragRowIndex === hoverRowIndex) {
|
|
151
|
+
dispatch({
|
|
152
|
+
type: 'REORDER_ROW',
|
|
153
|
+
dragRowIndex,
|
|
154
|
+
dragIndex,
|
|
155
|
+
hoverIndex,
|
|
156
|
+
});
|
|
157
|
+
} else {
|
|
158
|
+
dispatch({
|
|
159
|
+
type: 'REORDER_DIFF_ROW',
|
|
160
|
+
dragIndex,
|
|
161
|
+
hoverIndex,
|
|
162
|
+
dragRowIndex,
|
|
163
|
+
hoverRowIndex,
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const moveRow = (dragRowIndex, hoverRowIndex) => {
|
|
169
|
+
dispatch({
|
|
170
|
+
type: 'MOVE_ROW',
|
|
171
|
+
dragRowIndex,
|
|
172
|
+
hoverRowIndex,
|
|
173
|
+
});
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
const toggleModalForm = () => {
|
|
177
|
+
setIsModalFormOpen(prevState => !prevState);
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
const renderForm = () =>
|
|
181
|
+
formToDisplay.map((meta, index) => {
|
|
182
|
+
const formType = get(attributes, [metaToEdit, 'type']);
|
|
183
|
+
|
|
184
|
+
if (formType === 'dynamiczone' && !['label', 'description'].includes(meta)) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if ((formType === 'component' || formType === 'media') && meta !== 'label') {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if ((formType === 'json' || formType === 'boolean') && meta === 'placeholder') {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
if (formType === 'richtext' && meta === 'editable') {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<div className="col-6" key={meta}>
|
|
202
|
+
<FormattedMessage
|
|
203
|
+
id={`${pluginId}.containers.SettingPage.editSettings.relation-field.description`}
|
|
204
|
+
>
|
|
205
|
+
{description => (
|
|
206
|
+
<FormattedMessage
|
|
207
|
+
id={get(getInputProps(meta), 'label.id', 'app.utils.defaultMessage')}
|
|
208
|
+
>
|
|
209
|
+
{label => (
|
|
210
|
+
<Input
|
|
211
|
+
autoFocus={index === 0}
|
|
212
|
+
description={meta === 'mainField' ? description : ''}
|
|
213
|
+
label={label}
|
|
214
|
+
name={meta}
|
|
215
|
+
type={getInputProps(meta).type}
|
|
216
|
+
value={get(metaForm, meta, '')}
|
|
217
|
+
onChange={handleChangeMeta}
|
|
218
|
+
options={getSelectedItemSelectOptions(formType)}
|
|
219
|
+
/>
|
|
220
|
+
)}
|
|
221
|
+
</FormattedMessage>
|
|
222
|
+
)}
|
|
223
|
+
</FormattedMessage>
|
|
224
|
+
</div>
|
|
225
|
+
);
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
return (
|
|
229
|
+
<LayoutDndProvider
|
|
230
|
+
attributes={attributes}
|
|
231
|
+
buttonData={editLayoutRemainingFields}
|
|
232
|
+
componentLayouts={componentLayouts}
|
|
233
|
+
goTo={push}
|
|
234
|
+
isDraggingSibling={isDraggingSibling}
|
|
235
|
+
layout={editLayout}
|
|
236
|
+
metadatas={get(modifiedData, ['metadatas'], {})}
|
|
237
|
+
moveItem={moveItem}
|
|
238
|
+
moveRow={moveRow}
|
|
239
|
+
onAddData={name => {
|
|
240
|
+
dispatch({
|
|
241
|
+
type: 'ON_ADD_DATA',
|
|
242
|
+
name,
|
|
243
|
+
});
|
|
244
|
+
}}
|
|
245
|
+
relationsLayout={relationsLayout}
|
|
246
|
+
removeField={(rowIndex, fieldIndex) => {
|
|
247
|
+
dispatch({
|
|
248
|
+
type: 'REMOVE_FIELD',
|
|
249
|
+
rowIndex,
|
|
250
|
+
fieldIndex,
|
|
251
|
+
});
|
|
252
|
+
}}
|
|
253
|
+
setEditFieldToSelect={name => {
|
|
254
|
+
dispatch({
|
|
255
|
+
type: 'SET_FIELD_TO_EDIT',
|
|
256
|
+
name,
|
|
257
|
+
});
|
|
258
|
+
toggleModalForm();
|
|
259
|
+
}}
|
|
260
|
+
setIsDraggingSibling={setIsDraggingSibling}
|
|
261
|
+
selectedItemName={metaToEdit}
|
|
262
|
+
>
|
|
263
|
+
<SettingsViewWrapper
|
|
264
|
+
inputs={[
|
|
265
|
+
{
|
|
266
|
+
label: {
|
|
267
|
+
id: `${pluginId}.containers.SettingPage.editSettings.entry.title`,
|
|
268
|
+
},
|
|
269
|
+
description: {
|
|
270
|
+
id: `${pluginId}.containers.SettingPage.editSettings.entry.title.description`,
|
|
271
|
+
},
|
|
272
|
+
type: 'select',
|
|
273
|
+
name: 'settings.mainField',
|
|
274
|
+
customBootstrapClass: 'col-md-4',
|
|
275
|
+
selectOptions: ['id'],
|
|
276
|
+
didCheckErrors: false,
|
|
277
|
+
validations: {},
|
|
278
|
+
},
|
|
279
|
+
]}
|
|
280
|
+
initialData={initialData}
|
|
281
|
+
isLoading={false}
|
|
282
|
+
modifiedData={modifiedData}
|
|
283
|
+
name={modifiedData.info.name}
|
|
284
|
+
onChange={handleChange}
|
|
285
|
+
onConfirmReset={() => {
|
|
286
|
+
dispatch({
|
|
287
|
+
type: 'ON_RESET',
|
|
288
|
+
});
|
|
289
|
+
}}
|
|
290
|
+
onConfirmSubmit={handleConfirm}
|
|
291
|
+
slug={slug}
|
|
292
|
+
isEditSettings
|
|
293
|
+
>
|
|
294
|
+
<div className="row">
|
|
295
|
+
<LayoutTitle className={fieldsReorderClassName}>
|
|
296
|
+
<div
|
|
297
|
+
style={{
|
|
298
|
+
display: 'flex',
|
|
299
|
+
justifyContent: 'space-between',
|
|
300
|
+
}}
|
|
301
|
+
>
|
|
302
|
+
<div>
|
|
303
|
+
<FormTitle
|
|
304
|
+
title={`${pluginId}.global.displayedFields`}
|
|
305
|
+
description={`${pluginId}.containers.SettingPage.editSettings.description`}
|
|
306
|
+
/>
|
|
307
|
+
</div>
|
|
308
|
+
<div
|
|
309
|
+
style={{
|
|
310
|
+
marginTop: -6,
|
|
311
|
+
}}
|
|
312
|
+
>
|
|
313
|
+
{getInjectedComponents(
|
|
314
|
+
'editSettingsView',
|
|
315
|
+
'left.links',
|
|
316
|
+
plugins,
|
|
317
|
+
currentEnvironment,
|
|
318
|
+
slug,
|
|
319
|
+
push,
|
|
320
|
+
{
|
|
321
|
+
componentSlug: slug,
|
|
322
|
+
type: isContentTypeView ? 'content-types' : 'components',
|
|
323
|
+
modifiedData,
|
|
324
|
+
}
|
|
325
|
+
)}
|
|
326
|
+
</div>
|
|
327
|
+
</div>
|
|
328
|
+
</LayoutTitle>
|
|
329
|
+
{isContentTypeView && (
|
|
330
|
+
<LayoutTitle className="col-4">
|
|
331
|
+
<FormTitle
|
|
332
|
+
title={`${pluginId}.containers.SettingPage.relations`}
|
|
333
|
+
description={`${pluginId}.containers.SettingPage.editSettings.description`}
|
|
334
|
+
/>
|
|
335
|
+
</LayoutTitle>
|
|
336
|
+
)}
|
|
337
|
+
|
|
338
|
+
<FieldsReorder className={fieldsReorderClassName} />
|
|
339
|
+
{isContentTypeView && (
|
|
340
|
+
<SortableList
|
|
341
|
+
addItem={name => {
|
|
342
|
+
dispatch({
|
|
343
|
+
type: 'ADD_RELATION',
|
|
344
|
+
name,
|
|
345
|
+
});
|
|
346
|
+
}}
|
|
347
|
+
buttonData={editRelationsLayoutRemainingFields}
|
|
348
|
+
moveItem={(dragIndex, hoverIndex) => {
|
|
349
|
+
dispatch({
|
|
350
|
+
type: 'MOVE_RELATION',
|
|
351
|
+
dragIndex,
|
|
352
|
+
hoverIndex,
|
|
353
|
+
});
|
|
354
|
+
}}
|
|
355
|
+
removeItem={index => {
|
|
356
|
+
dispatch({
|
|
357
|
+
type: 'REMOVE_RELATION',
|
|
358
|
+
index,
|
|
359
|
+
});
|
|
360
|
+
}}
|
|
361
|
+
/>
|
|
362
|
+
)}
|
|
363
|
+
</div>
|
|
364
|
+
</SettingsViewWrapper>
|
|
365
|
+
|
|
366
|
+
<PopupForm
|
|
367
|
+
headerId={`${pluginId}.containers.EditSettingsView.modal-form.edit-field`}
|
|
368
|
+
isOpen={isModalFormOpen}
|
|
369
|
+
onClosed={() => {
|
|
370
|
+
dispatch({
|
|
371
|
+
type: 'UNSET_FIELD_TO_EDIT',
|
|
372
|
+
});
|
|
373
|
+
}}
|
|
374
|
+
onSubmit={handleSubmitMetaForm}
|
|
375
|
+
onToggle={toggleModalForm}
|
|
376
|
+
renderForm={renderForm}
|
|
377
|
+
subHeaderContent={metaToEdit}
|
|
378
|
+
type={get(attributes, [metaToEdit, 'type'], '')}
|
|
379
|
+
/>
|
|
380
|
+
</LayoutDndProvider>
|
|
381
|
+
);
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
EditSettingsView.defaultProps = {
|
|
385
|
+
isContentTypeView: false,
|
|
386
|
+
updateLayout: null,
|
|
387
|
+
};
|
|
388
|
+
|
|
389
|
+
EditSettingsView.propTypes = {
|
|
390
|
+
components: PropTypes.object.isRequired,
|
|
391
|
+
mainLayout: PropTypes.shape({
|
|
392
|
+
attributes: PropTypes.object.isRequired,
|
|
393
|
+
info: PropTypes.object.isRequired,
|
|
394
|
+
layouts: PropTypes.shape({
|
|
395
|
+
list: PropTypes.array.isRequired,
|
|
396
|
+
editRelations: PropTypes.array.isRequired,
|
|
397
|
+
edit: PropTypes.array.isRequired,
|
|
398
|
+
}).isRequired,
|
|
399
|
+
metadatas: PropTypes.object.isRequired,
|
|
400
|
+
options: PropTypes.object.isRequired,
|
|
401
|
+
}).isRequired,
|
|
402
|
+
isContentTypeView: PropTypes.bool,
|
|
403
|
+
|
|
404
|
+
slug: PropTypes.string.isRequired,
|
|
405
|
+
updateLayout: PropTypes.func,
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
export default EditSettingsView;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { fromJS } from 'immutable';
|
|
2
|
+
import { cloneDeep, set } from 'lodash';
|
|
3
|
+
import { createLayout, formatLayout } from './utils/layout';
|
|
4
|
+
|
|
5
|
+
const init = (initialState, mainLayout, components) => {
|
|
6
|
+
let initialData = cloneDeep(mainLayout);
|
|
7
|
+
|
|
8
|
+
set(initialData, ['layouts', 'edit'], formatLayout(createLayout(mainLayout.layouts.edit)));
|
|
9
|
+
|
|
10
|
+
return fromJS({
|
|
11
|
+
...initialState.toJS(),
|
|
12
|
+
initialData,
|
|
13
|
+
modifiedData: initialData,
|
|
14
|
+
componentLayouts: components,
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export default init;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { fromJS } from 'immutable';
|
|
2
|
+
import { formatLayout, getInputSize } from './utils/layout';
|
|
3
|
+
|
|
4
|
+
const initialState = fromJS({
|
|
5
|
+
fieldForm: {},
|
|
6
|
+
componentLayouts: {},
|
|
7
|
+
metaToEdit: '',
|
|
8
|
+
initialData: {},
|
|
9
|
+
metaForm: {},
|
|
10
|
+
modifiedData: {},
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const reducer = (state, action) => {
|
|
14
|
+
const layoutPathEdit = ['modifiedData', 'layouts', 'edit'];
|
|
15
|
+
const layoutPathRelations = ['modifiedData', 'layouts', 'editRelations'];
|
|
16
|
+
|
|
17
|
+
switch (action.type) {
|
|
18
|
+
case 'ADD_RELATION':
|
|
19
|
+
return state.updateIn(layoutPathRelations, list => list.push(action.name));
|
|
20
|
+
case 'MOVE_RELATION': {
|
|
21
|
+
return state.updateIn(layoutPathRelations, list => {
|
|
22
|
+
return list
|
|
23
|
+
.delete(action.dragIndex)
|
|
24
|
+
.insert(action.hoverIndex, state.getIn([...layoutPathRelations, action.dragIndex]));
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
case 'MOVE_ROW':
|
|
28
|
+
return state.updateIn(layoutPathEdit, list => {
|
|
29
|
+
return list
|
|
30
|
+
.delete(action.dragRowIndex)
|
|
31
|
+
.insert(action.hoverRowIndex, state.getIn([...layoutPathEdit, action.dragRowIndex]));
|
|
32
|
+
});
|
|
33
|
+
case 'ON_ADD_DATA': {
|
|
34
|
+
const size = getInputSize(state.getIn(['modifiedData', 'attributes', action.name, 'type']));
|
|
35
|
+
|
|
36
|
+
const listSize = state.getIn(layoutPathEdit).size;
|
|
37
|
+
const newList = state.getIn(layoutPathEdit).updateIn([listSize - 1, 'rowContent'], list => {
|
|
38
|
+
if (list) {
|
|
39
|
+
return list.push({
|
|
40
|
+
name: action.name,
|
|
41
|
+
size,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return fromJS([{ name: action.name, size }]);
|
|
46
|
+
});
|
|
47
|
+
const formattedList = formatLayout(newList.toJS());
|
|
48
|
+
|
|
49
|
+
return state.updateIn(layoutPathEdit, () => fromJS(formattedList));
|
|
50
|
+
}
|
|
51
|
+
case 'ON_CHANGE':
|
|
52
|
+
return state.updateIn(['modifiedData', ...action.keys], () => action.value);
|
|
53
|
+
case 'ON_CHANGE_META':
|
|
54
|
+
return state.updateIn(['metaForm', ...action.keys], () => action.value);
|
|
55
|
+
case 'ON_RESET':
|
|
56
|
+
return state.update('modifiedData', () => state.get('initialData'));
|
|
57
|
+
case 'REMOVE_FIELD': {
|
|
58
|
+
const row = state.getIn([...layoutPathEdit, action.rowIndex, 'rowContent']);
|
|
59
|
+
let newState;
|
|
60
|
+
|
|
61
|
+
// Delete the entire row if length is one or if lenght is equal to 2 and the second element is the hidden div used to make the dnd exp smoother
|
|
62
|
+
if (row.size === 1 || (row.size === 2 && row.getIn([1, 'name']) === '_TEMP_')) {
|
|
63
|
+
newState = state.updateIn(layoutPathEdit, list => list.delete(action.rowIndex));
|
|
64
|
+
} else {
|
|
65
|
+
newState = state.updateIn([...layoutPathEdit, action.rowIndex, 'rowContent'], list =>
|
|
66
|
+
list.delete(action.fieldIndex)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
const updatedList = fromJS(formatLayout(newState.getIn(layoutPathEdit).toJS()));
|
|
70
|
+
|
|
71
|
+
return state.updateIn(layoutPathEdit, () => updatedList);
|
|
72
|
+
}
|
|
73
|
+
case 'REMOVE_RELATION':
|
|
74
|
+
return state.updateIn(layoutPathRelations, list => list.delete(action.index));
|
|
75
|
+
case 'REORDER_DIFF_ROW': {
|
|
76
|
+
const newState = state
|
|
77
|
+
.updateIn([...layoutPathEdit, action.dragRowIndex, 'rowContent'], list => {
|
|
78
|
+
return list.remove(action.dragIndex);
|
|
79
|
+
})
|
|
80
|
+
.updateIn([...layoutPathEdit, action.hoverRowIndex, 'rowContent'], list => {
|
|
81
|
+
return list.insert(
|
|
82
|
+
action.hoverIndex,
|
|
83
|
+
state.getIn([...layoutPathEdit, action.dragRowIndex, 'rowContent', action.dragIndex])
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
const updatedList = formatLayout(newState.getIn(layoutPathEdit).toJS());
|
|
88
|
+
|
|
89
|
+
return state.updateIn(layoutPathEdit, () => fromJS(updatedList));
|
|
90
|
+
}
|
|
91
|
+
case 'REORDER_ROW': {
|
|
92
|
+
const newState = state.updateIn(
|
|
93
|
+
[...layoutPathEdit, action.dragRowIndex, 'rowContent'],
|
|
94
|
+
list => {
|
|
95
|
+
return list
|
|
96
|
+
.delete(action.dragIndex)
|
|
97
|
+
.insert(action.hoverIndex, list.get(action.dragIndex));
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const updatedList = formatLayout(newState.getIn(layoutPathEdit).toJS());
|
|
102
|
+
|
|
103
|
+
return state.updateIn(layoutPathEdit, () => fromJS(updatedList));
|
|
104
|
+
}
|
|
105
|
+
case 'SET_FIELD_TO_EDIT':
|
|
106
|
+
return state
|
|
107
|
+
.update('metaToEdit', () => action.name)
|
|
108
|
+
.updateIn(['metaForm'], () =>
|
|
109
|
+
state.getIn(['modifiedData', 'metadatas', action.name, 'edit'])
|
|
110
|
+
);
|
|
111
|
+
case 'SUBMIT_META_FORM': {
|
|
112
|
+
const metaPath = ['modifiedData', 'metadatas', state.get('metaToEdit'), 'edit'];
|
|
113
|
+
|
|
114
|
+
return state.updateIn(metaPath, () => state.getIn(['metaForm']));
|
|
115
|
+
}
|
|
116
|
+
case 'SUBMIT_SUCCEEDED':
|
|
117
|
+
return state.update('initialData', () => state.get('modifiedData'));
|
|
118
|
+
case 'UNSET_FIELD_TO_EDIT':
|
|
119
|
+
return state.update('metaToEdit', () => '').update('metaForm', () => fromJS({}));
|
|
120
|
+
default:
|
|
121
|
+
return state;
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export default reducer;
|
|
126
|
+
export { initialState };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { get } from 'lodash';
|
|
2
|
+
|
|
3
|
+
const createPossibleMainFieldsForModelsAndComponents = array => {
|
|
4
|
+
return array.reduce((acc, current) => {
|
|
5
|
+
const attributes = get(current, ['attributes'], {});
|
|
6
|
+
const possibleMainFields = Object.keys(attributes).filter(attr => {
|
|
7
|
+
return ![
|
|
8
|
+
'boolean',
|
|
9
|
+
'component',
|
|
10
|
+
'dynamiczone',
|
|
11
|
+
'json',
|
|
12
|
+
'media',
|
|
13
|
+
'password',
|
|
14
|
+
'relation',
|
|
15
|
+
'text',
|
|
16
|
+
'richtext',
|
|
17
|
+
].includes(get(attributes, [attr, 'type'], ''));
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
acc[current.uid] = possibleMainFields;
|
|
21
|
+
|
|
22
|
+
return acc;
|
|
23
|
+
}, {});
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default createPossibleMainFieldsForModelsAndComponents;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import pluginId from '../../../pluginId';
|
|
2
|
+
|
|
3
|
+
const getInputProps = fieldName => {
|
|
4
|
+
let type;
|
|
5
|
+
|
|
6
|
+
switch (fieldName) {
|
|
7
|
+
case 'description':
|
|
8
|
+
case 'label':
|
|
9
|
+
case 'placeholder':
|
|
10
|
+
type = 'text';
|
|
11
|
+
break;
|
|
12
|
+
case 'mainField':
|
|
13
|
+
type = 'select';
|
|
14
|
+
break;
|
|
15
|
+
case 'editable':
|
|
16
|
+
type = 'bool';
|
|
17
|
+
break;
|
|
18
|
+
default:
|
|
19
|
+
type = '';
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const labelId =
|
|
23
|
+
fieldName === 'mainField'
|
|
24
|
+
? `${pluginId}.containers.SettingPage.editSettings.entry.title`
|
|
25
|
+
: `${pluginId}.form.Input.${fieldName}`;
|
|
26
|
+
|
|
27
|
+
return { type, label: { id: labelId } };
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default getInputProps;
|