@red-hat-developer-hub/backstage-plugin-global-header 0.0.3 → 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 (68) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/app-config.dynamic.yaml +54 -2
  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 +6 -77
  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 +39 -67
  12. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js.map +1 -1
  13. package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js +15 -59
  14. package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js.map +1 -1
  15. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js +14 -25
  16. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
  17. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +57 -51
  18. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
  19. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +30 -0
  20. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -0
  21. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +70 -0
  22. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -0
  23. package/dist/components/HeaderIcon/HeaderIcon.esm.js +38 -0
  24. package/dist/components/HeaderIcon/HeaderIcon.esm.js.map +1 -0
  25. package/dist/components/HeaderIconButton/HeaderIconButton.esm.js +25 -10
  26. package/dist/components/HeaderIconButton/HeaderIconButton.esm.js.map +1 -1
  27. package/dist/components/LogoutButton/LogoutButton.esm.js +23 -0
  28. package/dist/components/LogoutButton/LogoutButton.esm.js.map +1 -0
  29. package/dist/components/MenuItemLink/MenuItemLink.esm.js +29 -0
  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 +38 -8
  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 +14 -0
  48. package/dist/hooks/useCreateDropdownMountPoints.esm.js.map +1 -0
  49. package/dist/hooks/useDropdownManager.esm.js +7 -6
  50. package/dist/hooks/useDropdownManager.esm.js.map +1 -1
  51. package/dist/hooks/useGlobalHeaderMountPoints.esm.js +10 -0
  52. package/dist/hooks/useGlobalHeaderMountPoints.esm.js.map +1 -0
  53. package/dist/hooks/useNotificationCount.esm.js +54 -0
  54. package/dist/hooks/useNotificationCount.esm.js.map +1 -0
  55. package/dist/hooks/useProfileDropdownMountPoints.esm.js +14 -0
  56. package/dist/hooks/useProfileDropdownMountPoints.esm.js.map +1 -0
  57. package/dist/index.d.ts +277 -4
  58. package/dist/index.esm.js +2 -1
  59. package/dist/index.esm.js.map +1 -1
  60. package/dist/plugin.esm.js +142 -1
  61. package/dist/plugin.esm.js.map +1 -1
  62. package/dist/types.esm.js +14 -0
  63. package/dist/types.esm.js.map +1 -0
  64. package/package.json +31 -16
  65. package/dist/components/HeaderDropdownComponent/MenuItemContent.esm.js +0 -15
  66. package/dist/components/HeaderDropdownComponent/MenuItemContent.esm.js.map +0 -1
  67. package/dist/components/HeaderIconButton/SmallIconWrapper.esm.js +0 -11
  68. package/dist/components/HeaderIconButton/SmallIconWrapper.esm.js.map +0 -1
@@ -4,17 +4,15 @@ import Box from '@mui/material/Box';
4
4
  import Typography from '@mui/material/Typography';
5
5
  import MenuItem from '@mui/material/MenuItem';
6
6
  import { Link } from '@backstage/core-components';
7
- import MenuItemContent from './MenuItemContent.esm.js';
8
7
 
9
8
  const MenuSection = ({
10
- sectionKey,
11
9
  sectionLabel,
12
10
  optionalLink,
13
11
  optionalLinkLabel,
14
12
  items,
15
13
  hideDivider = false,
16
14
  handleClose
17
- }) => /* @__PURE__ */ React.createElement(Box, null, sectionLabel && sectionKey && /* @__PURE__ */ React.createElement(
15
+ }) => /* @__PURE__ */ React.createElement(Box, null, sectionLabel && /* @__PURE__ */ React.createElement(
18
16
  Box,
19
17
  {
20
18
  sx: {
@@ -37,7 +35,7 @@ const MenuSection = ({
37
35
  disableTouchRipple: true,
38
36
  onClick: handleClose
39
37
  },
40
- optionalLink && optionalLinkLabel && /* @__PURE__ */ React.createElement(
38
+ optionalLink && optionalLinkLabel && items.length > 0 && /* @__PURE__ */ React.createElement(
41
39
  Link,
42
40
  {
43
41
  to: optionalLink,
@@ -47,35 +45,26 @@ const MenuSection = ({
47
45
  optionalLinkLabel
48
46
  )
49
47
  )
50
- ), /* @__PURE__ */ React.createElement("ul", { style: { padding: 0, listStyle: "none" } }, items.map(({ itemKey, icon: Icon, label, subLabel, link, onClick }) => /* @__PURE__ */ React.createElement(
48
+ ), /* @__PURE__ */ React.createElement("ul", { style: { padding: 0, listStyle: "none" } }, items.map(({ type, icon, label, subLabel, link, Component }, index) => /* @__PURE__ */ React.createElement(
51
49
  MenuItem,
52
50
  {
53
- key: `menu-item-${itemKey}`,
51
+ key: `menu-item-${index.toString()}`,
54
52
  disableRipple: true,
55
53
  disableTouchRipple: true,
56
54
  onClick: handleClose,
57
55
  sx: { py: 0.5, "&:hover": { background: "transparent" } }
58
56
  },
59
- link ? /* @__PURE__ */ React.createElement(
60
- Link,
57
+ link && /* @__PURE__ */ React.createElement(
58
+ Component,
61
59
  {
60
+ icon,
62
61
  to: link,
63
- style: {
64
- color: "inherit",
65
- textDecoration: "none",
66
- width: "100%"
67
- }
68
- },
69
- /* @__PURE__ */ React.createElement(MenuItemContent, { Icon, label, subLabel })
70
- ) : /* @__PURE__ */ React.createElement(
71
- Box,
72
- {
73
- onClick,
74
- sx: { cursor: "pointer", width: "100%", color: "inherit" }
75
- },
76
- /* @__PURE__ */ React.createElement(MenuItemContent, { Icon, label, subLabel })
77
- )
78
- ))), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { margin: "8px 0" } }));
62
+ title: label,
63
+ subTitle: subLabel
64
+ }
65
+ ),
66
+ type === "logout" && /* @__PURE__ */ React.createElement(Component, null)
67
+ ))), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { my: 0.5 } }));
79
68
 
