@blaze-cms/plugin-data-ui 0.139.0-alpha.3 → 0.139.0-alpha.6

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 (217) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +42 -0
  3. package/lib/components/EntityDataListing/EntityDataListing.js +4 -26
  4. package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
  5. package/lib/components/EntityDataListing/index.js +1 -2
  6. package/lib/components/EntityDataListing/index.js.map +1 -1
  7. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +38 -0
  8. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  9. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +11 -0
  10. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  11. package/lib/components/EntityManager/Entity/Entity.js +19 -7
  12. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  13. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js +1 -2
  14. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  15. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +1 -2
  16. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  17. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js +1 -2
  18. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -1
  19. package/lib/components/EntityManager/Entity/EntityHeader/index.js +1 -2
  20. package/lib/components/EntityManager/Entity/EntityHeader/index.js.map +1 -1
  21. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +43 -0
  22. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  23. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +32 -0
  24. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  25. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +44 -0
  26. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  27. package/lib/components/EntityManager/Entity/SideBarRelations/index.js +15 -6
  28. package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  29. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +37 -0
  30. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  31. package/lib/components/EntityManager/Entity/actions-handlers/create/index.js +1 -2
  32. package/lib/components/EntityManager/Entity/actions-handlers/create/index.js.map +1 -1
  33. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +1 -2
  34. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  35. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js +1 -2
  36. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -1
  37. package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js +1 -2
  38. package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -1
  39. package/lib/components/EntityManager/Entity/actions-handlers/index.js +1 -2
  40. package/lib/components/EntityManager/Entity/actions-handlers/index.js.map +1 -1
  41. package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js +1 -2
  42. package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -1
  43. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js +1 -2
  44. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  45. package/lib/components/EntityManager/Entity/actions-handlers/update/index.js +1 -2
  46. package/lib/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -1
  47. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js +1 -2
  48. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
  49. package/lib/components/EntityManager/Entity/index.js +1 -2
  50. package/lib/components/EntityManager/Entity/index.js.map +1 -1
  51. package/lib/components/EntityManager/EntityManager.js +3 -4
  52. package/lib/components/EntityManager/EntityManager.js.map +1 -1
  53. package/lib/components/EntityManager/index.js +1 -2
  54. package/lib/components/EntityManager/index.js.map +1 -1
  55. package/lib/components/EntityManager/utils/data-mappers.js +4 -8
  56. package/lib/components/EntityManager/utils/data-mappers.js.map +1 -1
  57. package/lib/components/EntityManager/utils/entityAvailableActions.js +1 -2
  58. package/lib/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
  59. package/lib/components/EntityManager/utils/is-form-empty.js +1 -2
  60. package/lib/components/EntityManager/utils/is-form-empty.js.map +1 -1
  61. package/lib/components/EntityManager/utils/query.js +1 -2
  62. package/lib/components/EntityManager/utils/query.js.map +1 -1
  63. package/lib/components/InfoBoxes/InfoBoxes.js +35 -0
  64. package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -0
  65. package/lib/components/InfoBoxes/container/InfoBoxContainer.js +43 -0
  66. package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  67. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  68. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  69. package/lib/components/InfoBoxes/hooks/useData.js +41 -0
  70. package/lib/components/InfoBoxes/hooks/useData.js.map +1 -0
  71. package/lib/components/InfoBoxes/hooks/useInfoBox.js +25 -0
  72. package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  73. package/lib/components/InfoBoxes/index.js +11 -0
  74. package/lib/components/InfoBoxes/index.js.map +1 -0
  75. package/lib/components/InfoBoxes/presentational/InfoBox.js +45 -0
  76. package/lib/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  77. package/lib/components/ListingTable/ListingTable.js +127 -84
  78. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  79. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +9 -22
  80. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  81. package/lib/components/ListingTable/ListingTableContent/index.js +1 -2
  82. package/lib/components/ListingTable/ListingTableContent/index.js.map +1 -1
  83. package/lib/components/ListingTable/TableActions/TableActions.js +1 -2
  84. package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
  85. package/lib/components/ListingTable/TableActions/index.js +1 -2
  86. package/lib/components/ListingTable/TableActions/index.js.map +1 -1
  87. package/lib/components/ListingTable/index.js +1 -2
  88. package/lib/components/ListingTable/index.js.map +1 -1
  89. package/lib/components/ListingTable/mappers/populate-rows.js +92 -29
  90. package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
  91. package/lib/components/ListingTable/service/index.js +74 -13
  92. package/lib/components/ListingTable/service/index.js.map +1 -1
  93. package/lib/components/Tabs/index.js +3 -4
  94. package/lib/components/Tabs/index.js.map +1 -1
  95. package/lib/constants.js +33 -49
  96. package/lib/constants.js.map +1 -1
  97. package/lib/icons/ContentIcon.js +90 -0
  98. package/lib/icons/ContentIcon.js.map +1 -0
  99. package/lib/icons/SettingsIcon.js +46 -0
  100. package/lib/icons/SettingsIcon.js.map +1 -0
  101. package/lib/icons/TaxonomyIcon.js +70 -0
  102. package/lib/icons/TaxonomyIcon.js.map +1 -0
  103. package/lib/icons/UsersIcon.js +43 -0
  104. package/lib/icons/UsersIcon.js.map +1 -0
  105. package/lib/icons/index.js +36 -0
  106. package/lib/icons/index.js.map +1 -0
  107. package/lib/index.js +40 -13
  108. package/lib/index.js.map +1 -1
  109. package/lib/utils/add-content-menu-items.js +62 -15
  110. package/lib/utils/add-content-menu-items.js.map +1 -1
  111. package/lib/utils/build-create-entity-mutation.js +1 -2
  112. package/lib/utils/build-create-entity-mutation.js.map +1 -1
  113. package/lib/utils/build-delete-entity-mutation.js +1 -2
  114. package/lib/utils/build-delete-entity-mutation.js.map +1 -1
  115. package/lib/utils/build-listing-query.js +12 -4
  116. package/lib/utils/build-listing-query.js.map +1 -1
  117. package/lib/utils/build-update-data-query.js +1 -2
  118. package/lib/utils/build-update-data-query.js.map +1 -1
  119. package/lib/utils/build-update-publish-unpublish-mutation.js +1 -2
  120. package/lib/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  121. package/lib/utils/get-default-query-params.js +3 -5
  122. package/lib/utils/get-default-query-params.js.map +1 -1
  123. package/lib/utils/hoc/withContext.js +1 -2
  124. package/lib/utils/hoc/withContext.js.map +1 -1
  125. package/lib/utils/hooks/useToggle.js +1 -2
  126. package/lib/utils/hooks/useToggle.js.map +1 -1
  127. package/lib-es/components/EntityDataListing/EntityDataListing.js +3 -14
  128. package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -1
  129. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +30 -0
  130. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  131. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  132. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  133. package/lib-es/components/EntityManager/Entity/Entity.js +16 -3
  134. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  135. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +30 -0
  136. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  137. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +26 -0
  138. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  139. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +39 -0
  140. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  141. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +12 -2
  142. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  143. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +24 -0
  144. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  145. package/lib-es/components/InfoBoxes/InfoBoxes.js +28 -0
  146. package/lib-es/components/InfoBoxes/InfoBoxes.js.map +1 -0
  147. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +30 -0
  148. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  149. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  150. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  151. package/lib-es/components/InfoBoxes/hooks/useData.js +37 -0
  152. package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -0
  153. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +19 -0
  154. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  155. package/lib-es/components/InfoBoxes/index.js +3 -0
  156. package/lib-es/components/InfoBoxes/index.js.map +1 -0
  157. package/lib-es/components/InfoBoxes/presentational/InfoBox.js +31 -0
  158. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  159. package/lib-es/components/ListingTable/ListingTable.js +56 -51
  160. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  161. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +11 -19
  162. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  163. package/lib-es/components/ListingTable/mappers/populate-rows.js +76 -24
  164. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
  165. package/lib-es/components/ListingTable/service/index.js +65 -7
  166. package/lib-es/components/ListingTable/service/index.js.map +1 -1
  167. package/lib-es/constants.js +9 -1
  168. package/lib-es/constants.js.map +1 -1
  169. package/lib-es/icons/ContentIcon.js +80 -0
  170. package/lib-es/icons/ContentIcon.js.map +1 -0
  171. package/lib-es/icons/SettingsIcon.js +36 -0
  172. package/lib-es/icons/SettingsIcon.js.map +1 -0
  173. package/lib-es/icons/TaxonomyIcon.js +60 -0
  174. package/lib-es/icons/TaxonomyIcon.js.map +1 -0
  175. package/lib-es/icons/UsersIcon.js +33 -0
  176. package/lib-es/icons/UsersIcon.js.map +1 -0
  177. package/lib-es/icons/index.js +6 -0
  178. package/lib-es/icons/index.js.map +1 -0
  179. package/lib-es/index.js +37 -9
  180. package/lib-es/index.js.map +1 -1
  181. package/lib-es/utils/add-content-menu-items.js +46 -5
  182. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  183. package/lib-es/utils/build-listing-query.js +10 -1
  184. package/lib-es/utils/build-listing-query.js.map +1 -1
  185. package/lib-es/utils/get-default-query-params.js +1 -3
  186. package/lib-es/utils/get-default-query-params.js.map +1 -1
  187. package/package.json +6 -5
  188. package/src/components/EntityDataListing/EntityDataListing.js +3 -12
  189. package/src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +26 -0
  190. package/src/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  191. package/src/components/EntityManager/Entity/Entity.js +10 -1
  192. package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +22 -0
  193. package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +33 -0
  194. package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +28 -0
  195. package/src/components/EntityManager/Entity/SideBarRelations/index.js +34 -16
  196. package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +33 -0
  197. package/src/components/InfoBoxes/InfoBoxes.js +24 -0
  198. package/src/components/InfoBoxes/container/InfoBoxContainer.js +22 -0
  199. package/src/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  200. package/src/components/InfoBoxes/hooks/useData.js +20 -0
  201. package/src/components/InfoBoxes/hooks/useInfoBox.js +13 -0
  202. package/src/components/InfoBoxes/index.js +3 -0
  203. package/src/components/InfoBoxes/presentational/InfoBox.js +34 -0
  204. package/src/components/ListingTable/ListingTable.js +73 -39
  205. package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +8 -22
  206. package/src/components/ListingTable/mappers/populate-rows.js +83 -18
  207. package/src/components/ListingTable/service/index.js +42 -5
  208. package/src/constants.js +13 -1
  209. package/src/icons/ContentIcon.js +83 -0
  210. package/src/icons/SettingsIcon.js +41 -0
  211. package/src/icons/TaxonomyIcon.js +62 -0
  212. package/src/icons/UsersIcon.js +37 -0
  213. package/src/icons/index.js +6 -0
  214. package/src/index.js +36 -8
  215. package/src/utils/add-content-menu-items.js +42 -3
  216. package/src/utils/build-listing-query.js +11 -1
  217. package/src/utils/get-default-query-params.js +1 -1
