@red-hat-developer-hub/backstage-plugin-global-header 0.0.4 → 0.2.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 (75) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/app-config.dynamic.yaml +31 -38
  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 +26 -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 +22 -56
  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 +5 -14
  16. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
  17. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +47 -26
  18. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
  19. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +4 -5
  20. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -1
  21. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +48 -3
  22. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -1
  23. package/dist/components/{HeaderIconButtonComponent → HeaderIcon}/HeaderIcon.esm.js +19 -6
  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 +38 -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/SearchComponent.esm.js +1 -2
  38. package/dist/components/SearchComponent/SearchComponent.esm.js.map +1 -1
  39. package/dist/components/SearchComponent/SearchInput.esm.js +0 -1
  40. package/dist/components/SearchComponent/SearchInput.esm.js.map +1 -1
  41. package/dist/components/SearchComponent/SearchOption.esm.js +1 -1
  42. package/dist/components/SearchComponent/SearchOption.esm.js.map +1 -1
  43. package/dist/components/SearchComponent/SearchResultItem.esm.js +13 -1
  44. package/dist/components/SearchComponent/SearchResultItem.esm.js.map +1 -1
  45. package/dist/components/Spacer/Spacer.esm.js +21 -0
  46. package/dist/components/Spacer/Spacer.esm.js.map +1 -0
  47. package/dist/components/SupportButton/SupportButton.esm.js +45 -0
  48. package/dist/components/SupportButton/SupportButton.esm.js.map +1 -0
  49. package/dist/defaultMountPoints/defaultMountPoints.esm.js +107 -0
  50. package/dist/defaultMountPoints/defaultMountPoints.esm.js.map +1 -0
  51. package/dist/hooks/useCreateDropdownMountPoints.esm.js +4 -0
  52. package/dist/hooks/useCreateDropdownMountPoints.esm.js.map +1 -1
  53. package/dist/hooks/useDropdownManager.esm.js +7 -6
  54. package/dist/hooks/useDropdownManager.esm.js.map +1 -1
  55. package/dist/hooks/useNotificationCount.esm.js +51 -0
  56. package/dist/hooks/useNotificationCount.esm.js.map +1 -0
  57. package/dist/hooks/useProfileDropdownMountPoints.esm.js +4 -0
  58. package/dist/hooks/useProfileDropdownMountPoints.esm.js.map +1 -1
  59. package/dist/index.d.ts +177 -41
  60. package/dist/index.esm.js +2 -1
  61. package/dist/index.esm.js.map +1 -1
  62. package/dist/plugin.esm.js +109 -14
  63. package/dist/plugin.esm.js.map +1 -1
  64. package/package.json +6 -1
  65. package/dist/components/HeaderButtonComponent/HeaderButton.esm.js +0 -17
  66. package/dist/components/HeaderButtonComponent/HeaderButton.esm.js.map +0 -1
  67. package/dist/components/HeaderButtonComponent/LogoutButton.esm.js.map +0 -1
  68. package/dist/components/HeaderIconButtonComponent/HeaderIcon.esm.js.map +0 -1
  69. package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js +0 -25
  70. package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js.map +0 -1
  71. package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js +0 -19
  72. package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js.map +0 -1
  73. package/dist/components/HeaderLinkComponent/HeaderLink.esm.js.map +0 -1
  74. package/dist/types.esm.js +0 -17
  75. package/dist/types.esm.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,32 @@
1
1
  # @red-hat-developer-hub/backstage-plugin-global-header
2
2
 
3
+ ## 0.2.0
4
+
5
+ ### Minor Changes
6
+
7
+ - e19aed1: Remove ComponmentType to simplify API and add layout prop to the header components to support some responsive design tweaks in dynamic plugin config. Moved some local styles to the incl. app config as well and hide the username on xs and sm screen sizes.
8
+
9
+ ## 0.1.0
10
+
11
+ ### Minor Changes
12
+
13
+ - f35b797: First version of Global Header plugin with the following components:
14
+
15
+ - GlobalHeaderComponent
16
+ - SearchComponent
17
+ - CreateDropdown
18
+ - SoftwareTemplatesSection
19
+ - RegisterAComponentSection
20
+ - ProfileDropdown
21
+ - LogoutButton
22
+ - HeaderButton
23
+ - HeaderIcon
24
+ - HeaderIconButton
25
+ - MenuItemLink
26
+ - Spacer
27
+ - Divider
28
+ - NotificationBanner
29
+
3
30
  ## 0.0.4
