@akemona-org/strapi-plugin-content-manager 3.7.0 → 3.7.2

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.
Files changed (155) hide show
  1. package/admin/src/InjectedComponents/ContentTypeBuilder/ConfigureViewButton/index.js +2 -5
  2. package/admin/src/components/AddDropdown/index.js +5 -12
  3. package/admin/src/components/Block/index.js +2 -4
  4. package/admin/src/components/ComponentInitializer/index.js +1 -1
  5. package/admin/src/components/CustomTable/ActionCollapse/index.js +2 -2
  6. package/admin/src/components/CustomTable/Row/Cell.js +1 -1
  7. package/admin/src/components/CustomTable/Row/index.js +6 -6
  8. package/admin/src/components/CustomTable/index.js +5 -5
  9. package/admin/src/components/CustomTable/styledComponents.js +2 -2
  10. package/admin/src/components/DragLayer/index.js +1 -1
  11. package/admin/src/components/DraggedField/Wrapper.js +2 -7
  12. package/admin/src/components/DraggedField/index.js +3 -3
  13. package/admin/src/components/DraggedField/utils/getHeight.js +1 -1
  14. package/admin/src/components/DraggedFieldWithPreview/DynamicComponent.js +2 -2
  15. package/admin/src/components/DraggedFieldWithPreview/Wrapper.js +1 -2
  16. package/admin/src/components/DraggedFieldWithPreview/index.js +4 -4
  17. package/admin/src/components/DynamicComponentCard/index.js +2 -8
  18. package/admin/src/components/DynamicZone/Picker/index.js +3 -3
  19. package/admin/src/components/DynamicZone/index.js +4 -4
  20. package/admin/src/components/DynamicZone/utils/select.js +1 -1
  21. package/admin/src/components/FieldComponent/index.js +1 -1
  22. package/admin/src/components/FieldComponent/utils/select.js +6 -6
  23. package/admin/src/components/FieldsReorder/Item.js +6 -9
  24. package/admin/src/components/FieldsReorder/index.js +6 -17
  25. package/admin/src/components/FilterOptionsCTA/index.js +1 -1
  26. package/admin/src/components/FilterPicker/components.js +2 -2
  27. package/admin/src/components/FilterPicker/index.js +7 -7
  28. package/admin/src/components/FilterPicker/reducer.js +2 -2
  29. package/admin/src/components/FilterPickerOption/Input.js +1 -1
  30. package/admin/src/components/FilterPickerOption/Option.js +1 -3
  31. package/admin/src/components/FilterPickerOption/components.js +2 -2
  32. package/admin/src/components/FilterPickerOption/index.js +4 -4
  33. package/admin/src/components/FormTitle/index.js +1 -5
  34. package/admin/src/components/InputJSON/index.js +3 -3
  35. package/admin/src/components/InputJSON/jsonlint.js +639 -383
  36. package/admin/src/components/InputJSONWithErrors/index.js +2 -2
  37. package/admin/src/components/InputUID/Options/index.js +2 -2
  38. package/admin/src/components/InputUID/Options/wrapper.js +1 -1
  39. package/admin/src/components/InputUID/index.js +2 -2
  40. package/admin/src/components/Inputs/index.js +4 -4
  41. package/admin/src/components/Inputs/utils/generateOptions.js +2 -2
  42. package/admin/src/components/Inputs/utils/getStep.js +1 -1
  43. package/admin/src/components/MediaPreviewList/index.js +5 -5
  44. package/admin/src/components/NonRepeatableComponent/index.js +4 -4
  45. package/admin/src/components/PreviewWysiwyg/Wrapper.js +1 -1
  46. package/admin/src/components/PreviewWysiwyg/utils/satinizeHtml.js +1 -1
  47. package/admin/src/components/RelationPreviewList/RelationPreviewTooltip.js +3 -3
  48. package/admin/src/components/RelationPreviewList/index.js +1 -1
  49. package/admin/src/components/RepeatableComponent/Banner.js +2 -2
  50. package/admin/src/components/RepeatableComponent/BannerWrapper.js +1 -2
  51. package/admin/src/components/RepeatableComponent/DraggedItem/index.js +3 -9
  52. package/admin/src/components/RepeatableComponent/index.js +8 -8
  53. package/admin/src/components/RepeatableComponent/reducer.js +9 -9
  54. package/admin/src/components/Search/index.js +2 -2
  55. package/admin/src/components/SectionTitle/index.js +1 -3
  56. package/admin/src/components/SelectMany/ListItem.js +2 -2
  57. package/admin/src/components/SelectMany/index.js +3 -3
  58. package/admin/src/components/SelectOne/SingleValue.js +1 -1
  59. package/admin/src/components/SelectWrapper/ClearIndicator.js +1 -1
  60. package/admin/src/components/SelectWrapper/Option.js +1 -1
  61. package/admin/src/components/SelectWrapper/index.js +17 -27
  62. package/admin/src/components/SelectWrapper/utils/styles.js +6 -6
  63. package/admin/src/components/SettingsViewWrapper/index.js +9 -9
  64. package/admin/src/components/SortableList/Item.js +5 -11
  65. package/admin/src/components/Wysiwyg/MediaLib.js +1 -1
  66. package/admin/src/components/Wysiwyg/index.js +17 -25
  67. package/admin/src/components/Wysiwyg/toggleMode.js +3 -7
  68. package/admin/src/components/Wysiwyg/utils.js +2 -10
  69. package/admin/src/components/WysiwygDropUpload/index.js +1 -1
  70. package/admin/src/components/WysiwygInlineControls/Button.js +1 -1
  71. package/admin/src/components/WysiwygInlineControls/index.js +1 -1
  72. package/admin/src/components/WysiwygWithErrors/index.js +1 -1
  73. package/admin/src/containers/CollectionTypeFormWrapper/index.js +7 -12
  74. package/admin/src/containers/CollectionTypeFormWrapper/utils/getRequestUrl.js +1 -1
  75. package/admin/src/containers/CollectionTypeRecursivePath/index.js +1 -1
  76. package/admin/src/containers/ComponentSetttingsView/index.js +2 -2
  77. package/admin/src/containers/EditSettingsView/index.js +17 -17
  78. package/admin/src/containers/EditSettingsView/reducer.js +10 -10
  79. package/admin/src/containers/EditSettingsView/utils/createPossibleMainFieldsForModelsAndComponents.js +2 -2
  80. package/admin/src/containers/EditSettingsView/utils/getInputProps.js +1 -1
  81. package/admin/src/containers/EditSettingsView/utils/layout.js +9 -9
  82. package/admin/src/containers/EditView/DeleteLink/index.js +1 -1
  83. package/admin/src/containers/EditView/Header/index.js +10 -9
  84. package/admin/src/containers/EditView/Header/utils/getDraftRelations.js +3 -3
  85. package/admin/src/containers/EditView/index.js +7 -10
  86. package/admin/src/containers/EditView/utils/createAttributesLayout.js +4 -9
  87. package/admin/src/containers/EditView/utils/getFieldsActionMatchingPermissions.js +1 -1
  88. package/admin/src/containers/EditViewDataManagerProvider/index.js +7 -12
  89. package/admin/src/containers/EditViewDataManagerProvider/reducer.js +14 -14
  90. package/admin/src/containers/EditViewDataManagerProvider/utils/cleanData.js +4 -4
  91. package/admin/src/containers/EditViewDataManagerProvider/utils/getYupInnerErrors.js +2 -8
  92. package/admin/src/containers/EditViewDataManagerProvider/utils/schema.js +12 -12
  93. package/admin/src/containers/EditViewLayoutManager/Permissions.js +1 -1
  94. package/admin/src/containers/EditViewLayoutManager/reducer.js +1 -1
  95. package/admin/src/containers/EditViewLayoutManager/selectors.js +1 -1
  96. package/admin/src/containers/ListSettingsView/Label.js +2 -11
  97. package/admin/src/containers/ListSettingsView/index.js +9 -9
  98. package/admin/src/containers/ListSettingsView/reducer.js +2 -2
  99. package/admin/src/containers/ListView/FieldPicker/Fields/Wrapper.js +1 -1
  100. package/admin/src/containers/ListView/FieldPicker/Fields/index.js +2 -2
  101. package/admin/src/containers/ListView/FieldPicker/index.js +2 -2
  102. package/admin/src/containers/ListView/Filter.js +1 -4
  103. package/admin/src/containers/ListView/actions.js +2 -2
  104. package/admin/src/containers/ListView/index.js +8 -7
  105. package/admin/src/containers/ListView/reducer.js +5 -5
  106. package/admin/src/containers/ListView/selectors.js +2 -2
  107. package/admin/src/containers/ListView/utils/createPluginsFilter.js +1 -1
  108. package/admin/src/containers/ListView/utils/getAllAllowedHeaders.js +1 -1
  109. package/admin/src/containers/ListView/utils/getFirstSortableHeader.js +2 -2
  110. package/admin/src/containers/ListViewLayoutManager/Permissions.js +1 -1
  111. package/admin/src/containers/ListViewProvider/index.js +1 -3
  112. package/admin/src/containers/Main/index.js +2 -2
  113. package/admin/src/containers/Main/reducer.js +1 -1
  114. package/admin/src/containers/Main/selectors.js +2 -2
  115. package/admin/src/containers/RBACManager/reducer.js +1 -1
  116. package/admin/src/containers/SingleTypeFormWrapper/index.js +6 -11
  117. package/admin/src/containers/SingleTypeFormWrapper/utils/getRequestUrl.js +1 -1
  118. package/admin/src/containers/WysiwygProvider/index.js +1 -3
  119. package/admin/src/hooks/useContentTypeLayout/index.js +1 -1
  120. package/admin/src/hooks/useFetchContentTypeLayout/index.js +3 -3
  121. package/admin/src/hooks/useFetchContentTypeLayout/reducer.js +1 -1
  122. package/admin/src/hooks/useFetchContentTypeLayout/utils/formatLayouts.js +8 -8
  123. package/admin/src/hooks/useFindRedirectionLink/index.js +1 -1
  124. package/admin/src/hooks/useFindRedirectionLink/selectors.js +1 -1
  125. package/admin/src/icons/Cross/index.js +1 -6
  126. package/admin/src/icons/Na/index.js +3 -22
  127. package/admin/src/index.js +1 -1
  128. package/admin/src/pluginId.js +1 -1
  129. package/admin/src/selectors.js +2 -2
  130. package/admin/src/sharedReducers/crudReducer/actions.js +3 -3
  131. package/admin/src/sharedReducers/crudReducer/reducer.js +1 -1
  132. package/admin/src/sharedReducers/crudReducer/selectors.js +1 -1
  133. package/admin/src/utils/checkIfAttributeIsDisplayable.js +1 -1
  134. package/admin/src/utils/formatFiltersFromQuery.js +2 -2
  135. package/admin/src/utils/formatLayoutToApi.js +2 -2
  136. package/admin/src/utils/generatePermissionsObject.js +3 -2
  137. package/admin/src/utils/getComponents.js +3 -5
  138. package/admin/src/utils/getFieldName.js +2 -2
  139. package/admin/src/utils/getMaxTempKey.js +2 -2
  140. package/admin/src/utils/getRequestUrl.js +1 -1
  141. package/admin/src/utils/getTrad.js +1 -1
  142. package/admin/src/utils/mergeMetasWithSchema.js +2 -2
  143. package/admin/src/utils/removeKeyInObject.js +1 -1
  144. package/admin/src/utils/removePasswordFieldsFromData.js +2 -2
  145. package/controllers/content-types.js +4 -4
  146. package/package.json +4 -4
  147. package/services/components.js +1 -1
  148. package/services/configuration.js +9 -9
  149. package/services/permission-checker.js +6 -6
  150. package/services/uid.js +1 -1
  151. package/services/utils/configuration/layouts.js +14 -35
  152. package/services/utils/configuration/metadatas.js +1 -1
  153. package/services/utils/store.js +9 -9
  154. package/utils/index.js +1 -1
  155. package/utils/wrap-bad-request.js +14 -12