@@ -1,12 +1,49 @@
1
1
  import buildListingQuery from '../../../utils/build-listing-query';
2
2
 
3
- const fetchData = async ({ client, querySettings: { entitySchema, queryParams } }) => {
4
- const query = buildListingQuery(entitySchema);
3
+ function buildVariables({ entitySchema, isSearchQuery, listFilters = [], queryParams = {} }) {
4
+ const { identifier } = entitySchema;
5
+ const { sort, offset, limit, where } = queryParams;
6
+ const [{ property, direction }] = sort;
7
+ const parsedOffset = `${property}:${direction}`;
8
+
9
+ if (!isSearchQuery)
10
+ return {
11
+ ...queryParams,
12
+ where: !Array.isArray(listFilters) ? listFilters : where
13
+ };
14
+
15
+ const rawQuery = {
16
+ bool: {
17
+ must: listFilters || [],
18
+ filter: [
19
+ {
20
+ term: {
21
+ entityIdentifier: identifier
22
+ }
23
+ }
24
+ ]
25
+ }
26
+ };
27
+
28
+ return {
29
+ limit,
30
+ offset,
31
+ sort: parsedOffset,
32
+ where: JSON.stringify(rawQuery)
33
+ };
34
+ }
35
+
36
+ const fetchData = async ({ client, querySettings: { entitySchema, queryParams }, listFilters }) => {
5
37
  const {
6
- data: { listingData }
7
- } = await client.query({ query, variables: queryParams, fetchPolicy: 'network-only' });
38
+ displayProperties: { adminListings: { dataSource: { source } = {} } = {} } = {}
39
+ } = entitySchema;
40
+
41
+ const isSearchQuery = source === 'search';
42
+ const query = buildListingQuery(entitySchema, isSearchQuery);
43
+ const variables = buildVariables({ entitySchema, listFilters, queryParams, isSearchQuery });
44
+ const { data = {} } = await client.query({ query, variables, fetchPolicy: 'network-only' });
8
45
 
9
- return listingData;
46
+ return data.searchResults ? data.searchResults.results : data.listingData;
10
47
  };
