Skip to content

Commit

Permalink
feat(normalizeMenu): add uuid
Browse files Browse the repository at this point in the history
  • Loading branch information
SailorF committed May 21, 2024
1 parent 8aee98b commit 75dc2dc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/brick-utils/src/builder/normalizeMenu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,24 @@ describe("normalizeMenu", () => {
instanceId: "",
attributeId: "",
},
uuid: "a",
items: [
{
if: null,
_object_id: "MENU_ITEM",
text: "Menu Item 1",
uuid: "a-1",
},
{
if: "<% null %>",
_object_id: "MENU_ITEM",
text: "Menu Item 2",
uuid: "a-2",
children: [
{
text: "Menu Item 2-1",
children: [{ text: "Menu Item 2-1-1" }],
children: [{ text: "Menu Item 2-1-1", uuid: "a-2-1-1" }],
uuid: "a-2-1",
},
],
},
Expand All @@ -37,24 +41,30 @@ describe("normalizeMenu", () => {
itemsResolve: {
useProvider: "my.menu-provider",
},
uuid: "b",
},
];
expect(menus.map(normalizeMenu)).toEqual([
{
menuId: "menu-a",
uuid: "a",
items: [
{
text: "Menu Item 1",
uuid: "a-1",
},
{
if: "<% null %>",
text: "Menu Item 2",
uuid: "a-2",
children: [
{
text: "Menu Item 2-1",
uuid: "a-2-1",
children: [
{
text: "Menu Item 2-1-1",
uuid: "a-2-1-1",
},
],
},
Expand All @@ -68,6 +78,7 @@ describe("normalizeMenu", () => {
itemsResolve: {
useProvider: "my.menu-provider",
},
uuid: "b",
},
]);
});
Expand Down
2 changes: 2 additions & 0 deletions packages/brick-utils/src/builder/normalizeMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const fieldsToKeepInMenu = [
"injectMenuGroupId",
"dynamicItems",
"itemsResolve",
"uuid",
];

const fieldsToKeepInMenuItem = [
Expand All @@ -31,6 +32,7 @@ const fieldsToKeepInMenuItem = [
"if",
"groupId",
"childLayout",
"uuid",
];

export interface MenuNode {
Expand Down

0 comments on commit 75dc2dc

Please sign in to comment.