@red-hat-developer-hub/backstage-plugin-global-header 0.0.4 → 0.1.0

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 (71) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/app-config.dynamic.yaml +4 -13
  3. package/dist/components/Divider/Divider.esm.js +16 -0
  4. package/dist/components/Divider/Divider.esm.js.map +1 -0
  5. package/dist/components/GlobalHeader.esm.js +5 -90
  6. package/dist/components/GlobalHeader.esm.js.map +1 -1
  7. package/dist/components/GlobalHeaderComponent.esm.js +25 -0
  8. package/dist/components/GlobalHeaderComponent.esm.js.map +1 -0
  9. package/dist/components/HeaderButton/HeaderButton.esm.js +41 -0
  10. package/dist/components/HeaderButton/HeaderButton.esm.js.map +1 -0
  11. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js +20 -53
  12. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js.map +1 -1
  13. package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js +13 -10
  14. package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js.map +1 -1
  15. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js +3 -3
  16. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
  17. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +34 -22
  18. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
  19. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +4 -3
  20. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -1
  21. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +50 -3
  22. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -1
  23. package/dist/components/{HeaderIconButtonComponent → HeaderIcon}/HeaderIcon.esm.js +10 -5
  24. package/dist/components/HeaderIcon/HeaderIcon.esm.js.map +1 -0
  25. package/dist/components/HeaderIconButton/HeaderIconButton.esm.js +37 -0
  26. package/dist/components/HeaderIconButton/HeaderIconButton.esm.js.map +1 -0
  27. package/dist/components/{HeaderButtonComponent → LogoutButton}/LogoutButton.esm.js +10 -2
  28. package/dist/components/LogoutButton/LogoutButton.esm.js.map +1 -0
  29. package/dist/components/{HeaderLinkComponent/HeaderLink.esm.js → MenuItemLink/MenuItemLink.esm.js} +6 -6
  30. package/dist/components/MenuItemLink/MenuItemLink.esm.js.map +1 -0
  31. package/dist/components/MenuItemLink/MenuItemLinkContent.esm.js +40 -0
  32. package/dist/components/MenuItemLink/MenuItemLinkContent.esm.js.map +1 -0
  33. package/dist/components/NotificationButton/NotificationButton.esm.js +36 -0
  34. package/dist/components/NotificationButton/NotificationButton.esm.js.map +1 -0
  35. package/dist/components/SearchComponent/SearchBar.esm.js +37 -7
  36. package/dist/components/SearchComponent/SearchBar.esm.js.map +1 -1
  37. package/dist/components/SearchComponent/SearchOption.esm.js +1 -1
  38. package/dist/components/SearchComponent/SearchOption.esm.js.map +1 -1
  39. package/dist/components/SearchComponent/SearchResultItem.esm.js +13 -1
  40. package/dist/components/SearchComponent/SearchResultItem.esm.js.map +1 -1
  41. package/dist/components/Spacer/Spacer.esm.js +16 -0
  42. package/dist/components/Spacer/Spacer.esm.js.map +1 -0
  43. package/dist/components/SupportButton/SupportButton.esm.js +36 -0
  44. package/dist/components/SupportButton/SupportButton.esm.js.map +1 -0
  45. package/dist/defaultMountPoints/defaultMountPoints.esm.js +93 -0
  46. package/dist/defaultMountPoints/defaultMountPoints.esm.js.map +1 -0
  47. package/dist/hooks/useCreateDropdownMountPoints.esm.js +4 -0
  48. package/dist/hooks/useCreateDropdownMountPoints.esm.js.map +1 -1
  49. package/dist/hooks/useDropdownManager.esm.js +7 -6
  50. package/dist/hooks/useDropdownManager.esm.js.map +1 -1
  51. package/dist/hooks/useNotificationCount.esm.js +54 -0
  52. package/dist/hooks/useNotificationCount.esm.js.map +1 -0
  53. package/dist/hooks/useProfileDropdownMountPoints.esm.js +4 -0
  54. package/dist/hooks/useProfileDropdownMountPoints.esm.js.map +1 -1
  55. package/dist/index.d.ts +190 -41
  56. package/dist/index.esm.js +2 -1
  57. package/dist/index.esm.js.map +1 -1
  58. package/dist/plugin.esm.js +81 -14
  59. package/dist/plugin.esm.js.map +1 -1
  60. package/dist/types.esm.js +3 -6
  61. package/dist/types.esm.js.map +1 -1
  62. package/package.json +6 -1
  63. package/dist/components/HeaderButtonComponent/HeaderButton.esm.js +0 -17
  64. package/dist/components/HeaderButtonComponent/HeaderButton.esm.js.map +0 -1
  65. package/dist/components/HeaderButtonComponent/LogoutButton.esm.js.map +0 -1
  66. package/dist/components/HeaderIconButtonComponent/HeaderIcon.esm.js.map +0 -1
  67. package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js +0 -25
  68. package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js.map +0 -1
  69. package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js +0 -19
  70. package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js.map +0 -1
  71. package/dist/components/HeaderLinkComponent/HeaderLink.esm.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,26 @@
1
1
  # @red-hat-developer-hub/backstage-plugin-global-header
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f35b797: First version of Global Header plugin with the following components:
8
+
9
+ - GlobalHeaderComponent
10
+ - SearchComponent
11
+ - CreateDropdown
12
+ - SoftwareTemplatesSection
13
+ - RegisterAComponentSection
14
+ - ProfileDropdown
15
+ - LogoutButton
16
+ - HeaderButton
17
+ - HeaderIcon
18
+ - HeaderIconButton
19
+ - MenuItemLink
20
+ - Spacer
21
+ - Divider
22
+ - NotificationBanner
23
+
3
24
  ## 0.0.4
4
25
 
5
26
  ### Patch Changes
@@ -6,20 +6,16 @@ dynamicPlugins:
6
6
  - mountPoint: application/header
7
7
  importName: GlobalHeader
8
8
  config:
9
- layout:
10
- position: above-main-content # above-main-content | below-main-content
9
+ position: above-main-content # above-main-content | below-main-content
11
10
  - mountPoint: global.header/component
12
11
  importName: SearchComponent
13
12
  config:
14
13
  type: search
15
- slot: header-start
16
14
  priority: 100
17
15
  - mountPoint: global.header/component
18
16
  importName: CreateDropdown
19
17
  config:
20
18
  type: dropdown_button
21
- key: create
22
- slot: header-start
23
19
  priority: 90
24
20
  - mountPoint: global.header/create
25
21
  importName: SoftwareTemplatesSection
@@ -34,7 +30,6 @@ dynamicPlugins:
34
30
  importName: HeaderIconButton
35
31
  config:
36
32
  type: icon_button
37
- slot: header-start
38
33
  priority: 80
39
34
  props:
40
35
  icon: support
@@ -43,7 +38,6 @@ dynamicPlugins:
43
38
  importName: HeaderIconButton
44
39
  config:
45
40
  type: icon_button
46
- slot: header-start
47
41
  priority: 70
48
42
  props:
49
43
  icon: notifications
@@ -52,14 +46,12 @@ dynamicPlugins:
52
46
  importName: ProfileDropdown
53
47
  config:
54
48
  type: dropdown_button
55
- key: profile
56
- slot: header-end
57
49
  priority: 0
58
50
  - mountPoint: global.header/profile
59
- importName: HeaderLink
51
+ importName: MenuItemLink
60
52
  config:
61
53
  type: link
62
- priority: 10
54
+ priority: 200
63
55
  props:
64
56
  title: Settings
65
57
  link: /settings
@@ -67,5 +59,4 @@ dynamicPlugins:
67
59
  - mountPoint: global.header/profile