80
- export { MenuSection as default };
69
+ export { MenuSection };
81
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 { SvgIconProps } from '@mui/material/SvgIcon';\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 MenuItemContent from './MenuItemContent';\n\nexport interface MenuItemBase {\n itemKey: string;\n icon?: React.ElementType<SvgIconProps>;\n label: string;\n subLabel?: string;\n}\n\nexport interface MenuItemLink extends MenuItemBase {\n link: string;\n onClick?: never;\n}\n\nexport interface MenuItemAction extends MenuItemBase {\n onClick: () => void;\n link?: never;\n}\n\nexport type MenuItemConfig = MenuItemLink | MenuItemAction;\n\nexport interface MenuSectionConfig {\n sectionKey: string;\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 sectionKey,\n sectionLabel,\n optionalLink,\n optionalLinkLabel,\n items,\n hideDivider = false,\n handleClose,\n}) => (\n <Box>\n {sectionLabel && sectionKey && (\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(({ itemKey, icon: Icon, label, subLabel, link, onClick }) => (\n <MenuItem\n key={`menu-item-${itemKey}`}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n sx={{ py: 0.5, '&:hover': { background: 'transparent' } }}\n >\n {link ? (\n <Link\n to={link}\n style={{\n color: 'inherit',\n textDecoration: 'none',\n width: '100%',\n }}\n >\n <MenuItemContent Icon={Icon} label={label} subLabel={subLabel} />\n </Link>\n ) : (\n <Box\n onClick={onClick}\n sx={{ cursor: 'pointer', width: '100%', color: 'inherit' }}\n >\n <MenuItemContent Icon={Icon} label={label} subLabel={subLabel} />\n </Box>\n )}\n </MenuItem>\n ))}\n </ul>\n {!hideDivider && <Divider sx={{ margin: '8px 0' }} />}\n </Box>\n);\n\nexport default MenuSection;\n"],"names":[],"mappings":";;;;;;;;AAsDA,MAAM,cAA2C,CAAC;AAAA,EAChD,UAAA;AAAA,EACA,YAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAc,GAAA,KAAA;AAAA,EACd;AACF,CACE,qBAAA,KAAA,CAAA,aAAA,CAAC,GACE,EAAA,IAAA,EAAA,YAAA,IAAgB,UACf,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,eAAg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C,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,EAAgB,IAAY,EAAA,KAAA,EAAc,QAAoB,EAAA;AAAA,GAGjE,mBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,OAAA;AAAA,MACA,IAAI,EAAE,MAAA,EAAQ,WAAW,KAAO,EAAA,MAAA,EAAQ,OAAO,SAAU;AAAA,KAAA;AAAA,oBAExD,KAAA,CAAA,aAAA,CAAA,eAAA,EAAA,EAAgB,IAAY,EAAA,KAAA,EAAc,QAAoB,EAAA;AAAA;AAGrE,CACD,CACH,CACC,EAAA,CAAC,WAAe,oBAAA,KAAA,CAAA,aAAA,CAAC,OAAQ,EAAA,EAAA,EAAA,EAAI,EAAE,MAAA,EAAQ,OAAQ,EAAA,EAAG,CACrD;;;;"}
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 { 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,M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EAAA,IAAA;AAAA,IACb,kBAAkB,EAAA,IAAA;AAAA,IAClB,OAAS,EAAA,WAAA;AAAA,IACT,EAAA,EAAI,EAAE,EAAI,EAAA,GAAA,EAAK,WAAW,EAAE,UAAA,EAAY,eAAgB;AAAA,GAAA;AAAA,EAEvD,IACC,oBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,SAAA;AAAA,IAAA;AAAA,MACC,IAAA;AAAA,MACA,EAAI,EAAA,IAAA;AAAA,MACJ,KAAO,EAAA,KAAA;AAAA,MACP,QAAU,EAAA;AAAA;AAAA,GACZ;AAAA,EAED,IAAA,KAAS,QAAY,oBAAA,KAAA,CAAA,aAAA,CAAC,SAAU,EAAA,IAAA;AACnC,CACD,CACH,CACC,EAAA,CAAC,WAAe,oBAAA,KAAA,CAAA,aAAA,CAAC,OAAQ,EAAA,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,GAAI,EAAA,EAAG,CAC7C;;;;"}
@@ -1,78 +1,84 @@
1
- import React from 'react';
2
- import HeaderDropdownComponent from './HeaderDropdownComponent.esm.js';
1
+ import React, { useState, useRef, useEffect, useMemo } from 'react';
2
+ import { useApi, identityApiRef } from '@backstage/core-plugin-api';
3
3
  import AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined';
4
- import ManageAccountsOutlinedIcon from '@mui/icons-material/ManageAccountsOutlined';
5
- import LogoutOutlinedIcon from '@mui/icons-material/LogoutOutlined';
6
4
  import KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';
7
5
  import Typography from '@mui/material/Typography';
8
- import SmallIconWrapper from '../HeaderIconButton/SmallIconWrapper.esm.js';
9
- import { useApi, errorApiRef, identityApiRef } from '@backstage/core-plugin-api';
6
+ import { lighten } from '@mui/material/styles';
7
+ import { HeaderDropdownComponent } from './HeaderDropdownComponent.esm.js';
8
+ import { useProfileDropdownMountPoints } from '../../hooks/useProfileDropdownMountPoints.esm.js';
9
+ import { ComponentType } from '../../types.esm.js';
10
+ import { MenuSection } from './MenuSection.esm.js';
11
+ import { useDropdownManager } from '../../hooks/useDropdownManager.esm.js';
10
12
 
11
- const ProfileDropdown = ({
12
- handleMenu,
13
- anchorEl,
14
- setAnchorEl
15
- }) => {
16
- const errorApi = useApi(errorApiRef);
13
+ const ProfileDropdown = () => {
14
+ const { anchorEl, handleOpen, handleClose } = useDropdownManager();
17
15
  const identityApi = useApi(identityApiRef);
18
- const user = "Guest User";
19
- const handleLogout = () => {
20
- identityApi.signOut().catch((error) => errorApi.post(error));
21
- };
22
- const menuSections = [
23
- {
24
- sectionKey: "profile",
25
- items: [
26
- {
27
- itemKey: "settings",
28
- icon: ManageAccountsOutlinedIcon,
29
- label: "Settings",
30
- link: "/settings"
31
- },
32
- {
33
- itemKey: "logout",
34
- icon: LogoutOutlinedIcon,
35
- label: "Log out",
36
- onClick: handleLogout
37
- }
38
- ],
39
- handleClose: () => setAnchorEl(null)
16
+ const [user, setUser] = useState();
17
+ const profileDropdownMountPoints = useProfileDropdownMountPoints();
18
+ const headerRef = useRef(null);
19
+ const [bgColor, setBgColor] = useState("#3C3F42");
20
+ useEffect(() => {
21
+ if (headerRef.current) {
22
+ const computedStyle = window.getComputedStyle(headerRef.current);
23
+ const baseColor = computedStyle.backgroundColor;
24
+ setBgColor(lighten(baseColor, 0.2));
40
25
  }
41
- ];
26
+ }, []);
27
+ useEffect(() => {
28
+ const container = document.getElementById("global-header");
29
+ if (container) {
30
+ const computedStyle = window.getComputedStyle(container);
31
+ const baseColor = computedStyle.backgroundColor;
32
+ setBgColor(lighten(baseColor, 0.2));
33
+ }
34
+ }, []);
35
+ useEffect(() => {
36
+ const fetchUser = async () => {
37
+ const userProfile = await identityApi.getProfileInfo();
38
+ setUser(userProfile);
39
+ };
40
+ fetchUser();
41
+ }, [identityApi]);
42
+ const menuItems = useMemo(() => {
43
+ return (profileDropdownMountPoints ?? []).map((mp) => ({
44
+ Component: mp.Component,
45
+ type: mp.config?.type ?? ComponentType.LINK,
46
+ icon: mp.config?.props?.icon ?? "",
47
+ label: mp.config?.props?.title ?? "",
48
+ link: mp.config?.props?.link ?? "",
49
+ priority: mp.config?.priority ?? 0
50
+ })).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
51
+ }, [profileDropdownMountPoints]);
52
+ if (menuItems.length === 0) {
53
+ return null;
54
+ }
42
55
  return /* @__PURE__ */ React.createElement(
43
56
  HeaderDropdownComponent,
44
57
  {
45
- buttonContent: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
46
- SmallIconWrapper,
47
- {
48
- IconComponent: AccountCircleOutlinedIcon,
49
- sx: { mx: 1 }
50
- }
51
- ), /* @__PURE__ */ React.createElement(Typography, { variant: "body2", sx: { fontWeight: 500, mx: 1 } }, user), /* @__PURE__ */ React.createElement(
58
+ buttonContent: /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(AccountCircleOutlinedIcon, { fontSize: "small", sx: { mx: 1 } }), /* @__PURE__ */ React.createElement(Typography, { variant: "body2", sx: { fontWeight: 500, mx: 1 } }, user?.displayName ?? "Guest"), /* @__PURE__ */ React.createElement(
52
59
  KeyboardArrowDownOutlinedIcon,
53
60
  {
54
61
  sx: {
55
62
  marginLeft: "1rem",
56
- bgcolor: "#383838",
63
+ bgcolor: bgColor,
57
64
  borderRadius: "25%"
58
65
  }
59
66
  }
60
67
  )),
61
- menuSections,
62
68
  buttonProps: {
63
69
  color: "inherit",
64
70
  sx: {
65
71
  display: "flex",
66
- alignItems: "center",
67
- ml: 1
72
+ alignItems: "center"
68
73
  }
69
74
  },
70
- buttonClick: handleMenu,
71
- anchorEl,
72
- setAnchorEl
73
- }
75
+ onOpen: handleOpen,
76
+ onClose: handleClose,
77
+ anchorEl
78
+ },
79
+ /* @__PURE__ */ React.createElement(MenuSection, { hideDivider: true, items: menuItems, handleClose })
74
80
  );
75
81
  };
76
82
 
77
- export { ProfileDropdown as default };
83
+ export { ProfileDropdown };
78
84
  //# sourceMappingURL=ProfileDropdown.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/ProfileDropdown.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 HeaderDropdownComponent from './HeaderDropdownComponent';\nimport AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined';\nimport ManageAccountsOutlinedIcon from '@mui/icons-material/ManageAccountsOutlined';\nimport LogoutOutlinedIcon from '@mui/icons-material/LogoutOutlined';\nimport KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';\nimport Typography from '@mui/material/Typography';\nimport SmallIconWrapper from '../HeaderIconButton/SmallIconWrapper';\nimport {\n identityApiRef,\n errorApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\n\ninterface ProfileDropdownProps {\n handleMenu: (event: React.MouseEvent<HTMLElement>) => void;\n anchorEl: HTMLElement | null;\n setAnchorEl: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n}\n\nconst ProfileDropdown: React.FC<ProfileDropdownProps> = ({\n handleMenu,\n anchorEl,\n setAnchorEl,\n}) => {\n const errorApi = useApi(errorApiRef);\n const identityApi = useApi(identityApiRef);\n const user = 'Guest User';\n\n const handleLogout = () => {\n identityApi.signOut().catch(error => errorApi.post(error));\n };\n const menuSections = [\n {\n sectionKey: 'profile',\n items: [\n {\n itemKey: 'settings',\n icon: ManageAccountsOutlinedIcon,\n label: 'Settings',\n link: '/settings',\n },\n {\n itemKey: 'logout',\n icon: LogoutOutlinedIcon,\n label: 'Log out',\n onClick: handleLogout,\n },\n ],\n handleClose: () => setAnchorEl(null),\n },\n ];\n return (\n <HeaderDropdownComponent\n buttonContent={\n <>\n <SmallIconWrapper\n IconComponent={AccountCircleOutlinedIcon}\n sx={{ mx: 1 }}\n />\n <Typography variant=\"body2\" sx={{ fontWeight: 500, mx: 1 }}>\n {user ?? 'Guest User'}\n </Typography>\n <KeyboardArrowDownOutlinedIcon\n sx={{\n marginLeft: '1rem',\n bgcolor: '#383838',\n borderRadius: '25%',\n }}\n />\n </>\n }\n menuSections={menuSections}\n buttonProps={{\n color: 'inherit',\n sx: {\n display: 'flex',\n alignItems: 'center',\n ml: 1,\n },\n }}\n buttonClick={handleMenu}\n anchorEl={anchorEl}\n setAnchorEl={setAnchorEl}\n />\n );\n};\n\nexport default ProfileDropdown;\n"],"names":[],"mappings":";;;;;;;;;;AAoCA,MAAM,kBAAkD,CAAC;AAAA,EACvD,UAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA;AACzC,EAAA,MAAM,IAAO,GAAA,YAAA;AAEb,EAAA,MAAM,eAAe,MAAM;AACzB,IAAA,WAAA,CAAY,SAAU,CAAA,KAAA,CAAM,WAAS,QAAS,CAAA,IAAA,CAAK,KAAK,CAAC,CAAA;AAAA,GAC3D;AACA,EAAA,MAAM,YAAe,GAAA;AAAA,IACnB;AAAA,MACE,UAAY,EAAA,SAAA;AAAA,MACZ,KAAO,EAAA;AAAA,QACL;AAAA,UACE,OAAS,EAAA,UAAA;AAAA,UACT,IAAM,EAAA,0BAAA;AAAA,UACN,KAAO,EAAA,UAAA;AAAA,UACP,IAAM,EAAA;AAAA,SACR;AAAA,QACA;AAAA,UACE,OAAS,EAAA,QAAA;AAAA,UACT,IAAM,EAAA,kBAAA;AAAA,UACN,KAAO,EAAA,SAAA;AAAA,UACP,OAAS,EAAA;AAAA;AACX,OACF;AAAA,MACA,WAAA,EAAa,MAAM,WAAA,CAAY,IAAI;AAAA;AACrC,GACF;AACA,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,uBAAA;AAAA,IAAA;AAAA,MACC,+BAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,gBAAA;AAAA,QAAA;AAAA,UACC,aAAe,EAAA,yBAAA;AAAA,UACf,EAAA,EAAI,EAAE,EAAA,EAAI,CAAE;AAAA;AAAA,OAEd,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,SAAQ,EAAI,EAAA,EAAE,UAAY,EAAA,GAAA,EAAK,EAAI,EAAA,CAAA,EACpD,EAAA,EAAA,IACH,CACA,kBAAA,KAAA,CAAA,aAAA;AAAA,QAAC,6BAAA;AAAA,QAAA;AAAA,UACC,EAAI,EAAA;AAAA,YACF,UAAY,EAAA,MAAA;AAAA,YACZ,OAAS,EAAA,SAAA;AAAA,YACT,YAAc,EAAA;AAAA;AAChB;AAAA,OAEJ,CAAA;AAAA,MAEF,YAAA;AAAA,MACA,WAAa,EAAA;AAAA,QACX,KAAO,EAAA,SAAA;AAAA,QACP,EAAI,EAAA;AAAA,UACF,OAAS,EAAA,MAAA;AAAA,UACT,UAAY,EAAA,QAAA;AAAA,UACZ,EAAI,EAAA;AAAA;AACN,OACF;AAAA,MACA,WAAa,EAAA,UAAA;AAAA,MACb,QAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"ProfileDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/ProfileDropdown.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, useRef, useState } from 'react';\nimport {\n identityApiRef,\n useApi,\n ProfileInfo,\n} from '@backstage/core-plugin-api';\nimport AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined';\nimport KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';\nimport Typography from '@mui/material/Typography';\nimport { lighten } from '@mui/material/styles';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { useProfileDropdownMountPoints } from '../../hooks/useProfileDropdownMountPoints';\nimport { ComponentType } from '../../types';\nimport { MenuSection } from './MenuSection';\nimport { useDropdownManager } from '../../hooks';\n\nexport const ProfileDropdown = () => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n\n const identityApi = useApi(identityApiRef);\n const [user, setUser] = useState<ProfileInfo>();\n const profileDropdownMountPoints = useProfileDropdownMountPoints();\n\n const headerRef = useRef<HTMLElement | null>(null);\n const [bgColor, setBgColor] = useState('#3C3F42');\n\n useEffect(() => {\n if (headerRef.current) {\n const computedStyle = window.getComputedStyle(headerRef.current);\n const baseColor = computedStyle.backgroundColor;\n setBgColor(lighten(baseColor, 0.2));\n }\n }, []);\n\n useEffect(() => {\n const container = document.getElementById('global-header');\n if (container) {\n const computedStyle = window.getComputedStyle(container);\n const baseColor = computedStyle.backgroundColor;\n setBgColor(lighten(baseColor, 0.2));\n }\n }, []);\n\n useEffect(() => {\n const fetchUser = async () => {\n const userProfile = await identityApi.getProfileInfo();\n setUser(userProfile);\n };\n\n fetchUser();\n }, [identityApi]);\n\n const menuItems = useMemo(() => {\n return (profileDropdownMountPoints ?? [])\n .map(mp => ({\n Component: mp.Component,\n type: mp.config?.type ?? ComponentType.LINK,\n icon: mp.config?.props?.icon ?? '',\n label: mp.config?.props?.title ?? '',\n link: mp.config?.props?.link ?? '',\n priority: mp.config?.priority ?? 0,\n }))\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }, [profileDropdownMountPoints]);\n\n if (menuItems.length === 0) {\n return null;\n }\n\n return (\n <HeaderDropdownComponent\n buttonContent={\n <>\n <AccountCircleOutlinedIcon fontSize=\"small\" sx={{ mx: 1 }} />\n <Typography variant=\"body2\" sx={{ fontWeight: 500, mx: 1 }}>\n {user?.displayName ?? 'Guest'}\n </Typography>\n <KeyboardArrowDownOutlinedIcon\n sx={{\n marginLeft: '1rem',\n bgcolor: bgColor,\n borderRadius: '25%',\n }}\n />\n </>\n }\n buttonProps={{\n color: 'inherit',\n sx: {\n display: 'flex',\n alignItems: 'center',\n },\n }}\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n <MenuSection hideDivider items={menuItems} handleClose={handleClose} />\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AAgCO,MAAM,kBAAkB,MAAM;AACnC,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AAEjE,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA;AACzC,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAsB,EAAA;AAC9C,EAAA,MAAM,6BAA6B,6BAA8B,EAAA;AAEjE,EAAM,MAAA,SAAA,GAAY,OAA2B,IAAI,CAAA;AACjD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,SAAS,CAAA;AAEhD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,UAAU,OAAS,EAAA;AACrB,MAAA,MAAM,aAAgB,GAAA,MAAA,CAAO,gBAAiB,CAAA,SAAA,CAAU,OAAO,CAAA;AAC/D,MAAA,MAAM,YAAY,aAAc,CAAA,eAAA;AAChC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E;AAEJ;;;;"}
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { MenuSection } from './MenuSection.esm.js';
3
+ import { MenuItemLink } from '../MenuItemLink/MenuItemLink.esm.js';
4
+ import { ComponentType } from '../../types.esm.js';
5
+
6
+ const RegisterAComponentSection = ({
7
+ hideDivider,
8
+ handleClose
9
+ }) => {
10
+ return /* @__PURE__ */ React.createElement(
11
+ MenuSection,
12
+ {
13
+ hideDivider,
14
+ items: [
15
+ {
16
+ type: ComponentType.LINK,
17
+ label: "Register a component",
18
+ subLabel: "Import it to the catalog page",
19
+ link: "/catalog-import",
20
+ icon: "category",
21
+ Component: MenuItemLink
22
+ }
23
+ ],
24
+ handleClose
25
+ }
26
+ );
27
+ };
28
+
29
+ export { RegisterAComponentSection };
30
+ //# sourceMappingURL=RegisterAComponentSection.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RegisterAComponentSection.esm.js","sources":["../../../src/components/HeaderDropdownComponent/RegisterAComponentSection.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 { MenuSection } from './MenuSection';\nimport { MenuItemLink } from '../MenuItemLink/MenuItemLink';\nimport { ComponentType } from '../../types';\n\n/**\n * Register A Component Section properties\n *\n * @public\n */\nexport type RegisterAComponentSectionProps = {\n hideDivider: boolean;\n handleClose: () => void;\n};\n\nexport const RegisterAComponentSection = ({\n hideDivider,\n handleClose,\n}: RegisterAComponentSectionProps) => {\n return (\n <MenuSection\n hideDivider={hideDivider}\n items={[\n {\n type: ComponentType.LINK,\n label: 'Register a component',\n subLabel: 'Import it to the catalog page',\n link: '/catalog-import',\n icon: 'category',\n Component: MenuItemLink as React.ComponentType,\n },\n ]}\n handleClose={handleClose}\n />\n );\n};\n"],"names":[],"mappings":";;;;;AA+BO,MAAM,4BAA4B,CAAC;AAAA,EACxC,WAAA;AAAA,EACA;AACF,CAAsC,KAAA;AACpC,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,WAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACL;AAAA,UACE,MAAM,aAAc,CAAA,IAAA;AAAA,UACpB,KAAO,EAAA,sBAAA;AAAA,UACP,QAAU,EAAA,+BAAA;AAAA,UACV,IAAM,EAAA,iBAAA;AAAA,UACN,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA;AAAA;AACb,OACF;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -0,0 +1,70 @@
1
+ import React, { useState, useEffect, useMemo } from 'react';
2
+ import { useApi } from '@backstage/core-plugin-api';
3
+ import { catalogApiRef } from '@backstage/plugin-catalog-react';
4
+ import Box from '@mui/material/Box';
5
+ import Divider from '@mui/material/Divider';
6
+ import Typography from '@mui/material/Typography';
7
+ import { MenuSection } from './MenuSection.esm.js';
8
+ import { MenuItemLink } from '../MenuItemLink/MenuItemLink.esm.js';
9
+ import { ComponentType } from '../../types.esm.js';
10
+
11
+ const SoftwareTemplatesSection = ({
12
+ handleClose,
13
+ hideDivider
14
+ }) => {
15
+ const catalogApi = useApi(catalogApiRef);
16
+ const [entities, setEntities] = useState([]);
17
+ const [_loading, setLoading] = useState(true);
18
+ const [error, setError] = useState(null);
19
+ useEffect(() => {
20
+ const fetchEntities = async () => {
21
+ try {
22
+ const response = await catalogApi.getEntities({
23
+ filter: { kind: ["Template"] },
24
+ limit: 7
25
+ });
26
+ setEntities(response.items);
27
+ } catch (err) {
28
+ setError(err);
29
+ } finally {
30
+ setLoading(false);
31
+ }
32
+ };
33
+ fetchEntities();
34
+ }, [catalogApi]);
35
+ const items = useMemo(() => {
36
+ return entities.filter((e) => e.kind === "Template").map((m) => ({
37
+ Component: MenuItemLink,
38
+ type: ComponentType.LINK,
39
+ label: m.metadata.title ?? m.metadata.name,
40
+ link: `/create/templates/default/${m.metadata.name}`
41
+ }));
42
+ }, [entities]);
43
+ if (error) {
44
+ return /* @__PURE__ */ React.createElement(Box, { display: "flex", justifyContent: "center", alignItems: "center", p: 2 }, /* @__PURE__ */ React.createElement(Typography, { variant: "body1", color: "error" }, "Error fetching templates"));
45
+ }
46
+ if (items.length === 0) {
47
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(
48
+ Typography,
49
+ {
50
+ variant: "body2",
51
+ sx: { mx: 2, my: 1, color: "text.disabled" }
52
+ },
53
+ "No templates available"
54
+ ), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { my: 0.5 } }));
55
+ }
56
+ return /* @__PURE__ */ React.createElement(
57
+ MenuSection,
58
+ {
59
+ hideDivider,
60
+ sectionLabel: "Use a template",
61
+ optionalLink: "/create",
62
+ optionalLinkLabel: "All templates",
63
+ items,
64
+ handleClose
65
+ }
66
+ );
67
+ };
68
+
69
+ export { SoftwareTemplatesSection };
70
+ //# sourceMappingURL=SoftwareTemplatesSection.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SoftwareTemplatesSection.esm.js","sources":["../../../src/components/HeaderDropdownComponent/SoftwareTemplatesSection.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';\n\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\n\nimport Box from '@mui/material/Box';\nimport Divider from '@mui/material/Divider';\nimport Typography from '@mui/material/Typography';\n\nimport { MenuSection } from './MenuSection';\nimport { MenuItemLink } from '../MenuItemLink/MenuItemLink';\nimport { ComponentType } from '../../types';\n\n/**\n * Software Templates Section properties\n *\n * @public\n */\nexport type SoftwareTemplatesSectionProps = {\n handleClose: () => void;\n hideDivider?: boolean;\n};\n\nexport const SoftwareTemplatesSection = ({\n handleClose,\n hideDivider,\n}: SoftwareTemplatesSectionProps) => {\n const catalogApi = useApi(catalogApiRef);\n\n const [entities, setEntities] = useState<Entity[]>([]);\n // TODO: handle loading\n const [_loading, setLoading] = useState(true);\n const [error, setError] = useState(null);\n\n useEffect(() => {\n const fetchEntities = async () => {\n try {\n const response = await catalogApi.getEntities({\n filter: { kind: ['Template'] },\n limit: 7,\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: MenuItemLink 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 if (error) {\n return (\n <Box display=\"flex\" justifyContent=\"center\" alignItems=\"center\" p={2}>\n <Typography variant=\"body1\" color=\"error\">\n Error fetching templates\n </Typography>\n </Box>\n );\n }\n\n if (items.length === 0) {\n return (\n <>\n <Typography\n variant=\"body2\"\n sx={{ mx: 2, my: 1, color: 'text.disabled' }}\n >\n No templates available\n </Typography>\n {!hideDivider && <Divider sx={{ my: 0.5 }} />}\n </>\n );\n }\n return (\n <MenuSection\n hideDivider={hideDivider}\n sectionLabel=\"Use a template\"\n optionalLink=\"/create\"\n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,MACtC,IAAM,EAAA,CAAA,0BAAA,EAA6B,CAAE,CAAA,QAAA,CAAS,IAAI,CAAA;AAAA,KAClD,CAAA,CAAA;AAAA,GACN,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEb,EAAA,IAAI,KAAO,EAAA;AACT,IAAA,2CACG,GAAI,EAAA,EAAA,OAAA,EAAQ,MAAO,EAAA,cAAA,EAAe,UAAS,UAAW,EAAA,QAAA,EAAS,CAAG,EAAA,CAAA,EAAA,sCAChE,UAAW,EAAA,EAAA,OAAA,EAAQ,SAAQ,KAAM,EAAA,OAAA,EAAA,EAAQ,0BAE1C,CACF,CAAA;AAAA;AAIJ,EAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACtB,IAAA,uBAEI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,OAAQ,EAAA,OAAA;AAAA,QACR,IAAI,EAAE,EAAA,EAAI,GAAG,EAAI,EAAA,CAAA,EAAG,OAAO,eAAgB;AAAA,OAAA;AAAA,MAC5C;AAAA,KAED,EACC,CAAC,WAAA,oBAAgB,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,IAAI,EAAE,EAAA,EAAI,GAAI,EAAA,EAAG,CAC7C,CAAA;AAAA;AAGJ,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,WAAA;AAAA,MACA,YAAa,EAAA,gBAAA;AAAA,MACb,YAAa,EAAA,SAAA;AAAA,MACb,iBAAkB,EAAA,eAAA;AAAA,MAClB,KAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -0,0 +1,38 @@
1
+ import React from 'react';
2
+ import { useApp } from '@backstage/core-plugin-api';
3
+ import MuiIcon from '@mui/material/Icon';
4
+ import Box from '@mui/material/Box';
5
+
6
+ const HeaderIcon = ({
7
+ icon,
8
+ size = "small",
9
+ styles
10
+ }) => {
11
+ const app = useApp();
12
+ if (!icon) {
13
+ return null;
14
+ }
15
+ const SystemIcon = app.getSystemIcon(icon);
16
+ if (SystemIcon) {
17
+ return /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex", alignItems: "center", ...styles } }, /* @__PURE__ */ React.createElement(SystemIcon, { fontSize: size }));
18
+ }
19
+ if (icon.startsWith("<svg")) {
20
+ const svgDataUri = `data:image/svg+xml;base64,${btoa(icon)}`;
21
+ return /* @__PURE__ */ React.createElement(MuiIcon, { fontSize: size, sx: { ...styles } }, /* @__PURE__ */ React.createElement("img", { src: svgDataUri, alt: "" }));
22
+ }
23
+ if (icon.startsWith("https://") || icon.startsWith("http://") || icon.startsWith("/")) {
24
+ return /* @__PURE__ */ React.createElement(
25
+ MuiIcon,
26
+ {
27
+ fontSize: size,
28
+ sx: styles,
29
+ baseClassName: "material-icons-outlined"
30
+ },
31
+ /* @__PURE__ */ React.createElement("img", { src: icon, alt: "" })
32
+ );
33
+ }
34
+ return /* @__PURE__ */ React.createElement(MuiIcon, { fontSize: size, baseClassName: "material-icons-outlined" }, icon);
35
+ };
36
+
37
+ export { HeaderIcon };
38
+ //# sourceMappingURL=HeaderIcon.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderIcon.esm.js","sources":["../../../src/components/HeaderIcon/HeaderIcon.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 */\nimport React from 'react';\nimport { useApp } from '@backstage/core-plugin-api';\nimport MuiIcon from '@mui/material/Icon';\nimport Box from '@mui/material/Box';\n\n/**\n * @public\n */\nexport interface HeaderIconProps {\n icon: string;\n size?: 'small' | 'medium' | 'large';\n styles?: React.CSSProperties;\n}\n\n/**\n * @public\n */\nexport const HeaderIcon = ({\n icon,\n size = 'small',\n styles,\n}: HeaderIconProps) => {\n const app = useApp();\n if (!icon) {\n return null;\n }\n\n const SystemIcon = app.getSystemIcon(icon);\n if (SystemIcon) {\n return (\n <Box sx={{ display: 'flex', alignItems: 'center', ...styles }}>\n <SystemIcon fontSize={size} />\n </Box>\n );\n }\n\n if (icon.startsWith('<svg')) {\n const svgDataUri = `data:image/svg+xml;base64,${btoa(icon)}`;\n return (\n <MuiIcon fontSize={size} sx={{ ...styles }}>\n <img src={svgDataUri} alt=\"\" />\n </MuiIcon>\n );\n }\n\n if (\n icon.startsWith('https://') ||\n icon.startsWith('http://') ||\n icon.startsWith('/')\n ) {\n return (\n <MuiIcon\n fontSize={size}\n sx={styles}\n baseClassName=\"material-icons-outlined\"\n >\n <img src={icon} alt=\"\" />\n </MuiIcon>\n );\n }\n\n return (\n <MuiIcon fontSize={size} baseClassName=\"material-icons-outlined\">\n {icon}\n </MuiIcon>\n );\n};\n"],"names":[],"mappings":";;;;;AAgCO,MAAM,aAAa,CAAC;AAAA,EACzB,IAAA;AAAA,EACA,IAAO,GAAA,OAAA;AAAA,EACP;AACF,CAAuB,KAAA;AACrB,EAAA,MAAM,MAAM,MAAO,EAAA;AACnB,EAAA,IAAI,CAAC,IAAM,EAAA;AACT,IAAO,OAAA,IAAA;AAAA;AAGT,EAAM,MAAA,UAAA,GAAa,GAAI,CAAA,aAAA,CAAc,IAAI,CAAA;AACzC,EAAA,IAAI,UAAY,EAAA;AACd,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,EAAI,EAAA,EAAE,SAAS,MAAQ,EAAA,UAAA,EAAY,QAAU,EAAA,GAAG,QACnD,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,QAAA,EAAU,MAAM,CAC9B,CAAA;AAAA;AAIJ,EAAI,IAAA,IAAA,CAAK,UAAW,CAAA,MAAM,CAAG,EAAA;AAC3B,IAAA,MAAM,UAAa,GAAA,CAAA,0BAAA,EAA6B,IAAK,CAAA,IAAI,CAAC,CAAA,CAAA;AAC1D,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,QAAU,EAAA,IAAA,EAAM,IAAI,EAAE,GAAG,MAAO,EAAA,EAAA,sCACtC,KAAI,EAAA,EAAA,GAAA,EAAK,UAAY,EAAA,GAAA,EAAI,IAAG,CAC/B,CAAA;AAAA;AAIJ,EACE,IAAA,IAAA,CAAK,UAAW,CAAA,UAAU,CAC1B,IAAA,IAAA,CAAK,UAAW,CAAA,SAAS,CACzB,IAAA,IAAA,CAAK,UAAW,CAAA,GAAG,CACnB,EAAA;AACA,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,OAAA;AAAA,MAAA;AAAA,QACC,QAAU,EAAA,IAAA;AAAA,QACV,EAAI,EAAA,MAAA;AAAA,QACJ,aAAc,EAAA;AAAA,OAAA;AAAA,sBAEb,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAI,GAAK,EAAA,IAAA,EAAM,KAAI,EAAG,EAAA;AAAA,KACzB;AAAA;AAIJ,EAAA,2CACG,OAAQ,EAAA,EAAA,QAAA,EAAU,IAAM,EAAA,aAAA,EAAc,6BACpC,IACH,CAAA;AAEJ;;;;"}
@@ -1,21 +1,36 @@
1
1
  import React from 'react';
