@akemona-org/strapi-plugin-content-type-builder 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 +19 -0
- package/admin/src/InjectedComponents/ContentManager/EditSettingViewButton.js +76 -0
- package/admin/src/InjectedComponents/ContentManager/EditViewLink.js +44 -0
- package/admin/src/assets/images/logo.svg +1 -0
- package/admin/src/components/AllowedTypesSelect/MenuList.js +115 -0
- package/admin/src/components/AllowedTypesSelect/Text.js +26 -0
- package/admin/src/components/AllowedTypesSelect/index.js +55 -0
- package/admin/src/components/AttributeOption/Button.js +50 -0
- package/admin/src/components/AttributeOption/Card.js +26 -0
- package/admin/src/components/AttributeOption/index.js +127 -0
- package/admin/src/components/BooleanBox/CT.js +21 -0
- package/admin/src/components/BooleanBox/Enumeration.js +10 -0
- package/admin/src/components/BooleanBox/EnumerationWrapper.js +14 -0
- package/admin/src/components/BooleanBox/Label.js +9 -0
- package/admin/src/components/BooleanBox/ST.js +21 -0
- package/admin/src/components/BooleanBox/Wrapper.js +75 -0
- package/admin/src/components/BooleanBox/icons/CTSelected.js +136 -0
- package/admin/src/components/BooleanBox/icons/CTUnselected.js +136 -0
- package/admin/src/components/BooleanBox/icons/STSelected.js +80 -0
- package/admin/src/components/BooleanBox/icons/STUnselected.js +76 -0
- package/admin/src/components/BooleanBox/index.js +103 -0
- package/admin/src/components/CheckboxWithDescription/Wrapper.js +12 -0
- package/admin/src/components/CheckboxWithDescription/index.js +40 -0
- package/admin/src/components/ComponentCard/Close.js +12 -0
- package/admin/src/components/ComponentCard/Wrapper.js +84 -0
- package/admin/src/components/ComponentCard/index.js +62 -0
- package/admin/src/components/ComponentIconPicker/Cell.js +40 -0
- package/admin/src/components/ComponentIconPicker/CellRenderer.js +36 -0
- package/admin/src/components/ComponentIconPicker/Search.js +12 -0
- package/admin/src/components/ComponentIconPicker/SearchWrapper.js +34 -0
- package/admin/src/components/ComponentIconPicker/Wrapper.js +60 -0
- package/admin/src/components/ComponentIconPicker/index.js +143 -0
- package/admin/src/components/ComponentList/index.js +78 -0
- package/admin/src/components/ComponentSelect/Category.js +20 -0
- package/admin/src/components/ComponentSelect/CategoryName.js +11 -0
- package/admin/src/components/ComponentSelect/MenuList.js +110 -0
- package/admin/src/components/ComponentSelect/MultipleMenuList.js +271 -0
- package/admin/src/components/ComponentSelect/Value.js +83 -0
- package/admin/src/components/ComponentSelect/index.js +83 -0
- package/admin/src/components/ComponentSelect/utils/HasSomeSubArray.js +5 -0
- package/admin/src/components/ComponentSelect/utils/hasSubArray.js +5 -0
- package/admin/src/components/CreatableSelect/index.js +58 -0
- package/admin/src/components/CustomCheckbox/StyledCustomCheckbox.js +25 -0
- package/admin/src/components/CustomCheckbox/index.js +71 -0
- package/admin/src/components/CustomLink/P.js +17 -0
- package/admin/src/components/CustomLink/StyledCustomLink.js +20 -0
- package/admin/src/components/CustomLink/index.js +31 -0
- package/admin/src/components/DynamicZoneList/ComponentButton.js +39 -0
- package/admin/src/components/DynamicZoneList/index.js +124 -0
- package/admin/src/components/HeaderModalNavContainer/index.js +25 -0
- package/admin/src/components/HeaderNavLink/Wrapper.js +21 -0
- package/admin/src/components/HeaderNavLink/index.js +50 -0
- package/admin/src/components/List/List.js +131 -0
- package/admin/src/components/List/index.js +295 -0
- package/admin/src/components/ListButton/index.js +9 -0
- package/admin/src/components/ListHeader/Title.js +19 -0
- package/admin/src/components/ListHeader/Wrapper.js +24 -0
- package/admin/src/components/ListHeader/index.js +37 -0
- package/admin/src/components/ListRow/Wrapper.js +76 -0
- package/admin/src/components/ListRow/index.js +334 -0
- package/admin/src/components/ModalHeader/ComponentIcon.js +21 -0
- package/admin/src/components/ModalHeader/ComponentInfos.js +22 -0
- package/admin/src/components/ModalHeader/ComponentInfosWrapper.js +9 -0
- package/admin/src/components/ModalHeader/DropdownInfos.js +50 -0
- package/admin/src/components/ModalHeader/Icon.js +26 -0
- package/admin/src/components/ModalHeader/IconWrapper.js +11 -0
- package/admin/src/components/ModalHeader/Item.js +19 -0
- package/admin/src/components/ModalHeader/Menu.js +8 -0
- package/admin/src/components/ModalHeader/Toggle.js +14 -0
- package/admin/src/components/ModalHeader/Wrapper.js +12 -0
- package/admin/src/components/ModalHeader/index.js +105 -0
- package/admin/src/components/RelationForm/Wrapper.js +9 -0
- package/admin/src/components/RelationForm/index.js +66 -0
- package/admin/src/components/RelationFormBox/Wrapper.js +34 -0
- package/admin/src/components/RelationFormBox/index.js +85 -0
- package/admin/src/components/RelationFormNaturePicker/Wrapper.js +53 -0
- package/admin/src/components/RelationFormNaturePicker/index.js +112 -0
- package/admin/src/components/RelationTargetPicker/Item.js +62 -0
- package/admin/src/components/RelationTargetPicker/Wrapper.js +89 -0
- package/admin/src/components/RelationTargetPicker/index.js +88 -0
- package/admin/src/components/SelectCheckbox/index.js +8 -0
- package/admin/src/components/SelectMenuSubUl/ToggleUl.js +23 -0
- package/admin/src/components/SelectMenuSubUl/index.js +23 -0
- package/admin/src/components/SelectMenuUl/index.js +66 -0
- package/admin/src/components/Td/index.js +37 -0
- package/admin/src/components/UpperFirst/index.js +14 -0
- package/admin/src/components/WrapperSelect/index.js +89 -0
- package/admin/src/containers/App/Wrapper.js +14 -0
- package/admin/src/containers/App/index.js +39 -0
- package/admin/src/containers/App/utils/icons.json +962 -0
- package/admin/src/containers/DataManagerProvider/constants.js +15 -0
- package/admin/src/containers/DataManagerProvider/index.js +610 -0
- package/admin/src/containers/DataManagerProvider/reducer.js +461 -0
- package/admin/src/containers/DataManagerProvider/selectors.js +25 -0
- package/admin/src/containers/DataManagerProvider/utils/cleanData.js +167 -0
- package/admin/src/containers/DataManagerProvider/utils/createDataObject.js +8 -0
- package/admin/src/containers/DataManagerProvider/utils/createModifiedDataSchema.js +91 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsFromSchema.js +55 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveComponentsThatHaveComponents.js +35 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveNestedComponents.js +34 -0
- package/admin/src/containers/DataManagerProvider/utils/retrieveSpecificInfoFromComponents.js +12 -0
- package/admin/src/containers/FormModal/CustomButton.js +12 -0
- package/admin/src/containers/FormModal/attributes/advancedForm.js +269 -0
- package/admin/src/containers/FormModal/attributes/attributeOptions.js +99 -0
- package/admin/src/containers/FormModal/attributes/baseForm.js +322 -0
- package/admin/src/containers/FormModal/attributes/commonBaseForm.js +7 -0
- package/admin/src/containers/FormModal/attributes/form.js +9 -0
- package/admin/src/containers/FormModal/attributes/index.js +4 -0
- package/admin/src/containers/FormModal/attributes/nameField.js +19 -0
- package/admin/src/containers/FormModal/attributes/types.js +309 -0
- package/admin/src/containers/FormModal/attributes/uiHelpers.js +11 -0
- package/admin/src/containers/FormModal/attributes/validation/common.js +151 -0
- package/admin/src/containers/FormModal/category/createCategorySchema.js +28 -0
- package/admin/src/containers/FormModal/category/form.js +27 -0
- package/admin/src/containers/FormModal/category/index.js +3 -0
- package/admin/src/containers/FormModal/category/regex.js +3 -0
- package/admin/src/containers/FormModal/component/componentField.js +25 -0
- package/admin/src/containers/FormModal/component/createComponentSchema.js +49 -0
- package/admin/src/containers/FormModal/component/form.js +67 -0
- package/admin/src/containers/FormModal/component/index.js +4 -0
- package/admin/src/containers/FormModal/constants.js +11 -0
- package/admin/src/containers/FormModal/contentType/createContentTypeSchema.js +44 -0
- package/admin/src/containers/FormModal/contentType/form.js +116 -0
- package/admin/src/containers/FormModal/contentType/index.js +2 -0
- package/admin/src/containers/FormModal/dynamicZone/form.js +45 -0
- package/admin/src/containers/FormModal/dynamicZone/index.js +2 -0
- package/admin/src/containers/FormModal/forms/index.js +164 -0
- package/admin/src/containers/FormModal/index.js +1552 -0
- package/admin/src/containers/FormModal/reducer.js +293 -0
- package/admin/src/containers/FormModal/selectors.js +24 -0
- package/admin/src/containers/FormModal/utils/canEditContentType.js +19 -0
- package/admin/src/containers/FormModal/utils/createHeadersArray.js +37 -0
- package/admin/src/containers/FormModal/utils/createHeadersObjectFromArray.js +27 -0
- package/admin/src/containers/FormModal/utils/createUid.js +17 -0
- package/admin/src/containers/FormModal/utils/getAttributesToDisplay.js +35 -0
- package/admin/src/containers/FormModal/utils/getModalTitleSubHeader.js +25 -0
- package/admin/src/containers/FormModal/utils/getNextSearch.js +17 -0
- package/admin/src/containers/FormModal/utils/index.js +6 -0
- package/admin/src/containers/FormModal/utils/relations.js +9 -0
- package/admin/src/containers/FormModal/utils/staticData.js +43 -0
- package/admin/src/containers/Initializer/index.js +26 -0
- package/admin/src/containers/LeftMenu/Wrapper.js +14 -0
- package/admin/src/containers/LeftMenu/index.js +220 -0
- package/admin/src/containers/ListView/Wrapper.js +16 -0
- package/admin/src/containers/ListView/index.js +322 -0
- package/admin/src/containers/NotFoundPage/index.js +20 -0
- package/admin/src/containers/RecursivePath/index.js +22 -0
- package/admin/src/contexts/DataManagerContext.js +5 -0
- package/admin/src/contexts/ListViewContext.js +5 -0
- package/admin/src/hooks/useDataManager.js +6 -0
- package/admin/src/hooks/useListView.js +6 -0
- package/admin/src/icons/Curve.js +26 -0
- package/admin/src/icons/ManyToMany.js +98 -0
- package/admin/src/icons/ManyToOne.js +64 -0
- package/admin/src/icons/ManyWay.js +36 -0
- package/admin/src/icons/OneToMany.js +65 -0
- package/admin/src/icons/OneToOne.js +47 -0
- package/admin/src/icons/OneWay.js +38 -0
- package/admin/src/index.js +83 -0
- package/admin/src/lifecycles.js +13 -0
- package/admin/src/permissions.js +9 -0
- package/admin/src/pluginId.js +5 -0
- package/admin/src/reducers.js +10 -0
- package/admin/src/translations/ar.json +48 -0
- package/admin/src/translations/cs.json +151 -0
- package/admin/src/translations/de.json +187 -0
- package/admin/src/translations/dk.json +181 -0
- package/admin/src/translations/en.json +188 -0
- package/admin/src/translations/es.json +188 -0
- package/admin/src/translations/fr.json +87 -0
- package/admin/src/translations/id.json +187 -0
- package/admin/src/translations/index.js +51 -0
- package/admin/src/translations/it.json +187 -0
- package/admin/src/translations/ja.json +50 -0
- package/admin/src/translations/ko.json +57 -0
- package/admin/src/translations/ms.json +179 -0
- package/admin/src/translations/nl.json +171 -0
- package/admin/src/translations/pl.json +152 -0
- package/admin/src/translations/pt-BR.json +51 -0
- package/admin/src/translations/pt.json +51 -0
- package/admin/src/translations/ru.json +188 -0
- package/admin/src/translations/sk.json +186 -0
- package/admin/src/translations/th.json +181 -0
- package/admin/src/translations/tr.json +51 -0
- package/admin/src/translations/uk.json +180 -0
- package/admin/src/translations/zh-Hans.json +188 -0
- package/admin/src/translations/zh.json +178 -0
- package/admin/src/utils/convertAttrObjToArray.js +7 -0
- package/admin/src/utils/formAPI.js +112 -0
- package/admin/src/utils/getAttributeDisplayedType.js +31 -0
- package/admin/src/utils/getComponents.js +31 -0
- package/admin/src/utils/getTrad.js +5 -0
- package/admin/src/utils/makeSearch.js +15 -0
- package/admin/src/utils/makeUnique.js +3 -0
- package/config/functions/bootstrap.js +14 -0
- package/config/routes.json +144 -0
- package/controllers/Builder.js +7 -0
- package/controllers/ComponentCategories.js +43 -0
- package/controllers/Components.js +152 -0
- package/controllers/Connections.js +9 -0
- package/controllers/ContentTypes.js +143 -0
- package/controllers/validation/common.js +118 -0
- package/controllers/validation/component-category.js +21 -0
- package/controllers/validation/component.js +89 -0
- package/controllers/validation/content-type.js +161 -0
- package/controllers/validation/data-transform.js +32 -0
- package/controllers/validation/model-schema.js +91 -0
- package/controllers/validation/relations.js +56 -0
- package/controllers/validation/types.js +277 -0
- package/package.json +63 -0
- package/services/Builder.js +7 -0
- package/services/ComponentCategories.js +88 -0
- package/services/Components.js +103 -0
- package/services/ContentTypes.js +263 -0
- package/services/api-handler.js +158 -0
- package/services/constants.js +59 -0
- package/services/schema-builder/component-builder.js +137 -0
- package/services/schema-builder/content-type-builder.js +256 -0
- package/services/schema-builder/index.js +196 -0
- package/services/schema-builder/schema-handler.js +297 -0
- package/utils/attributes.js +154 -0
- package/utils/helpers.js +31 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2015-present Strapi Solutions SAS
|
|
2
|
+
|
|
3
|
+
Portions of the Strapi software are licensed as follows:
|
|
4
|
+
|
|
5
|
+
* All software that resides under an "ee/" directory (the “EE Software”), if that directory exists, is licensed under the license defined in "ee/LICENSE".
|
|
6
|
+
|
|
7
|
+
* All software outside of the above-mentioned directories or restrictions above is available under the "MIT Expat" license as set forth below.
|
|
8
|
+
|
|
9
|
+
MIT Expat License
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# Strapi plugin
|
|
2
|
+
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
## Deprecation Warning :warning:
|
|
6
|
+
|
|
7
|
+
Hello! We have some news to share,
|
|
8
|
+
|
|
9
|
+
We’ve decided it’ll soon be time to end the support for `strapi-plugin-content-type-builder`.
|
|
10
|
+
|
|
11
|
+
After years of iterations, Strapi is going to V4 and we won’t maintain V3 packages when it’ll reach its end-of-support milestone (~end of Q3 2022).
|
|
12
|
+
|
|
13
|
+
If you’ve been using `strapi-plugin-content-type-builder` and have migrated to V4 (or if you want to), you can find the equivalent and updated version of this package at this [URL](https://github.com/strapi/strapi/tree/master/packages/core/content-type-builder) and with the following name on NPM: `@strapi/plugin-content-type-builder`.
|
|
14
|
+
|
|
15
|
+
If you’ve contributed to the development of this package, thank you again for that! We hope to see you on the V4 soon.
|
|
16
|
+
|
|
17
|
+
The Akemona team
|
|
18
|
+
|
|
19
|
+
---
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* EditViewButton
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { useGlobalContext, CheckPermissions } from 'strapi-helper-plugin';
|
|
10
|
+
import { get } from 'lodash';
|
|
11
|
+
import { Button } from '@buffetjs/core';
|
|
12
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
13
|
+
import getTrad from '../../utils/getTrad';
|
|
14
|
+
import pluginPermissions from '../../permissions';
|
|
15
|
+
|
|
16
|
+
// Create link from content-type-builder to content-manager
|
|
17
|
+
function EditViewButton(props) {
|
|
18
|
+
const { currentEnvironment, emitEvent, formatMessage } = useGlobalContext();
|
|
19
|
+
// Retrieve URL from props
|
|
20
|
+
const { modifiedData, componentSlug, type } = get(
|
|
21
|
+
props,
|
|
22
|
+
['viewProps', '0'],
|
|
23
|
+
|
|
24
|
+
{
|
|
25
|
+
componentSlug: '',
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
const baseUrl = `/plugins/content-type-builder/${
|
|
30
|
+
type === 'content-types' ? type : 'component-categories'
|
|
31
|
+
}`;
|
|
32
|
+
const category = get(modifiedData, 'category', '');
|
|
33
|
+
|
|
34
|
+
const suffixUrl =
|
|
35
|
+
type === 'content-types' ? props.getModelName() : `${category}/${componentSlug}`;
|
|
36
|
+
|
|
37
|
+
const handleClick = () => {
|
|
38
|
+
emitEvent('willEditEditLayout');
|
|
39
|
+
props.push(`${baseUrl}/${suffixUrl}`);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
if (currentEnvironment !== 'development') {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (props.getModelName() === 'strapi::administrator') {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<CheckPermissions permissions={pluginPermissions.main}>
|
|
52
|
+
<Button
|
|
53
|
+
{...props}
|
|
54
|
+
onClick={handleClick}
|
|
55
|
+
icon={<FontAwesomeIcon icon="cog" style={{ fontSize: 13 }} />}
|
|
56
|
+
label={formatMessage({
|
|
57
|
+
id: getTrad(`injected-components.content-manager.edit-settings-view.link.${type}`),
|
|
58
|
+
})}
|
|
59
|
+
style={{
|
|
60
|
+
paddingLeft: 15,
|
|
61
|
+
paddingRight: 15,
|
|
62
|
+
outline: 0,
|
|
63
|
+
fontWeight: 600,
|
|
64
|
+
}}
|
|
65
|
+
/>
|
|
66
|
+
</CheckPermissions>
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
EditViewButton.propTypes = {
|
|
71
|
+
currentEnvironment: PropTypes.string.isRequired,
|
|
72
|
+
getModelName: PropTypes.func.isRequired,
|
|
73
|
+
push: PropTypes.func.isRequired,
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default EditViewButton;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* EditViewLink
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import PropTypes from 'prop-types';
|
|
9
|
+
import { LiLink, useGlobalContext, CheckPermissions } from 'strapi-helper-plugin';
|
|
10
|
+
import pluginPermissions from '../../permissions';
|
|
11
|
+
|
|
12
|
+
// Create link from content-type-builder to content-manager
|
|
13
|
+
function EditViewLink(props) {
|
|
14
|
+
const { currentEnvironment, emitEvent } = useGlobalContext();
|
|
15
|
+
// Retrieve URL from props
|
|
16
|
+
const url = `/plugins/content-type-builder/content-types/${props.getModelName()}`;
|
|
17
|
+
|
|
18
|
+
if (currentEnvironment !== 'development') {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (props.getModelName() === 'strapi::administrator') {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<CheckPermissions permissions={pluginPermissions.main}>
|
|
28
|
+
<LiLink
|
|
29
|
+
{...props}
|
|
30
|
+
url={url}
|
|
31
|
+
onClick={() => {
|
|
32
|
+
emitEvent('willEditEditLayout');
|
|
33
|
+
}}
|
|
34
|
+
/>
|
|
35
|
+
</CheckPermissions>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
EditViewLink.propTypes = {
|
|
40
|
+
currentEnvironment: PropTypes.string.isRequired,
|
|
41
|
+
getModelName: PropTypes.func.isRequired,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export default EditViewLink;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<svg width="30" height="30" xmlns="http://www.w3.org/2000/svg"><text transform="translate(-19 -4)" fill="#4B515A" fill-rule="evenodd" font-size="30" font-family="AppleColorEmoji, Apple Color Emoji"><tspan x="19" y="32">🏭</tspan></text></svg>
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import { components } from 'react-select';
|
|
4
|
+
import { useGlobalContext } from 'strapi-helper-plugin';
|
|
5
|
+
import { CheckboxWrapper, Label } from '@buffetjs/styles';
|
|
6
|
+
import getTrad from '../../utils/getTrad';
|
|
7
|
+
import SelectCheckbox from '../SelectCheckbox';
|
|
8
|
+
import SubUl from '../SelectMenuSubUl';
|
|
9
|
+
import UpperFirst from '../UpperFirst';
|
|
10
|
+
import Ul from '../SelectMenuUl';
|
|
11
|
+
import Text from './Text';
|
|
12
|
+
|
|
13
|
+
const MenuList = ({ selectProps: { changeMediaAllowedTypes, value }, ...rest }) => {
|
|
14
|
+
const { formatMessage } = useGlobalContext();
|
|
15
|
+
const Component = components.MenuList;
|
|
16
|
+
const areAllAllowedTypesSelected = value.value && value.value.length === 3;
|
|
17
|
+
const someChecked = value.value && !areAllAllowedTypesSelected && value.value.length > 0;
|
|
18
|
+
const options = [
|
|
19
|
+
{
|
|
20
|
+
name: 'images',
|
|
21
|
+
infos: '(JPEG, PNG, GIF, SVG, TIFF, ICO, DVU)',
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
name: 'videos',
|
|
25
|
+
infos: '(MPEG, MP4, Quicktime, WMV, AVI, FLV)',
|
|
26
|
+
},
|
|
27
|
+
|
|
28
|
+
{
|
|
29
|
+
name: 'files',
|
|
30
|
+
infos: '(CSV, ZIP, MP3, PDF, Excel, JSON, ...)',
|
|
31
|
+
},
|
|
32
|
+
];
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<Component {...rest}>
|
|
36
|
+
<Ul>
|
|
37
|
+
<li className="li-multi-menu">
|
|
38
|
+
<div style={{ marginTop: 3 }}>
|
|
39
|
+
<CheckboxWrapper>
|
|
40
|
+
<Label
|
|
41
|
+
htmlFor="overrideReactSelectBehavior"
|
|
42
|
+
onClick={() => {
|
|
43
|
+
changeMediaAllowedTypes({
|
|
44
|
+
target: { name: 'all', value: !areAllAllowedTypesSelected },
|
|
45
|
+
});
|
|
46
|
+
}}
|
|
47
|
+
>
|
|
48
|
+
<SelectCheckbox
|
|
49
|
+
id="checkAll"
|
|
50
|
+
checked={areAllAllowedTypesSelected}
|
|
51
|
+
someChecked={someChecked}
|
|
52
|
+
name="all"
|
|
53
|
+
onChange={() => {}}
|
|
54
|
+
/>
|
|
55
|
+
<UpperFirst content="All" />
|
|
56
|
+
</Label>
|
|
57
|
+
</CheckboxWrapper>
|
|
58
|
+
</div>
|
|
59
|
+
<SubUl tad="ul" isOpen>
|
|
60
|
+
{options.map(({ name, infos }) => {
|
|
61
|
+
const isChecked = value.value && value.value.includes(name);
|
|
62
|
+
const target = { name, value: !isChecked };
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<li key={name}>
|
|
66
|
+
<CheckboxWrapper>
|
|
67
|
+
<Label
|
|
68
|
+
htmlFor={name}
|
|
69
|
+
onClick={() => {
|
|
70
|
+
changeMediaAllowedTypes({ target });
|
|
71
|
+
}}
|
|
72
|
+
>
|
|
73
|
+
<SelectCheckbox
|
|
74
|
+
id="check"
|
|
75
|
+
name={name}
|
|
76
|
+
// Remove the handler
|
|
77
|
+
onChange={() => {}}
|
|
78
|
+
checked={isChecked}
|
|
79
|
+
/>
|
|
80
|
+
<Text>
|
|
81
|
+
<UpperFirst
|
|
82
|
+
content={formatMessage({
|
|
83
|
+
id: getTrad(`form.attribute.media.allowed-types.option-${name}`),
|
|
84
|
+
})}
|
|
85
|
+
/>
|
|
86
|
+
</Text>
|
|
87
|
+
<Text fontSize="sm" color="#B3B5B9" textTransform="italic">
|
|
88
|
+
{infos}
|
|
89
|
+
</Text>
|
|
90
|
+
</Label>
|
|
91
|
+
</CheckboxWrapper>
|
|
92
|
+
</li>
|
|
93
|
+
);
|
|
94
|
+
})}
|
|
95
|
+
</SubUl>
|
|
96
|
+
</li>
|
|
97
|
+
</Ul>
|
|
98
|
+
</Component>
|
|
99
|
+
);
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
MenuList.defaultProps = {
|
|
103
|
+
selectProps: {
|
|
104
|
+
value: {},
|
|
105
|
+
},
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
MenuList.propTypes = {
|
|
109
|
+
selectProps: PropTypes.shape({
|
|
110
|
+
changeMediaAllowedTypes: PropTypes.func.isRequired,
|
|
111
|
+
value: PropTypes.object,
|
|
112
|
+
}),
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
export default MenuList;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
|
|
4
|
+
const Text = styled.p`
|
|
5
|
+
display: contents;
|
|
6
|
+
color: ${({ theme, color }) => theme.main.colors[color] || color};
|
|
7
|
+
font-size: ${({ theme, fontSize }) => theme.main.sizes.fonts[fontSize]};
|
|
8
|
+
font-weight: ${({ theme, fontWeight }) => theme.main.fontWeights[fontWeight]};
|
|
9
|
+
text-transform: ${({ textTransform }) => textTransform};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
Text.defaultProps = {
|
|
13
|
+
color: 'black',
|
|
14
|
+
fontSize: 'md',
|
|
15
|
+
fontWeight: 'regular',
|
|
16
|
+
textTransform: 'none',
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
Text.propTypes = {
|
|
20
|
+
color: PropTypes.string,
|
|
21
|
+
fontSize: PropTypes.string,
|
|
22
|
+
fontWeight: PropTypes.string,
|
|
23
|
+
textTransform: PropTypes.string,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export default Text;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Select from 'react-select';
|
|
4
|
+
import { useGlobalContext } from 'strapi-helper-plugin';
|
|
5
|
+
import { upperFirst } from 'lodash';
|
|
6
|
+
import MenuList from './MenuList';
|
|
7
|
+
import getTrad from '../../utils/getTrad';
|
|
8
|
+
|
|
9
|
+
const AllowedTypesSelect = ({ name, changeMediaAllowedTypes, styles, value }) => {
|
|
10
|
+
const { formatMessage } = useGlobalContext();
|
|
11
|
+
// Create a ref in order to access the StateManager
|
|
12
|
+
// So we can close the menu after clicking on a menu item
|
|
13
|
+
// This allows us to get rid of the menuIsOpen state management
|
|
14
|
+
// So we let the custom components taking care of it
|
|
15
|
+
const ref = useRef();
|
|
16
|
+
|
|
17
|
+
/* eslint-disable indent */
|
|
18
|
+
|
|
19
|
+
const displayedValue =
|
|
20
|
+
value === null || value.length === 0
|
|
21
|
+
? formatMessage({ id: getTrad('form.attribute.media.allowed-types.none') })
|
|
22
|
+
: value
|
|
23
|
+
.sort()
|
|
24
|
+
.map(v => upperFirst(v))
|
|
25
|
+
.join(', ');
|
|
26
|
+
|
|
27
|
+
/* eslint-enable indent */
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Select
|
|
31
|
+
components={{ MenuList }}
|
|
32
|
+
isClearable={false}
|
|
33
|
+
isSearchable={false}
|
|
34
|
+
name={name}
|
|
35
|
+
changeMediaAllowedTypes={changeMediaAllowedTypes}
|
|
36
|
+
ref={ref}
|
|
37
|
+
refState={ref}
|
|
38
|
+
styles={styles}
|
|
39
|
+
value={{ label: displayedValue, value: value || '' }}
|
|
40
|
+
/>
|
|
41
|
+
);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
AllowedTypesSelect.defaultProps = {
|
|
45
|
+
value: null,
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
AllowedTypesSelect.propTypes = {
|
|
49
|
+
changeMediaAllowedTypes: PropTypes.func.isRequired,
|
|
50
|
+
name: PropTypes.string.isRequired,
|
|
51
|
+
styles: PropTypes.object.isRequired,
|
|
52
|
+
value: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
export default AllowedTypesSelect;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const Button = styled.button`
|
|
4
|
+
display: flex;
|
|
5
|
+
width: 100% !important;
|
|
6
|
+
height: 4rem;
|
|
7
|
+
padding: 0 1rem 0 1rem;
|
|
8
|
+
margin-top: 0.6rem;
|
|
9
|
+
margin-bottom: 0.8rem;
|
|
10
|
+
align-items: center;
|
|
11
|
+
justify-content: space-between;
|
|
12
|
+
border-radius: 0.25rem;
|
|
13
|
+
border: 1px solid #e3e9f3;
|
|
14
|
+
background: #ffffff;
|
|
15
|
+
line-height: 4rem;
|
|
16
|
+
box-shadow: 1px 1px 1px rgba(104, 118, 145, 0.05);
|
|
17
|
+
cursor: pointer;
|
|
18
|
+
|
|
19
|
+
&:hover,
|
|
20
|
+
&:active,
|
|
21
|
+
&:focus {
|
|
22
|
+
background: #e6f0fb;
|
|
23
|
+
border-color: #aed4fb;
|
|
24
|
+
outline: 0;
|
|
25
|
+
|
|
26
|
+
.attributeIcon {
|
|
27
|
+
background-color: #007eff;
|
|
28
|
+
|
|
29
|
+
> svg {
|
|
30
|
+
g {
|
|
31
|
+
path {
|
|
32
|
+
fill: #007eff;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.attributeType {
|
|
40
|
+
margin-right: 1.2rem;
|
|
41
|
+
color: #323740;
|
|
42
|
+
text-transform: capitalize;
|
|
43
|
+
font-size: 1.3rem;
|
|
44
|
+
font-weight: 500;
|
|
45
|
+
font-style: normal;
|
|
46
|
+
-webkit-font-smoothing: subpixel-antialiased;
|
|
47
|
+
}
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
export default Button;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
const Card = styled.div`
|
|
4
|
+
font-size: 1.3rem;
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
max-width: calc(100% - 18px);
|
|
8
|
+
|
|
9
|
+
> span {
|
|
10
|
+
white-space: nowrap;
|
|
11
|
+
color: #9ea7b8;
|
|
12
|
+
font-size: 1.2rem;
|
|
13
|
+
font-weight: 400;
|
|
14
|
+
-webkit-font-smoothing: antialiased;
|
|
15
|
+
margin-top: auto;
|
|
16
|
+
margin-bottom: auto;
|
|
17
|
+
line-height: normal;
|
|
18
|
+
|
|
19
|
+
&:last-child {
|
|
20
|
+
text-overflow: ellipsis;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
|
|
26
|
+
export default Card;
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* AttributeOption
|
|
4
|
+
*
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';
|
|
8
|
+
import { AttributeIcon } from '@buffetjs/core';
|
|
9
|
+
import PropTypes from 'prop-types';
|
|
10
|
+
import { FormattedMessage } from 'react-intl';
|
|
11
|
+
import { useHistory } from 'react-router-dom';
|
|
12
|
+
import { useGlobalContext, useQuery } from 'strapi-helper-plugin';
|
|
13
|
+
import getTrad from '../../utils/getTrad';
|
|
14
|
+
import makeSearch from '../../utils/makeSearch';
|
|
15
|
+
import Button from './Button';
|
|
16
|
+
import Card from './Card';
|
|
17
|
+
|
|
18
|
+
const AttributeOption = forwardRef(({ tabIndex, type }, ref) => {
|
|
19
|
+
const buttonRef = useRef();
|
|
20
|
+
const tabRef = useRef();
|
|
21
|
+
const query = useQuery();
|
|
22
|
+
const { push } = useHistory();
|
|
23
|
+
const { emitEvent } = useGlobalContext();
|
|
24
|
+
tabRef.current = tabIndex;
|
|
25
|
+
|
|
26
|
+
useImperativeHandle(ref, () => ({
|
|
27
|
+
focus: () => {
|
|
28
|
+
buttonRef.current.focus();
|
|
29
|
+
},
|
|
30
|
+
}));
|
|
31
|
+
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (tabRef.current === 0) {
|
|
34
|
+
buttonRef.current.focus();
|
|
35
|
+
}
|
|
36
|
+
}, []);
|
|
37
|
+
|
|
38
|
+
const handleClick = () => {
|
|
39
|
+
const forTarget = query.get('forTarget');
|
|
40
|
+
const targetUid = query.get('targetUid');
|
|
41
|
+
const header_label_1 = query.get('header_label_1');
|
|
42
|
+
const header_info_category_1 = query.get('header_info_category_1');
|
|
43
|
+
const header_info_name_1 = query.get('header_info_name_1');
|
|
44
|
+
const header_label_2 = query.get('header_label_2');
|
|
45
|
+
const header_icon_name_2 = query.get('header_icon_name_2');
|
|
46
|
+
const header_icon_isCustom_2 = query.get('header_icon_isCustom_2');
|
|
47
|
+
const header_info_category_2 = query.get('header_info_category_2');
|
|
48
|
+
const header_info_name_2 = query.get('header_info_name_2');
|
|
49
|
+
const header_label_3 = query.get('header_label_3');
|
|
50
|
+
const header_icon_name_3 = query.get('header_icon_name_3');
|
|
51
|
+
const header_icon_isCustom_3 = query.get('header_icon_isCustom_3');
|
|
52
|
+
const header_info_category_3 = query.get('header_info_category_3');
|
|
53
|
+
const header_info_name_3 = query.get('header_info_name_3');
|
|
54
|
+
const header_label_4 = query.get('header_label_4');
|
|
55
|
+
const header_icon_name_4 = query.get('header_icon_name_4');
|
|
56
|
+
const header_icon_isCustom_4 = query.get('header_icon_isCustom_4');
|
|
57
|
+
const header_info_category_4 = query.get('header_info_category_4');
|
|
58
|
+
const header_info_name_4 = query.get('header_info_name_4');
|
|
59
|
+
|
|
60
|
+
const search = makeSearch({
|
|
61
|
+
modalType: 'attribute',
|
|
62
|
+
actionType: 'create',
|
|
63
|
+
settingType: 'base',
|
|
64
|
+
forTarget,
|
|
65
|
+
targetUid,
|
|
66
|
+
attributeType: type,
|
|
67
|
+
step: type === 'component' ? '1' : null,
|
|
68
|
+
|
|
69
|
+
header_label_1,
|
|
70
|
+
header_info_name_1,
|
|
71
|
+
header_info_category_1,
|
|
72
|
+
header_label_2,
|
|
73
|
+
header_icon_name_2,
|
|
74
|
+
header_icon_isCustom_2,
|
|
75
|
+
header_info_name_2,
|
|
76
|
+
header_info_category_2,
|
|
77
|
+
header_label_3,
|
|
78
|
+
header_icon_name_3,
|
|
79
|
+
header_icon_isCustom_3,
|
|
80
|
+
header_info_name_3,
|
|
81
|
+
header_info_category_3,
|
|
82
|
+
header_label_4,
|
|
83
|
+
header_icon_name_4,
|
|
84
|
+
header_icon_isCustom_4,
|
|
85
|
+
header_info_name_4,
|
|
86
|
+
header_info_category_4,
|
|
87
|
+
header_icon_isCustom_1: false,
|
|
88
|
+
header_icon_name_1: type,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
if (forTarget === 'contentType') {
|
|
92
|
+
emitEvent('didSelectContentTypeFieldType', { type });
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
push({
|
|
96
|
+
search,
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
return (
|
|
101
|
+
<div className="col-6">
|
|
102
|
+
<Button ref={buttonRef} type="button" onClick={handleClick}>
|
|
103
|
+
<Card>
|
|
104
|
+
<AttributeIcon type={type} style={{ marginRight: 10 }} className="attributeIcon" />
|
|
105
|
+
<FormattedMessage id={getTrad(`attribute.${type}`)}>
|
|
106
|
+
{message => <span className="attributeType">{message}</span>}
|
|
107
|
+
</FormattedMessage>
|
|
108
|
+
<FormattedMessage id={getTrad(`attribute.${type}.description`)} />
|
|
109
|
+
</Card>
|
|
110
|
+
</Button>
|
|
111
|
+
</div>
|
|
112
|
+
);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
AttributeOption.displayName = 'AttributeOption';
|
|
116
|
+
|
|
117
|
+
AttributeOption.defaultProps = {
|
|
118
|
+
tabIndex: 0,
|
|
119
|
+
type: 'text',
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
AttributeOption.propTypes = {
|
|
123
|
+
tabIndex: PropTypes.number,
|
|
124
|
+
type: PropTypes.string,
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
export default AttributeOption;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import CTSelected from './icons/CTSelected';
|
|
4
|
+
import CTUnselected from './icons/CTUnselected';
|
|
5
|
+
|
|
6
|
+
const CT = ({ selected }) =>
|
|
7
|
+
selected ? (
|
|
8
|
+
<CTSelected aria-hidden data-testid="ct-selected" />
|
|
9
|
+
) : (
|
|
10
|
+
<CTUnselected aria-hidden data-testid="ct-unselected" />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
CT.defaultProps = {
|
|
14
|
+
selected: false,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
CT.propTypes = {
|
|
18
|
+
selected: PropTypes.bool,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default CT;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { Label } from '@buffetjs/core';
|
|
3
|
+
|
|
4
|
+
const EnumerationWrapper = styled(Label)`
|
|
5
|
+
width: 415px;
|
|
6
|
+
margin-bottom: 3px;
|
|
7
|
+
min-height: 91px;
|
|
8
|
+
position: relative;
|
|
9
|
+
padding-left: 54px;
|
|
10
|
+
padding-top: 17px;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
`;
|
|
13
|
+
|
|
14
|
+
export default EnumerationWrapper;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import STSelected from './icons/STSelected';
|
|
4
|
+
import STUnselected from './icons/STUnselected';
|
|
5
|
+
|
|
6
|
+
const ST = ({ selected }) =>
|
|
7
|
+
selected ? (
|
|
8
|
+
<STSelected aria-hidden data-testid="st-selected" />
|
|
9
|
+
) : (
|
|
10
|
+
<STUnselected aria-hidden data-testid="st-unselected" />
|
|
11
|
+
);
|
|
12
|
+
|
|
13
|
+
ST.defaultProps = {
|
|
14
|
+
selected: false,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
ST.propTypes = {
|
|
18
|
+
selected: PropTypes.bool,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export default ST;
|