68
60
  importName: LogoutButton
69
61
  config:
70
- type: logout
71
- priority: 0
62
+ priority: 100
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import Divider$1 from '@mui/material/Divider';
3
+
4
+ const Divider = () => {
5
+ return /* @__PURE__ */ React.createElement(
6
+ Divider$1,
7
+ {
8
+ orientation: "vertical",
9
+ flexItem: true,
10
+ sx: { borderColor: "#383838", marginX: 1 }
11
+ }
12
+ );
13
+ };
14
+
15
+ export { Divider };
16
+ //# sourceMappingURL=Divider.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Divider.esm.js","sources":["../../../src/components/Divider/Divider.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nimport MUIDivider from '@mui/material/Divider';\n\n/**\n * @public\n */\nexport const Divider = () => {\n return (\n <MUIDivider\n orientation=\"vertical\"\n flexItem\n sx={{ borderColor: '#383838', marginX: 1 }}\n />\n );\n};\n"],"names":["MUIDivider"],"mappings":";;;AAuBO,MAAM,UAAU,MAAM;AAC3B,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAACA,SAAA;AAAA,IAAA;AAAA,MACC,WAAY,EAAA,UAAA;AAAA,MACZ,QAAQ,EAAA,IAAA;AAAA,MACR,EAAI,EAAA,EAAE,WAAa,EAAA,SAAA,EAAW,SAAS,CAAE;AAAA;AAAA,GAC3C;AAEJ;;;;"}
@@ -1,99 +1,14 @@
1
- import React, { useMemo } from 'react';
2
- import AppBar from '@mui/material/AppBar';
3
- import Toolbar from '@mui/material/Toolbar';
4
- import Divider from '@mui/material/Divider';
5
- import { useDropdownManager } from '../hooks/useDropdownManager.esm.js';
1
+ import React from 'react';
6
2
  import { useGlobalHeaderMountPoints } from '../hooks/useGlobalHeaderMountPoints.esm.js';
7
- import { Slot, ComponentType } from '../types.esm.js';
8
- import { ErrorBoundary } from '@backstage/core-components';
9
- import { useApi, configApiRef } from '@backstage/core-plugin-api';
3
+ import { GlobalHeaderComponent } from './GlobalHeaderComponent.esm.js';
10
4
 
11
5
  const GlobalHeader = () => {
12
- const config = useApi(configApiRef);
13
- const frontendConfig = config.getOptionalConfig("dynamicPlugins.frontend");
14
- const frontendData = frontendConfig?.get();
15
6
  const allGlobalHeaderMountPoints = useGlobalHeaderMountPoints();
16
- const filteredAndSortedGlobalHeaderComponents = useMemo(() => {
17
- if (!allGlobalHeaderMountPoints) {
18
- return [];
19
- }
20
- const filteredAndSorted = allGlobalHeaderMountPoints.filter(
21
- (component) => (component.config?.priority ?? 0) > -1
22
- );
23
- filteredAndSorted.sort(
24
- (a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0)
25
- );
26
- return filteredAndSorted;
27
- }, [allGlobalHeaderMountPoints]);
28
- const globalHeaderStartComponentsMountPoints = filteredAndSortedGlobalHeaderComponents.filter(
29
- (component) => component.config?.slot === Slot.HEADER_START
30
- );
31
- const globalHeaderEndComponentsMountPoints = filteredAndSortedGlobalHeaderComponents.filter(
32
- (component) => component.config?.slot === Slot.HEADER_END
33
- );
34
- const { menuStates, handleOpen, handleClose } = useDropdownManager();
35
- const getDropdownButtonProps = (key) => ({
36
- handleMenu: handleOpen(key),
37
- anchorEl: menuStates[key],
38
- setAnchorEl: handleClose(key)
39
- });
40
- const getIconButtonProps = (props) => ({
41
- icon: props.icon ?? "",
42
- tooltip: props.tooltip ?? "",
43
- to: props.to ?? ""
44
- });
45
- const renderComponents = (mountPoints) => mountPoints.map((mp, index) => {
46
- let displayHeaderIcon = false;
47
- if (frontendData) {
48
- for (const pluginData of Object.values(frontendData)) {
49
- const dynamicRoutes = pluginData.dynamicRoutes ?? [];
50
- if (dynamicRoutes.some(
51
- (route) => route.path === mp.config?.props?.to
52
- )) {
53
- displayHeaderIcon = true;
54
- break;
55
- }
56
- }
57
- }
58
- switch (mp.config?.type) {
59
- case ComponentType.SEARCH:
60
- return /* @__PURE__ */ React.createElement(ErrorBoundary, null, /* @__PURE__ */ React.createElement(mp.Component, { key: index }));
61
- case ComponentType.DROPDOWN_BUTTON:
62
- return /* @__PURE__ */ React.createElement(ErrorBoundary, null, /* @__PURE__ */ React.createElement(
63
- mp.Component,
64
- {
65
- key: index,
66
- ...getDropdownButtonProps(mp.config?.key ?? index.toString()),
67
- ...mp.config?.props
68
- }
69
- ));
70
- case ComponentType.ICON_BUTTON:
71
- return /* @__PURE__ */ React.createElement(ErrorBoundary, null, displayHeaderIcon && /* @__PURE__ */ React.createElement(
72
- mp.Component,
73
- {
74
- key: index,
75
- ...getIconButtonProps(mp.config?.props ?? {})
76
- }
77
- ));
78
- default:
79
- return null;
80
- }
81
- });
82
7
  return /* @__PURE__ */ React.createElement(
83
- AppBar,
8
+ GlobalHeaderComponent,
84
9
  {
85
- position: "sticky",
86
- component: "nav",
87
- sx: { backgroundColor: "#212427" }
88
- },
89
- /* @__PURE__ */ React.createElement(Toolbar, null, renderComponents(globalHeaderStartComponentsMountPoints), globalHeaderStartComponentsMountPoints.length > 0 && globalHeaderEndComponentsMountPoints.length > 0 && /* @__PURE__ */ React.createElement(
90
- Divider,
91
- {
92
- orientation: "vertical",
93
- flexItem: true,
94
- sx: { borderColor: "#4F5255", marginX: 1 }
95
- }
96
- ), renderComponents(globalHeaderEndComponentsMountPoints))
10
+ globalHeaderMountPoints: allGlobalHeaderMountPoints ?? []
11
+ }
97
12
  );
98
13
  };
99
14
 