11
48
 
12
49
  export { fetchData };
package/src/constants.js CHANGED
@@ -25,6 +25,16 @@ const PAGE_BUILDER_TAB_INDEX = 1;
25
25
  const EDITOR_VIEW_TAB = 'Editor view';
26
26
  const EDITOR_VIEW_TAB_INDEX = 0;
27
27
 
28
+ const ICON_SIZE = {
29
+ WIDTH: '25px',
30
+ HEIGHT: '25px'
31
+ };
32
+
33
+ const ICON_COLOR = {
34
+ STROKE: '#63779C',
35
+ FILL: '#63779C'
36
+ };
37
+
28
38
  export {
29
39
  DATA_LISTING_PREFIX,
30
40
  ENTITY_PUBLISHED,
@@ -49,5 +59,7 @@ export {
49
59
  EDITOR_VIEW_TAB,
50
60
  PAGE_BUILDER_TAB,
51
61
  UNPUBLISHED_WARNING,
52
- SAVE_BEFORE_PUBLISH_MESSAGE
62
+ SAVE_BEFORE_PUBLISH_MESSAGE,
63
+ ICON_SIZE,
64
+ ICON_COLOR
53
65
  };
@@ -0,0 +1,83 @@
1
+ import React from 'react';
2
+ import { ICON_COLOR } from '../constants';
3
+
4
+ function ContentIcon({ fill = ICON_COLOR.FILL, stroke = ICON_COLOR.STROKE }) {
5
+ return (
6
+ <svg
7
+ width="19px"
8
+ height="19px"
9
+ viewBox="0 0 21 21"
10
+ version="1.1"
11
+ xmlns="http://www.w3.org/2000/svg"
12
+ xmlnsXlink="http://www.w3.org/1999/xlink">
13
+ <title>content</title>
14
+ <g id="Page-1" stroke="none" strokeWidth={1} fill="none" fillRule="evenodd">
15
+ <g id="content" transform="translate(1, 1)">
16
+ <g id="Group">
17
+ <path
18
+ d="M0,8.70833334 L5.445875,3.26245834 C6.37331215,2.33530123 7.87668785,2.33530123 8.804125,3.26245834 L14.25,8.70833334"
19
+ id="Shape-path"
20
+ stroke={stroke}
21
+ strokeLinecap="round"
22
+ strokeLinejoin="round"
23
+ />
24
+ <path
25
+ d="M11.875,6.33333334 L13.758375,4.44995834 C14.6858122,3.52280123 16.1891878,3.52280123 17.116625,4.44995834 L19,6.33333334"
26
+ id="Shape-path"
27
+ stroke={stroke}
28
+ strokeLinecap="round"
29
+ strokeLinejoin="round"
30
+ />
31
+ <path
32
+ d="M2.375,19 L16.625,19 C17.9366763,19 19,17.9366763 19,16.625 L19,2.375 C19,1.06332371 17.9366763,0 16.625,0 L2.375,0 C1.06332371,0 0,1.06332371 0,2.375 L0,16.625 C0,17.9366763 1.06332371,19 2.375,19 Z"
33
+ id="Shape-path"
34
+ stroke={stroke}
35
+ strokeLinecap="round"
36
+ strokeLinejoin="round"
37
+ />
38
+ <circle
39
+ id="Oval"
40
+ fill={fill}
41
+ fillRule="nonzero"
42
+ cx="11.4791666"
43
+ cy="2.77083334"
44
+ r="1.1875"
45
+ />
46
+ </g>
47
+ <line
48
+ x1={0}
49
+ y1="9.23611111"
50
+ x2={19}
51
+ y2="9.23611111"
52
+ id="Path"
53
+ stroke={stroke}
54
+ strokeLinecap="round"
55
+ strokeLinejoin="round"
56
+ />
57
+ <line
58
+ x1="3.95833334"
59
+ y1="12.4027778"
60
+ x2="15.3055553"
61
+ y2="12.4027778"
62
+ id="Path"
63
+ stroke={stroke}
64
+ strokeLinecap="round"
65
+ strokeLinejoin="round"
66
+ />
67
+ <line
68
+ x1="3.95833334"
69
+ y1="15.5694445"
70
+ x2="12.1388885"
71
+ y2="15.5694445"
72
+ id="Path"
73
+ stroke={stroke}
74
+ strokeLinecap="round"
75
+ strokeLinejoin="round"
76
+ />
77
+ </g>
78
+ </g>
79
+ </svg>
80
+ );
81
+ }
82
+
83
+ export default ContentIcon;
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { ICON_SIZE, ICON_COLOR } from '../constants';
3
+
4
+ function SettingsIcon({
5
+ width = ICON_SIZE.WIDTH,
6
+ height = ICON_SIZE.HEIGHT,
7
+ stroke = ICON_COLOR.STROKE
8
+ }) {
9
+ return (
10
+ <svg
11
+ width={width}
12
+ height={height}
13
+ viewBox="0 0 22 22"
14
+ version="1.1"
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ xmlnsXlink="http://www.w3.org/1999/xlink">
17
+ <title>setting</title>
18
+ <g
19
+ id="Page-1"
20
+ stroke="none"
21
+ strokeWidth={1}
22
+ fill="none"
23
+ fillRule="evenodd"
24
+ strokeLinecap="round"
25
+ strokeLinejoin="round">
26
+ <g id="Group" transform="translate(1, 1)" stroke={stroke}>
27
+ <path
28
+ d="M8.13888889,1.46333333 C8.61222222,-0.487777777 11.3877778,-0.487777777 11.8611111,1.46333333 C12.0051589,2.05784356 12.4244819,2.54780471 12.9896128,2.78193979 C13.5547438,3.01607487 14.1977123,2.96622362 14.72,2.64777778 C16.4344444,1.60333333 18.3977778,3.56555556 17.3533333,5.28111111 C17.0353472,5.803171 16.9856162,6.44564563 17.2194755,7.0104213 C17.4533348,7.57519696 17.9426987,7.99444609 18.5366667,8.13888889 C20.4877778,8.61222222 20.4877778,11.3877778 18.5366667,11.8611111 C17.9421564,12.0051589 17.4521953,12.4244819 17.2180602,12.9896128 C16.9839251,13.5547438 17.0337764,14.1977123 17.3522222,14.72 C18.3966667,16.4344444 16.4344444,18.3977778 14.7188889,17.3533333 C14.196829,17.0353472 13.5543544,16.9856162 12.9895787,17.2194755 C12.424803,17.4533348 12.0055539,17.9426987 11.8611111,18.5366667 C11.3877778,20.4877778 8.61222222,20.4877778 8.13888889,18.5366667 C7.99484107,17.9421564 7.57551807,17.4521953 7.01038716,17.2180602 C6.44525624,16.9839251 5.80228769,17.0337764 5.28,17.3522222 C3.56555556,18.3966667 1.60222222,16.4344444 2.64666667,14.7188889 C2.96465281,14.196829 3.01438377,13.5543544 2.78052448,12.9895787 C2.5466652,12.424803 2.05730134,12.0055539 1.46333333,11.8611111 C-0.487777777,11.3877778 -0.487777777,8.61222222 1.46333333,8.13888889 C2.05784356,7.99484107 2.54780471,7.57551807 2.78193979,7.01038716 C3.01607487,6.44525624 2.96622362,5.80228769 2.64777778,5.28 C1.60333333,3.56555556 3.56555556,1.60222222 5.28111111,2.64666667 C6.38777778,3.32222222 7.83222222,2.72444444 8.13888889,1.46333333 Z"
29
+ id="Path"
30
+ />
31
+ <path
32
+ d="M13.6666666,10.3333333 C13.6666666,12.1742825 12.1742825,13.6666666 10.3333333,13.6666666 C8.49238416,13.6666666 7,12.1742825 7,10.3333333 C7,8.49238416 8.49238416,7 10.3333333,7 C12.1742825,7 13.6666666,8.49238416 13.6666666,10.3333333 L13.6666666,10.3333333 Z"
33
+ id="Path"
34
+ />
35
+ </g>
36
+ </g>
37
+ </svg>
38
+ );
39
+ }
40
+
41
+ export default SettingsIcon;
@@ -0,0 +1,62 @@
1
+ import React from 'react';
2
+ import { ICON_SIZE, ICON_COLOR } from '../constants';
3
+
4
+ function TaxonomyIcon({
5
+ width = ICON_SIZE.WIDTH,
6
+ height = ICON_SIZE.HEIGHT,
7
+ stroke = ICON_COLOR.STROKE
8
+ }) {
9
+ return (
10
+ <svg
11
+ width={width}
12
+ height={height}
13
+ viewBox="0 0 22 22"
14
+ version="1.1"
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ xmlnsXlink="http://www.w3.org/1999/xlink">
17
+ <title>taxonomy</title>
18
+ <g
19
+ id="Page-1"
20
+ stroke="none"
21
+ strokeWidth="1"
22
+ fill="none"
23
+ fillRule="evenodd"
24
+ strokeLinecap="round"
25
+ strokeLinejoin="round">
26
+ <g id="Group" transform="translate(1, 1)" stroke={stroke}>
27
+ <rect
28
+ id="Rectangle"
29
+ x="0"
30
+ y="13.2173913"
31
+ width="6.78260868"
32
+ height="6.60869564"
33
+ rx="1.5"
34
+ />
35
+ <rect
36
+ id="Rectangle"
37
+ x="13.2173913"
38
+ y="13.2173913"
39
+ width="6.78260868"
40
+ height="6.60869564"
41
+ rx="1.5"
42
+ />
43
+ <rect
44
+ id="Rectangle"
45
+ x="6.60869564"
46
+ y="0"
47
+ width="6.78260868"
48
+ height="6.60869564"
49
+ rx="1.5"
50
+ />
51
+ <path
52
+ d="M3.30434782,13.2173913 L3.30434782,12.115942 C3.30434782,10.8993147 4.2906191,9.91304346 5.50724637,9.91304346 L14.3188405,9.91304346 C15.5354678,9.91304346 16.5217391,10.8993147 16.5217391,12.115942 L16.5217391,13.2173913"
53
+ id="Path"
54
+ />
55
+ <line x1="9.91304346" y1="6.60869564" x2="9.91304346" y2="9.91304346" id="Path" />
56
+ </g>
57
+ </g>
58
+ </svg>
59
+ );
60
+ }
61
+
62
+ export default TaxonomyIcon;
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { ICON_SIZE, ICON_COLOR } from '../constants';
3
+
4
+ function UserIcon({
5
+ width = ICON_SIZE.WIDTH,
6
+ height = ICON_SIZE.HEIGHT,
7
+ stroke = ICON_COLOR.STROKE
8
+ }) {
9
+ return (
10
+ <svg
11
+ width={width}
12
+ height={height}
13
+ viewBox="0 0 22 22"
14
+ version="1.1"
15
+ xmlns="http://www.w3.org/2000/svg"
16
+ xmlnsXlink="http://www.w3.org/1999/xlink">
17
+ <title>user</title>
18
+ <g
19
+ id="Page-1"
20
+ stroke="none"
21
+ strokeWidth={1}
22
+ fill="none"
23
+ fillRule="evenodd"
24
+ strokeLinecap="round"
25
+ strokeLinejoin="round">
26
+ <g id="Group" transform="translate(1, 0.76)" stroke={stroke}>
27
+ <path
28
+ d="M2.35666666,16.4488888 C4.68824079,15.1310199 7.32175438,14.4403878 10,14.4444089 C12.7777778,14.4444089 15.3855556,15.1722221 17.6433334,16.4488888 M13.3333334,7.7777776 C13.3333334,9.61872677 11.8409492,11.1111109 10,11.1111109 C8.15905083,11.1111109 6.66666666,9.61872677 6.66666666,7.7777776 C6.66666666,5.93682842 8.15905083,4.44444425 10,4.44444425 C11.8409492,4.44444425 13.3333334,5.93682842 13.3333334,7.7777776 L13.3333334,7.7777776 Z M20,10 C20,13.5726558 18.0940108,16.8739261 15,18.660254 C11.9059893,20.446582 8.09401075,20.446582 5,18.660254 C1.90598917,16.8739261 0,13.5726558 0,10 C0,4.47715239 4.47715258,0 10,0 C15.5228474,0 20,4.47715239 20,10 L20,10 Z"
29
+ id="Shape"
30
+ />
31
+ </g>
32
+ </g>
33
+ </svg>
34
+ );
35
+ }
36
+
37
+ export default UserIcon;
@@ -0,0 +1,6 @@
1
+ import UserIcon from './UsersIcon';
2
+ import TaxonomyIcon from './TaxonomyIcon';
3
+ import ContentIcon from './ContentIcon';
4
+ import SettingsIcon from './SettingsIcon';
5
+
6
+ export { UserIcon, TaxonomyIcon, ContentIcon, SettingsIcon };
package/src/index.js CHANGED
@@ -3,6 +3,7 @@ import React from 'react';
3
3
  import pkg from '../package.json';
4
4
  import { DATA_LISTING_PREFIX, PLUGIN_NAME } from './constants';
5
5
  import getAddContentMenuItems from './utils/add-content-menu-items';
6
+ import { UserIcon, TaxonomyIcon, ContentIcon, SettingsIcon } from './icons';
6
7
 
7
8
  const EntityDataListing = React.lazy(() =>
8
9
  import(/* webpackChunkName: 'EntityDataListing' */ './components/EntityDataListing')
@@ -12,14 +13,7 @@ const EntityManager = React.lazy(() =>
12
13
  );
13
14
 
14
15
  export default async function load(app) {
15
- // To load different plugin information into menu
16
- const sectionKey = 'content';
17
-
18
- app.events.once('load:menu-section', addSection => {
19
- addSection(sectionKey, { header: 'content', order: 100 });
20
- });
21
-
22
- app.events.once('load:menu-items', getAddContentMenuItems(app, sectionKey));
16
+ app.events.once('admin:menu:config:load', getAddContentMenuItems(app));
23
17
 
24
18
  app.events.once('load:custom:field:type', addFieldType => {
25
19
  Object.keys(formFieldTypes).forEach(type => {
@@ -31,6 +25,40 @@ export default async function load(app) {
31
25
  await app.events.emitAsync('load:custom:field:type', getFormBuilderLookup.addFieldType);
32
26
  });
33
27
 
28
+ app.events.once('admin:menu:config:load', ({ addConfig }) => {
29
+ addConfig({
30
+ main: {
31
+ items: {
32
+ content: {
33
+ label: 'content',
34
+ loadOpen: true,
35
+ items: {},
36
+ icon: ContentIcon,
37
+ order: 10
38
+ },
39
+ taxonomy: {
40
+ label: 'Taxonomy',
41
+ items: {},
42
+ icon: TaxonomyIcon,
43
+ order: 40
44
+ },
45
+ user: {
46
+ label: 'User',
47
+ items: {},
48
+ icon: UserIcon,
49
+ order: 90
50
+ },
51
+ settings: {
52
+ label: 'Settings',
53
+ items: {},
54
+ icon: SettingsIcon,
55
+ order: 100
56
+ }
57
+ }
58
+ }
59
+ });
60
+ });
61
+
34
62
  const entityDataListingRoute = {
35
63
  path: `${DATA_LISTING_PREFIX}/:entityIdentifier`,
36
64
  key: 'entityDataListing',
@@ -2,8 +2,8 @@ import { getQuery } from '@blaze-cms/admin-ui-utils';
2
2
 
3
3
  const { MENU_PERMISSIONS } = require('../constants');
4
4
 
5
- function getAddContentMenuItems(app, sectionKey) {
6
- return async addItem => {
5
+ function getAddContentMenuItems(app) {
6
+ return async ({ addConfig }) => {
7
7
  const client = app.getClient();
8
8
  const {
9
9
  data: { getEntitySchemas }
@@ -14,9 +14,48 @@ function getAddContentMenuItems(app, sectionKey) {
14
14
  canDoActions: MENU_PERMISSIONS
15
15
  }
16
16
  });
17
+
18
+ if (!getEntitySchemas || !getEntitySchemas.length) return; // no items so don't add section
19
+
20
+ const menuItems = {};
21
+ const sectionMenuItems = { settings: {} };
22
+
23
+ getEntitySchemas.forEach(({ id, displayName, displayProperties }) => {
24
+ if (!displayProperties) return null;
25
+
26
+ const { adminMenu: { sectionKey = 'settings' } = {} } = displayProperties;
27
+ const sectionItems = sectionMenuItems[sectionKey] || {};
28
+ sectionItems[id] = {
29
+ label: displayName,
30
+ uri: `/data-listing/${id}`
31
+ };
32
+ sectionMenuItems[sectionKey] = sectionItems;
33
+ });
34
+
35
+ const menuConfig = {
36
+ main: {
37
+ items: {
38
+ settings: {
39
+ items: menuItems
40
+ }
41
+ }
42
+ }
43
+ };
44
+
45
+ Object.entries(sectionMenuItems).forEach(([sectionKey, sectionItems]) => {
46
+ const sectionConfig = menuConfig.main.items[sectionKey] || {};
47
+ sectionConfig.items = sectionItems;
48
+ menuConfig.main.items[sectionKey] = sectionConfig;
49
+ });
50
+
17
51
  getEntitySchemas.forEach(({ id, displayName }) => {
18
- addItem({ name: displayName, uri: `/data-listing/${id}` }, sectionKey);
52
+ menuItems[id] = {
53
+ label: displayName,
54
+ uri: `/data-listing/${id}`
55
+ };
19
56
  });
57
+
58
+ addConfig(menuConfig);
20
59
  };
21
60
  }
22
61
 
@@ -1,13 +1,23 @@
1
1
  import { gql } from '@apollo/client';
2
2
  import { BlazeError } from '@blaze-cms/core-errors';
3
+ import { getDynamicQuery } from '@blaze-cms/admin-ui-utils';
3
4
 
4
- function buildListingQuery(entitySchema) {
5
+ const buildAdminSearchQuery = entitySchema => {
6
+ const { listingProperties = [] } = entitySchema || {};
7
+ const parsedProperties = `id, ${listingProperties.join(' ') || 'id name'}`;
8
+
9
+ return getDynamicQuery('ADMIN_SEARCH')([entitySchema], parsedProperties, true);
10
+ };
11
+
12
+ function buildListingQuery(entitySchema, isSearchQuery) {
5
13
  if (!entitySchema.actions || !entitySchema.actions.getAll || !entitySchema.listingProperties) {
6
14
  throw new BlazeError(
7
15
  'Listing query requires getAll action and listingProperties from entity schema'
8
16
  );
9
17
  }
10
18
 
19
+ if (isSearchQuery) return buildAdminSearchQuery(entitySchema);
20
+
11
21
  const sortType =
12
22
  entitySchema.actions.getAll[0].toUpperCase() + entitySchema.actions.getAll.substr(1);
13
23
 
@@ -1,4 +1,4 @@
1
- const getDefaultQueryParams = ({ schema }) => {
1
+ const getDefaultQueryParams = schema => {
2
2
  const updated = schema.properties && schema.properties.updated;
3
3
  const { adminDefaultListingFilter: where } = schema.displayProperties || {};
4
4