@@ -14,7 +14,7 @@ export const getData = () => {
14
14
  };
15
15
  };
16
16
 
17
- export const getDataSucceeded = data => ({
17
+ export const getDataSucceeded = (data) => ({
18
18
  type: GET_DATA_SUCCEEDED,
19
19
  data,
20
20
  });
@@ -33,12 +33,12 @@ export const setDataStructures = (componentsDataStructure, contentTypeDataStruct
33
33
  contentTypeDataStructure,
34
34
  });
35
35
 
36
- export const setStatus = status => ({
36
+ export const setStatus = (status) => ({
37
37
  type: SET_STATUS,
38
38
  status,
39
39
  });
40
40
 
41
- export const submitSucceeded = data => ({
41
+ export const submitSucceeded = (data) => ({
42
42
  type: SUBMIT_SUCCEEDED,
43
43
  data,
44
44
  });
@@ -26,7 +26,7 @@ const crudInitialState = {
26
26
  };
27
27
 
28
28
  const crudReducer = (state = crudInitialState, action) =>
29
- produce(state, draftState => {
29
+ produce(state, (draftState) => {
30
30
  switch (action.type) {
31
31
  case GET_DATA: {
32
32
  draftState.isLoading = true;
@@ -1,5 +1,5 @@
1
1
  import pluginId from '../../pluginId';
2
2
 
3
- const selectCrudReducer = state => state.get(`${pluginId}_editViewCrudReducer`);
3
+ const selectCrudReducer = (state) => state.get(`${pluginId}_editViewCrudReducer`);
4
4
 
5
5
  export default selectCrudReducer;
@@ -1,6 +1,6 @@
1
1
  import { toLower } from 'lodash';
2
2
 
3
- const checkIfAttributeIsDisplayable = attribute => {
3
+ const checkIfAttributeIsDisplayable = (attribute) => {
4
4
  const type = attribute.type;
5
5
 
6
6
  if (type === 'relation') {
@@ -16,7 +16,7 @@ const VALID_REST_OPERATORS = [
16
16
  ];
17
17
 
18
18
  // from strapi-utils/convert-rest-query-params
19
- const findAppliedFilter = whereClause => {
19
+ const findAppliedFilter = (whereClause) => {
20
20
  // Useful to remove the mainField of relation fields.
21
21
  const formattedWhereClause = whereClause.split('.')[0];
22
22
  const separatorIndex = whereClause.lastIndexOf('_');
@@ -41,7 +41,7 @@ const formatFiltersFromQuery = ({ _where }) => {
41
41
  return [];
42
42
  }
43
43
 
44
- return _where.map(obj => {
44
+ return _where.map((obj) => {
45
45
  const [key] = Object.keys(obj);
46
46
  const { field, operator } = findAppliedFilter(key);
47
47
 
@@ -1,7 +1,7 @@
1
1
  import { omit, get } from 'lodash';
2
2
 
3
3
  const formatLayoutToApi = ({ layouts, metadatas, ...rest }) => {
4
- const list = layouts.list.map(obj => {
4
+ const list = layouts.list.map((obj) => {
5
5
  if (obj.name) {
6
6
  return obj.name;
7
7
  }
@@ -27,7 +27,7 @@ const formatLayoutToApi = ({ layouts, metadatas, ...rest }) => {
27
27
  };
28
28
  }, {});
29
29
 
30
- const edit = layouts.edit.map(row =>
30
+ const edit = layouts.edit.map((row) =>
31
31
  row.map(({ name, size }) => ({
32
32
  name,
33
33
  size,
@@ -1,6 +1,7 @@
1
- const addSubjectToPermissionsArray = (array, uid) => array.map(data => ({ ...data, subject: uid }));
1
+ const addSubjectToPermissionsArray = (array, uid) =>
2
+ array.map((data) => ({ ...data, subject: uid }));
2
3
 
3
- const generatePermissionsObject = uid => {
4
+ const generatePermissionsObject = (uid) => {
4
5
  const permissions = {
5
6
  create: [{ action: 'plugins::content-manager.explorer.create', subject: null }],
6
7
  delete: [{ action: 'plugins::content-manager.explorer.delete', subject: null }],
@@ -21,12 +21,10 @@ const getInjectedComponents = (
21
21
  const injectedComponents = get(currentPlugin, 'injectedComponents', []);
22
22
 
23
23
  const compos = injectedComponents
24
- .filter(compo => {
25
- return (
26
- compo.plugin === `${pluginId}.${container}` && compo.area === area
27
- );
24
+ .filter((compo) => {
25
+ return compo.plugin === `${pluginId}.${container}` && compo.area === area;
28
26
  })
29
- .map(compo => {
27
+ .map((compo) => {
30
28
  const Component = compo.component;
31
29
 
32
30
  return (
@@ -1,6 +1,6 @@
1
1
  import { isNaN } from 'lodash';
2
2
 
3
- const getFieldName = stringName =>
4
- stringName.split('.').filter(string => isNaN(parseInt(string, 10)));
3
+ const getFieldName = (stringName) =>
4
+ stringName.split('.').filter((string) => isNaN(parseInt(string, 10)));
5
5
 
6
6
  export default getFieldName;
@@ -1,11 +1,11 @@
1
- const getMaxTempKey = arr => {
1
+ const getMaxTempKey = (arr) => {
2
2
  if (arr.length === 0) {
3
3
  return -1;
4
4
  }
5
5
 
6
6
  return Math.max.apply(
7
7
  Math,
8
- arr.map(o => o.__temp_key__)
8
+ arr.map((o) => o.__temp_key__)
9
9
  );
10
10
  };
11
11
 
@@ -1,5 +1,5 @@
1
1
  import pluginId from '../pluginId';
2
2
 
3
- const getRequestUrl = path => `/${pluginId}/${path}`;
3
+ const getRequestUrl = (path) => `/${pluginId}/${path}`;
4
4
 
5
5
  export default getRequestUrl;
@@ -1,5 +1,5 @@
1
1
  import pluginId from '../pluginId';
2
2
 
3
- const getTrad = id => `${pluginId}.${id}`;
3
+ const getTrad = (id) => `${pluginId}.${id}`;
4
4
 
5
5
  export default getTrad;
@@ -1,14 +1,14 @@
1
1
  import { set } from 'lodash';
2
2
 
3
3
  const mergeMetasWithSchema = (data, schemas, mainSchemaKey) => {
4
- const findSchema = refUid => schemas.find(obj => obj.uid === refUid);
4
+ const findSchema = (refUid) => schemas.find((obj) => obj.uid === refUid);
5
5
  const merged = Object.assign({}, data);
6
6
  const mainUID = data[mainSchemaKey].uid;
7
7
  const mainSchema = findSchema(mainUID);
8
8
 
9
9
  set(merged, [mainSchemaKey], { ...data[mainSchemaKey], ...mainSchema });
10
10
 
11
- Object.keys(data.components).forEach(compoUID => {
11
+ Object.keys(data.components).forEach((compoUID) => {
12
12
  const compoSchema = findSchema(compoUID);
13
13
 
14
14
  set(merged, ['components', compoUID], { ...data.components[compoUID], ...compoSchema });
@@ -17,7 +17,7 @@ const removeKeyInObject = (obj, keyToRemove) => {
17
17
  return acc;
18
18
  }
19
19
 
20
- return { ...acc, [current]: value.map(obj => removeKeyInObject(obj, keyToRemove)) };
20
+ return { ...acc, [current]: value.map((obj) => removeKeyInObject(obj, keyToRemove)) };
21
21
  }
22
22
 
23
23
  if (typeof value === 'object') {
@@ -10,7 +10,7 @@ const removePasswordFieldsFromData = (data, contentTypeSchema, componentSchema)
10
10
  const isRepeatable = getOtherInfos(schema, [current, 'repeatable']);
11
11
 
12
12
  if (attrType === 'dynamiczone') {
13
- acc[current] = value.map(componentValue => {
13
+ acc[current] = value.map((componentValue) => {
14
14
  const subCleanedData = recursiveCleanData(
15
15
  componentValue,
16
16
  componentSchema[componentValue.__component]
@@ -26,7 +26,7 @@ const removePasswordFieldsFromData = (data, contentTypeSchema, componentSchema)
26
26
  if (isRepeatable) {
27
27
  /* eslint-disable indent */
28
28
  acc[current] = value
29
- ? value.map(compoData => {
29
+ ? value.map((compoData) => {
30
30
  const subCleanedData = recursiveCleanData(compoData, componentSchema[component]);
31
31
 
32
32
  return subCleanedData;
@@ -8,7 +8,7 @@ const hasEditMainField = has('edit.mainField');
8
8
  const getEditMainField = prop('edit.mainField');
9
9
  const assocListMainField = assoc('list.mainField');
10
10
 
11
- const assocMainField = metadata =>
11
+ const assocMainField = (metadata) =>
12
12
  hasEditMainField(metadata) ? assocListMainField(getEditMainField(metadata), metadata) : metadata;
13
13
 
14
14
  module.exports = {
@@ -32,7 +32,7 @@ module.exports = {
32
32
 
33
33
  const contentTypes = await findAllContentTypes();
34
34
  const configurations = await Promise.all(
35
- contentTypes.map(async contentType => {
35
+ contentTypes.map(async (contentType) => {
36
36
  const { uid, settings } = await findConfiguration(contentType);
37
37
  return { uid, settings };
38
38
  })
@@ -77,7 +77,7 @@ module.exports = {
77
77
  const { body } = ctx.request;
78
78
 
79
79
  const contentTypeService = getService('content-types');
80
- const metricsService = getService('metrics');
80
+ // const metricsService = getService('metrics');
81
81
 
82
82
  const contentType = await contentTypeService.findContentType(uid);
83
83
 
@@ -105,7 +105,7 @@ module.exports = {
105
105
 
106
106
  const newConfiguration = await contentTypeService.updateConfiguration(contentType, input);
107
107
 
108
- await metricsService.sendDidConfigureListView(contentType, newConfiguration);
108
+ // await metricsService.sendDidConfigureListView(contentType, newConfiguration);
109
109
 
110
110
  ctx.body = { data: newConfiguration };
111
111
  },
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "3.7.0",
6
+ "version": "3.7.2",
7
7
  "description": "A powerful UI to easily manage your data.",
8
8
  "strapi": {
9
9
  "name": "Content Manager",
@@ -12,8 +12,8 @@
12
12
  "required": true
13
13
  },
14
14
  "dependencies": {
15
- "@akemona-org/strapi-helper-plugin": "3.7.0",
16
- "@akemona-org/strapi-utils": "3.7.0",
15
+ "@akemona-org/strapi-helper-plugin": "3.7.2",
16
+ "@akemona-org/strapi-utils": "3.7.2",
17
17
  "@buffetjs/core": "3.3.8",
18
18
  "@buffetjs/custom": "3.3.8",
19
19
  "@buffetjs/hooks": "3.3.8",
@@ -73,5 +73,5 @@
73
73
  "npm": ">=6.0.0"
74
74
  },
75
75
  "license": "SEE LICENSE IN LICENSE",
76
- "gitHead": "129a8d6191b55810fd66448dcc47fee829df986c"
76
+ "gitHead": "4ab59dbae5135819558c6ae27b45a556ff27cf55"
77
77
  }
@@ -55,7 +55,7 @@ module.exports = {
55
55
  async findComponentsConfigurations(model) {
56
56
  const componentsMap = {};
57
57
 
58
- const getComponentConfigurations = async uid => {
58
+ const getComponentConfigurations = async (uid) => {
59
59
  const component = this.findComponent(uid);
60
60
 
61
61
  if (has(uid, componentsMap)) return;
@@ -4,11 +4,11 @@ const { intersection, difference } = require('lodash');
4
4
  const { createDefaultConfiguration, syncConfiguration } = require('./utils/configuration');
5
5
 
6
6
  module.exports = ({ isComponent, prefix, storeUtils, getModels }) => {
7
- const uidToStoreKey = uid => {
7
+ const uidToStoreKey = (uid) => {
8
8
  return `${prefix}::${uid}`;
9
9
  };
10
10
 
11
- const getConfiguration = uid => {
11
+ const getConfiguration = (uid) => {
12
12
  const storeKey = uidToStoreKey(uid);
13
13
  return storeUtils.getModelConfiguration(storeKey);
14
14
  };
@@ -31,7 +31,7 @@ module.exports = ({ isComponent, prefix, storeUtils, getModels }) => {
31
31
  return storeUtils.setModelConfiguration(storeKey, configuration);
32
32
  };
33
33
 
34
- const deleteConfiguration = uid => {
34
+ const deleteConfiguration = (uid) => {
35
35
  const storeKey = uidToStoreKey(uid);
36
36
  return storeUtils.deleteKey(storeKey);
37
37
  };
@@ -43,13 +43,13 @@ module.exports = ({ isComponent, prefix, storeUtils, getModels }) => {
43
43
  `plugin_content_manager_configuration_${prefix}`
44
44
  );
45
45
 
46
- const updateConfiguration = async uid => {
47
- const conf = configurations.find(conf => conf.uid === uid);
46
+ const updateConfiguration = async (uid) => {
47
+ const conf = configurations.find((conf) => conf.uid === uid);
48
48
 
49
49
  return setConfiguration(uid, await syncConfiguration(conf, models[uid]));
50
50
  };
51
51
 
52
- const generateNewConfiguration = async uid => {
52
+ const generateNewConfiguration = async (uid) => {
53
53
  return setConfiguration(uid, await createDefaultConfiguration(models[uid]));
54
54
  };
55
55
 
@@ -61,13 +61,13 @@ module.exports = ({ isComponent, prefix, storeUtils, getModels }) => {
61
61
  const contentTypesToDelete = difference(DBUIDs, currentUIDS);
62
62
 
63
63
  // delete old schemas
64
- await Promise.all(contentTypesToDelete.map(uid => deleteConfiguration(uid)));
64
+ await Promise.all(contentTypesToDelete.map((uid) => deleteConfiguration(uid)));
65
65
 
66
66
  // create new schemas
67
- await Promise.all(contentTypesToAdd.map(uid => generateNewConfiguration(uid)));
67
+ await Promise.all(contentTypesToAdd.map((uid) => generateNewConfiguration(uid)));
68
68
 
69
69
  // update current schemas
70
- await Promise.all(contentTypesToUpdate.map(uid => updateConfiguration(uid)));
70
+ await Promise.all(contentTypesToUpdate.map((uid) => updateConfiguration(uid)));
71
71
  };
72
72
 
73
73
  return {
@@ -15,7 +15,7 @@ const createPermissionChecker = ({ userAbility, model }) => {
15
15
  model,
16
16
  });
17
17
 
18
- const toSubject = entity => (entity ? permissionsManager.toSubject(entity, model) : model);
18
+ const toSubject = (entity) => (entity ? permissionsManager.toSubject(entity, model) : model);
19
19
 
20
20
  const can = (action, entity, field) => {
21
21
  return userAbility.can(action, toSubject(entity), field);
@@ -40,15 +40,15 @@ const createPermissionChecker = ({ userAbility, model }) => {
40
40
  });
41
41
  };
42
42
 
43
- const sanitizeCreateInput = data => sanitizeInput(ACTIONS.create, data);
44
- const sanitizeUpdateInput = entity => data => sanitizeInput(ACTIONS.update, data, entity);
43
+ const sanitizeCreateInput = (data) => sanitizeInput(ACTIONS.create, data);
44
+ const sanitizeUpdateInput = (entity) => (data) => sanitizeInput(ACTIONS.update, data, entity);
45
45
 
46
46
  const buildPermissionQuery = (query, action) => permissionsManager.queryFrom(query, action);
47
47
 
48
- const buildReadQuery = query => buildPermissionQuery(query, ACTIONS.read);
49
- const buildDeleteQuery = query => buildPermissionQuery(query, ACTIONS.delete);
48
+ const buildReadQuery = (query) => buildPermissionQuery(query, ACTIONS.read);
49
+ const buildDeleteQuery = (query) => buildPermissionQuery(query, ACTIONS.delete);
50
50
 
51
- Object.keys(ACTIONS).forEach(action => {
51
+ Object.keys(ACTIONS).forEach((action) => {
52
52
  can[action] = (...args) => can(ACTIONS[action], ...args);
53
53
  cannot[action] = (...args) => cannot(ACTIONS[action], ...args);
54
54
  });
package/services/uid.js CHANGED
@@ -34,7 +34,7 @@ module.exports = {
34
34
  [`${field}_contains`]: value,
35
35
  _limit: -1,
36
36
  })
37
- .then(results => results.map(result => result[field]));
37
+ .then((results) => results.map((result) => result[field]));
38
38
 
39
39
  if (possibleColisions.length === 0) {
40
40
  return value;
@@ -1,16 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  const _ = require('lodash');
4
- const {
5
- isListable,
6
- hasEditableAttribute,
7
- hasRelationAttribute,
8
- } = require('./attributes');
4
+ const { isListable, hasEditableAttribute, hasRelationAttribute } = require('./attributes');
9
5
 
10
6
  const DEFAULT_LIST_LENGTH = 4;
11
7
  const MAX_ROW_SIZE = 12;
12
8
 
13
- const typeToSize = type => {
9
+ const typeToSize = (type) => {
14
10
  switch (type) {
15
11
  case 'checkbox':
16
12
  case 'boolean':
@@ -38,34 +34,26 @@ async function createDefaultLayouts(schema) {
38
34
  list: createDefaultListLayout(schema),
39
35
  editRelations: createDefaultEditRelationsLayout(schema),
40
36
  edit: createDefaultEditLayout(schema),
41
- ..._.pick(_.get(schema, ['config', 'layouts'], {}), [
42
- 'list',
43
- 'edit',
44
- 'editRelations',
45
- ]),
37
+ ..._.pick(_.get(schema, ['config', 'layouts'], {}), ['list', 'edit', 'editRelations']),
46
38
  };
47
39
  }
48
40
 
49
41
  function createDefaultListLayout(schema) {
50
42
  return Object.keys(schema.attributes)
51
- .filter(name => isListable(schema, name))
43
+ .filter((name) => isListable(schema, name))
52
44
  .slice(0, DEFAULT_LIST_LENGTH);
53
45
  }
54
46
 
55
47
  function createDefaultEditRelationsLayout(schema) {
56
48
  if (schema.modelType === 'component') return [];
57
49
 
58
- return Object.keys(schema.attributes).filter(name =>
59
- hasRelationAttribute(schema, name)
60
- );
50
+ return Object.keys(schema.attributes).filter((name) => hasRelationAttribute(schema, name));
61
51
  }
62
52
 
63
- const rowSize = els => els.reduce((sum, el) => sum + el.size, 0);
53
+ const rowSize = (els) => els.reduce((sum, el) => sum + el.size, 0);
64
54
 
65
55
  function createDefaultEditLayout(schema) {
66
- const keys = Object.keys(schema.attributes).filter(name =>
67
- hasEditableAttribute(schema, name)
68
- );
56
+ const keys = Object.keys(schema.attributes).filter((name) => hasEditableAttribute(schema, name));
69
57
 
70
58
  return appendToEditLayout([], keys, schema);
71
59
  }
@@ -75,14 +63,11 @@ function createDefaultEditLayout(schema) {
75
63
  function syncLayouts(configuration, schema) {
76
64
  if (_.isEmpty(configuration.layouts)) return createDefaultLayouts(schema);
77
65
 
78
- const { list = [], editRelations = [], edit = [] } =
79
- configuration.layouts || {};
66
+ const { list = [], editRelations = [], edit = [] } = configuration.layouts || {};
80
67
 
81
- let cleanList = list.filter(attr => isListable(schema, attr));
68
+ let cleanList = list.filter((attr) => isListable(schema, attr));
82
69
 
83
- let cleanEditRelations = editRelations.filter(attr =>
84
- hasRelationAttribute(schema, attr)
85
- );
70
+ let cleanEditRelations = editRelations.filter((attr) => hasRelationAttribute(schema, attr));
86
71
 
87
72
  let elementsToReAppend = [];
88
73
  let cleanEdit = [];
@@ -120,24 +105,20 @@ function syncLayouts(configuration, schema) {
120
105
  // only add valid listable attributes
121
106
  cleanList = _.uniq(
122
107
  cleanList
123
- .concat(newAttributes.filter(key => isListable(schema, key)))
108
+ .concat(newAttributes.filter((key) => isListable(schema, key)))
124
109
  .slice(0, DEFAULT_LIST_LENGTH)
125
110
  );
126
111
  }
127
112
 
128
113
  // add new relations to layout
129
114
  if (schema.modelType !== 'component') {
130
- const newRelations = newAttributes.filter(key =>
131
- hasRelationAttribute(schema, key)
132
- );
115
+ const newRelations = newAttributes.filter((key) => hasRelationAttribute(schema, key));
133
116
 
134
117
  cleanEditRelations = _.uniq(cleanEditRelations.concat(newRelations));
135
118
  }
136
119
 
137
120
  // add new attributes to edit view
138
- const newEditAttributes = newAttributes.filter(key =>
139
- hasEditableAttribute(schema, key)
140
- );
121
+ const newEditAttributes = newAttributes.filter((key) => hasEditableAttribute(schema, key));
141
122
 
142
123
  cleanEdit = appendToEditLayout(cleanEdit, newEditAttributes, schema);
143
124
 
@@ -145,9 +126,7 @@ function syncLayouts(configuration, schema) {
145
126
  list: cleanList.length > 0 ? cleanList : createDefaultListLayout(schema),
146
127
  edit: cleanEdit.length > 0 ? cleanEdit : createDefaultEditLayout(schema),
147
128
  editRelations:
148
- cleanEditRelations.length > 0
149
- ? cleanEditRelations
150
- : createDefaultEditRelationsLayout(schema),
129
+ cleanEditRelations.length > 0 ? cleanEditRelations : createDefaultEditRelationsLayout(schema),
151
130
  };
152
131
  }
153
132
 
@@ -132,7 +132,7 @@ async function syncMetadatas(configuration, schema) {
132
132
  return _.assign(metasWithDefaults, updatedMetas);
133
133
  }
134
134
 
135
- const getTargetSchema = targetModel => {
135
+ const getTargetSchema = (targetModel) => {
136
136
  return getService('content-types').findContentType(targetModel);
137
137
  };
138
138
 
@@ -21,9 +21,9 @@ const EMPTY_CONFIG = {
21
21
  layouts: {},
22
22
  };
23
23
 
24
- const configurationKey = key => `${keys.CONFIGURATION}_${key}`;
24
+ const configurationKey = (key) => `${keys.CONFIGURATION}_${key}`;
25
25
 
26
- const getModelConfiguration = async key => {
26
+ const getModelConfiguration = async (key) => {
27
27
  const config = await getStore().get({ key: configurationKey(key) });
28
28
  return _.merge({}, EMPTY_CONFIG, config);
29
29
  };
@@ -31,7 +31,7 @@ const getModelConfiguration = async key => {
31
31
  const setModelConfiguration = async (key, value) => {
32
32
  const storedConfig = (await getStore().get({ key: configurationKey(key) })) || {};
33
33
  const currentConfig = { ...storedConfig };
34
- Object.keys(value).forEach(key => {
34
+ Object.keys(value).forEach((key) => {
35
35
  if (value[key] !== null && value[key] !== undefined) {
36
36
  _.set(currentConfig, key, value[key]);
37
37
  }
@@ -45,7 +45,7 @@ const setModelConfiguration = async (key, value) => {
45
45
  }
46
46
  };
47
47
 
48
- const deleteKey = key => {
48
+ const deleteKey = (key) => {
49
49
  return strapi.query('core_store').delete({ key: `plugin_content_manager_configuration_${key}` });
50
50
  };
51
51
 
@@ -55,19 +55,19 @@ function findByKeyQuery({ model }, key) {
55
55
  .find({
56
56
  key: { $regex: `${key}.*` },
57
57
  })
58
- .then(results => results.map(({ value }) => JSON.parse(value)));
58
+ .then((results) => results.map(({ value }) => JSON.parse(value)));
59
59
  }
60
60
 
61
61
  return model
62
- .query(qb => {
62
+ .query((qb) => {
63
63
  qb.where('key', 'like', `${key}%`);
64
64
  })
65
65
  .fetchAll()
66
- .then(config => config && config.toJSON())
67
- .then(results => results.map(({ value }) => JSON.parse(value)));
66
+ .then((config) => config && config.toJSON())
67
+ .then((results) => results.map(({ value }) => JSON.parse(value)));
68
68
  }
69
69
 
70
- const findByKey = key => strapi.query('core_store').custom(findByKeyQuery)(key);
70
+ const findByKey = (key) => strapi.query('core_store').custom(findByKeyQuery)(key);
71
71
  const moveKey = (oldKey, newKey) => {
72
72
  return strapi.query('core_store').update(
73
73
  {
package/utils/index.js CHANGED
@@ -5,7 +5,7 @@ const wrapBadRequest = require('./wrap-bad-request');
5
5
  const pickWritableAttributes = require('./pick-writable-attributes');
6
6
 
7
7
  // retrieve a local service
8
- const getService = name => {
8
+ const getService = (name) => {
9
9
  return prop(`content-manager.services.${name}`, strapi.plugins);
10
10
  };
11
11
 
@@ -1,15 +1,17 @@
1
1
  'use strict';
2
2
 
3
- module.exports = fn => async (...args) => {
4
- try {
5
- await fn(...args);
6
- } catch (error) {
7
- if (strapi.errors.isBoom(error)) {
8
- throw error;
9
- }
3
+ module.exports =
4
+ (fn) =>
5
+ async (...args) => {
6
+ try {
7
+ await fn(...args);
8
+ } catch (error) {
9
+ if (strapi.errors.isBoom(error)) {
10
+ throw error;
11
+ }
10
12
 
11
- // these are errors like unique constraints
12
- strapi.log.error(error);
13
- throw strapi.errors.badRequest('Invalid input data. Please verify unique constraints');
14
- }
15
- };
13
+ // these are errors like unique constraints
14
+ strapi.log.error(error);
15
+ throw strapi.errors.badRequest('Invalid input data. Please verify unique constraints');
16
+ }
17
+ };