@blaze-cms/plugin-data-ui 0.146.0-core-styles.44 → 0.146.0-node18.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 (89) hide show
  1. package/CHANGELOG.md +16 -163
  2. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +1 -0
  3. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -1
  4. package/lib/components/EntityManager/Entity/Entity.js +6 -6
  5. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  6. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  7. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +1 -1
  8. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  9. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +1 -0
  10. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
  11. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
  12. package/lib/components/EntityManager/Entity/SideBarRelations/index.js +6 -6
  13. package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  14. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +1 -1
  15. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  16. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js +1 -1
  17. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -1
  18. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js +1 -1
  19. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  20. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js +1 -1
  21. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
  22. package/lib/components/EntityManager/EntityManager.js +3 -3
  23. package/lib/components/EntityManager/EntityManager.js.map +1 -1
  24. package/lib/components/EntityManager/utils/entity.js +1 -1
  25. package/lib/components/EntityManager/utils/entity.js.map +1 -1
  26. package/lib/components/EntityManager/utils/entityAvailableActions.js +2 -2
  27. package/lib/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
  28. package/lib/components/InfoBoxes/InfoBoxes.js +1 -0
  29. package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -1
  30. package/lib/components/InfoBoxes/container/InfoBoxContainer.js +1 -1
  31. package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
  32. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +1 -0
  33. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
  34. package/lib/components/InfoBoxes/hooks/useData.js.map +1 -1
  35. package/lib/components/ListingTable/ListingTable.js +8 -8
  36. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  37. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +2 -2
  38. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  39. package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
  40. package/lib/components/ListingTable/service/index.js +2 -1
  41. package/lib/components/ListingTable/service/index.js.map +1 -1
  42. package/lib/components/Tabs/index.js +1 -1
  43. package/lib/components/Tabs/index.js.map +1 -1
  44. package/lib/index.js +5 -5
  45. package/lib/index.js.map +1 -1
  46. package/lib/utils/add-content-menu-items.js +1 -1
  47. package/lib/utils/add-content-menu-items.js.map +1 -1
  48. package/lib-es/components/EntityManager/Entity/Entity.js +1 -1
  49. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  50. package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  51. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
  52. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
  53. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +1 -1
  54. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  55. package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  56. package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  57. package/lib-es/components/EntityManager/EntityManager.js.map +1 -1
  58. package/lib-es/components/EntityManager/utils/query.js.map +1 -1
  59. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
  60. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
  61. package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -1
  62. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
  63. package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
  64. package/lib-es/components/ListingTable/ListingTable.js +1 -1
  65. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  66. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +2 -2
  67. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  68. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
  69. package/lib-es/components/ListingTable/service/index.js.map +1 -1
  70. package/lib-es/index.js +2 -2
  71. package/lib-es/index.js.map +1 -1
  72. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  73. package/lib-es/utils/build-create-entity-mutation.js.map +1 -1
  74. package/lib-es/utils/build-delete-entity-mutation.js.map +1 -1
  75. package/lib-es/utils/build-listing-query.js.map +1 -1
  76. package/lib-es/utils/build-update-data-query.js.map +1 -1
  77. package/lib-es/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  78. package/package.json +18 -17
  79. package/src/components/EntityManager/Entity/Entity.js +41 -44
  80. package/src/components/EntityManager/Entity/EntityHeader/EntityHeader.js +1 -2
  81. package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +9 -7
  82. package/src/components/EntityManager/Entity/SideBarRelations/index.js +40 -51
  83. package/src/components/EntityManager/EntityManager.js +52 -45
  84. package/src/components/InfoBoxes/container/InfoBoxContainer.js +3 -6
  85. package/src/components/InfoBoxes/hooks/useData.js +6 -1
  86. package/src/components/ListingTable/ListingTable.js +26 -29
  87. package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +15 -17
  88. package/src/components/ListingTable/service/index.js +2 -3
  89. package/src/index.js +4 -4
