@blaze-cms/plugin-data-ui 0.129.0-admin-updates.2 → 0.129.0-project-admin-customisations.1

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 (133) hide show
  1. package/CHANGELOG.md +26 -3
  2. package/README.md +42 -0
  3. package/lib/components/EntityDataListing/EntityDataListing.js +3 -24
  4. package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
  5. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +39 -0
  6. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  7. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +12 -0
  8. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  9. package/lib/components/EntityManager/Entity/Entity.js +10 -1
  10. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  11. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  12. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  13. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +44 -0
  14. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  15. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +32 -0
  16. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  17. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +45 -0
  18. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  19. package/lib/components/EntityManager/Entity/SideBarRelations/index.js +12 -2
  20. package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  21. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +38 -0
  22. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  23. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  24. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  25. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
  26. package/lib/components/EntityManager/EntityManager.js.map +1 -1
  27. package/lib/components/EntityManager/utils/entity.js.map +1 -1
  28. package/lib/components/InfoBoxes/InfoBoxes.js +36 -0
  29. package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -0
  30. package/lib/components/InfoBoxes/container/InfoBoxContainer.js +44 -0
  31. package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  32. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  33. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  34. package/lib/components/InfoBoxes/hooks/useData.js +42 -0
  35. package/lib/components/InfoBoxes/hooks/useData.js.map +1 -0
  36. package/lib/components/InfoBoxes/hooks/useInfoBox.js +26 -0
  37. package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  38. package/lib/components/InfoBoxes/index.js +12 -0
  39. package/lib/components/InfoBoxes/index.js.map +1 -0
  40. package/lib/components/InfoBoxes/presentational/InfoBox.js +46 -0
  41. package/lib/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  42. package/lib/components/ListingTable/ListingTable.js +5 -26
  43. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  44. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +5 -12
  45. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  46. package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
  47. package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
  48. package/lib/components/Tabs/index.js.map +1 -1
  49. package/lib/index.js +3 -11
  50. package/lib/index.js.map +1 -1
  51. package/lib/utils/add-content-menu-items.js +64 -13
  52. package/lib/utils/add-content-menu-items.js.map +1 -1
  53. package/lib/utils/build-create-entity-mutation.js.map +1 -1
  54. package/lib/utils/build-delete-entity-mutation.js.map +1 -1
  55. package/lib/utils/build-listing-query.js.map +1 -1
  56. package/lib/utils/build-update-data-query.js.map +1 -1
  57. package/lib/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  58. package/lib/utils/hoc/withContext.js.map +1 -1
  59. package/lib-es/components/EntityDataListing/EntityDataListing.js +3 -14
  60. package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -1
  61. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +30 -0
  62. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  63. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  64. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  65. package/lib-es/components/EntityManager/Entity/Entity.js +10 -1
  66. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  67. package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  68. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  69. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +30 -0
  70. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  71. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +26 -0
  72. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  73. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +39 -0
  74. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  75. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +12 -2
  76. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  77. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +24 -0
  78. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  79. package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  80. package/lib-es/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
  81. package/lib-es/components/EntityManager/EntityManager.js.map +1 -1
  82. package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
  83. package/lib-es/components/InfoBoxes/InfoBoxes.js +28 -0
  84. package/lib-es/components/InfoBoxes/InfoBoxes.js.map +1 -0
  85. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +30 -0
  86. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  87. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  88. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  89. package/lib-es/components/InfoBoxes/hooks/useData.js +37 -0
  90. package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -0
  91. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +19 -0
  92. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  93. package/lib-es/components/InfoBoxes/index.js +3 -0
  94. package/lib-es/components/InfoBoxes/index.js.map +1 -0
  95. package/lib-es/components/InfoBoxes/presentational/InfoBox.js +31 -0
  96. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  97. package/lib-es/components/ListingTable/ListingTable.js +4 -25
  98. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  99. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +6 -13
  100. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  101. package/lib-es/components/ListingTable/TableActions/TableActions.js.map +1 -1
  102. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
  103. package/lib-es/components/Tabs/index.js.map +1 -1
  104. package/lib-es/index.js +1 -9
  105. package/lib-es/index.js.map +1 -1
  106. package/lib-es/utils/add-content-menu-items.js +49 -5
  107. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  108. package/lib-es/utils/build-create-entity-mutation.js.map +1 -1
  109. package/lib-es/utils/build-listing-query.js.map +1 -1
  110. package/lib-es/utils/build-update-data-query.js.map +1 -1
  111. package/lib-es/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  112. package/lib-es/utils/hoc/withContext.js.map +1 -1
  113. package/package.json +10 -9
  114. package/src/components/EntityDataListing/EntityDataListing.js +3 -12
  115. package/src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +26 -0
  116. package/src/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  117. package/src/components/EntityManager/Entity/Entity.js +4 -0
  118. package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +22 -0
  119. package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +33 -0
  120. package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +28 -0
  121. package/src/components/EntityManager/Entity/SideBarRelations/index.js +34 -16
  122. package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +33 -0
  123. package/src/components/InfoBoxes/InfoBoxes.js +24 -0
  124. package/src/components/InfoBoxes/container/InfoBoxContainer.js +22 -0
  125. package/src/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  126. package/src/components/InfoBoxes/hooks/useData.js +20 -0
  127. package/src/components/InfoBoxes/hooks/useInfoBox.js +13 -0
  128. package/src/components/InfoBoxes/index.js +3 -0
  129. package/src/components/InfoBoxes/presentational/InfoBox.js +34 -0
  130. package/src/components/ListingTable/ListingTable.js +4 -18
  131. package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +5 -16
  132. package/src/index.js +1 -8
  133. package/src/utils/add-content-menu-items.js +45 -3
