@blaze-cms/plugin-data-ui 0.146.0-rc-eagle-3.9 → 0.146.0-rc-eagle-3.11

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 (36) hide show
  1. package/lib/components/EntityManager/Entity/Entity.js +26 -1
  2. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  3. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js +14 -1
  4. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  5. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +16 -2
  6. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  7. package/lib/components/EntityManager/utils/entity.js +22 -1
  8. package/lib/components/EntityManager/utils/entity.js.map +1 -1
  9. package/lib/components/ListingTable/ListingTable.js +1 -1
  10. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  11. package/lib/constants.js +3 -1
  12. package/lib/constants.js.map +1 -1
  13. package/lib/utils/add-content-menu-items.js +25 -22
  14. package/lib/utils/add-content-menu-items.js.map +1 -1
  15. package/lib-es/components/EntityManager/Entity/Entity.js +29 -4
  16. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  17. package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js +14 -1
  18. package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  19. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +16 -2
  20. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  21. package/lib-es/components/EntityManager/utils/entity.js +23 -3
  22. package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
  23. package/lib-es/components/ListingTable/ListingTable.js +1 -1
  24. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  25. package/lib-es/constants.js +3 -1
  26. package/lib-es/constants.js.map +1 -1
  27. package/lib-es/utils/add-content-menu-items.js +25 -22
  28. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  29. package/package.json +5 -5
  30. package/src/components/EntityManager/Entity/Entity.js +31 -5
  31. package/src/components/EntityManager/Entity/EntityHeader/EntityHeader.js +17 -1
  32. package/src/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +19 -2
  33. package/src/components/EntityManager/utils/entity.js +28 -8
  34. package/src/components/ListingTable/ListingTable.js +1 -1
  35. package/src/constants.js +4 -0
  36. package/src/utils/add-content-menu-items.js +21 -20
@@ -2,6 +2,13 @@ import { getQuery } from '@blaze-cms/admin-ui-utils';
2
2
 
3
3
  const { MENU_PERMISSIONS } = require('../constants');
4
4
 
5
+ // Menu items label a listing of many records, so they use the plural. The
6
+ // fallback matters: this package and the API are published independently, so an
7
+ // admin bundle can run against an API that does not yet resolve the field.
8
+ function getMenuLabel({ displayName, displayNamePlural }) {
9
+ return displayNamePlural || displayName || '';
10
+ }
11
+
5
12
  function getAddContentMenuItems(app) {
6
13
  return async ({ addConfig }) => {
7
14
  const client = app.getClient();
@@ -17,30 +24,31 @@ function getAddContentMenuItems(app) {
17
24
 
18
25
  if (!getEntitySchemas || !getEntitySchemas.length) return; // no items so don't add section
19
26
 
20
- const menuItems = {};
21
27
  const sectionMenuItems = { settings: {} };
22
28
 
23
- getEntitySchemas.forEach(({ id, displayName, displayProperties }) => {
24
- if (!displayProperties) return null;
29
+ // Order by the label that is rendered, not by displayName. getEntitySchemas
30
+ // is sorted on displayName server-side and that order serves every other
31
+ // consumer, which shows the singular, so the plural ordering belongs here.
32
+ // The explicit `order` is what MenuSectionItems reads to sort.
33
+ const orderedEntities = [...getEntitySchemas].sort((entityA, entityB) =>
34
+ getMenuLabel(entityA).localeCompare(getMenuLabel(entityB))
35
+ );
36
+
37
+ orderedEntities.forEach((entity, order) => {
38
+ const { id, displayProperties } = entity;
39
+ if (!displayProperties) return;
25
40
 
26
41
  const { adminMenu: { sectionKey = 'settings' } = {} } = displayProperties;
27
42
  const sectionItems = sectionMenuItems[sectionKey] || {};
28
43
  sectionItems[id] = {
29
- label: displayName,
44
+ label: getMenuLabel(entity),
45
+ order,
30
46
  uri: `/data-listing/${id}`
31
47
  };
32
48
  sectionMenuItems[sectionKey] = sectionItems;
33
49
  });
34
50
 
35
- const menuConfig = {
36
- main: {
37
- items: {
38
- settings: {
39
- items: menuItems
40
- }
41
- }
42
- }
43
- };
51
+ const menuConfig = { main: { items: {} } };
44
52
 
45
53
  Object.entries(sectionMenuItems).forEach(([sectionKey, sectionItems]) => {
46
54
  const sectionConfig = menuConfig.main.items[sectionKey] || {};
@@ -48,13 +56,6 @@ function getAddContentMenuItems(app) {
48
56
  menuConfig.main.items[sectionKey] = sectionConfig;
49
57
  });
50
58
 
51
- getEntitySchemas.forEach(({ id, displayName }) => {
52
- menuItems[id] = {
53
- label: displayName,
54
- uri: `/data-listing/${id}`
55
- };
56
- });
57
-
58
59
  addConfig(menuConfig);
59
60
  };
60
61
  }