4
31
 
5
32
  ### Patch Changes
@@ -6,66 +6,59 @@ 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
10
+
11
11
  - mountPoint: global.header/component
12
12
  importName: SearchComponent
13
13
  config:
14
- type: search
15
- slot: header-start
16
14
  priority: 100
15
+
17
16
  - mountPoint: global.header/component
18
- importName: CreateDropdown
17
+ importName: Spacer
19
18
  config:
20
- type: dropdown_button
21
- key: create
22
- slot: header-start
23
- priority: 90
24
- - mountPoint: global.header/create
25
- importName: SoftwareTemplatesSection
26
- config:
27
- type: list
28
- priority: 10
29
- - mountPoint: global.header/create
30
- importName: RegisterAComponentSection
31
- config:
32
- type: link
19
+ priority: 99
20
+ props:
21
+ growFactor: 0
22
+
33
23
  - mountPoint: global.header/component
34
24
  importName: HeaderIconButton
35
25
  config:
36
- type: icon_button
37
- slot: header-start
38
- priority: 80
26
+ priority: 90
39
27
  props:
40
- icon: support
41
- tooltip: 'Support'
28
+ title: Create...
29
+ icon: add
30
+ to: create
31
+
42
32
  - mountPoint: global.header/component
43
- importName: HeaderIconButton
33
+ importName: SupportButton
34
+ config:
35
+ priority: 80
36
+
37
+ - mountPoint: global.header/component
38
+ importName: NotificationButton
44
39
  config:
45
- type: icon_button
46
- slot: header-start
47
40
  priority: 70
48
- props:
49
- icon: notifications
50
- tooltip: 'Notifications'
41
+
42
+ - mountPoint: global.header/component
43
+ importName: Divider
44
+ config:
45
+ priority: 50
46
+
51
47
  - mountPoint: global.header/component
52
48
  importName: ProfileDropdown
53
49
  config:
54
- type: dropdown_button
55
- key: profile
56
- slot: header-end
57
- priority: 0
50
+ priority: 10
51
+
58
52
  - mountPoint: global.header/profile
59
- importName: HeaderLink
53
+ importName: MenuItemLink
60
54
  config:
61
- type: link
62
- priority: 10
55
+ priority: 100
63
56
  props:
64
57
  title: Settings
65
58
  link: /settings
66
59
  icon: manageAccounts
60
+
67
61
  - mountPoint: global.header/profile
68
62
  importName: LogoutButton
69
63
  config:
70
- type: logout
71
- priority: 0
64
+ priority: 10
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+ import Divider$1 from '@mui/material/Divider';
3
+
4
+ const Divider = ({ layout }) => {
5
+ return /* @__PURE__ */ React.createElement(
6
+ Divider$1,
7
+ {
8
+ orientation: "vertical",
9
+ flexItem: true,
10
+ sx: { borderColor: "#383838", marginX: 1, ...layout }
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 interface DividerProps {\n layout?: React.CSSProperties;\n}\n\n/**\n * @public\n */\nexport const Divider = ({ layout }: DividerProps) => {\n return (\n <MUIDivider\n orientation=\"vertical\"\n flexItem\n sx={{ borderColor: '#383838', marginX: 1, ...layout }}\n />\n );\n};\n"],"names":["MUIDivider"],"mappings":";;;AA8BO,MAAM,OAAU,GAAA,CAAC,EAAE,MAAA,EAA2B,KAAA;AACnD,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAACA,SAAA;AAAA,IAAA;AAAA,MACC,WAAY,EAAA,UAAA;AAAA,MACZ,QAAQ,EAAA,IAAA;AAAA,MACR,IAAI,EAAE,WAAA,EAAa,WAAW,OAAS,EAAA,CAAA,EAAG,GAAG,MAAO;AAAA;AAAA,GACtD;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;AAAA,KACnD;AAEA,IAAkB,iBAAA,CAAA,IAAA;AAAA,MAChB,CAAC,GAAG,CAAO,KAAA,CAAA,CAAA,CAAE,QAAQ,QAAY,IAAA,CAAA,KAAM,CAAE,CAAA,MAAA,EAAQ,QAAY,IAAA,CAAA;AAAA,KAC/D;AAEA,IAAO,OAAA,iBAAA;AAAA,GACT,EAAG,CAAC,0BAA0B,CAAC,CAAA;AAE/B,EAAA,MAAM,yCACJ,uCAAwC,CAAA,MAAA;AAAA,IACtC,CAAa,SAAA,KAAA,SAAA,CAAU,MAAQ,EAAA,IAAA,KAAS,IAAK,CAAA;AAAA,GAC/C;AAEF,EAAA,MAAM,uCACJ,uCAAwC,CAAA,MAAA;AAAA,IACtC,CAAa,SAAA,KAAA,SA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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,26 @@
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
+ layout: mountPoint.config?.layout
21
+ }
22
+ )))));
23
+ };
24
+
25
+ export { GlobalHeaderComponent };
26
+ //# 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 * Global Header Component properties\n * @public\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 layout={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,KAAA;AAAA,MACvB,MAAA,EAAQ,WAAW,MAAQ,EAAA;AAAA;AAAA,GAE/B,CACD,CACH,CACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { LinkButton } from '@backstage/core-components';
3
+ import Box from '@mui/material/Box';
4
+ import Tooltip from '@mui/material/Tooltip';
5
+ import { HeaderIcon } from '../HeaderIcon/HeaderIcon.esm.js';
6
+
7
+ const HeaderButton = ({
8
+ title,
9
+ tooltip,
10
+ color = "inherit",
11
+ size = "small",
12
+ variant,
13
+ ariaLabel,
14
+ startIcon,
15
+ endIcon,
16
+ externalLinkIcon = true,
17
+ to,
18
+ layout
19
+ }) => {
20
+ const button = /* @__PURE__ */ React.createElement(
21
+ LinkButton,
22
+ {
23
+ color,
24
+ size,
25
+ variant,
26
+ "aria-label": ariaLabel,
27
+ startIcon: startIcon ? /* @__PURE__ */ React.createElement(HeaderIcon, { icon: startIcon, size }) : null,
28
+ endIcon: endIcon ? /* @__PURE__ */ React.createElement(HeaderIcon, { icon: endIcon, size }) : null,
29
+ externalLinkIcon,
30
+ to
31
+ },
32
+ title
33
+ );
34
+ if (tooltip) {
35
+ return /* @__PURE__ */ React.createElement(Box, { sx: layout }, /* @__PURE__ */ React.createElement(Tooltip, { title: tooltip }, /* @__PURE__ */ React.createElement("div", null, button)));
36
+ }
37
+ return /* @__PURE__ */ React.createElement(Box, { sx: layout }, 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 Box from '@mui/material/Box';\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 layout?: 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 layout,\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 >\n {title}\n </LinkButton>\n );\n\n if (tooltip) {\n return (\n <Box sx={layout}>\n <Tooltip title={tooltip}>\n <div>{button}</div>\n </Tooltip>\n </Box>\n );\n }\n\n return <Box sx={layout}>{button}</Box>;\n};\n"],"names":[],"mappings":";;;;;;AA4CO,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;AAAA,KAAA;AAAA,IAEC;AAAA,GACH;AAGF,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,EAAI,EAAA,MAAA,EAAA,kBACN,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,KAAO,EAAA,OAAA,EAAA,kBACb,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA,EAAK,MAAO,CACf,CACF,CAAA;AAAA;AAIJ,EAAA,uBAAQ,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,EAAI,EAAA,MAAA,EAAA,EAAS,MAAO,CAAA;AAClC;;;;"}
@@ -1,81 +1,47 @@
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
- import { ComponentType } from '../../types.esm.js';
10
- import { HeaderLink } from '../HeaderLinkComponent/HeaderLink.esm.js';
11
3
  import { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints.esm.js';
4
+ import { useDropdownManager } from '../../hooks/useDropdownManager.esm.js';
5
+ import { HeaderDropdownComponent } from './HeaderDropdownComponent.esm.js';
6
+ import Box from '@mui/material/Box';
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 = ({ layout }) => {
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,
49
- type: mp.config?.type ?? ComponentType.LINK,
50
14
  priority: mp.config?.priority ?? 0
51
15
  })).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
52
16
  }, [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));
17
+ if (menuSections.length === 0) {
18
+ return null;
58
19
  }