@@ -0,0 +1,28 @@
1
+ import ProptTypes from 'prop-types';
2
+ import { useQuery, gql } from '@apollo/client';
3
+ import buildDynamicQuery from '../helpers/build-dynamic-query';
4
+
5
+ const useCustomSidebarData = ({ id, schema, displayProperties }) => {
6
+ const query = buildDynamicQuery({ id, schema, displayProperties });
7
+
8
+ const customSidebarInfoQuery =
9
+ query ||
10
+ gql`
11
+ query {
12
+ __typename
13
+ }
14
+ `;
15
+
16
+ const { data = {}, loading, error } = useQuery(customSidebarInfoQuery, {
17
+ variables: { id },
18
+ skip: !query
19
+ });
20
+
21
+ return { data: data.__typename !== 'Query' ? data : null, loading, error };
22
+ };
23
+
24
+ export default useCustomSidebarData;
25
+
26
+ useCustomSidebarData.propTypes = {
27
+ displayProperties: ProptTypes.object.isRequired
28
+ };
@@ -7,6 +7,8 @@ import { formFieldTypes } from '@blaze-cms/react-form-builder';
7
7
  import classnames from 'classnames';
8
8
  import { VersionsList } from '@blaze-cms/versioning-ui';
9
9
  import { PUBLISHED, UNPUBLISHED } from '../../../../constants';
10
+ import CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';
11
+ import EntityNavLinks from '../EntitiyNavLinks';
10
12
 
11
13
  const SideBarRelations = ({ schema, onChange, formData, entity }) => {
12
14
  const { relation: RelationComponent } = formFieldTypes;
@@ -18,7 +20,9 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
18
20
  status
19
21
  } = formData;
20
22
  const client = useApolloClient();
23
+
21
24
  const [relationsComponents, setRelationsComponents] = useState(null);