@@ -12,51 +12,43 @@ import EntityNavLinks from '../EntitiyNavLinks';
12
12
 
13
13
  const SideBarRelations = ({ schema, onChange, formData, entity }) => {
14
14
  const { relation: RelationComponent } = formFieldTypes;
15
- const {
16
- formattedStatus,
17
- formattedUpdated,
18
- formattedCreated,
19
- formattedPublished,
20
- status
21
- } = formData;
15
+ const { formattedStatus, formattedUpdated, formattedCreated, formattedPublished, status } =
16
+ formData;
22
17
  const client = useApolloClient();
23
18
 
24
19
  const [relationsComponents, setRelationsComponents] = useState(null);
25
20
 
26
- useEffect(
27
- () => {
28
- (async () => {
29
- const fetchRelationSchema = async ({ entityIdentifier }) => {
30
- if (!entityIdentifier) return null;
21
+ useEffect(() => {
22
+ (async () => {
23
+ const fetchRelationSchema = async ({ entityIdentifier }) => {
24
+ if (!entityIdentifier) return null;
31
25
 
32
- const {
33
- data: {
34
- getEntitySchemas: [relationSchema]
35
- }
36
- } = await client.query({
37
- query: getQuery('GET_ENTITY_SCHEMA'),
38
- variables: { identifier: entityIdentifier }
39
- });
40
- return relationSchema;
41
- };
26
+ const {
27
+ data: {
28
+ getEntitySchemas: [relationSchema]
29
+ }
30
+ } = await client.query({
31
+ query: getQuery('GET_ENTITY_SCHEMA'),
32
+ variables: { identifier: entityIdentifier }
33
+ });
34
+ return relationSchema;
35
+ };
42
36
 
43
- if (!relationsComponents && schema) {
44
- const allRelationComponents = await Promise.all(
45
- schema.relations
46
- .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])
47
- .map(async relation => ({
48
- id: uuidv1(),
49
- staticData: relation,
50
- schema: await fetchRelationSchema(relation)
51
- }))
52
- );
37
+ if (!relationsComponents && schema) {
38
+ const allRelationComponents = await Promise.all(
39
+ schema.relations
40
+ .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])
41
+ .map(async relation => ({
42
+ id: uuidv1(),
43
+ staticData: relation,
44
+ schema: await fetchRelationSchema(relation)
45
+ }))
46
+ );
53
47
 
54
- setRelationsComponents(allRelationComponents);
55
- }
56
- })();
57
- },
58
- [client, relationsComponents, schema, schema.relations]
59
- );
48
+ setRelationsComponents(allRelationComponents);
49
+ }
50
+ })();
51
+ }, [client, relationsComponents, schema, schema.relations]);
60
52
  const { id: itemId } = entity;
61
53
  const { identifier: itemEntity, interfaces } = schema;
62
54
 
@@ -82,19 +74,16 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
82
74
  )}
83
75
  </div>
84
76
  )}
85
- {!schema.displayProperties.disableDefaultAdminInfo &&
86
- formattedCreated && (
87
- <>
88
- <>
89
- <p>
90
- Created: <span>{formattedCreated}</span>
91
- </p>
92
- <p>
93
- Updated: <span>{formattedUpdated}</span>
94
- </p>
95
- </>
96
- </>
97
- )}
77
+ {!schema.displayProperties.disableDefaultAdminInfo && formattedCreated && (
78
+ <>
79
+ <p>
80
+ Created: <span>{formattedCreated}</span>
81
+ </p>
82
+ <p>
83
+ Updated: <span>{formattedUpdated}</span>
84
+ </p>
85
+ </>
86
+ )}
98
87
 
99
88
  <CustomSidebarInfoContainer
100
89
  id={itemId}