59
20
  return /* @__PURE__ */ React.createElement(
60
21
  HeaderDropdownComponent,
61
22
  {
62
- buttonContent: /* @__PURE__ */ React.createElement(React.Fragment, null, "Create ", /* @__PURE__ */ React.createElement(ArrowDropDownOutlinedIcon, { sx: { ml: 1 } })),
23
+ buttonContent: /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex", alignItems: "center" } }, "Create ", /* @__PURE__ */ React.createElement(ArrowDropDownOutlinedIcon, { sx: { ml: 1 } })),
63
24
  buttonProps: {
64
- color: "primary",
65
- variant: "contained",
66
- sx: { mr: 2 }
25
+ variant: "outlined",
26
+ sx: {
27
+ color: "#fff",
28
+ border: "1px solid rgba(255, 255, 255, 0.5)",
29
+ "&:hover, &.Mui-focusVisible": {
30
+ border: "1px solid #fff"
31
+ },
32
+ ...layout
33
+ }
67
34
  },
68
- buttonClick: handleMenu,
69
- anchorEl,
70
- setAnchorEl
35
+ onOpen: handleOpen,
36
+ onClose: handleClose,
37
+ anchorEl
71
38
  },
72
39
  menuSections.map((section, index) => /* @__PURE__ */ React.createElement(
73
40
  section.Component,
74
41
  {
75
42
  key: `menu-section-${index.toString()}`,
76
43
  hideDivider: index === menuSections.length - 1,
77
- handleClose: () => setAnchorEl(null),
78
- ...section.type === ComponentType.LIST ? { items } : {}
44
+ handleClose
79
45
  }
80
46
  ))
81
47
  );
@@ -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,CAAm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A,EAA0B,IAAI,EAAE,EAAA,EAAI,CAAE,EAAA,EAAG,CACnD,CAAA;AAAA,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 { MenuItemConfig } from './MenuSection';\nimport { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport Box from '@mui/material/Box';\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\n/**\n * @public\n * Props for Create Dropdown\n */\nexport interface CreateDropdownProps {\n layout?: React.CSSProperties;\n}\n\nexport const CreateDropdown = ({ layout }: CreateDropdownProps) => {\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 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 <Box sx={{ display: 'flex', alignItems: 'center' }}>\n Create <ArrowDropDownOutlinedIcon sx={{ ml: 1 }} />\n </Box>\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 ...layout,\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":";;;;;;;AA4CO,MAAM,cAAiB,GAAA,CAAC,EAAE,MAAA,EAAkC,KAAA;AACjE,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AAEjE,EAAA,MAAM,4BAA4B,4BAA6B,EAAA;AAE/D,EA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K,EAAA,CAAA,aAAA,EAAgB,KAAM,CAAA,QAAA,EAAU,CAAA,CAAA;AAAA,QACrC,WAAA,EAAa,KAAU,KAAA,YAAA,CAAa,MAAS,GAAA,CAAA;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,Q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oBAEC,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,IAAK,EAAA,MAAA,EAAA,EAAQ,QAAS;AAAA,GAEnC,CAAA;AAEJ;;;;"}
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 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,
@@ -45,7 +45,7 @@ const MenuSection = ({
45
45
  optionalLinkLabel
46
46
  )
47
47
  )
48
- ), /* @__PURE__ */ React.createElement("ul", { style: { padding: 0, listStyle: "none" } }, items.map(({ type, icon, label, subLabel, link, Component }, index) => /* @__PURE__ */ React.createElement(
48
+ ), /* @__PURE__ */ React.createElement("ul", { style: { padding: 0, listStyle: "none" } }, items.map(({ icon, label, subLabel, link, Component }, index) => /* @__PURE__ */ React.createElement(
49
49
  MenuItem,
50
50
  {
51
51
  key: `menu-item-${index.toString()}`,
@@ -54,17 +54,8 @@ const MenuSection = ({
54
54
  onClick: handleClose,
55
55
  sx: { py: 0.5, "&:hover": { background: "transparent" } }
56
56
  },
57
- link && /* @__PURE__ */ React.createElement(
58
- Component,
59
- {
60
- icon,
61
- to: link,
62
- title: label,
63
- subTitle: subLabel
64
- }
65
- ),
66
- type === "logout" && /* @__PURE__ */ React.createElement(Component, null)
67
- ))), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { margin: "8px 0" } }));
57
+ /* @__PURE__ */ React.createElement(Component, { icon, to: link, title: label, subTitle: subLabel })
58
+ ))), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { my: 0.5 } }));
68
59
 
69
- export { MenuSection as default };
60
+ export { MenuSection };
70
61
  //# sourceMappingURL=MenuSection.esm.js.map