@blaze-cms/plugin-data-ui 0.146.0-translations.8 → 0.147.0-rc-eagle.4

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 (211) hide show
  1. package/lib/components/EntityDataListing/EntityDataListing.js +21 -19
  2. package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
  3. package/lib/components/EntityDataListing/index.js +2 -3
  4. package/lib/components/EntityDataListing/index.js.map +1 -1
  5. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +18 -19
  6. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -1
  7. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +2 -3
  8. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -1
  9. package/lib/components/EntityManager/Entity/Entity.js +284 -457
  10. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  11. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js +62 -66
  12. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  13. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +32 -56
  14. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  15. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js +2 -3
  16. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -1
  17. package/lib/components/EntityManager/Entity/EntityHeader/index.js +2 -3
  18. package/lib/components/EntityManager/Entity/EntityHeader/index.js.map +1 -1
  19. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +20 -26
  20. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -1
  21. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +20 -17
  22. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
  23. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +34 -32
  24. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
  25. package/lib/components/EntityManager/Entity/SideBarRelations/index.js +95 -158
  26. package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  27. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +23 -30
  28. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
  29. package/lib/components/EntityManager/Entity/actions-handlers/create/index.js +2 -3
  30. package/lib/components/EntityManager/Entity/actions-handlers/create/index.js.map +1 -1
  31. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +42 -56
  32. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  33. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js +29 -45
  34. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -1
  35. package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js +2 -3
  36. package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -1
  37. package/lib/components/EntityManager/Entity/actions-handlers/index.js +7 -8
  38. package/lib/components/EntityManager/Entity/actions-handlers/index.js.map +1 -1
  39. package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js +2 -3
  40. package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -1
  41. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js +36 -57
  42. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  43. package/lib/components/EntityManager/Entity/actions-handlers/update/index.js +2 -3
  44. package/lib/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -1
  45. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js +47 -66
  46. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
  47. package/lib/components/EntityManager/Entity/index.js +2 -3
  48. package/lib/components/EntityManager/Entity/index.js.map +1 -1
  49. package/lib/components/EntityManager/EntityManager.js +91 -166
  50. package/lib/components/EntityManager/EntityManager.js.map +1 -1
  51. package/lib/components/EntityManager/index.js +2 -3
  52. package/lib/components/EntityManager/index.js.map +1 -1
  53. package/lib/components/EntityManager/utils/RecordEditContext/index.js +3 -4
  54. package/lib/components/EntityManager/utils/RecordEditContext/index.js.map +1 -1
  55. package/lib/components/EntityManager/utils/data-mappers.js +34 -46
  56. package/lib/components/EntityManager/utils/data-mappers.js.map +1 -1
  57. package/lib/components/EntityManager/utils/entity.js +35 -80
  58. package/lib/components/EntityManager/utils/entity.js.map +1 -1
  59. package/lib/components/EntityManager/utils/entityAvailableActions.js +51 -110
  60. package/lib/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
  61. package/lib/components/EntityManager/utils/is-form-empty.js +6 -10
  62. package/lib/components/EntityManager/utils/is-form-empty.js.map +1 -1
  63. package/lib/components/EntityManager/utils/query.js +17 -10
  64. package/lib/components/EntityManager/utils/query.js.map +1 -1
  65. package/lib/components/InfoBoxes/InfoBoxTooltip.js +19 -16
  66. package/lib/components/InfoBoxes/InfoBoxTooltip.js.map +1 -1
  67. package/lib/components/InfoBoxes/InfoBoxes.js +19 -19
  68. package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -1
  69. package/lib/components/InfoBoxes/container/InfoBoxContainer.js +26 -38
  70. package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
  71. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +21 -16
  72. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
  73. package/lib/components/InfoBoxes/hooks/useData.js +33 -30
  74. package/lib/components/InfoBoxes/hooks/useData.js.map +1 -1
  75. package/lib/components/InfoBoxes/hooks/useInfoBox.js +10 -10
  76. package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +1 -1
  77. package/lib/components/InfoBoxes/index.js +2 -3
  78. package/lib/components/InfoBoxes/index.js.map +1 -1
  79. package/lib/components/InfoBoxes/presentational/InfoBox.js +27 -34
  80. package/lib/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
  81. package/lib/components/InfoBoxes/presentational/InfoBoxLabel.js +11 -12
  82. package/lib/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
  83. package/lib/components/InfoBoxes/presentational/InfoBoxValue.js +12 -12
  84. package/lib/components/InfoBoxes/presentational/InfoBoxValue.js.map +1 -1
  85. package/lib/components/ListingTable/ListingTable.js +155 -296
  86. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  87. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +53 -58
  88. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  89. package/lib/components/ListingTable/ListingTableContent/index.js +2 -3
  90. package/lib/components/ListingTable/ListingTableContent/index.js.map +1 -1
  91. package/lib/components/ListingTable/SearchFilter/SearchContainer.js +436 -262
  92. package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
  93. package/lib/components/ListingTable/SearchFilter/SearchFilter.js +30 -37
  94. package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
  95. package/lib/components/ListingTable/SearchFilter/helpers.js +82 -71
  96. package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -1
  97. package/lib/components/ListingTable/SearchFilter/querys.js +5 -5
  98. package/lib/components/ListingTable/SearchFilter/querys.js.map +1 -1
  99. package/lib/components/ListingTable/TableActions/TableActions.js +27 -31
  100. package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
  101. package/lib/components/ListingTable/TableActions/index.js +2 -3
  102. package/lib/components/ListingTable/TableActions/index.js.map +1 -1
  103. package/lib/components/ListingTable/index.js +2 -3
  104. package/lib/components/ListingTable/index.js.map +1 -1
  105. package/lib/components/ListingTable/mappers/populate-rows.js +103 -122
  106. package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
  107. package/lib/components/ListingTable/service/index.js +66 -83
  108. package/lib/components/ListingTable/service/index.js.map +1 -1
  109. package/lib/components/Tabs/index.js +26 -42
  110. package/lib/components/Tabs/index.js.map +1 -1
  111. package/lib/components/hooks/useCallbackDebounce.js +5 -9
  112. package/lib/components/hooks/useCallbackDebounce.js.map +1 -1
  113. package/lib/constants.js +30 -31
  114. package/lib/constants.js.map +1 -1
  115. package/lib/icons/ContentIcon.js +17 -20
  116. package/lib/icons/ContentIcon.js.map +1 -1
  117. package/lib/icons/SettingsIcon.js +12 -15
  118. package/lib/icons/SettingsIcon.js.map +1 -1
  119. package/lib/icons/TaxonomyIcon.js +15 -18
  120. package/lib/icons/TaxonomyIcon.js.map +1 -1
  121. package/lib/icons/UsersIcon.js +11 -14
  122. package/lib/icons/UsersIcon.js.map +1 -1
  123. package/lib/icons/index.js +8 -9
  124. package/lib/icons/index.js.map +1 -1
  125. package/lib/index.js +88 -121
  126. package/lib/index.js.map +1 -1
  127. package/lib/utils/add-content-menu-items.js +67 -93
  128. package/lib/utils/add-content-menu-items.js.map +1 -1
  129. package/lib/utils/build-create-entity-mutation.js +12 -9
  130. package/lib/utils/build-create-entity-mutation.js.map +1 -1
  131. package/lib/utils/build-delete-entity-mutation.js +11 -8
  132. package/lib/utils/build-delete-entity-mutation.js.map +1 -1
  133. package/lib/utils/build-listing-query.js +17 -14
  134. package/lib/utils/build-listing-query.js.map +1 -1
  135. package/lib/utils/build-update-data-query.js +15 -9
  136. package/lib/utils/build-update-data-query.js.map +1 -1
  137. package/lib/utils/build-update-publish-unpublish-mutation.js +15 -8
  138. package/lib/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  139. package/lib/utils/get-default-query-params.js +7 -6
  140. package/lib/utils/get-default-query-params.js.map +1 -1
  141. package/lib/utils/hoc/withContext.js +4 -6
  142. package/lib/utils/hoc/withContext.js.map +1 -1
  143. package/lib/utils/hooks/useToggle.js +4 -12
  144. package/lib/utils/hooks/useToggle.js.map +1 -1
  145. package/lib/utils/index.js +2 -3
  146. package/lib/utils/index.js.map +1 -1
  147. package/lib-es/components/EntityManager/Entity/Entity.js +8 -20
  148. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  149. package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  150. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  151. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
  152. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
  153. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +6 -3
  154. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  155. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
  156. package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  157. package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  158. package/lib-es/components/EntityManager/EntityManager.js.map +1 -1
  159. package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
  160. package/lib-es/components/EntityManager/utils/query.js.map +1 -1
  161. package/lib-es/components/InfoBoxes/InfoBoxTooltip.js.map +1 -1
  162. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
  163. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
  164. package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -1
  165. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
  166. package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
  167. package/lib-es/components/ListingTable/ListingTable.js +2 -2
  168. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  169. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +20 -17
  170. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  171. package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js +323 -51
  172. package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
  173. package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js +7 -3
  174. package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
  175. package/lib-es/components/ListingTable/SearchFilter/helpers.js +39 -8
  176. package/lib-es/components/ListingTable/SearchFilter/helpers.js.map +1 -1
  177. package/lib-es/components/ListingTable/SearchFilter/querys.js.map +1 -1
  178. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
  179. package/lib-es/components/ListingTable/service/index.js.map +1 -1
  180. package/lib-es/components/Tabs/index.js +6 -7
  181. package/lib-es/components/Tabs/index.js.map +1 -1
  182. package/lib-es/index.js +12 -3
  183. package/lib-es/index.js.map +1 -1
  184. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  185. package/lib-es/utils/build-create-entity-mutation.js.map +1 -1
  186. package/lib-es/utils/build-delete-entity-mutation.js.map +1 -1
  187. package/lib-es/utils/build-listing-query.js.map +1 -1
  188. package/lib-es/utils/build-update-data-query.js.map +1 -1
  189. package/lib-es/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  190. package/lib-es/utils/hoc/withContext.js +1 -1
  191. package/lib-es/utils/hoc/withContext.js.map +1 -1
  192. package/package.json +27 -22
  193. package/src/components/EntityManager/Entity/Entity.js +59 -77
  194. package/src/components/EntityManager/Entity/EntityHeader/EntityHeader.js +1 -2
  195. package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +9 -7
  196. package/src/components/EntityManager/Entity/SideBarRelations/index.js +64 -59
  197. package/src/components/EntityManager/EntityManager.js +52 -45
  198. package/src/components/InfoBoxes/container/InfoBoxContainer.js +3 -6
  199. package/src/components/InfoBoxes/hooks/useData.js +6 -1
  200. package/src/components/ListingTable/ListingTable.js +13 -21
  201. package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +38 -44
  202. package/src/components/ListingTable/SearchFilter/SearchContainer.js +411 -134
  203. package/src/components/ListingTable/SearchFilter/SearchFilter.js +5 -2
  204. package/src/components/ListingTable/SearchFilter/helpers.js +56 -8
  205. package/src/components/ListingTable/service/index.js +2 -3
  206. package/src/components/Tabs/index.js +17 -21
  207. package/src/index.js +11 -7
  208. package/src/utils/hoc/withContext.js +5 -4
  209. package/CHANGELOG.md +0 -1947
  210. package/babel.config.js +0 -3
  211. package/jest.config.js +0 -5
