@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
package/package.json
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@akemona-org/strapi-plugin-content-manager",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public"
|
|
5
|
+
},
|
|
6
|
+
"version": "3.7.0",
|
|
7
|
+
"description": "A powerful UI to easily manage your data.",
|
|
8
|
+
"strapi": {
|
|
9
|
+
"name": "Content Manager",
|
|
10
|
+
"icon": "plug",
|
|
11
|
+
"description": "content-manager.plugin.description",
|
|
12
|
+
"required": true
|
|
13
|
+
},
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@akemona-org/strapi-helper-plugin": "3.7.0",
|
|
16
|
+
"@akemona-org/strapi-utils": "3.7.0",
|
|
17
|
+
"@buffetjs/core": "3.3.8",
|
|
18
|
+
"@buffetjs/custom": "3.3.8",
|
|
19
|
+
"@buffetjs/hooks": "3.3.8",
|
|
20
|
+
"@buffetjs/icons": "3.3.8",
|
|
21
|
+
"@buffetjs/styles": "3.3.8",
|
|
22
|
+
"@buffetjs/utils": "3.3.8",
|
|
23
|
+
"@sindresorhus/slugify": "1.1.0",
|
|
24
|
+
"classnames": "^2.3.1",
|
|
25
|
+
"codemirror": "^5.61.0",
|
|
26
|
+
"draft-js": "^0.11.5",
|
|
27
|
+
"highlight.js": "^10.4.1",
|
|
28
|
+
"immutable": "^3.8.2",
|
|
29
|
+
"lodash": "4.17.21",
|
|
30
|
+
"markdown-it": "^12.0.6",
|
|
31
|
+
"markdown-it-abbr": "^1.0.4",
|
|
32
|
+
"markdown-it-container": "^3.0.0",
|
|
33
|
+
"markdown-it-deflist": "^2.0.3",
|
|
34
|
+
"markdown-it-emoji": "^2.0.0",
|
|
35
|
+
"markdown-it-footnote": "^3.0.2",
|
|
36
|
+
"markdown-it-ins": "^3.0.1",
|
|
37
|
+
"markdown-it-mark": "^3.0.1",
|
|
38
|
+
"markdown-it-sub": "^1.0.0",
|
|
39
|
+
"markdown-it-sup": "^1.0.0",
|
|
40
|
+
"pluralize": "^8.0.0",
|
|
41
|
+
"react": "^16.14.0",
|
|
42
|
+
"react-dom": "^16.9.0",
|
|
43
|
+
"react-fast-compare": "^3.2.0",
|
|
44
|
+
"react-intl": "4.5.0",
|
|
45
|
+
"react-redux": "7.2.3",
|
|
46
|
+
"react-router": "^5.2.0",
|
|
47
|
+
"react-router-dom": "^5.0.0",
|
|
48
|
+
"reactstrap": "8.4.1",
|
|
49
|
+
"redux": "^4.0.1",
|
|
50
|
+
"redux-immutable": "^4.0.0",
|
|
51
|
+
"reselect": "^4.0.0",
|
|
52
|
+
"sanitize-html": "2.7.2",
|
|
53
|
+
"yup": "^0.32.9"
|
|
54
|
+
},
|
|
55
|
+
"author": {
|
|
56
|
+
"name": "Akemona team",
|
|
57
|
+
"email": "strapi@akemona.com",
|
|
58
|
+
"url": "https://strapi.akemona.com"
|
|
59
|
+
},
|
|
60
|
+
"maintainers": [
|
|
61
|
+
{
|
|
62
|
+
"name": "Akemona team",
|
|
63
|
+
"email": "strapi@akemona.com",
|
|
64
|
+
"url": "https://strapi.akemona.com"
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "git://github.com/akemona/strapi.git"
|
|
70
|
+
},
|
|
71
|
+
"engines": {
|
|
72
|
+
"node": ">=10.16.0 <=14.x.x",
|
|
73
|
+
"npm": ">=6.0.0"
|
|
74
|
+
},
|
|
75
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
76
|
+
"gitHead": "129a8d6191b55810fd66448dcc47fee829df986c"
|
|
77
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { has, isNil, mapValues } = require('lodash/fp');
|
|
4
|
+
|
|
5
|
+
const { getService } = require('../utils');
|
|
6
|
+
const storeUtils = require('./utils/store');
|
|
7
|
+
const createConfigurationService = require('./configuration');
|
|
8
|
+
|
|
9
|
+
const STORE_KEY_PREFIX = 'components';
|
|
10
|
+
|
|
11
|
+
const configurationService = createConfigurationService({
|
|
12
|
+
storeUtils,
|
|
13
|
+
isComponent: true,
|
|
14
|
+
prefix: STORE_KEY_PREFIX,
|
|
15
|
+
getModels() {
|
|
16
|
+
const { toContentManagerModel } = getService('data-mapper');
|
|
17
|
+
|
|
18
|
+
return mapValues(toContentManagerModel, strapi.components);
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
module.exports = {
|
|
23
|
+
findAllComponents() {
|
|
24
|
+
const { toContentManagerModel } = getService('data-mapper');
|
|
25
|
+
|
|
26
|
+
return Object.values(strapi.components).map(toContentManagerModel);
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
findComponent(uid) {
|
|
30
|
+
const { toContentManagerModel } = getService('data-mapper');
|
|
31
|
+
|
|
32
|
+
const component = strapi.components[uid];
|
|
33
|
+
|
|
34
|
+
return isNil(component) ? component : toContentManagerModel(component);
|
|
35
|
+
},
|
|
36
|
+
|
|
37
|
+
// configuration
|
|
38
|
+
|
|
39
|
+
async findConfiguration(component) {
|
|
40
|
+
const configuration = await configurationService.getConfiguration(component.uid);
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
uid: component.uid,
|
|
44
|
+
category: component.categoru,
|
|
45
|
+
...configuration,
|
|
46
|
+
};
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
async updateConfiguration(component, newConfiguration) {
|
|
50
|
+
await configurationService.setConfiguration(component.uid, newConfiguration);
|
|
51
|
+
|
|
52
|
+
return this.findConfiguration(component);
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
async findComponentsConfigurations(model) {
|
|
56
|
+
const componentsMap = {};
|
|
57
|
+
|
|
58
|
+
const getComponentConfigurations = async uid => {
|
|
59
|
+
const component = this.findComponent(uid);
|
|
60
|
+
|
|
61
|
+
if (has(uid, componentsMap)) return;
|
|
62
|
+
|
|
63
|
+
const componentConfiguration = await this.findConfiguration(component);
|
|
64
|
+
const componentsConfigurations = await this.findComponentsConfigurations(component);
|
|
65
|
+
|
|
66
|
+
Object.assign(componentsMap, {
|
|
67
|
+
[uid]: componentConfiguration,
|
|
68
|
+
...componentsConfigurations,
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
for (const key in model.attributes) {
|
|
73
|
+
const attribute = model.attributes[key];
|
|
74
|
+
|
|
75
|
+
if (attribute.type === 'component') {
|
|
76
|
+
await getComponentConfigurations(attribute.component);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (attribute.type === 'dynamiczone') {
|
|
80
|
+
for (const componentUid of attribute.components) {
|
|
81
|
+
await getComponentConfigurations(componentUid);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return componentsMap;
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
syncConfigurations() {
|
|
90
|
+
return configurationService.syncConfigurations();
|
|
91
|
+
},
|
|
92
|
+
};
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { intersection, difference } = require('lodash');
|
|
4
|
+
const { createDefaultConfiguration, syncConfiguration } = require('./utils/configuration');
|
|
5
|
+
|
|
6
|
+
module.exports = ({ isComponent, prefix, storeUtils, getModels }) => {
|
|
7
|
+
const uidToStoreKey = uid => {
|
|
8
|
+
return `${prefix}::${uid}`;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const getConfiguration = uid => {
|
|
12
|
+
const storeKey = uidToStoreKey(uid);
|
|
13
|
+
return storeUtils.getModelConfiguration(storeKey);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const setConfiguration = (uid, input) => {
|
|
17
|
+
const { settings, metadatas, layouts } = input;
|
|
18
|
+
|
|
19
|
+
const configuration = {
|
|
20
|
+
uid,
|
|
21
|
+
settings,
|
|
22
|
+
metadatas,
|
|
23
|
+
layouts,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
if (isComponent) {
|
|
27
|
+
configuration.isComponent = isComponent;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const storeKey = uidToStoreKey(uid);
|
|
31
|
+
return storeUtils.setModelConfiguration(storeKey, configuration);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const deleteConfiguration = uid => {
|
|
35
|
+
const storeKey = uidToStoreKey(uid);
|
|
36
|
+
return storeUtils.deleteKey(storeKey);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
const syncConfigurations = async () => {
|
|
40
|
+
const models = getModels();
|
|
41
|
+
|
|
42
|
+
const configurations = await storeUtils.findByKey(
|
|
43
|
+
`plugin_content_manager_configuration_${prefix}`
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const updateConfiguration = async uid => {
|
|
47
|
+
const conf = configurations.find(conf => conf.uid === uid);
|
|
48
|
+
|
|
49
|
+
return setConfiguration(uid, await syncConfiguration(conf, models[uid]));
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const generateNewConfiguration = async uid => {
|
|
53
|
+
return setConfiguration(uid, await createDefaultConfiguration(models[uid]));
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const currentUIDS = Object.keys(models);
|
|
57
|
+
const DBUIDs = configurations.map(({ uid }) => uid);
|
|
58
|
+
|
|
59
|
+
const contentTypesToUpdate = intersection(currentUIDS, DBUIDs);
|
|
60
|
+
const contentTypesToAdd = difference(currentUIDS, DBUIDs);
|
|
61
|
+
const contentTypesToDelete = difference(DBUIDs, currentUIDS);
|
|
62
|
+
|
|
63
|
+
// delete old schemas
|
|
64
|
+
await Promise.all(contentTypesToDelete.map(uid => deleteConfiguration(uid)));
|
|
65
|
+
|
|
66
|
+
// create new schemas
|
|
67
|
+
await Promise.all(contentTypesToAdd.map(uid => generateNewConfiguration(uid)));
|
|
68
|
+
|
|
69
|
+
// update current schemas
|
|
70
|
+
await Promise.all(contentTypesToUpdate.map(uid => updateConfiguration(uid)));
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return {
|
|
74
|
+
getConfiguration,
|
|
75
|
+
setConfiguration,
|
|
76
|
+
deleteConfiguration,
|
|
77
|
+
syncConfigurations,
|
|
78
|
+
};
|
|
79
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { isNil, mapValues } = require('lodash/fp');
|
|
4
|
+
const { contentTypes: contentTypesUtils } = require('@akemona-org/strapi-utils');
|
|
5
|
+
|
|
6
|
+
const { getService } = require('../utils');
|
|
7
|
+
const storeUtils = require('./utils/store');
|
|
8
|
+
const createConfigurationService = require('./configuration');
|
|
9
|
+
|
|
10
|
+
const configurationService = createConfigurationService({
|
|
11
|
+
storeUtils,
|
|
12
|
+
prefix: 'content_types',
|
|
13
|
+
getModels() {
|
|
14
|
+
const { toContentManagerModel } = getService('data-mapper');
|
|
15
|
+
|
|
16
|
+
return mapValues(toContentManagerModel, strapi.contentTypes);
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const service = {
|
|
21
|
+
findAllContentTypes() {
|
|
22
|
+
const { toContentManagerModel } = getService('data-mapper');
|
|
23
|
+
|
|
24
|
+
return Object.values(strapi.contentTypes).map(toContentManagerModel);
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
findContentType(uid) {
|
|
28
|
+
const { toContentManagerModel } = getService('data-mapper');
|
|
29
|
+
|
|
30
|
+
const contentType = strapi.contentTypes[uid];
|
|
31
|
+
|
|
32
|
+
return isNil(contentType) ? contentType : toContentManagerModel(contentType);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
findDisplayedContentTypes() {
|
|
36
|
+
return this.findAllContentTypes().filter(({ isDisplayed }) => isDisplayed === true);
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
findContentTypesByKind(kind) {
|
|
40
|
+
if (!kind) {
|
|
41
|
+
return this.findAllContentTypes();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return this.findAllContentTypes().filter(contentTypesUtils.isKind(kind));
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
// configuration
|
|
48
|
+
|
|
49
|
+
async findConfiguration(contentType) {
|
|
50
|
+
const configuration = await configurationService.getConfiguration(contentType.uid);
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
uid: contentType.uid,
|
|
54
|
+
...configuration,
|
|
55
|
+
};
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
async updateConfiguration(contentType, newConfiguration) {
|
|
59
|
+
await configurationService.setConfiguration(contentType.uid, newConfiguration);
|
|
60
|
+
return this.findConfiguration(contentType);
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
findComponentsConfigurations(contentType) {
|
|
64
|
+
// delegate to componentService
|
|
65
|
+
return getService('components').findComponentsConfigurations(contentType);
|
|
66
|
+
},
|
|
67
|
+
|
|
68
|
+
syncConfigurations() {
|
|
69
|
+
return configurationService.syncConfigurations();
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
module.exports = service;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { upperFirst, has, prop, pick, getOr } = require('lodash/fp');
|
|
4
|
+
const pluralize = require('pluralize');
|
|
5
|
+
const { contentTypes: contentTypesUtils } = require('@akemona-org/strapi-utils');
|
|
6
|
+
const { isMediaAttribute } = require('@akemona-org/strapi-utils').contentTypes;
|
|
7
|
+
|
|
8
|
+
const dtoFields = [
|
|
9
|
+
'uid',
|
|
10
|
+
'isDisplayed',
|
|
11
|
+
'apiID',
|
|
12
|
+
'kind',
|
|
13
|
+
'category',
|
|
14
|
+
'info',
|
|
15
|
+
'options',
|
|
16
|
+
'pluginOptions',
|
|
17
|
+
'attributes',
|
|
18
|
+
'pluginOptions',
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
module.exports = {
|
|
22
|
+
toContentManagerModel(contentType) {
|
|
23
|
+
return {
|
|
24
|
+
...contentType,
|
|
25
|
+
apiID: contentType.modelName,
|
|
26
|
+
isDisplayed: isVisible(contentType),
|
|
27
|
+
info: {
|
|
28
|
+
...contentType.info,
|
|
29
|
+
label: formatContentTypeLabel(contentType),
|
|
30
|
+
},
|
|
31
|
+
attributes: {
|
|
32
|
+
id: {
|
|
33
|
+
type: contentType.primaryKeyType,
|
|
34
|
+
},
|
|
35
|
+
...formatAttributes(contentType),
|
|
36
|
+
...contentTypesUtils.getTimestampsAttributes(contentType),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
|
|
41
|
+
toDto: pick(dtoFields),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const formatContentTypeLabel = (contentType) => {
|
|
45
|
+
const name = prop('info.name', contentType) || contentType.modelName;
|
|
46
|
+
|
|
47
|
+
try {
|
|
48
|
+
return contentTypesUtils.isSingleType(contentType)
|
|
49
|
+
? upperFirst(name)
|
|
50
|
+
: upperFirst(pluralize(name));
|
|
51
|
+
} catch (error) {
|
|
52
|
+
// in case pluralize throws cyrillic characters
|
|
53
|
+
return upperFirst(name);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const formatAttributes = (model) => {
|
|
58
|
+
const { getVisibleAttributes } = contentTypesUtils;
|
|
59
|
+
|
|
60
|
+
// only get attributes that can be seen in the auto generated Edit view or List view
|
|
61
|
+
return getVisibleAttributes(model).reduce((acc, key) => {
|
|
62
|
+
acc[key] = formatAttribute(key, model.attributes[key], { model });
|
|
63
|
+
return acc;
|
|
64
|
+
}, {});
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const formatAttribute = (key, attribute, { model }) => {
|
|
68
|
+
if (has('type', attribute)) return attribute;
|
|
69
|
+
|
|
70
|
+
if (isMediaAttribute(attribute)) {
|
|
71
|
+
return toMedia(attribute);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const relation = (model.associations || []).find((assoc) => assoc.alias === key);
|
|
75
|
+
return toRelation(attribute, relation);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const toMedia = (attribute) => {
|
|
79
|
+
return {
|
|
80
|
+
type: 'media',
|
|
81
|
+
multiple: attribute.collection ? true : false,
|
|
82
|
+
required: attribute.required ? true : false,
|
|
83
|
+
allowedTypes: attribute.allowedTypes,
|
|
84
|
+
pluginOptions: attribute.pluginOptions,
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const toRelation = (attribute, relation) => {
|
|
89
|
+
return {
|
|
90
|
+
...attribute,
|
|
91
|
+
type: 'relation',
|
|
92
|
+
targetModel: relation.targetUid,
|
|
93
|
+
relationType: relation.nature,
|
|
94
|
+
pluginOptions: attribute.pluginOptions,
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
const isVisible = (model) => getOr(true, 'pluginOptions.content-manager.visible', model) === true;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { assoc, has, prop, omit } = require('lodash/fp');
|
|
4
|
+
const strapiUtils = require('@akemona-org/strapi-utils');
|
|
5
|
+
|
|
6
|
+
const { sanitizeEntity } = strapiUtils;
|
|
7
|
+
const { hasDraftAndPublish } = strapiUtils.contentTypes;
|
|
8
|
+
const { PUBLISHED_AT_ATTRIBUTE, CREATED_BY_ATTRIBUTE } = strapiUtils.contentTypes.constants;
|
|
9
|
+
const { ENTRY_PUBLISH, ENTRY_UNPUBLISH } = strapiUtils.webhook.webhookEvents;
|
|
10
|
+
|
|
11
|
+
const omitPublishedAtField = omit(PUBLISHED_AT_ATTRIBUTE);
|
|
12
|
+
|
|
13
|
+
const emitEvent = (event, fn) => async (entity, model) => {
|
|
14
|
+
const result = await fn(entity, model);
|
|
15
|
+
|
|
16
|
+
const modelDef = strapi.getModel(model);
|
|
17
|
+
|
|
18
|
+
strapi.eventHub.emit(event, {
|
|
19
|
+
model: modelDef.modelName,
|
|
20
|
+
entry: sanitizeEntity(result, { model: modelDef }),
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const findCreatorRoles = (entity) => {
|
|
27
|
+
const createdByPath = `${CREATED_BY_ATTRIBUTE}.id`;
|
|
28
|
+
|
|
29
|
+
if (has(createdByPath, entity)) {
|
|
30
|
+
const creatorId = prop(createdByPath, entity);
|
|
31
|
+
return strapi.query('role', 'admin').find({ 'users.id': creatorId }, []);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return [];
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
module.exports = {
|
|
38
|
+
async assocCreatorRoles(entity) {
|
|
39
|
+
if (!entity) {
|
|
40
|
+
return entity;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const roles = await findCreatorRoles(entity);
|
|
44
|
+
return assoc(`${CREATED_BY_ATTRIBUTE}.roles`, roles, entity);
|
|
45
|
+
},
|
|
46
|
+
|
|
47
|
+
find(params, model, populate) {
|
|
48
|
+
return strapi.entityService.find({ params, populate }, { model });
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
findPage(params, model, populate) {
|
|
52
|
+
return strapi.entityService.findPage({ params, populate }, { model });
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
findWithRelationCounts(params, model, populate) {
|
|
56
|
+
return strapi.entityService.findWithRelationCounts({ params, populate }, { model });
|
|
57
|
+
},
|
|
58
|
+
|
|
59
|
+
search(params, model, populate) {
|
|
60
|
+
return strapi.entityService.search({ params, populate }, { model });
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
searchPage(params, model, populate) {
|
|
64
|
+
return strapi.entityService.searchPage({ params, populate }, { model });
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
searchWithRelationCounts(params, model, populate) {
|
|
68
|
+
return strapi.entityService.searchWithRelationCounts({ params, populate }, { model });
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
count(params, model) {
|
|
72
|
+
return strapi.entityService.count({ params }, { model });
|
|
73
|
+
},
|
|
74
|
+
|
|
75
|
+
async findOne(id, model, populate) {
|
|
76
|
+
return strapi.entityService.findOne({ params: { id }, populate }, { model });
|
|
77
|
+
},
|
|
78
|
+
|
|
79
|
+
async findOneWithCreatorRoles(id, model, populate) {
|
|
80
|
+
const entity = await this.findOne(id, model, populate);
|
|
81
|
+
|
|
82
|
+
if (!entity) {
|
|
83
|
+
return entity;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
return this.assocCreatorRoles(entity);
|
|
87
|
+
},
|
|
88
|
+
|
|
89
|
+
async create(body, model) {
|
|
90
|
+
const modelDef = strapi.getModel(model);
|
|
91
|
+
const publishData = { ...body };
|
|
92
|
+
|
|
93
|
+
if (hasDraftAndPublish(modelDef)) {
|
|
94
|
+
publishData[PUBLISHED_AT_ATTRIBUTE] = null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return strapi.entityService.create({ data: publishData }, { model });
|
|
98
|
+
},
|
|
99
|
+
|
|
100
|
+
update(entity, body, model) {
|
|
101
|
+
const params = { id: entity.id };
|
|
102
|
+
const publishData = omitPublishedAtField(body);
|
|
103
|
+
|
|
104
|
+
return strapi.entityService.update({ params, data: publishData }, { model });
|
|
105
|
+
},
|
|
106
|
+
|
|
107
|
+
delete(entity, model) {
|
|
108
|
+
const params = { id: entity.id };
|
|
109
|
+
return strapi.entityService.delete({ params }, { model });
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
findAndDelete(params, model) {
|
|
113
|
+
return strapi.entityService.delete({ params }, { model });
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
publish: emitEvent(ENTRY_PUBLISH, async (entity, model) => {
|
|
117
|
+
if (entity[PUBLISHED_AT_ATTRIBUTE]) {
|
|
118
|
+
throw strapi.errors.badRequest('already.published');
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// validate the entity is valid for publication
|
|
122
|
+
await strapi.entityValidator.validateEntityCreation(strapi.getModel(model), entity);
|
|
123
|
+
|
|
124
|
+
const params = { id: entity.id };
|
|
125
|
+
const data = { [PUBLISHED_AT_ATTRIBUTE]: new Date() };
|
|
126
|
+
|
|
127
|
+
return strapi.entityService.update({ params, data }, { model });
|
|
128
|
+
}),
|
|
129
|
+
|
|
130
|
+
unpublish: emitEvent(ENTRY_UNPUBLISH, (entity, model) => {
|
|
131
|
+
if (!entity[PUBLISHED_AT_ATTRIBUTE]) {
|
|
132
|
+
throw strapi.errors.badRequest('already.draft');
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const params = { id: entity.id };
|
|
136
|
+
const data = { [PUBLISHED_AT_ATTRIBUTE]: null };
|
|
137
|
+
|
|
138
|
+
return strapi.entityService.update({ params, data }, { model });
|
|
139
|
+
}),
|
|
140
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const { intersection, prop } = require('lodash/fp');
|
|
4
|
+
const { getRelationalFields } = require('@akemona-org/strapi-utils').relations;
|
|
5
|
+
|
|
6
|
+
const sendDidConfigureListView = async (contentType, configuration) => {
|
|
7
|
+
const displayedFields = prop('length', configuration.layouts.list);
|
|
8
|
+
const relationalFields = getRelationalFields(contentType);
|
|
9
|
+
const displayedRelationalFields = intersection(
|
|
10
|
+
relationalFields,
|
|
11
|
+
configuration.layouts.list
|
|
12
|
+
).length;
|
|
13
|
+
|
|
14
|
+
const data = {
|
|
15
|
+
containsRelationalFields: !!displayedRelationalFields,
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
if (data.containsRelationalFields) {
|
|
19
|
+
Object.assign(data, {
|
|
20
|
+
displayedFields,
|
|
21
|
+
displayedRelationalFields,
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
try {
|
|
26
|
+
// await strapi.telemetry.send('didConfigureListView', data);
|
|
27
|
+
} catch (e) {
|
|
28
|
+
// silence
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
module.exports = {
|
|
33
|
+
sendDidConfigureListView,
|
|
34
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const ACTIONS = {
|
|
4
|
+
read: 'plugins::content-manager.explorer.read',
|
|
5
|
+
create: 'plugins::content-manager.explorer.create',
|
|
6
|
+
update: 'plugins::content-manager.explorer.update',
|
|
7
|
+
delete: 'plugins::content-manager.explorer.delete',
|
|
8
|
+
publish: 'plugins::content-manager.explorer.publish',
|
|
9
|
+
unpublish: 'plugins::content-manager.explorer.publish',
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
const createPermissionChecker = ({ userAbility, model }) => {
|
|
13
|
+
const permissionsManager = strapi.admin.services.permission.createPermissionsManager({
|
|
14
|
+
ability: userAbility,
|
|
15
|
+
model,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const toSubject = entity => (entity ? permissionsManager.toSubject(entity, model) : model);
|
|
19
|
+
|
|
20
|
+
const can = (action, entity, field) => {
|
|
21
|
+
return userAbility.can(action, toSubject(entity), field);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const cannot = (action, entity, field) => {
|
|
25
|
+
return userAbility.cannot(action, toSubject(entity), field);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
const sanitizeOutput = (data, { action = ACTIONS.read } = {}) => {
|
|
29
|
+
return permissionsManager.sanitize(data, {
|
|
30
|
+
subject: toSubject(data),
|
|
31
|
+
action,
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const sanitizeInput = (action, data, entity) => {
|
|
36
|
+
return permissionsManager.sanitize(data, {
|
|
37
|
+
subject: entity ? toSubject(entity) : model,
|
|
38
|
+
action,
|
|
39
|
+
isOutput: false,
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const sanitizeCreateInput = data => sanitizeInput(ACTIONS.create, data);
|
|
44
|
+
const sanitizeUpdateInput = entity => data => sanitizeInput(ACTIONS.update, data, entity);
|
|
45
|
+
|
|
46
|
+
const buildPermissionQuery = (query, action) => permissionsManager.queryFrom(query, action);
|
|
47
|
+
|
|
48
|
+
const buildReadQuery = query => buildPermissionQuery(query, ACTIONS.read);
|
|
49
|
+
const buildDeleteQuery = query => buildPermissionQuery(query, ACTIONS.delete);
|
|
50
|
+
|
|
51
|
+
Object.keys(ACTIONS).forEach(action => {
|
|
52
|
+
can[action] = (...args) => can(ACTIONS[action], ...args);
|
|
53
|
+
cannot[action] = (...args) => cannot(ACTIONS[action], ...args);
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return {
|
|
57
|
+
can,
|
|
58
|
+
cannot,
|
|
59
|
+
sanitizeOutput,
|
|
60
|
+
sanitizeCreateInput,
|
|
61
|
+
sanitizeUpdateInput,
|
|
62
|
+
buildReadQuery,
|
|
63
|
+
buildDeleteQuery,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
module.exports = {
|
|
68
|
+
create: createPermissionChecker,
|
|
69
|
+
};
|