@@ -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,35 +159,33 @@ 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
- <PageHeader.Actions>
183
- <More>
184
- <More.Avatar isMoreMenu>
185
- <span className="material-icons">more_vert</span>
186
- </More.Avatar>
187
- <More.Content isMoreMenu />
188
- </More>
189
- </PageHeader.Actions>
190
- </Fragment>
191
- )}
171
+ {createAction.active && !showAddButton && (
172
+ <>
173
+ <Link
174
+ data-testid="addEntity"
175
+ className="button button--small"
176
+ to={`${match.url}/create`}>
177
+ Add
178
+ </Link>
179
+ <PageHeader.Actions>
180
+ <More>
181
+ <More.Avatar isMoreMenu>
182
+ <span className="material-icons">more_vert</span>
183
+ </More.Avatar>
184
+ <More.Content isMoreMenu />
185
+ </More>
186
+ </PageHeader.Actions>
187
+ </>
188
+ )}
192
189
  </PageHeader>
193
190
  {showAddButton ? (
194
191
  <CardPrompt>
@@ -20,23 +20,21 @@ const ListingTableContent = ({
20
20
  return (
21
21
  <>
22
22
  {displayTable ? (
23
- <>
24
- <div className={className}>
25
- <Table
26
- onSort={onSort}
27
- data={tableData}
28
- checkboxes={!isEnquiry}
29
- onSelect={handleSelect}
30
- data-testid="listing-table-content"
31
- />
32
- <Pagination
33
- visiblePages={10}
34
- totalItems={totalItems}
35
- currentPage={currentPage}
36
- onPageChange={handleOnPageChange}
37
- />
38
- </div>
39
- </>
23
+ <div className={className}>
24
+ <Table
25
+ onSort={onSort}
26
+ data={tableData}
27
+ checkboxes={!isEnquiry}
28
+ onSelect={handleSelect}
29
+ data-testid="listing-table-content"
30
+ />
31
+ <Pagination
32
+ visiblePages={10}
33
+ totalItems={totalItems}
34
+ currentPage={currentPage}
35
+ onPageChange={handleOnPageChange}
36
+ />
37
+ </div>
40
38
  ) : (
41
39
  <span className="table-no-results" data-testid="no-results">
42
40
  No results
@@ -34,9 +34,8 @@ function buildVariables({ entitySchema, isSearchQuery, listFilters = [], queryPa
34
34
  }
35
35
 
36
36
  const fetchData = async ({ client, querySettings: { entitySchema, queryParams }, listFilters }) => {
37
- const {
38
- displayProperties: { adminListings: { dataSource: { source } = {} } = {} } = {}
39
- } = entitySchema;
37
+ const { displayProperties: { adminListings: { dataSource: { source } = {} } = {} } = {} } =
38
+ entitySchema;
40
39
 
41
40
  const isSearchQuery = source === 'search';
42
41
  const query = buildListingQuery(entitySchema, isSearchQuery);
package/src/index.js CHANGED
@@ -5,11 +5,11 @@ import { DATA_LISTING_PREFIX, PLUGIN_NAME } from './constants';
5
5
  import getAddContentMenuItems from './utils/add-content-menu-items';
6
6
  import { UserIcon, TaxonomyIcon, ContentIcon, SettingsIcon } from './icons';
7
7
 
8
- const EntityDataListing = React.lazy(() =>
9
- import(/* webpackChunkName: 'EntityDataListing' */ './components/EntityDataListing')
8
+ const EntityDataListing = React.lazy(
9
+ () => import(/* webpackChunkName: 'EntityDataListing' */ './components/EntityDataListing')
10
10
  );
11
- const EntityManager = React.lazy(() =>
12
- import(/* webpackChunkName: 'EntityManager' */ './components/EntityManager')
11
+ const EntityManager = React.lazy(
12
+ () => import(/* webpackChunkName: 'EntityManager' */ './components/EntityManager')
13
13
  );
14
14
 
15
15
  export default async function load(app) {