2
+ import { Link as Link$1 } from '@backstage/core-components';
2
3
  import IconButton from '@mui/material/IconButton';
3
- import SmallIconWrapper from './SmallIconWrapper.esm.js';
4
+ import Tooltip from '@mui/material/Tooltip';
5
+ import { HeaderIcon } from '../HeaderIcon/HeaderIcon.esm.js';
4
6
 
7
+ const Link = (props) => /* @__PURE__ */ React.createElement(Link$1, { ...props, color: "inherit", externalLinkIcon: false });
5
8
  const HeaderIconButton = ({
6
- Icon,
7
- onClick
9
+ title,
10
+ icon,
11
+ tooltip,
12
+ color = "inherit",
13
+ size = "small",
14
+ ariaLabel,
15
+ to,
16
+ style
8
17
  }) => {
9
- return /* @__PURE__ */ React.createElement(
18
+ if (!title) {
19
+ console.warn("HeaderIconButton has no title:", { icon, to });
20
+ }
21
+ const linkProps = { to };
22
+ return /* @__PURE__ */ React.createElement(Tooltip, { title: tooltip ?? title }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
10
23
  IconButton,
11
24
  {
12
- color: "inherit",
13
- "aria-label": "help",
14
- sx: { mr: 1.5 },
15
- onClick
25
+ LinkComponent: Link,
26
+ color,
27
+ size,
28
+ "aria-label": ariaLabel ?? title,
29
+ ...linkProps,
30
+ sx: style
16
31
  },
17
- /* @__PURE__ */ React.createElement(SmallIconWrapper, { IconComponent: Icon })
18
- );
32
+ /* @__PURE__ */ React.createElement(HeaderIcon, { icon, size })
33
+ )));
19
34
  };