@@ -1 +1 @@
1
- {"version":3,"file":"GlobalHeader.esm.js","sources":["../../src/components/GlobalHeader.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\nimport AppBar from '@mui/material/AppBar';\nimport Toolbar from '@mui/material/Toolbar';\nimport Divider from '@mui/material/Divider';\nimport { useDropdownManager } from '../hooks';\nimport { useGlobalHeaderMountPoints } from '../hooks/useGlobalHeaderMountPoints';\nimport { ComponentType, GlobalHeaderComponentMountPoint, Slot } from '../types';\nimport { ErrorBoundary } from '@backstage/core-components';\nimport { configApiRef, useApi } from '@backstage/core-plugin-api';\n\nexport const GlobalHeader = () => {\n const config = useApi(configApiRef);\n const frontendConfig = config.getOptionalConfig('dynamicPlugins.frontend');\n const frontendData = frontendConfig?.get();\n\n const allGlobalHeaderMountPoints = useGlobalHeaderMountPoints();\n\n const filteredAndSortedGlobalHeaderComponents = useMemo(() => {\n if (!allGlobalHeaderMountPoints) {\n return [];\n }\n\n const filteredAndSorted = allGlobalHeaderMountPoints.filter(\n component => (component.config?.priority ?? 0) > -1,\n );\n\n filteredAndSorted.sort(\n (a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0),\n );\n\n return filteredAndSorted;\n }, [allGlobalHeaderMountPoints]);\n\n const globalHeaderStartComponentsMountPoints =\n filteredAndSortedGlobalHeaderComponents.filter(\n component => component.config?.slot === Slot.HEADER_START,\n );\n\n const globalHeaderEndComponentsMountPoints =\n filteredAndSortedGlobalHeaderComponents.filter(\n component => component.config?.slot === Slot.HEADER_END,\n );\n\n const { menuStates, handleOpen, handleClose } = useDropdownManager();\n\n const getDropdownButtonProps = (key: string) => ({\n handleMenu: handleOpen(key),\n anchorEl: menuStates[key],\n setAnchorEl: handleClose(key),\n });\n\n const getIconButtonProps = (props: Record<string, any>) => ({\n icon: props.icon ?? '',\n tooltip: props.tooltip ?? '',\n to: props.to ?? '',\n });\n const renderComponents = (mountPoints: GlobalHeaderComponentMountPoint[]) =>\n mountPoints.map((mp, index) => {\n let displayHeaderIcon = false;\n if (frontendData) {\n for (const pluginData of Object.values(frontendData)) {\n const dynamicRoutes = pluginData.dynamicRoutes ?? [];\n if (\n dynamicRoutes.some(\n (route: { path: string }) => route.path === mp.config?.props?.to,\n )\n ) {\n displayHeaderIcon = true;\n break;\n }\n }\n }\n\n switch (mp.config?.type) {\n case ComponentType.SEARCH:\n return (\n <ErrorBoundary>\n {/* eslint-disable-next-line react/no-array-index-key */}\n <mp.Component key={index} />\n </ErrorBoundary>\n );\n case ComponentType.DROPDOWN_BUTTON:\n return (\n <ErrorBoundary>\n <mp.Component\n // eslint-disable-next-line react/no-array-index-key\n key={index}\n {...getDropdownButtonProps(mp.config?.key ?? index.toString())}\n {...mp.config?.props}\n />\n </ErrorBoundary>\n );\n case ComponentType.ICON_BUTTON:\n return (\n <ErrorBoundary>\n {displayHeaderIcon && (\n <mp.Component\n // eslint-disable-next-line react/no-array-index-key\n key={index}\n {...getIconButtonProps(mp.config?.props ?? {})}\n />\n )}\n </ErrorBoundary>\n );\n default:\n return null;\n }\n });\n\n return (\n <AppBar\n position=\"sticky\"\n component=\"nav\"\n sx={{ backgroundColor: '#212427' }}\n >\n <Toolbar>\n {renderComponents(globalHeaderStartComponentsMountPoints)}\n {globalHeaderStartComponentsMountPoints.length > 0 &&\n globalHeaderEndComponentsMountPoints.length > 0 && (\n <Divider\n orientation=\"vertical\"\n flexItem\n sx={{ borderColor: '#4F5255', marginX: 1 }}\n />\n )}\n {renderComponents(globalHeaderEndComponentsMountPoints)}\n </Toolbar>\n </AppBar>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA0BO,MAAM,eAAe,MAAM;AAChC,EAAM,MAAA,MAAA,GAAS,OAAO,YAAY,CAAA;AAClC,EAAM,MAAA,cAAA,GAAiB,MAAO,CAAA,iBAAA,CAAkB,yBAAyB,CAAA;AACzE,EAAM,MAAA,YAAA,GAAe,gBAAgB,GAAI,EAAA;AAEzC,EAAA,MAAM,6BAA6B,0BAA2B,EAAA;AAE9D,EAAM,MAAA,uCAAA,GAA0C,QAAQ,MAAM;AAC5D,IAAA,IAAI,CAAC,0BAA4B,EAAA;AAC/B,MAAA,OAAO,EAAC;AAAA;AAGV,IAAA,MAAM,oBAAoB,0BAA2B,CAAA,MAAA;AAAA,MACnD,CAAc,SAAA,KAAA,CAAA,SAAA,CAAU,MAAQ,EAAA,QAAA,IAAY,CAAK,IAAA,CAAA;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C,QAAS,EAAA,QAAA;AAAA,MACT,SAAU,EAAA,KAAA;AAAA,MACV,EAAA,EAAI,EAAE,eAAA,EAAiB,SAAU;AAAA,KAAA;AAAA,oBAEjC,KAAA,CAAA,aAAA,CAAC,OACE,EAAA,IAAA,EAAA,gBAAA,CAAiB,sCAAsC,CAAA,EACvD,uCAAuC,MAAS,GAAA,CAAA,IAC/C,oCAAqC,CAAA,MAAA,GAAS,CAC5C,oBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,WAAY,EAAA,UAAA;AAAA,QACZ,QAAQ,EAAA,IAAA;AAAA,QACR,EAAI,EAAA,EAAE,WAAa,EAAA,SAAA,EAAW,SAAS,CAAE;AAAA;AAAA,KAC3C,EAEH,gBAAiB,CAAA,oCAAoC,CACxD;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"GlobalHeader.esm.js","sources":["../../src/components/GlobalHeader.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport { useGlobalHeaderMountPoints } from '../hooks/useGlobalHeaderMountPoints';\nimport { GlobalHeaderComponent } from './GlobalHeaderComponent';\n\nexport const GlobalHeader = () => {\n const allGlobalHeaderMountPoints = useGlobalHeaderMountPoints();\n\n return (\n <GlobalHeaderComponent\n globalHeaderMountPoints={allGlobalHeaderMountPoints ?? []}\n />\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,eAAe,MAAM;AAChC,EAAA,MAAM,6BAA6B,0BAA2B,EAAA;AAE9D,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,uBAAA,EAAyB,8BAA8B;AAAC;AAAA,GAC1D;AAEJ;;;;"}
@@ -0,0 +1,25 @@
1
+ import React, { useMemo } from 'react';
2
+ import { ErrorBoundary } from '@backstage/core-components';
3
+ import AppBar from '@mui/material/AppBar';
4
+ import Toolbar from '@mui/material/Toolbar';
5
+
6
+ const GlobalHeaderComponent = ({
7
+ globalHeaderMountPoints
8
+ }) => {
9
+ const mountPoints = useMemo(() => {
10
+ if (!globalHeaderMountPoints) {
11
+ return [];
12
+ }
13
+ const filteredAndSorted = globalHeaderMountPoints.filter((component) => (component.config?.priority ?? 0) > -1).sort((a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0));
14
+ return filteredAndSorted;
15
+ }, [globalHeaderMountPoints]);
16
+ return /* @__PURE__ */ React.createElement(AppBar, { position: "sticky", component: "nav", id: "global-header" }, /* @__PURE__ */ React.createElement(Toolbar, { sx: { gap: 1 } }, mountPoints.map((mountPoint, index) => /* @__PURE__ */ React.createElement(ErrorBoundary, { key: `header-component-${index}` }, /* @__PURE__ */ React.createElement(
17
+ mountPoint.Component,
18
+ {
19
+ ...mountPoint.config?.props
20
+ }
21
+ )))));
22
+ };
23
+
24
+ export { GlobalHeaderComponent };
25
+ //# sourceMappingURL=GlobalHeaderComponent.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GlobalHeaderComponent.esm.js","sources":["../../src/components/GlobalHeaderComponent.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\n\nimport { ErrorBoundary } from '@backstage/core-components';\n\nimport AppBar from '@mui/material/AppBar';\nimport Toolbar from '@mui/material/Toolbar';\n\nimport { GlobalHeaderComponentMountPoint } from '../types';\n\n/**\n * @public\n * Global Header Component properties\n */\nexport interface GlobalHeaderComponentProps {\n globalHeaderMountPoints: GlobalHeaderComponentMountPoint[];\n}\n\nexport const GlobalHeaderComponent = ({\n globalHeaderMountPoints,\n}: GlobalHeaderComponentProps) => {\n const mountPoints = useMemo(() => {\n if (!globalHeaderMountPoints) {\n return [];\n }\n\n const filteredAndSorted = globalHeaderMountPoints\n .filter(component => (component.config?.priority ?? 0) > -1)\n .sort((a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0));\n\n return filteredAndSorted;\n }, [globalHeaderMountPoints]);\n\n return (\n <AppBar position=\"sticky\" component=\"nav\" id=\"global-header\">\n <Toolbar sx={{ gap: 1 }}>\n {mountPoints.map((mountPoint, index) => (\n <ErrorBoundary key={`header-component-${index}`}>\n <mountPoint.Component\n {...mountPoint.config?.props}\n // sx={mountPoint.config.layout}\n />\n </ErrorBoundary>\n ))}\n </Toolbar>\n </AppBar>\n );\n};\n"],"names":[],"mappings":";;;;;AAiCO,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,CAAkC,KAAA;AAChC,EAAM,MAAA,WAAA,GAAc,QAAQ,MAAM;AAChC,IAAA,IAAI,CAAC,uBAAyB,EAAA;AAC5B,MAAA,OAAO,EAAC;AAAA;AAGV,IAAM,MAAA,iBAAA,GAAoB,wBACvB,MAAO,CAAA,CAAA,SAAA,KAAA,CAAc,UAAU,MAAQ,EAAA,QAAA,IAAY,KAAK,CAAE,CAAA,CAAA,CAC1D,KAAK,CAAC,CAAA,EAAG,OAAO,CAAE,CAAA,MAAA,EAAQ,YAAY,CAAM,KAAA,CAAA,CAAE,MAAQ,EAAA,QAAA,IAAY,CAAE,CAAA,CAAA;AAEvE,IAAO,OAAA,iBAAA;AAAA,GACT,EAAG,CAAC,uBAAuB,CAAC,CAAA;AAE5B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,MAAO,EAAA,EAAA,QAAA,EAAS,QAAS,EAAA,SAAA,EAAU,OAAM,EAAG,EAAA,eAAA,EAAA,kBAC1C,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,EAAI,EAAA,EAAE,KAAK,CAAE,EAAA,EAAA,EACnB,WAAY,CAAA,GAAA,CAAI,CAAC,UAAA,EAAY,KAC5B,qBAAA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,GAAA,EAAK,CAAoB,iBAAA,EAAA,KAAK,CAC3C,CAAA,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAW,CAAA,SAAA;AAAA,IAAX;AAAA,MACE,GAAG,WAAW,MAAQ,EAAA;AAAA;AAAA,GAG3B,CACD,CACH,CACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { LinkButton } from '@backstage/core-components';
3
+ import Tooltip from '@mui/material/Tooltip';
4
+ import { HeaderIcon } from '../HeaderIcon/HeaderIcon.esm.js';
5
+
6
+ const HeaderButton = ({
7
+ title,
8
+ tooltip,
9
+ color = "inherit",
10
+ size = "small",
11
+ variant,
12
+ ariaLabel,
13
+ startIcon,
14
+ endIcon,
15
+ externalLinkIcon = true,
16
+ to,
17
+ style
18
+ }) => {
19
+ const button = /* @__PURE__ */ React.createElement(
20
+ LinkButton,
21
+ {
22
+ color,
23
+ size,
24
+ variant,
25
+ "aria-label": ariaLabel,
26
+ startIcon: startIcon ? /* @__PURE__ */ React.createElement(HeaderIcon, { icon: startIcon, size }) : null,
27
+ endIcon: endIcon ? /* @__PURE__ */ React.createElement(HeaderIcon, { icon: endIcon, size }) : null,
28
+ externalLinkIcon,
29
+ to,
30
+ style
31
+ },
32
+ title
33
+ );
34
+ if (tooltip) {
35
+ return /* @__PURE__ */ React.createElement(Tooltip, { title: tooltip }, /* @__PURE__ */ React.createElement("div", null, button));
36
+ }
37
+ return button;
38
+ };
39
+
40
+ export { HeaderButton };
41
+ //# sourceMappingURL=HeaderButton.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderButton.esm.js","sources":["../../../src/components/HeaderButton/HeaderButton.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nimport { LinkButton } from '@backstage/core-components';\n\nimport Tooltip from '@mui/material/Tooltip';\nimport { HeaderIcon } from '../HeaderIcon/HeaderIcon';\n\n/**\n * @public\n */\nexport interface HeaderButtonProps {\n title: string;\n tooltip?: string;\n color?: 'inherit' | 'primary' | 'secondary' | 'default';\n size?: 'small' | 'medium' | 'large';\n variant?: 'text' | 'outlined' | 'contained';\n ariaLabel?: string;\n startIcon?: string;\n endIcon?: string;\n externalLinkIcon?: boolean;\n to: string;\n style?: React.CSSProperties;\n}\n\n/**\n * @public\n */\nexport const HeaderButton = ({\n title,\n tooltip,\n color = 'inherit',\n size = 'small',\n variant,\n ariaLabel,\n startIcon,\n endIcon,\n externalLinkIcon = true,\n to,\n style,\n}: HeaderButtonProps) => {\n const button = (\n <LinkButton\n color={color}\n size={size}\n variant={variant}\n aria-label={ariaLabel}\n startIcon={startIcon ? <HeaderIcon icon={startIcon} size={size} /> : null}\n endIcon={endIcon ? <HeaderIcon icon={endIcon} size={size} /> : null}\n externalLinkIcon={externalLinkIcon}\n to={to}\n style={style}\n >\n {title}\n </LinkButton>\n );\n\n if (tooltip) {\n return (\n <Tooltip title={tooltip}>\n <div>{button}</div>\n </Tooltip>\n );\n }\n\n return button;\n};\n"],"names":[],"mappings":";;;;;AA2CO,MAAM,eAAe,CAAC;AAAA,EAC3B,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAQ,GAAA,SAAA;AAAA,EACR,IAAO,GAAA,OAAA;AAAA,EACP,OAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAmB,GAAA,IAAA;AAAA,EACnB,EAAA;AAAA,EACA;AACF,CAAyB,KAAA;AACvB,EAAA,MAAM,MACJ,mBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAA;AAAA,MACA,YAAY,EAAA,SAAA;AAAA,MACZ,WAAW,SAAY,mBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,IAAM,EAAA,SAAA,EAAW,MAAY,CAAK,GAAA,IAAA;AAAA,MACrE,SAAS,OAAU,mBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,IAAM,EAAA,OAAA,EAAS,MAAY,CAAK,GAAA,IAAA;AAAA,MAC/D,gBAAA;AAAA,MACA,EAAA;AAAA,MACA;AAAA,KAAA;AAAA,IAEC;AAAA,GACH;AAGF,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,2CACG,OAAQ,EAAA,EAAA,KAAA,EAAO,2BACb,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA,EAAK,MAAO,CACf,CAAA;AAAA;AAIJ,EAAO,OAAA,MAAA;AACT;;;;"}
@@ -1,48 +1,13 @@
1
- import React, { useState, useEffect, useMemo } from 'react';
2
- import { catalogApiRef } from '@backstage/plugin-catalog-react';
3
- import HeaderDropdownComponent from './HeaderDropdownComponent.esm.js';
1
+ import React, { useMemo } from 'react';
4
2
  import ArrowDropDownOutlinedIcon from '@mui/icons-material/ArrowDropDownOutlined';
5
- import { useApi } from '@backstage/core-plugin-api';
6
- import CircularProgress from '@mui/material/CircularProgress';
7
- import Box from '@mui/material/Box';
8
- import Typography from '@mui/material/Typography';
9
3
  import { ComponentType } from '../../types.esm.js';
10
- import { HeaderLink } from '../HeaderLinkComponent/HeaderLink.esm.js';
11
4
  import { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints.esm.js';
5
+ import { useDropdownManager } from '../../hooks/useDropdownManager.esm.js';
6
+ import { HeaderDropdownComponent } from './HeaderDropdownComponent.esm.js';
12
7
 
13
- const CreateDropdown = ({
14
- handleMenu,
15
- anchorEl,
16
- setAnchorEl
17
- }) => {
18
- const catalogApi = useApi(catalogApiRef);
19
- const [entities, setEntities] = useState([]);
20
- const [loading, setLoading] = useState(true);
21
- const [error, setError] = useState(null);
8
+ const CreateDropdown = () => {
9
+ const { anchorEl, handleOpen, handleClose } = useDropdownManager();
22
10
  const createDropdownMountPoints = useCreateDropdownMountPoints();
23
- useEffect(() => {
24
- const fetchEntities = async () => {
25
- try {
26
- const response = await catalogApi.getEntities({
27
- filter: { kind: ["Template"] }
28
- });
29
- setEntities(response.items);
30
- } catch (err) {
31
- setError(err);
32
- } finally {
33
- setLoading(false);
34
- }
35
- };
36
- fetchEntities();
37
- }, [catalogApi]);
38
- const items = useMemo(() => {
39
- return entities.filter((e) => e.kind === "Template").map((m) => ({
40
- Component: HeaderLink,
41
- type: ComponentType.LINK,
42
- label: m.metadata.title ?? m.metadata.name,
43
- link: `/create/templates/default/${m.metadata.name}`
44
- }));
45
- }, [entities]);
46
11
  const menuSections = useMemo(() => {
47
12
  return (createDropdownMountPoints ?? []).map((mp) => ({
48
13
  Component: mp.Component,
@@ -50,32 +15,34 @@ const CreateDropdown = ({
50
15
  priority: mp.config?.priority ?? 0
51
16
  })).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
52
17
  }, [createDropdownMountPoints]);
53
- if (loading) {
54
- return /* @__PURE__ */ React.createElement(Box, { display: "flex", justifyContent: "center", alignItems: "center", p: 2 }, /* @__PURE__ */ React.createElement(CircularProgress, null), /* @__PURE__ */ React.createElement(Typography, { variant: "body1", sx: { ml: 2 } }, "Loading templates..."));
55
- }
56
- if (error) {
57
- return /* @__PURE__ */ React.createElement(Box, { display: "flex", justifyContent: "center", alignItems: "center", p: 2 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body1", color: "error" }, "Error fetching templates: ", error));
18
+ if (menuSections.length === 0) {
19
+ return null;
58
20
  }
59
21
  return /* @__PURE__ */ React.createElement(
60
22
  HeaderDropdownComponent,
61
23
  {
62
24
  buttonContent: /* @__PURE__ */ React.createElement(React.Fragment, null, "Create ", /* @__PURE__ */ React.createElement(ArrowDropDownOutlinedIcon, { sx: { ml: 1 } })),
63
25
  buttonProps: {
64
- color: "primary",
65
- variant: "contained",
66
- sx: { mr: 2 }
26
+ variant: "outlined",
27
+ sx: {
28
+ color: "#fff",
29
+ border: "1px solid rgba(255, 255, 255, 0.5)",
30
+ "&:hover, &.Mui-focusVisible": {
31
+ border: "1px solid #fff"
32
+ },
33
+ mr: 1.5
34
+ }
67
35
  },
68
- buttonClick: handleMenu,
69
- anchorEl,
70
- setAnchorEl
36
+ onOpen: handleOpen,
37
+ onClose: handleClose,
38
+ anchorEl
71
39
  },
72
40
  menuSections.map((section, index) => /* @__PURE__ */ React.createElement(
73
41
  section.Component,
74
42
  {
75
43
  key: `menu-section-${index.toString()}`,
76
44
  hideDivider: index === menuSections.length - 1,
77
- handleClose: () => setAnchorEl(null),
78
- ...section.type === ComponentType.LIST ? { items } : {}
45
+ handleClose
79
46
  }
80
47
  ))
81
48
  );
@@ -1 +1 @@
1
- {"version":3,"file":"CreateDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/CreateDropdown.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useEffect, useMemo, useState } from 'react';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport HeaderDropdownComponent from './HeaderDropdownComponent';\nimport ArrowDropDownOutlinedIcon from '@mui/icons-material/ArrowDropDownOutlined';\nimport { MenuItemConfig } from './MenuSection';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { Entity } from '@backstage/catalog-model';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport { ComponentType } from '../../types';\nimport { HeaderLink } from '../HeaderLinkComponent/HeaderLink';\nimport { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints';\n\n/**\n * @public\n * Create button properties\n */\nexport interface CreateButtonProps {\n handleMenu: (event: React.MouseEvent<HTMLElement>) => void;\n anchorEl: HTMLElement | null;\n setAnchorEl: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n}\n\n/**\n * @public\n * Props for each dropdown section component\n */\ninterface SectionComponentProps {\n handleClose: () => void;\n hideDivider: boolean;\n items?: MenuItemConfig[];\n}\n\nexport const CreateDropdown = ({\n handleMenu,\n anchorEl,\n setAnchorEl,\n}: CreateButtonProps) => {\n const catalogApi = useApi(catalogApiRef);\n const [entities, setEntities] = useState<Entity[]>([]);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n const createDropdownMountPoints = useCreateDropdownMountPoints();\n\n useEffect(() => {\n const fetchEntities = async () => {\n try {\n const response = await catalogApi.getEntities({\n filter: { kind: ['Template'] },\n });\n setEntities(response.items);\n } catch (err) {\n setError(err);\n } finally {\n setLoading(false);\n }\n };\n\n fetchEntities();\n }, [catalogApi]);\n\n const items = useMemo(() => {\n return entities\n .filter(e => e.kind === 'Template')\n .map(m => ({\n Component: HeaderLink as React.ComponentType,\n type: ComponentType.LINK,\n label: m.metadata.title ?? m.metadata.name,\n link: `/create/templates/default/${m.metadata.name}`,\n }));\n }, [entities]);\n\n const menuSections = useMemo(() => {\n return (createDropdownMountPoints ?? [])\n .map(mp => ({\n Component: mp.Component as React.ComponentType<SectionComponentProps>,\n type: mp.config?.type ?? ComponentType.LINK,\n priority: mp.config?.priority ?? 0,\n }))\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }, [createDropdownMountPoints]);\n\n if (loading) {\n return (\n <Box display=\"flex\" justifyContent=\"center\" alignItems=\"center\" p={2}>\n <CircularProgress />\n <Typography variant=\"body1\" sx={{ ml: 2 }}>\n Loading templates...\n </Typography>\n </Box>\n );\n }\n\n if (error) {\n return (\n <Box display=\"flex\" justifyContent=\"center\" alignItems=\"center\" p={2}>\n <Typography variant=\"body1\" color=\"error\">\n Error fetching templates: {error}\n </Typography>\n </Box>\n );\n }\n\n return (\n <HeaderDropdownComponent\n buttonContent={\n <>\n Create <ArrowDropDownOutlinedIcon sx={{ ml: 1 }} />\n </>\n }\n buttonProps={{\n color: 'primary',\n variant: 'contained',\n sx: { mr: 2 },\n }}\n buttonClick={handleMenu}\n anchorEl={anchorEl}\n setAnchorEl={setAnchorEl}\n >\n {menuSections.map((section, index) => (\n <section.Component\n key={`menu-section-${index.toString()}`}\n hideDivider={index === menuSections.length - 1}\n handleClose={() => setAnchorEl(null)}\n {...(section.type === ComponentType.LIST ? { items } : {})}\n />\n ))}\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAkDO,MAAM,iBAAiB,CAAC;AAAA,EAC7B,UAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAyB,KAAA;AACvB,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA;AACvC,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAI,GAAA,QAAA,CAAmB,EAAE,CAAA;AACrD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,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,MAEF,WAAa,EAAA;AAAA,QACX,KAAO,EAAA,SAAA;AAAA,QACP,OAAS,EAAA,WAAA;AAAA,QACT,EAAA,EAAI,EAAE,EAAA,EAAI,CAAE;AAAA,OACd;AAAA,MACA,WAAa,EAAA,UAAA;AAAA,MACb,QAAA;AAAA,MACA;AAAA,KAAA;AAAA,IAEC,YAAa,CAAA,GAAA,CAAI,CAAC,OAAA,EAAS,KAC1B,qBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,OAAQ,CAAA,SAAA;AAAA,MAAR;AAAA,QACC,GAAK,EAAA,CAAA,aAAA,EAAgB,KAAM,CAAA,QAAA,EAAU,CAAA,CAAA;AAAA,QACrC,WAAA,EAAa,KAAU,KAAA,YAAA,CAAa,MAAS,GAAA,CAAA;AAAA,QAC7C,WAAA,EAAa,MAAM,WAAA,CAAY,IAAI,CAAA;AAAA,QAClC,GAAI,QAAQ,IAAS,KAAA,aAAA,CAAc,OAAO,EAAE,KAAA,KAAU;AAAC;AAAA,KAE3D;AAAA,GACH;AAEJ;;;;"}
1
+ {"version":3,"file":"CreateDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/CreateDropdown.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React, { useMemo } from 'react';\n\nimport ArrowDropDownOutlinedIcon from '@mui/icons-material/ArrowDropDownOutlined';\n\nimport { ComponentType } from '../../types';\nimport { MenuItemConfig } from './MenuSection';\nimport { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\n\n/**\n * @public\n * Props for each dropdown section component\n */\ninterface SectionComponentProps {\n handleClose: () => void;\n hideDivider: boolean;\n items?: MenuItemConfig[];\n}\n\nexport const CreateDropdown = () => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n\n const createDropdownMountPoints = useCreateDropdownMountPoints();\n\n const menuSections = useMemo(() => {\n return (createDropdownMountPoints ?? [])\n .map(mp => ({\n Component: mp.Component as React.ComponentType<SectionComponentProps>,\n type: mp.config?.type ?? ComponentType.LINK,\n priority: mp.config?.priority ?? 0,\n }))\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }, [createDropdownMountPoints]);\n\n if (menuSections.length === 0) {\n return null;\n }\n\n return (\n <HeaderDropdownComponent\n buttonContent={\n <>\n Create <ArrowDropDownOutlinedIcon sx={{ ml: 1 }} />\n </>\n }\n buttonProps={{\n variant: 'outlined',\n sx: {\n color: '#fff',\n border: '1px solid rgba(255, 255, 255, 0.5)',\n '&:hover, &.Mui-focusVisible': {\n border: '1px solid #fff',\n },\n mr: 1.5,\n },\n }}\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n {menuSections.map((section, index) => (\n <section.Component\n key={`menu-section-${index.toString()}`}\n hideDivider={index === menuSections.length - 1}\n handleClose={handleClose}\n />\n ))}\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAoCO,MAAM,iBAAiB,MAAM;AAClC,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AAEjE,EAAA,MAAM,4BAA4B,4BAA6B,EAAA;AAE/D,EAAM,MAAA,YAAA,GAAe,QAAQ,MAAM;AACjC,IAAA,OAAA,CAAQ,yBAA6B,IAAA,EAClC,EAAA,GAAA,CAAI,CAAO,EAAA,MAAA;AAAA,MACV,WAAW,EAAG,CAAA,SAAA;AAAA,MACd,IAAM,EAAA,EAAA,CAAG,MAAQ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AAA;AAAA,QAC7C;AAAA;AAAA,KAEH;AAAA,GACH;AAEJ;;;;"}
@@ -11,15 +11,18 @@ const Listbox = styled("ul")(
11
11
  padding: 0;
12
12
  margin: 0;
13
13
  min-width: 160px;
14
- border-radius: 3px;
14
+ border-radius: 4px;
15
15
  text-decoration: none;
16
16
  list-style: none;
17
17
  overflow: auto;
18
18
  outline: 1;
19
- background: ${theme.palette.mode === "dark" ? theme.palette.background.default : "#fff"};
20
- border: 1px solid ${theme.palette.mode === "dark" ? theme.palette.divider : theme.palette.background.default};
19
+ background: ${theme.palette.background.paper};
20
+ border: 1px solid ${theme.palette.divider};
21
21
  color: ${theme.palette.mode === "dark" ? theme.palette.text.disabled : theme.palette.text.primary};
22
- box-shadow: 0 4px 6px ${theme.palette.mode === "dark" ? "rgba(0,0,0, 0.50)" : "rgba(0,0,0, 0.05)"};
22
+ boxShadow: theme.palette.mode === 'dark'
23
+ ? '0 2px 6px 2px rgba(0,0,0,0.50), 0 1px 2px 0 rgba(0,0,0,0.50)'
24
+ : '0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30)',
25
+ max-height: 60vh;
23
26
  z-index: 1;
24
27
  `
25
28
  );
@@ -27,9 +30,9 @@ const HeaderDropdownComponent = ({
27
30
  buttonContent,
28
31
  children,
29
32
  buttonProps,
30
- buttonClick,
31
- anchorEl,
32
- setAnchorEl
33
+ onOpen,
34
+ onClose,
35
+ anchorEl
33
36
  }) => {
34
37
  return /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(
35
38
  Button,
@@ -37,7 +40,7 @@ const HeaderDropdownComponent = ({
37
40
  disableRipple: true,
38
41
  disableTouchRipple: true,
39
42
  ...buttonProps,
40
- onClick: buttonClick
43
+ onClick: onOpen
41
44
  },
42
45
  buttonContent
43
46
  ), /* @__PURE__ */ React.createElement(
@@ -47,7 +50,7 @@ const HeaderDropdownComponent = ({
47
50
  anchorEl,
48
51
  keepMounted: true,
49
52
  open: Boolean(anchorEl),
50
- onClose: () => setAnchorEl(null),
53
+ onClose,
51
54
  anchorOrigin: {
52
55
  vertical: "bottom",
53
56
  horizontal: "center"
@@ -66,5 +69,5 @@ const HeaderDropdownComponent = ({
66
69
  ));
67
70
  };
68
71
 
69
- export { HeaderDropdownComponent as default };
72
+ export { HeaderDropdownComponent };
70
73
  //# sourceMappingURL=HeaderDropdownComponent.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderDropdownComponent.esm.js","sources":["../../../src/components/HeaderDropdownComponent/HeaderDropdownComponent.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Menu from '@mui/material/Menu';\nimport Button from '@mui/material/Button';\nimport { styled } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\nimport { MenuItemConfig, MenuSectionConfig } from './MenuSection';\n\ninterface HeaderDropdownProps {\n buttonContent: React.ReactNode;\n children: React.ReactNode;\n menuSections?: MenuSectionConfig[];\n menuBottomItems?: MenuItemConfig[];\n buttonProps?: React.ComponentProps<typeof Button>;\n buttonClick?: (event: React.MouseEvent<HTMLElement>) => void;\n anchorEl: HTMLElement | null;\n setAnchorEl: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n}\n\nconst Listbox = styled('ul')(\n ({ theme }) => `\n font-size: 0.875rem;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n min-width: 160px;\n border-radius: 3px;\n text-decoration: none;\n list-style: none;\n overflow: auto;\n outline: 1;\n background: ${\n theme.palette.mode === 'dark' ? theme.palette.background.default : '#fff'\n };\n border: 1px solid ${\n theme.palette.mode === 'dark'\n ? theme.palette.divider\n : theme.palette.background.default\n };\n color: ${\n theme.palette.mode === 'dark'\n ? theme.palette.text.disabled\n : theme.palette.text.primary\n };\n box-shadow: 0 4px 6px ${\n theme.palette.mode === 'dark' ? 'rgba(0,0,0, 0.50)' : 'rgba(0,0,0, 0.05)'\n };\n z-index: 1;\n `,\n);\n\nconst HeaderDropdownComponent: React.FC<HeaderDropdownProps> = ({\n buttonContent,\n children,\n buttonProps,\n buttonClick,\n anchorEl,\n setAnchorEl,\n}) => {\n return (\n <Box>\n <Button\n disableRipple\n disableTouchRipple\n {...buttonProps}\n onClick={buttonClick}\n >\n {buttonContent}\n </Button>\n <Menu\n id=\"menu-appbar\"\n anchorEl={anchorEl}\n keepMounted\n open={Boolean(anchorEl)}\n onClose={() => setAnchorEl(null)}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'center',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'center',\n }}\n sx={{\n '& ul[class*=\"MuiMenu-list\"]': {\n py: 0,\n },\n }}\n >\n <Listbox role=\"menu\">{children}</Listbox>\n </Menu>\n </Box>\n );\n};\n\nexport default HeaderDropdownComponent;\n"],"names":[],"mappings":";;;;;;AAkCA,MAAM,OAAA,GAAU,OAAO,IAAI,CAAA;AAAA,EACzB,CAAC,EAAE,KAAA,EAAY,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAYb,EAAA,KAAA,CAAM,QAAQ,IAAS,KAAA,MAAA,GAAS,MAAM,OAAQ,CAAA,UAAA,CAAW,UAAU,MACrE,CAAA;AAAA,oBAEE,EAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,KAAS,MACnB,GAAA,KAAA,CAAM,QAAQ,OACd,GAAA,KAAA,CAAM,OAAQ,CAAA,UAAA,CAAW,OAC/B,CAAA;AAAA,SAEE,EAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,KAAS,MAC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 {"version":3,"file":"HeaderDropdownComponent.esm.js","sources":["../../../src/components/HeaderDropdownComponent/HeaderDropdownComponent.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Menu from '@mui/material/Menu';\nimport Button from '@mui/material/Button';\nimport { styled } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\nimport { MenuItemConfig, MenuSectionConfig } from './MenuSection';\n\ninterface HeaderDropdownProps {\n buttonContent: React.ReactNode;\n children: React.ReactNode;\n menuSections?: MenuSectionConfig[];\n menuBottomItems?: MenuItemConfig[];\n buttonProps?: React.ComponentProps<typeof Button>;\n onOpen: (event: React.MouseEvent<HTMLElement>) => void;\n onClose: () => void;\n anchorEl: HTMLElement | null;\n}\n\nconst Listbox = styled('ul')(\n ({ theme }) => `\n font-size: 0.875rem;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n min-width: 160px;\n border-radius: 4px;\n text-decoration: none;\n list-style: none;\n overflow: auto;\n outline: 1;\n background: ${theme.palette.background.paper};\n border: 1px solid ${theme.palette.divider};\n color: ${\n theme.palette.mode === 'dark'\n ? theme.palette.text.disabled\n : theme.palette.text.primary\n };\n boxShadow: theme.palette.mode === 'dark'\n ? '0 2px 6px 2px rgba(0,0,0,0.50), 0 1px 2px 0 rgba(0,0,0,0.50)'\n : '0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30)',\n max-height: 60vh;\n z-index: 1;\n `,\n);\n\nexport const HeaderDropdownComponent: React.FC<HeaderDropdownProps> = ({\n buttonContent,\n children,\n buttonProps,\n onOpen,\n onClose,\n anchorEl,\n}) => {\n return (\n <Box>\n <Button\n disableRipple\n disableTouchRipple\n {...buttonProps}\n onClick={onOpen}\n >\n {buttonContent}\n </Button>\n <Menu\n id=\"menu-appbar\"\n anchorEl={anchorEl}\n keepMounted\n open={Boolean(anchorEl)}\n onClose={onClose}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'center',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'center',\n }}\n sx={{\n '& ul[class*=\"MuiMenu-list\"]': {\n py: 0,\n },\n }}\n >\n <Listbox role=\"menu\">{children}</Listbox>\n </Menu>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;AAkCA,MAAM,OAAA,GAAU,OAAO,IAAI,CAAA;AAAA,EACzB,CAAC,EAAE,KAAA,EAAY,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAWD,EAAA,KAAA,CAAM,OAAQ,CAAA,UAAA,CAAW,KAAK,CAAA;AAAA,oBACxB,EAAA,KAAA,CAAM,QAAQ,OAAO,CAAA;AAAA,SAEvC,EAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,KAAS,MACnB,GAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,CAAK,QACnB,GAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,CAAK,OACzB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AAOF,CAAA;AAEO,MAAM,0BAAyD,CAAC;AAAA,EACrE,aAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EAAA,2CACG,GACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,aAAa,EAAA,IAAA;AAAA,MACb,kBAAkB,EAAA,IAAA;AAAA,MACjB,GAAG,WAAA;AAAA,MACJ,OAAS,EAAA;AAAA,KAAA;AAAA,IAER;AAAA,GAEH,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,EAAG,EAAA,aAAA;AAAA,MACH,QAAA;AAAA,MACA,WAAW,EAAA,IAAA;AAAA,MACX,IAAA,EAAM,QAAQ,QAAQ,CAAA;AAAA,MACtB,OAAA;AAAA,MACA,YAAc,EAAA;AAAA,QACZ,QAAU,EAAA,QAAA;AAAA,QACV,UAAY,EAAA;AAAA,OACd;AAAA,MACA,eAAiB,EAAA;AAAA,QACf,QAAU,EAAA,KAAA;AAAA,QACV,UAAY,EAAA;AAAA,OACd;AAAA,MACA,EAAI,EAAA;AAAA,QACF,6BAA+B,EAAA;AAAA,UAC7B,EAAI,EAAA;AAAA;AACN;AACF,KAAA;AAAA,oBAEC,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,IAAK,EAAA,MAAA,EAAA,EAAQ,QAAS;AAAA,GAEnC,CAAA;AAEJ;;;;"}
@@ -35,7 +35,7 @@ const MenuSection = ({
35
35
  disableTouchRipple: true,
36
36
  onClick: handleClose
37
37
  },
38
- optionalLink && optionalLinkLabel && /* @__PURE__ */ React.createElement(
38
+ optionalLink && optionalLinkLabel && items.length > 0 && /* @__PURE__ */ React.createElement(
39
39
  Link,
40
40
  {
41
41
  to: optionalLink,
@@ -64,7 +64,7 @@ const MenuSection = ({
64
64
  }
65
65
  ),
66
66
  type === "logout" && /* @__PURE__ */ React.createElement(Component, null)
67
- ))), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { margin: "8px 0" } }));
67
+ ))), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { my: 0.5 } }));
68
68
 
69
- export { MenuSection as default };
69
+ export { MenuSection };
70
70
  //# sourceMappingURL=MenuSection.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"MenuSection.esm.js","sources":["../../../src/components/HeaderDropdownComponent/MenuSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Divider from '@mui/material/Divider';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport MenuItem from '@mui/material/MenuItem';\nimport { Link } from '@backstage/core-components';\nimport { HeaderLinkProps } from '../HeaderLinkComponent/HeaderLink';\n\n/**\n * Menu item configuration\n *\n * @public\n */\nexport interface MenuItemConfig {\n Component: React.ComponentType<HeaderLinkProps | {}>;\n type: string;\n label: string;\n icon?: string;\n subLabel?: string;\n link?: string;\n}\n\nexport interface MenuSectionConfig {\n sectionLabel?: string;\n optionalLink?: string;\n optionalLinkLabel?: string;\n items: MenuItemConfig[];\n hideDivider?: boolean;\n handleClose: () => void;\n}\n\nconst MenuSection: React.FC<MenuSectionConfig> = ({\n sectionLabel,\n optionalLink,\n optionalLinkLabel,\n items,\n hideDivider = false,\n handleClose,\n}) => (\n <Box>\n {sectionLabel && (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n mx: 0,\n mt: '0.5rem',\n '&:hover': { background: 'transparent' },\n }}\n >\n <Typography variant=\"body2\" sx={{ pl: 2, color: 'text.disabled' }}>\n {sectionLabel}\n </Typography>\n <MenuItem\n sx={{\n '&:hover': { background: 'transparent' },\n }}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n >\n {optionalLink && optionalLinkLabel && (\n <Link\n to={optionalLink}\n underline=\"none\"\n style={{ fontSize: '0.875em' }}\n >\n {optionalLinkLabel}\n </Link>\n )}\n </MenuItem>\n </Box>\n )}\n <ul style={{ padding: 0, listStyle: 'none' }}>\n {items.map(({ type, icon, label, subLabel, link, Component }, index) => (\n <MenuItem\n key={`menu-item-${index.toString()}`}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n sx={{ py: 0.5, '&:hover': { background: 'transparent' } }}\n >\n {link && (\n <Component\n icon={icon}\n to={link}\n title={label}\n subTitle={subLabel}\n />\n )}\n {type === 'logout' && <Component />}\n </MenuItem>\n ))}\n </ul>\n {!hideDivider && <Divider sx={{ margin: '8px 0' }} />}\n </Box>\n);\n\nexport default MenuSection;\n"],"names":[],"mappings":";;;;;;;AA+CA,MAAM,cAA2C,CAAC;AAAA,EAChD,YAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAc,GAAA,KAAA;AAAA,EACd;AACF,CACE,qBAAA,KAAA,CAAA,aAAA,CAAC,WACE,YACC,oBAAA,KAAA,CAAA,aAAA;AAAA,EAAC,GAAA;AAAA,EAAA;AAAA,IACC,EAAI,EAAA;AAAA,MACF,OAAS,EAAA,MAAA;AAAA,MACT,cAAgB,EAAA,eAAA;AAAA,MAChB,UAAY,EAAA,QAAA;AAAA,MACZ,EAAI,EAAA,CAAA;AAAA,MACJ,EAAI,EAAA,QAAA;AAAA,MACJ,SAAA,EAAW,EAAE,UAAA,EAAY,aAAc;AAAA;AACzC,GAAA;AAAA,kBAEA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,CAAG,EAAA,KAAA,EAAO,eAAgB,EAAA,EAAA,EAC7D,YACH,CAAA;AAAA,kBACA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,SAAA,EAAW,EAAE,UAAA,EAAY,aAAc;AAAA,OACzC;AAAA,MACA,aAAa,EAAA,IAAA;AAAA,MACb,kBAAkB,EAAA,IAAA;AAAA,MAClB,OAA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../../../src/components/HeaderDropdownComponent/MenuSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Divider from '@mui/material/Divider';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport MenuItem from '@mui/material/MenuItem';\nimport { Link } from '@backstage/core-components';\nimport { MenuItemLinkProps } from '../MenuItemLink/MenuItemLink';\n\n/**\n * Menu item configuration\n *\n * @public\n */\nexport interface MenuItemConfig {\n Component: React.ComponentType<MenuItemLinkProps | {}>;\n type: string;\n label: string;\n icon?: string;\n subLabel?: string;\n link?: string;\n}\n\nexport interface MenuSectionConfig {\n sectionLabel?: string;\n optionalLink?: string;\n optionalLinkLabel?: string;\n items: MenuItemConfig[];\n hideDivider?: boolean;\n handleClose: () => void;\n}\n\nexport const MenuSection: React.FC<MenuSectionConfig> = ({\n sectionLabel,\n optionalLink,\n optionalLinkLabel,\n items,\n hideDivider = false,\n handleClose,\n}) => (\n <Box>\n {sectionLabel && (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n mx: 0,\n mt: '0.5rem',\n '&:hover': { background: 'transparent' },\n }}\n >\n <Typography variant=\"body2\" sx={{ pl: 2, color: 'text.disabled' }}>\n {sectionLabel}\n </Typography>\n <MenuItem\n sx={{\n '&:hover': { background: 'transparent' },\n }}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n >\n {optionalLink && optionalLinkLabel && items.length > 0 && (\n <Link\n to={optionalLink}\n underline=\"none\"\n style={{ fontSize: '0.875em' }}\n >\n {optionalLinkLabel}\n </Link>\n )}\n </MenuItem>\n </Box>\n )}\n <ul style={{ padding: 0, listStyle: 'none' }}>\n {items.map(({ type, icon, label, subLabel, link, Component }, index) => (\n <MenuItem\n key={`menu-item-${index.toString()}`}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n sx={{ py: 0.5, '&:hover': { background: 'transparent' } }}\n >\n {link && (\n <Component\n icon={icon}\n to={link}\n title={label}\n subTitle={subLabel}\n />\n )}\n {type === 'logout' && <Component />}\n </MenuItem>\n ))}\n </ul>\n {!hideDivider && <Divider sx={{ my: 0.5 }} />}\n </Box>\n);\n"],"names":[],"mappings":";;;;;;;AA+CO,MAAM,cAA2C,CAAC;AAAA,EACvD,YAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAc,GAAA,KAAA;AAAA,EACd;AACF,CACE,qBAAA,KAAA,CAAA,aAAA,CAAC,WACE,YACC,oBAAA,KAAA,CAAA,aAAA;AAAA,EAAC,GAAA;AAAA,EAAA;AAAA,IACC,EAAI,EAAA;AAAA,MACF,OAAS,EAAA,MAAA;AAAA,MACT,cAAgB,EAAA,eAAA;AAAA,MAChB,UAAY,EAAA,QAAA;AAAA,MACZ,EAAI,EAAA,CAAA;AAAA,MACJ,EAAI,EAAA,QAAA;AAAA,MACJ,SAAA,EAAW,EAAE,UAAA,EAAY,aAAc;AAAA;AACzC,GAAA;AAAA,kBAEA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,CAAG,EAAA,KAAA,EAAO,eAAgB,EAAA,EAAA,EAC7D,YACH,CAAA;AAAA,kBACA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,SAAA,EAAW,EAAE,UAAA,EAAY,aAAc;AAAA,OACzC;AAAA,MACA,aAAa,EAAA,IAAA;AAAA,MACb,kB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