@@ -4,7 +4,7 @@ import { withRouter, Prompt } from 'react-router-dom';
4
4
  import { useApolloClient } from '@apollo/client';
5
5
  import PropTypes from 'prop-types';
6
6
  import { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';
7
- import { getQuery, GET_CURRENT_TAB_ID } from '@blaze-cms/admin-ui-utils';
7
+ import { getQuery } from '@blaze-cms/admin-ui-utils';
8
8
  import { FormBuilder, parseFormValues } from '@blaze-cms/react-form-builder';
9
9
  import { DeleteAction, CopyDataFromAction } from '@blaze-cms/admin';
10
10
  import { useToasts } from '@blaze-react/toaster';
@@ -13,7 +13,6 @@ import { getPageName } from '../utils/data-mappers';
13
13
  import isFormEmpty from '../utils/is-form-empty';
14
14
  import availableActions from './actions-handlers';
15
15
  import SideBarRelations from './SideBarRelations';
16
- import Tabs from '../../Tabs';
17
16
  import useCallbackDebounce from '../../hooks/useCallbackDebounce';
18
17
 
19
18
  import {
@@ -51,7 +50,6 @@ const Entity = ({
51
50
  onViewUrl,
52
51
  refetchRecord
53
52
  }) => {
54
- const [, setCurrentTabId] = useState(null);
55
53
  const [formValues, setFormValues] = useState(null);
56
54
  const [entitySchema, setEntitySchema] = useState(null);
57
55
  const [entityData, setEntityData] = useState(null);
@@ -109,50 +107,48 @@ const Entity = ({
109
107
  []
110
108
  ); // Using an empty dependency array ensures this only runs on unmount
111
109
 
112
- useEffect(
113
- () => {
114
- if (shouldUpdateState) {
115
- setSaveButtonText(SAVE_BUTTON_TEXTS.save);
116
- setEntityData(entity);
117
- setPageTitle(getPageName(schema.displayProperties, entity));
118
- setEntityIsPublish(entity.status);
119
- setEntitySchema(schema);
120
- setEnablePublishButton(schema.actions.publish);
121
- setEntityIdentifier(schema.identifier);
122
- setEnablePreviewButton(!!schema.interfaces.includes(PREVIEW_INTERFACE));
123
- }
110
+ useEffect(() => {
111
+ if (shouldUpdateState) {
112
+ setSaveButtonText(SAVE_BUTTON_TEXTS.save);
113
+ setEntityData(entity);
114
+ setPageTitle(getPageName(schema.displayProperties, entity));
115
+ setEntityIsPublish(entity.status);
116
+ setEntitySchema(schema);
117
+ setEnablePublishButton(schema.actions.publish);
118
+ setEntityIdentifier(schema.identifier);
119
+ setEnablePreviewButton(!!schema.interfaces.includes(PREVIEW_INTERFACE));
120
+ }
124
121
 
125
- if (formData && pageBuilderTemplateStatus) {
126
- const isPageBuilderTemplateSet = !!formData.values.pageBuilderTemplateId;
127
- client.writeQuery({
128
- query: getQuery('GET_PB_TEMPLATE_STATUS'),
129
- data: {
130
- pageBuilderTemplateSet: isPageBuilderTemplateSet,
131
- pageBuilderTemplateId: formData.values.pageBuilderTemplateId || ''
132
- }
133
- });
134
- }
135
- if (schema) {
136
- client.writeQuery({
137
- query: getQuery('GET_CURRENT_ENTITY'),
138
- data: {
139
- currentEntity: schema.id
140
- }
141
- });
142
- }
143
- },
144
- [
145
- client,
146
- entity,
147
- entityData,
148
- formData,
149
- formValues,
150
- pageBuilderTemplateStatus,
151
- previousQuery,
152
- schema,
153
- shouldUpdateState
154
- ]
155
- );
122
+ if (formData && pageBuilderTemplateStatus) {
123
+ const isPageBuilderTemplateSet = !!formData.values.pageBuilderTemplateId;
124
+ client.writeQuery({
125
+ query: getQuery('GET_PB_TEMPLATE_STATUS'),
126
+ data: {
127
+ pageBuilderTemplateSet: isPageBuilderTemplateSet,
128
+ pageBuilderTemplateId: formData.values.pageBuilderTemplateId || ''
129
+ }
130
+ });
131
+ }
132
+ if (schema) {
133
+ client.writeQuery({
134
+ query: getQuery('GET_CURRENT_ENTITY'),
135
+ data: {
136
+ currentEntity: schema.id,
137
+ currentItemId: entity ? entity.id : null
138
+ }
139
+ });
140
+ }
141
+ }, [
142
+ client,
143
+ entity,
144
+ entityData,
145
+ formData,
146
+ formValues,
147
+ pageBuilderTemplateStatus,
148
+ previousQuery,
149
+ schema,
150
+ shouldUpdateState
151
+ ]);
156
152
 
157
153
  const getFullUrl = async () => {
158
154
  const query = getQuery('GET_ENTITY_URL');
@@ -420,9 +416,6 @@ const Entity = ({
420
416
  const hasToDisplayPrompt = isSaveButtonAvailable || hasNewFormValues;
421
417
 
422
418
  const showSideBarRelations = checkFulfilConditions(schema, formData);
423
- const showPageBuilderTabs =
424
- schema?.interfaces?.includes('page-builder/page-builder-template') ||
425
- schema?.interfaces?.includes('page-builder/page-builder');
426
419
 
427
420
  return (
428
421
  <RecordEditContextProvider value={{ externalUpdateTime, updated: formData?.values?.updated }}>
@@ -464,9 +457,8 @@ const Entity = ({
464
457
  )}
465
458
 
466
459
  <div
467
- className={`page__content--fixed${
468
- !isRightSidebarOpen ? ' right-sidebar-collapsed' : ''
469
- }`}>
460
+ className={`page__content--fixed${!isRightSidebarOpen ? ' right-sidebar-collapsed' : ''
461
+ }`}>
470
462
  <div className="page__content">
471
463
  <div className="content">
472
464
  <RenderHook
@@ -475,28 +467,19 @@ const Entity = ({
475
467
  schema={schema}
476
468
  />
477
469
  <InfoBoxes id={entity.id} schema={schema} />
478
- <Tabs
479
- enabled={showPageBuilderTabs}
480
- onTabChange={tabId => {
481
- client.writeQuery({
482
- query: GET_CURRENT_TAB_ID,
483
- data: { currentTabId: tabId }
484
- });
485
- setCurrentTabId(tabId);
486
- }}>
487
- <FormBuilder
488
- getIsFormValid={setIsFormValid}
489
- getFormValues={getFormValues}
490
- schema={schema}
491
- data={clonedFormData}
492
- onChange={onChangeFormValues}
493
- shouldCopyData={shouldCopyData}
494
- updateCopyData={updateCopyData}
495
- formValues={formValues}
496
- isNewEntity={isNewEntity}
497
- onExternalUpdate={setExternalUpdateTime}
498
- />
499
- </Tabs>
470
+ <FormBuilder
471
+ getIsFormValid={setIsFormValid}
472
+ getFormValues={getFormValues}
473
+ schema={schema}
474
+ data={clonedFormData}
475
+ onChange={onChangeFormValues}
476
+ shouldCopyData={shouldCopyData}
477
+ updateCopyData={updateCopyData}
478
+ formValues={formValues}
479
+ isNewEntity={isNewEntity}
480
+ onExternalUpdate={setExternalUpdateTime}
481
+ mode={isNewEntity ? 'create' : 'update'}
482
+ />
500
483
  <RenderHook
501
484
  hookKey={`entity:${action}:main:bottom`}
502
485
  entity={entity}
@@ -508,9 +491,8 @@ const Entity = ({
508
491
  </div>
509
492
 
510
493
  <div
511
- className={`column column--one-third page-sidebar page-sidebar--relations${
512
- !isRightSidebarOpen ? ' sidebar--collapsed' : ''
513
- }`}>
494
+ className={`column column--one-third page-sidebar page-sidebar--relations${!isRightSidebarOpen ? ' sidebar--collapsed' : ''
495
+ }`}>
514
496
  {showSideBarRelations && (
515
497
  <SideBarRelations
516
498
  entity={entity}
@@ -30,8 +30,7 @@ const EntityHeader = ({
30
30
 
31
31
  const {
32
32
  displayProperties: { adminCrudActions: { delete: deleteAction = { active: true } } = {} } = {}
33
- } =
34
- entitySchema || {};
33
+ } = entitySchema || {};
35
34
 
36
35
  const showDeleteButton =
37
36
  deleteAction.active && formData && Object.keys(formData.values).length !== 0;
@@ -21,17 +21,19 @@ const useCustomSidebarData = ({ id, schema, displayProperties }) => {
21
21
  }
22
22
  `;
23
23
 
24
- const { data = {}, loading, error, refetch } = useQuery(customSidebarInfoQuery, {
24
+ const {
25
+ data = {},
26
+ loading,
27
+ error,
28
+ refetch
29
+ } = useQuery(customSidebarInfoQuery, {
25
30
  variables: { id },
26
31
  skip: !query
27
32
  });
28
33
 
29
- useEffect(
30
- () => {
31
- refetch();
32
- },
33
- [externalUpdateTime, updated, refetch]
34
- );
34
+ useEffect(() => {
35
+ refetch();
36
+ }, [externalUpdateTime, updated, refetch]);
35
37
 
36
38
  return { data: data.__typename !== 'Query' ? data : null, loading, error };
37
39
  };
@@ -1,6 +1,7 @@
1
1
  import React, { useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import uuidv1 from 'uuid/v1';
4
+ import Accordion from '@blaze-react/accordion';
4
5
  import { useApolloClient } from '@apollo/client';
5
6
  import { getQuery } from '@blaze-cms/admin-ui-utils';
6
7
  import { formFieldTypes } from '@blaze-cms/react-form-builder';
@@ -24,40 +25,37 @@ const SideBarRelations = ({ schema, onChange, formData, entity, isOpen, onToggle
24
25
 
25
26
  const [relationsComponents, setRelationsComponents] = useState(null);
26
27
 
27
- useEffect(
28
- () => {
29
- (async () => {
30
- const fetchRelationSchema = async ({ entityIdentifier }) => {
31
- if (!entityIdentifier) return null;
28
+ useEffect(() => {
29
+ (async () => {
30
+ const fetchRelationSchema = async ({ entityIdentifier }) => {
31
+ if (!entityIdentifier) return null;
32
32
 
33
- const {
34
- data: {
35
- getEntitySchemas: [relationSchema]
36
- }
37
- } = await client.query({
38
- query: getQuery('GET_ENTITY_SCHEMA'),
39
- variables: { identifier: entityIdentifier }
40
- });
41
- return relationSchema;
42
- };
33
+ const {
34
+ data: {
35
+ getEntitySchemas: [relationSchema]
36
+ }
37
+ } = await client.query({
38
+ query: getQuery('GET_ENTITY_SCHEMA'),
39
+ variables: { identifier: entityIdentifier }
40
+ });
41
+ return relationSchema;
42
+ };
43
43
 
44
- if (!relationsComponents && schema) {
45
- const allRelationComponents = await Promise.all(
46
- schema.relations
47
- .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])
48
- .map(async relation => ({
49
- id: uuidv1(),
50
- staticData: relation,
51
- schema: await fetchRelationSchema(relation)
52
- }))
53
- );
44
+ if (!relationsComponents && schema) {
45
+ const allRelationComponents = await Promise.all(
46
+ schema.relations
47
+ .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])
48
+ .map(async relation => ({
49
+ id: uuidv1(),
50
+ staticData: relation,
51
+ schema: await fetchRelationSchema(relation)
52
+ }))
53
+ );
54
54
 
55
- setRelationsComponents(allRelationComponents);
56
- }
57
- })();
58
- },
59
- [client, relationsComponents, schema, schema.relations]
60
- );
55
+ setRelationsComponents(allRelationComponents);
56
+ }
57
+ })();
58
+ }, [client, relationsComponents, schema, schema.relations]);
61
59
  const { id: itemId } = entity;
62
60
  const { identifier: itemEntity, interfaces } = schema;
63
61
 
@@ -92,24 +90,21 @@ const SideBarRelations = ({ schema, onChange, formData, entity, isOpen, onToggle
92
90
  )}
93
91
  </div>
94
92
  )}
95
- {!schema.displayProperties.disableDefaultAdminInfo &&
96
- formattedCreated && (
97
- <>
98
- <>
99
- <p>
100
- Created: <span>{formattedCreated}</span>
101
- </p>
102
- <p>
103
- Updated: <span>{formattedUpdated}</span>
104
- </p>
105
- {updatedBy && (
106
- <p>
107
- Updated by: <span>{updatedBy.name}</span>
108
- </p>
109
- )}
110
- </>
111
- </>
112
- )}
93
+ {!schema.displayProperties.disableDefaultAdminInfo && formattedCreated && (
94
+ <>
95
+ <p>
96
+ Created: <span>{formattedCreated}</span>
97
+ </p>
98
+ <p>
99
+ Updated: <span>{formattedUpdated}</span>
100
+ </p>
101
+ {updatedBy && (
102
+ <p>
103
+ Updated by: <span>{updatedBy.name}</span>
104
+ </p>
105
+ )}
106
+ </>
107
+ )}
113
108
 
114
109
  <CustomSidebarInfoContainer
115
110
  id={itemId}
@@ -121,16 +116,26 @@ const SideBarRelations = ({ schema, onChange, formData, entity, isOpen, onToggle
121
116
  <VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />
122
117
  <EntityNavLinks schema={schema} />
123
118
 
124
- {relationsComponents &&
125
- relationsComponents.map(({ id, staticData, schema: entitySchema }) => (
126
- <RelationComponent
127
- formData={formData}
128
- schema={entitySchema}
129
- key={id}
130
- staticData={staticData}
131
- onSelect={onChange}
132
- />
133
- ))}
119
+ {relationsComponents && (
120
+ <Accordion isOpen>
121
+ <Accordion.Header>
122
+ <b>Classification</b>
123
+ </Accordion.Header>
124
+ <Accordion.Content>
125
+ <Accordion.ContentDetails>
126
+ {relationsComponents.map(({ id, staticData, schema: entitySchema }) => (
127
+ <RelationComponent
128
+ formData={formData}
129
+ schema={entitySchema}
130
+ key={id}
131
+ staticData={staticData}
132
+ onSelect={onChange}
133
+ />
134
+ ))}
135
+ </Accordion.ContentDetails>
136
+ </Accordion.Content>
137
+ </Accordion>
138
+ )}
134
139
  </div>
135
140
  </div>
136
141
  );
@@ -19,56 +19,63 @@ const EntityManager = ({ match, history }) => {
19
19
 
20
20
  const { action, entityIdentifier, id = null, onViewUrl } = match.params;
21
21
 
22
- useEffect(
23
- () => {
24
- (async () => {
25
- try {
26
- const [entitySchema, data = {}, requestedQuery] = await entityAvailableActions[action]({
27
- client,
28
- identifier: entityIdentifier,
29
- id
30
- });
31
-
32
- if (!data) {
33
- addToast(PAGE_NOT_FOUND, {
34
- appearance: ERROR,
35
- autoDismiss: true
36
- });
37
-
38
- history.push(`/data-listing/${entityIdentifier}`);
39
- }
40
-
41
- let localData = data;
42
-
43
- if (isPageBuilderTemplateSet(data)) {
44
- const pageBuilderComponents = await getPageBuilderComponents({
45
- entitySchema,
46
- client,
47
- id
48
- });
49
-
50
- localData = {
51
- ...localData,
52
- pageBuilder: pageBuilderComponents || localData.pageBuilder
53
- };
54
- }
55
-
56
- setFormData({ values: localData });
57
- setEntity(data);
58
- setSchema(entitySchema);
59
- setPreviousQuery(requestedQuery);
60
- setShouldRefetch(false);
61
- } catch (error) {
62
- addToast(error.message, {
22
+ useEffect(() => {
23
+ (async () => {
24
+ try {
25
+ const [entitySchema, data = {}, requestedQuery] = await entityAvailableActions[action]({
26
+ client,
27
+ identifier: entityIdentifier,
28
+ id
29
+ });
30
+
31
+ if (!data) {
32
+ addToast(PAGE_NOT_FOUND, {
63
33
  appearance: ERROR,
64
34
  autoDismiss: true
65
35
  });
36
+
66
37
  history.push(`/data-listing/${entityIdentifier}`);
67
38
  }
68
- })();
69
- },
70
- [action, addToast, client, entityIdentifier, history, history.push, id, schema, shouldRefetch]
71
- );
39
+
40
+ let localData = data;
41
+
42
+ if (isPageBuilderTemplateSet(data)) {
43
+ const pageBuilderComponents = await getPageBuilderComponents({
44
+ entitySchema,
45
+ client,
46
+ id
47
+ });
48
+
49
+ localData = {
50
+ ...localData,
51
+ pageBuilder: pageBuilderComponents || localData.pageBuilder
52
+ };
53
+ }
54
+
55
+ setFormData({ values: localData });
56
+ setEntity(data);
57
+ setSchema(entitySchema);
58
+ setPreviousQuery(requestedQuery);
59
+ setShouldRefetch(false);
60
+ } catch (error) {
61
+ addToast(error.message, {
62
+ appearance: ERROR,
63
+ autoDismiss: true
64
+ });
65
+ history.push(`/data-listing/${entityIdentifier}`);
66
+ }
67
+ })();
68
+ }, [
69
+ action,
70
+ addToast,
71
+ client,
72
+ entityIdentifier,
73
+ history,
74
+ history.push,
75
+ id,
76
+ schema,
77
+ shouldRefetch
78
+ ]);
72
79
 
73
80
  const updateFormData = (updatedFormData, shouldRefresh) => {
74
81
  if (shouldRefresh) setShouldRefetch(true);
@@ -9,12 +9,9 @@ const InfoBoxContainer = ({ id, schema, infoBox }) => {
9
9
 
10
10
  const { data, refetch } = useData({ id, schema, infoBox });
11
11
 
12
- useEffect(
13
- () => {
14
- refetch();
15
- },
16
- [externalUpdateTime, refetch]
17
- );
12
+ useEffect(() => {
13
+ refetch();
14
+ }, [externalUpdateTime, refetch]);
18
15
 
19
16
  if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
20
17
 
@@ -12,7 +12,12 @@ function useData({ id, schema, infoBox }) {
12
12
  }
13
13
  `;
14
14
 
15
- const { data = {}, loading, error, refetch } = useQuery(infoBoxQuery, {
15
+ const {
16
+ data = {},
17
+ loading,
18
+ error,
19
+ refetch
20
+ } = useQuery(infoBoxQuery, {
16
21
  variables: { id },
17
22
  skip: !query
18
23
  });
@@ -144,7 +144,6 @@ const ListingTable = ({ match, entitySchema, history }) => {
144
144
  });
145
145
  history.push('?page=1');
146
146
  };
147
-
148
147
  if (!tableData || !tableData.rows) return 'loading';
149
148
 
150
149
  const {
@@ -160,27 +159,20 @@ const ListingTable = ({ match, entitySchema, history }) => {
160
159
 
161
160
  return (
162
161
  <div className="page">
163
- {modalStatus &&
164
- _deleteAction.active && (
165
- <DeleteAction
166
- data-testid="deleteEntity"
167
- onClose={toggleModal}
168
- deleteAction={deleteAction}
169
- itemName={itemToDelete.name}
170
- />
171
- )}
162
+ {modalStatus && _deleteAction.active && (
163
+ <DeleteAction
164
+ data-testid="deleteEntity"
165
+ onClose={toggleModal}
166
+ deleteAction={deleteAction}
167
+ itemName={itemToDelete.name}
168
+ />
169
+ )}
172
170
  <PageHeader title={entitySchema.displayName} subtitle="">
173
- {createAction.active &&
174
- !showAddButton && (
175
- <Fragment>
176
- <Link
177
- data-testid="addEntity"
178
- className="button button--small"
179
- to={`${match.url}/create`}>
180
- Add
181
- </Link>
182
- </Fragment>
183
- )}
171
+ {createAction.active && !showAddButton && (
172
+ <Link data-testid="addEntity" className="button button--small" to={`${match.url}/create`}>
173
+ Add
174
+ </Link>
175
+ )}
184
176
  </PageHeader>
185
177
  {showAddButton ? (
186
178
  <CardPrompt>
@@ -1,7 +1,6 @@
1
1
  import React, { useEffect, useRef } from 'react';
2
2
  import Table from '@blaze-react/table';
3
3
  import Pagination from '@blaze-react/pagination';
4
-
5
4
  import PropTypes from 'prop-types';
6
5
  import { withRouter } from 'react-router-dom';
7
6
 
@@ -18,53 +17,48 @@ const ListingTableContent = ({
18
17
  const { isEnquiry } = tableData;
19
18
  const className = `page__content${isEnquiry ? ' array-table' : ''}`;
20
19
 
21
- useEffect(
22
- () => {
23
- // set table head to match body column widths to handle dynamic content
24
- if (ref.current) {
25
- const tableHeadCells = ref.current.querySelectorAll('.table-head .table-cell');
26
- const firstRowCells = ref.current.querySelectorAll(
27
- '.table-body .table-row:first-child .table-cell'
28
- );
20
+ useEffect(() => {
21
+ // set table head to match body column widths to handle dynamic content
22
+ if (ref.current && displayTable) {
23
+ const tableHeadCells = ref.current.querySelectorAll('.table-head .table-cell');
24
+ const firstRowCells = ref.current.querySelectorAll(
25
+ '.table-body .table-row:first-child .table-cell'
26
+ );
29
27
 
30
- firstRowCells.forEach((element, i) => {
31
- const styles = window.getComputedStyle(element);
28
+ firstRowCells.forEach((element, i) => {
29
+ const styles = window.getComputedStyle(element);
32
30
 
33
- if (tableHeadCells[i]) {
34
- tableHeadCells[i].style.flex = styles.flex;
35
- tableHeadCells[i].style['justify-content'] = styles['justify-content'];
36
- }
37
- });
38
- }
39
- },
40
- [tableData]
41
- );
31
+ if (tableHeadCells[i]) {
32
+ tableHeadCells[i].style.flex = styles.flex;
33
+ tableHeadCells[i].style['justify-content'] = styles['justify-content'];
34
+ }
35
+ });
36
+ }
37
+ }, [tableData, displayTable]);
38
+
39
+ if (displayTable) {
40
+ return (
41
+ <div ref={ref} className={className}>
42
+ <Table
43
+ onSort={onSort}
44
+ data={tableData}
45
+ onSelect={handleSelect}
46
+ data-testid="listing-table-content"
47
+ />
48
+ <Pagination
49
+ visiblePages={10}
50
+ totalItems={totalItems}
51
+ currentPage={currentPage}
52
+ onPageChange={handleOnPageChange}
53
+ />
54
+ </div>
55
+ );
56
+ }
42
57
 
43
58
  return (
44
- <>
45
- {displayTable ? (
46
- <>
47
- <div ref={ref} className={className}>
48
- <Table
49
- onSort={onSort}
50
- data={tableData}
51
- onSelect={handleSelect}
52
- data-testid="listing-table-content"
53
- />
54
- <Pagination
55
- visiblePages={10}
56
- totalItems={totalItems}
57
- currentPage={currentPage}
58
- onPageChange={handleOnPageChange}
59
- />
60
- </div>
61
- </>
62
- ) : (
63
- <span className="table-no-results" data-testid="no-results">
64
- No results
65
- </span>
66
- )}
67
- </>
59
+ <span className="table-no-results" data-testid="no-results">
60
+ No results
61
+ </span>
68
62
  );
69
63
  };
70
64