20
35
 
21
36
  export { HeaderIconButton };
@@ -1 +1 @@
1
- {"version":3,"file":"HeaderIconButton.esm.js","sources":["../../../src/components/HeaderIconButton/HeaderIconButton.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 IconButton from '@mui/material/IconButton';\nimport SmallIconWrapper, { IconComponentType } from './SmallIconWrapper';\n\ninterface HeaderIconButtonProps {\n Icon: IconComponentType;\n onClick: () => void;\n}\n\nexport const HeaderIconButton: React.FC<HeaderIconButtonProps> = ({\n Icon,\n onClick,\n}) => {\n return (\n <IconButton\n color=\"inherit\"\n aria-label=\"help\"\n sx={{ mr: 1.5 }}\n onClick={onClick}\n >\n <SmallIconWrapper IconComponent={Icon} />\n </IconButton>\n );\n};\n"],"names":[],"mappings":";;;;AAyBO,MAAM,mBAAoD,CAAC;AAAA,EAChE,IAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAM,EAAA,SAAA;AAAA,MACN,YAAW,EAAA,MAAA;AAAA,MACX,EAAA,EAAI,EAAE,EAAA,EAAI,GAAI,EAAA;AAAA,MACd;AAAA,KAAA;AAAA,oBAEA,KAAA,CAAA,aAAA,CAAC,gBAAiB,EAAA,EAAA,aAAA,EAAe,IAAM,EAAA;AAAA,GACzC;AAEJ;;;;"}
1
+ {"version":3,"file":"HeaderIconButton.esm.js","sources":["../../../src/components/HeaderIconButton/HeaderIconButton.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 { Link as BackstageLink } from '@backstage/core-components';\n\nimport IconButton, { IconButtonProps } from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\n\nimport { HeaderIcon } from '../HeaderIcon/HeaderIcon';\n\n/**\n * @public\n */\nexport interface HeaderIconButtonProps {\n title: string;\n icon: string;\n tooltip?: string;\n color?: 'inherit' | 'primary' | 'secondary' | 'default';\n size?: 'small' | 'medium' | 'large';\n ariaLabel?: string;\n to: string;\n style?: React.CSSProperties;\n}\n\n// Backstage Link automatically detects external links and emits analytic events.\nconst Link = (props: any) => (\n <BackstageLink {...props} color=\"inherit\" externalLinkIcon={false} />\n);\n\nexport const HeaderIconButton = ({\n title,\n icon,\n tooltip,\n color = 'inherit',\n size = 'small',\n ariaLabel,\n to,\n style,\n}: HeaderIconButtonProps) => {\n if (!title) {\n // eslint-disable-next-line no-console\n console.warn('HeaderIconButton has no title:', { icon, to });\n }\n\n const linkProps = { to } as IconButtonProps;\n\n return (\n <Tooltip title={tooltip ?? title}>\n <div>\n <IconButton\n LinkComponent={Link}\n color={color}\n size={size}\n aria-label={ariaLabel ?? title}\n {...linkProps} // to={to} isn't supported\n sx={style}\n >\n <HeaderIcon icon={icon} size={size} />\n </IconButton>\n </div>\n </Tooltip>\n );\n};\n"],"names":["BackstageLink"],"mappings":";;;;;;AAwCA,MAAM,IAAA,GAAO,CAAC,KAAA,qBACX,KAAA,CAAA,aAAA,CAAAA,MAAA,EAAA,EAAe,GAAG,KAAO,EAAA,KAAA,EAAM,SAAU,EAAA,gBAAA,EAAkB,KAAO,EAAA,CAAA;AAG9D,MAAM,mBAAmB,CAAC;AAAA,EAC/B,KAAA;AAAA,EACA,IAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAQ,GAAA,SAAA;AAAA,EACR,IAAO,GAAA,OAAA;AAAA,EACP,SAAA;AAAA,EACA,EAAA;AAAA,EACA;AACF,CAA6B,KAAA;AAC3B,EAAA,IAAI,CAAC,KAAO,EAAA;AAEV,IAAA,OAAA,CAAQ,IAAK,CAAA,gCAAA,EAAkC,EAAE,IAAA,EAAM,IAAI,CAAA;AAAA;AAG7D,EAAM,MAAA,SAAA,GAAY,EAAE,EAAG,EAAA;AAEvB,EAAA,2CACG,OAAQ,EAAA,EAAA,KAAA,EAAO,OAAW,IAAA,KAAA,EAAA,sCACxB,KACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,aAAe,EAAA,IAAA;AAAA,MACf,KAAA;AAAA,MACA,IAAA;AAAA,MACA,cAAY,SAAa,IAAA,KAAA;AAAA,MACxB,GAAG,SAAA;AAAA,MACJ,EAAI,EAAA;AAAA,KAAA;AAAA,oBAEJ,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,IAAA,EAAY,IAAY,EAAA;AAAA,GAExC,CACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import { useApi, errorApiRef, identityApiRef } from '@backstage/core-plugin-api';
3
+ import Box from '@mui/material/Box';
4
+ import { MenuItemLinkContent } from '../MenuItemLink/MenuItemLinkContent.esm.js';
5
+
6
+ const LogoutButton = () => {
7
+ const errorApi = useApi(errorApiRef);
8
+ const identityApi = useApi(identityApiRef);
9
+ const handleLogout = () => {
10
+ identityApi.signOut().catch((error) => errorApi.post(error));
11
+ };
12
+ return /* @__PURE__ */ React.createElement(
13
+ Box,
14
+ {
15
+ onClick: handleLogout,
16
+ sx: { cursor: "pointer", width: "100%", color: "inherit" }
17
+ },
18
+ /* @__PURE__ */ React.createElement(MenuItemLinkContent, { icon: "logout", label: "Logout" })
19
+ );
20
+ };
21
+
22
+ export { LogoutButton };
23
+ //# sourceMappingURL=LogoutButton.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LogoutButton.esm.js","sources":["../../../src/components/LogoutButton/LogoutButton.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 {\n errorApiRef,\n identityApiRef,\n useApi,\n} from '@backstage/core-plugin-api';\n\nimport Box from '@mui/material/Box';\n\nimport { MenuItemLinkContent } from '../MenuItemLink/MenuItemLinkContent';\n\nexport const LogoutButton = () => {\n const errorApi = useApi(errorApiRef);\n const identityApi = useApi(identityApiRef);\n\n const handleLogout = () => {\n identityApi.signOut().catch(error => errorApi.post(error));\n };\n\n // TODO switch to Button\n return (\n <Box\n onClick={handleLogout}\n sx={{ cursor: 'pointer', width: '100%', color: 'inherit' }}\n >\n <MenuItemLinkContent icon=\"logout\" label=\"Logout\" />\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;AA4BO,MAAM,eAAe,MAAM;AAChC,EAAM,MAAA,QAAA,GAAW,OAAO,WAAW,CAAA;AACnC,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA;AAEzC,EAAA,MAAM,eAAe,MAAM;AACzB,IAAA,WAAA,CAAY,SAAU,CAAA,KAAA,CAAM,WAAS,QAAS,CAAA,IAAA,CAAK,KAAK,CAAC,CAAA;AAAA,GAC3D;AAGA,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,OAAS,EAAA,YAAA;AAAA,MACT,IAAI,EAAE,MAAA,EAAQ,WAAW,KAAO,EAAA,MAAA,EAAQ,OAAO,SAAU;AAAA,KAAA;AAAA,oBAExD,KAAA,CAAA,aAAA,CAAA,mBAAA,EAAA,EAAoB,IAAK,EAAA,QAAA,EAAS,OAAM,QAAS,EAAA;AAAA,GACpD;AAEJ;;;;"}
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import Tooltip from '@mui/material/Tooltip';
3
+ import { Link } from 'react-router-dom';
4
+ import { MenuItemLinkContent } from './MenuItemLinkContent.esm.js';
5
+
6
+ const MenuItemLink = ({
7
+ to,
8
+ title,
9
+ subTitle,
10
+ icon,
11
+ tooltip
12
+ }) => {
13
+ const headerLinkContent = () => /* @__PURE__ */ React.createElement(
14
+ Link,
15
+ {
16
+ to,
17
+ style: {
18
+ color: "inherit",
19
+ textDecoration: "none",
20
+ width: "100%"
21
+ }
22
+ },
23
+ /* @__PURE__ */ React.createElement(MenuItemLinkContent, { icon, label: title, subLabel: subTitle })
24
+ );
25
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, tooltip && /* @__PURE__ */ React.createElement(Tooltip, { title: tooltip }, /* @__PURE__ */ React.createElement("div", null, headerLinkContent())), !tooltip && headerLinkContent());
26
+ };
27
+
28
+ export { MenuItemLink };
29
+ //# sourceMappingURL=MenuItemLink.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MenuItemLink.esm.js","sources":["../../../src/components/MenuItemLink/MenuItemLink.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 Tooltip from '@mui/material/Tooltip';\nimport { Link } from 'react-router-dom';\nimport { MenuItemLinkContent } from './MenuItemLinkContent';\n\n/**\n * Header Icon Button properties\n * @public\n */\nexport interface MenuItemLinkProps {\n to: string;\n title?: string;\n subTitle?: string;\n icon?: string;\n tooltip?: string;\n}\n\nexport const MenuItemLink = ({\n to,\n title,\n subTitle,\n icon,\n tooltip,\n}: MenuItemLinkProps) => {\n const headerLinkContent = () => (\n <Link\n to={to}\n style={{\n color: 'inherit',\n textDecoration: 'none',\n width: '100%',\n }}\n >\n <MenuItemLinkContent icon={icon} label={title} subLabel={subTitle} />\n </Link>\n );\n return (\n <>\n {tooltip && (\n <Tooltip title={tooltip}>\n <div>{headerLinkContent()}</div>\n </Tooltip>\n )}\n {!tooltip && headerLinkContent()}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;AAiCO,MAAM,eAAe,CAAC;AAAA,EAC3B,EAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAyB,KAAA;AACvB,EAAA,MAAM,oBAAoB,sBACxB,KAAA,CAAA,aAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,EAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACL,KAAO,EAAA,SAAA;AAAA,QACP,cAAgB,EAAA,MAAA;AAAA,QAChB,KAAO,EAAA;AAAA;AACT,KAAA;AAAA,wCAEC,mBAAoB,EAAA,EAAA,IAAA,EAAY,KAAO,EAAA,KAAA,EAAO,UAAU,QAAU,EAAA;AAAA,GACrE;AAEF,EAAA,uBAEK,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAA,OAAA,oBACE,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,OAAO,OACd,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,KAAK,EAAA,IAAA,EAAA,iBAAA,EAAoB,CAC5B,CAAA,EAED,CAAC,OAAA,IAAW,mBACf,CAAA;AAEJ;;;;"}