25
+
22
26
  useEffect(
23
27
  () => {
24
28
  (async () => {
@@ -64,28 +68,42 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
64
68
  return (
65
69
  <div className="sidebar" data-testid="sideBarRelations-main-div">
66
70
  <div className="sidebar__content">
67
- {formattedCreated && (
68
- <div className="sidebar__status">
69
- <div className="sidebar__status__wrapper">
70
- <b>Status</b>
71
- <span className={statusClassName}>{formattedStatus}</span>
71
+ <div className="sidebar__status">
72
+ {formattedCreated && (
73
+ <div className="sidebar__top">
74
+ <div className="sidebar__status__wrapper">
75
+ <b>Status</b>
76
+ <span className={statusClassName}>{formattedStatus}</span>
77
+ </div>
78
+ {formattedStatus === PUBLISHED && (
79
+ <p>
80
+ {formattedStatus} on: <span> {formattedPublished}</span>
81
+ </p>
82
+ )}
72
83
  </div>
73
- {formattedStatus === PUBLISHED && (
84
+ )}
85
+
86
+ {!schema.displayProperties.adminMainInfoProperty && (
87
+ <>
74
88
  <p>
75
- {formattedStatus} on: <span> {formattedPublished}</span>
89
+ Created: <span>{formattedCreated}</span>
76
90
  </p>
77
- )}
91
+ <p>
92
+ Updated: <span>{formattedUpdated}</span>
93
+ </p>
94
+ </>
95
+ )}
78
96
 
79
- <p>
80
- Created: <span>{formattedCreated}</span>
81
- </p>
82
- <p>
83
- Updated: <span>{formattedUpdated}</span>
84
- </p>
85
- </div>
86
- )}
97
+ <CustomSidebarInfoContainer
98
+ id={itemId}
99
+ schema={schema}
100
+ displayProperties={schema.displayProperties}
101
+ />
102
+ </div>
87
103
 
88
104
  <VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />
105
+ <EntityNavLinks schema={schema} />
106
+
89
107
  {relationsComponents &&
90
108
  relationsComponents.map(({ id, staticData, schema: entitySchema }) => (
91
109
  <RelationComponent
@@ -0,0 +1,33 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+
4
+ const CustomSidebarInfo = ({ items, customSidebarInfoKey }) => {
5
+ if (!items) return null;
6
+
7
+ const customSidebarInfoItems = items.map(item =>
8
+ Object.values(item)
9
+ .map(info => {
10
+ if (!info.label || !info.value) return null;
11
+
12
+ return (
13
+ <p>
14
+ {info.label}: <span>{info.value}</span>
15
+ </p>
16
+ );
17
+ })
18
+ .filter(Boolean)
19
+ );
20
+
21
+ return (
22
+ <div className="custom-sidebar-info" key={customSidebarInfoKey}>
23
+ <div className="custom-sidebar-info--container">{customSidebarInfoItems}</div>
24
+ </div>
25
+ );
26
+ };
27
+
28
+ export default CustomSidebarInfo;
29
+
30
+ CustomSidebarInfo.propTypes = {
31
+ customSidebarInfoKey: PropTypes.string.isRequired,
32
+ items: PropTypes.array.isRequired
33
+ };
@@ -0,0 +1,24 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import InfoBoxContainer from './container/InfoBoxContainer';
4
+
5
+ const InfoBoxes = ({ id, schema }) => {
6
+ const {
7
+ displayProperties: { adminInfoBoxes = [] }
8
+ } = schema;
9
+
10
+ if (adminInfoBoxes.length <= 0) {
11
+ return null;
12
+ }
13
+
14
+ return adminInfoBoxes.map(infoBox => (
15
+ <InfoBoxContainer id={id} schema={schema} key={infoBox.key} infoBox={infoBox} />
16
+ ));
17
+ };
18
+
19
+ export default InfoBoxes;
20
+
21
+ InfoBoxes.propTypes = {
22
+ id: PropTypes.string.isRequired,
23
+ schema: PropTypes.object.isRequired
24
+ };
@@ -0,0 +1,22 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import useData from '../hooks/useData';
4
+ import InfoBox from '../presentational/InfoBox';
5
+
6
+ const InfoBoxContainer = ({ id, schema, infoBox }) => {
7
+ const { data } = useData({ id, schema, infoBox });
8
+
9
+ if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
10
+
11
+ const items = Object.values(data).flatMap(item => Object.values(item));
12
+
13
+ return <InfoBox items={items} infoBoxKey={infoBox.key} />;
14
+ };
15
+
16
+ export default InfoBoxContainer;
17
+
18
+ InfoBoxContainer.propTypes = {
19
+ id: PropTypes.string.isRequired,
20
+ infoBox: PropTypes.object.isRequired,
21
+ schema: PropTypes.object.isRequired
22
+ };
@@ -0,0 +1,25 @@
1
+ import { gql } from '@apollo/client';
2
+ import { BlazeError } from '@blaze-cms/core-errors';
3
+
4
+ export default function buildDynamicQuery({ id, schema, infoBox }) {
5
+ if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {
6
+ throw new BlazeError(
7
+ 'DataEntity query requires get action, properties and fields from entity schema'
8
+ );
9
+ }
10
+
11
+ const fields = `${infoBox.property} {
12
+ label
13
+ value
14
+ }`;
15
+
16
+ return {
17
+ query: gql`query getInfoBoxData($id: String!){
18
+ ${schema.actions.get}( id: $id ) {
19
+ id
20
+ ${fields}
21
+ __typename
22
+ }
23
+ }`
24
+ };
25
+ }
@@ -0,0 +1,20 @@
1
+ import { useQuery, gql } from '@apollo/client';
2
+ import useInfoBoxData from './useInfoBox';
3
+
4
+ function useData({ id, schema, infoBox }) {
5
+ const { query } = useInfoBoxData({ id, schema, infoBox });
6
+
7
+ const infoBoxQuery =
8
+ query ||
9
+ gql`
10
+ query {
11
+ __typename
12
+ }
13
+ `;
14
+
15
+ const { data = {}, loading, error } = useQuery(infoBoxQuery, { variables: { id }, skip: !query });
16
+
17
+ return { data: data.__typename !== 'Query' ? data : null, loading, error };
18
+ }
19
+
20
+ export default useData;
@@ -0,0 +1,13 @@
1
+ import buildDynamicQuery from '../helpers/build-dynamic-query';
2
+
3
+ function useInfoBox({ id, schema, infoBox }) {
4
+ const { query } = buildDynamicQuery({
5
+ id,
6
+ schema,
7
+ infoBox
8
+ });
9
+
10
+ return { query: query || null };
11
+ }
12
+
13
+ export default useInfoBox;
@@ -0,0 +1,3 @@
1
+ import InfoBoxes from './InfoBoxes';
2
+
3
+ export default InfoBoxes;
@@ -0,0 +1,34 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+
4
+ const InfoBox = ({ items, infoBoxKey }) => {
5
+ if (!items) return null;
6
+
7
+ const infoBoxItems = items.map(item =>
8
+ Object.values(item)
9
+ .map(info => {
10
+ if (!info.label || !info.value) return null;
11
+
12
+ return (
13
+ <div className="info-box--item" key={`${infoBoxKey}-${info.label.toLowerCase()}`}>
14
+ <div className="info-box--label">{info.label}: </div>
15
+ <div className="info-box--value">{info.value}</div>
16
+ </div>
17
+ );
18
+ })
19
+ .filter(Boolean)
20
+ );
21
+
22
+ return (
23
+ <div className="info-box" key={infoBoxKey}>
24
+ <div className="info-box--container">{infoBoxItems}</div>
25
+ </div>
26
+ );
27
+ };
28
+
29
+ export default InfoBox;
30
+
31
+ InfoBox.propTypes = {
32
+ infoBoxKey: PropTypes.string.isRequired,
33
+ items: PropTypes.array.isRequired
34
+ };
@@ -3,7 +3,6 @@ import React, { useEffect, useState, Fragment } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { withRouter, Link } from 'react-router-dom';
5
5
  import More from '@blaze-react/more';
6
- import { MainContext, useMainContext } from '@blaze-cms/admin-ui-utils';
7
6
  import { PageHeader, DeleteAction } from '@blaze-cms/admin';
8
7
  import { useToasts } from '@blaze-react/toaster';
9
8
  import ListingTableContent from './ListingTableContent';
@@ -14,7 +13,7 @@ import { getDefaultQueryParams } from '../../utils/get-default-query-params';
14
13
 
15
14
  const OVER_SCAN_BUFFER = 10;
16
15
 
17
- const ListingTable = ({ match, entitySchema, selectedMenuItem }) => {
16
+ const ListingTable = ({ match, entitySchema }) => {
18
17
  const [tableData, setTableData] = useState({});
19
18
  const [modalStatus, setModalStatus] = useState(false);
20
19
  const [itemToDelete, setItemToDelete] = useState({});
@@ -23,7 +22,6 @@ const ListingTable = ({ match, entitySchema, selectedMenuItem }) => {
23
22
  const [verifiedRanges, setVerifiedRanges] = useState([]);
24
23
  const queryParamsDefault = getDefaultQueryParams({ schema: entitySchema });
25
24
  const [queryParams, setQueryParams] = useState(queryParamsDefault);
26
- const { menuItems, setMenuItems } = useMainContext(MainContext);
27
25
  const client = useApolloClient();
28
26
  const { addToast } = useToasts();
29
27
 
@@ -55,17 +53,7 @@ const ListingTable = ({ match, entitySchema, selectedMenuItem }) => {
55
53
  [client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps
56
54
  );
57
55
 
58
- const onCloseCardPrompt = () => {
59
- const updatedSelectedMenuItem = {
60
- ...selectedMenuItem,
61
- isDisplayedPrompt: false
62
- };
63
- const [{ header, items }] = menuItems;
64
- const updatedItems = items.map(
65
- item => (item.name === selectedMenuItem.name ? updatedSelectedMenuItem : item)
66
- );
67
- setMenuItems([{ header, items: updatedItems }]);
68
- };
56
+ const onCloseCardPrompt = () => null;
69
57
 
70
58
  const toggleModal = item => {
71
59
  setModalStatus(!!item);
@@ -162,7 +150,7 @@ const ListingTable = ({ match, entitySchema, selectedMenuItem }) => {
162
150
  />
163
151
  )}
164
152
  <PageHeader title={entitySchema.displayName} subtitle="">
165
- {(!selectedMenuItem.isDisplayedPrompt || !!tableData.rows.length) && (
153
+ {!!tableData.rows.length && (
166
154
  <Fragment>
167
155
  <Link
168
156
  data-testid="addEntity"
@@ -187,7 +175,6 @@ const ListingTable = ({ match, entitySchema, selectedMenuItem }) => {
187
175
  onRenderItems={handleRenderedItems}
188
176
  tableData={tableData}
189
177
  onCloseCardPrompt={onCloseCardPrompt}
190
- selectedMenuItem={selectedMenuItem}
191
178
  scrollToIndex={scrollToIndex}
192
179
  />
193
180
  </div>
@@ -195,8 +182,7 @@ const ListingTable = ({ match, entitySchema, selectedMenuItem }) => {
195
182
  };
196
183
  ListingTable.propTypes = {
197
184
  entitySchema: PropTypes.object.isRequired,
198
- match: PropTypes.object.isRequired,
199
- selectedMenuItem: PropTypes.object.isRequired
185
+ match: PropTypes.object.isRequired
200
186
  };
201
187
 
202
188
  export default withRouter(ListingTable);
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import Table from '@blaze-react/table';
3
3
  import PropTypes from 'prop-types';
4
- import { CardPrompt } from '@blaze-cms/admin';
5
- import { Link, withRouter } from 'react-router-dom';
4
+ import { withRouter } from 'react-router-dom';
6
5
 
7
6
  const ListingTableContent = ({
8
7
  tableData,
@@ -20,7 +19,7 @@ const ListingTableContent = ({
20
19
 
21
20
  return (
22
21
  <>
23
- {displayTable ? (
22
+ {displayTable && (
24
23
  <>
25
24
  <div className="page__content">
26
25
  <Table
@@ -36,17 +35,6 @@ const ListingTableContent = ({
36
35
  />
37
36
  </div>
38
37
  </>
39
- ) : (
40
- selectedMenuItem.isDisplayedPrompt && (
41
- <CardPrompt onClose={onCloseCardPrompt} data-testid="card-prompt">
42
- <Link
43
- className="button button--rounded button--cta"
44
- to={`${match.url}/create`}
45
- data-testid="add-button">
46
- Add
47
- </Link>
48
- </CardPrompt>
49
- )
50
38
  )}
51
39
  </>
52
40
  );
@@ -55,7 +43,7 @@ const ListingTableContent = ({
55
43
  ListingTableContent.propTypes = {
56
44
  tableData: PropTypes.object.isRequired,
57
45
  onCloseCardPrompt: PropTypes.func.isRequired,
58
- selectedMenuItem: PropTypes.object.isRequired,
46
+ selectedMenuItem: PropTypes.object,
59
47
  match: PropTypes.shape({
60
48
  url: PropTypes.string
61
49
  }).isRequired,
@@ -73,7 +61,8 @@ ListingTableContent.defaultProps = {
73
61
  onClickRow: () => {},
74
62
  overScanBuffer: 0,
75
63
  scrollToIndex: 0,
76
- onRenderItems: () => {}
64
+ onRenderItems: () => {},
65
+ selectedMenuItem: null
77
66
  };
78
67
 
79
68
  export default withRouter(ListingTableContent);
package/src/index.js CHANGED
@@ -12,14 +12,7 @@ const EntityManager = React.lazy(() =>
12
12
  );
13
13
 
14
14
  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));
15
+ app.events.once('admin:menu:config:load', getAddContentMenuItems(app));
23
16
 
24
17
  app.events.once('load:custom:field:type', addFieldType => {
25
18
  Object.keys(formFieldTypes).forEach(type => {
@@ -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,51 @@ 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 = { content: {} };
22
+
23
+ getEntitySchemas.forEach(({ id, displayName, displayProperties }) => {
24
+ if (!displayProperties) return null;
25
+
26
+ const { adminMenu: { sectionKey = 'content' } = {} } = 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
+ content: {
39
+ label: 'Content',
40
+ loadOpen: true,
41
+ order: 10,
42
+ items: menuItems
43
+ }
44
+ }
45
+ }
46
+ };
47
+
48
+ Object.entries(sectionMenuItems).forEach(([sectionKey, sectionItems]) => {
49
+ const sectionConfig = menuConfig.main.items[sectionKey] || {};
50
+ sectionConfig.items = sectionItems;
51
+ menuConfig.main.items[sectionKey] = sectionConfig;
52
+ });
53
+
17
54
  getEntitySchemas.forEach(({ id, displayName }) => {
18
- addItem({ name: displayName, uri: `/data-listing/${id}` }, sectionKey);
55
+ menuItems[id] = {
56
+ label: displayName,
57
+ uri: `/data-listing/${id}`
58
+ };
19
59
  });
60
+
61
+ addConfig(menuConfig);
20
62
  };
21
63
  }
22
64