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

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 (52) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/app-config.dynamic.yaml +71 -0
  3. package/dist/components/GlobalHeader.esm.js +75 -61
  4. package/dist/components/GlobalHeader.esm.js.map +1 -1
  5. package/dist/components/HeaderButtonComponent/HeaderButton.esm.js +17 -0
  6. package/dist/components/HeaderButtonComponent/HeaderButton.esm.js.map +1 -0
  7. package/dist/components/HeaderButtonComponent/LogoutButton.esm.js +15 -0
  8. package/dist/components/HeaderButtonComponent/LogoutButton.esm.js.map +1 -0
  9. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js +61 -56
  10. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js.map +1 -1
  11. package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js +2 -49
  12. package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js.map +1 -1
  13. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js +11 -22
  14. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
  15. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +36 -42
  16. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
  17. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +29 -0
  18. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -0
  19. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +23 -0
  20. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -0
  21. package/dist/components/HeaderIconButtonComponent/HeaderIcon.esm.js +33 -0
  22. package/dist/components/HeaderIconButtonComponent/HeaderIcon.esm.js.map +1 -0
  23. package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js +25 -0
  24. package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js.map +1 -0
  25. package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js +19 -0
  26. package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js.map +1 -0
  27. package/dist/components/HeaderLinkComponent/HeaderLink.esm.js +29 -0
  28. package/dist/components/HeaderLinkComponent/HeaderLink.esm.js.map +1 -0
  29. package/dist/components/NotificationBanner.esm.js +66 -0
  30. package/dist/components/NotificationBanner.esm.js.map +1 -0
  31. package/dist/components/SearchComponent/SearchBar.esm.js +1 -1
  32. package/dist/components/SearchComponent/SearchBar.esm.js.map +1 -1
  33. package/dist/hooks/useCreateDropdownMountPoints.esm.js +10 -0
  34. package/dist/hooks/useCreateDropdownMountPoints.esm.js.map +1 -0
  35. package/dist/hooks/useGlobalHeaderMountPoints.esm.js +10 -0
  36. package/dist/hooks/useGlobalHeaderMountPoints.esm.js.map +1 -0
  37. package/dist/hooks/useProfileDropdownMountPoints.esm.js +10 -0
  38. package/dist/hooks/useProfileDropdownMountPoints.esm.js.map +1 -0
  39. package/dist/index.d.ts +155 -5
  40. package/dist/index.esm.js +1 -1
  41. package/dist/index.esm.js.map +1 -1
  42. package/dist/plugin.esm.js +85 -1
  43. package/dist/plugin.esm.js.map +1 -1
  44. package/dist/types.esm.js +17 -0
  45. package/dist/types.esm.js.map +1 -0
  46. package/package.json +27 -16
  47. package/dist/components/HeaderDropdownComponent/MenuItemContent.esm.js +0 -15
  48. package/dist/components/HeaderDropdownComponent/MenuItemContent.esm.js.map +0 -1
  49. package/dist/components/HeaderIconButton/HeaderIconButton.esm.js +0 -22
  50. package/dist/components/HeaderIconButton/HeaderIconButton.esm.js.map +0 -1
  51. package/dist/components/HeaderIconButton/SmallIconWrapper.esm.js +0 -11
  52. package/dist/components/HeaderIconButton/SmallIconWrapper.esm.js.map +0 -1
@@ -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 MenuItem from '@mui/material/MenuItem';\nimport Button from '@mui/material/Button';\nimport Typography from '@mui/material/Typography';\nimport { Link } from '@backstage/core-components';\nimport { styled } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\nimport MenuSection, { MenuItemConfig, MenuSectionConfig } from './MenuSection';\n\ninterface HeaderDropdownProps {\n buttonContent: 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 menuSections = [],\n menuBottomItems = [],\n buttonProps,\n buttonClick,\n anchorEl,\n setAnchorEl,\n}) => {\n const shouldHideDivider = (index: number) =>\n menuSections.length === 1 &&\n index === menuSections.length - 1 &&\n menuBottomItems.length === 0;\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\">\n {menuSections.map((section, index) => (\n <MenuSection\n key={`menu-section-${section.sectionKey}`}\n {...{ hideDivider: shouldHideDivider(index), ...section }}\n handleClose={section.handleClose}\n />\n ))}\n {menuBottomItems.map(\n ({ itemKey, icon: Icon, label, subLabel, link }) => (\n <MenuItem\n key={`menu-item-${itemKey}`}\n sx={{ my: '8px', '&:hover': { background: 'transparent' } }}\n onClick={() => setAnchorEl(null)}\n disableRipple\n >\n {link && (\n <Link\n to={link}\n style={{\n display: 'flex',\n color: 'inherit',\n alignItems: 'center',\n textDecoration: 'none',\n }}\n >\n {Icon && (\n <Icon\n fontSize=\"small\"\n style={{\n marginRight: '0.5rem',\n flexShrink: 0,\n color: 'slategray',\n }}\n />\n )}\n <Box>\n <Typography variant=\"body2\">{label}</Typography>\n {subLabel && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {subLabel}\n </Typography>\n )}\n </Box>\n </Link>\n )}\n </MenuItem>\n ),\n )}\n </Listbox>\n </Menu>\n </Box>\n );\n};\n\nexport default HeaderDropdownComponent;\n"],"names":[],"mappings":";;;;;;;;;;AAoCA,MAAM,OAAA,GAAU,OAAO,IAAI,CAAA;AAAA,EACzB,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AA,SAAA;AAAA,QAEZ,IACC,oBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,IAAA;AAAA,UAAA;AAAA,YACC,EAAI,EAAA,IAAA;AAAA,YACJ,KAAO,EAAA;AAAA,cACL,OAAS,EAAA,MAAA;AAAA,cACT,KAAO,EAAA,SAAA;AAAA,cACP,UAAY,EAAA,QAAA;AAAA,cACZ,cAAgB,EAAA;AAAA;AAClB,WAAA;AAAA,UAEC,IACC,oBAAA,KAAA,CAAA,aAAA;AAAA,YAAC,IAAA;AAAA,YAAA;AAAA,cACC,QAAS,EAAA,OAAA;AAAA,cACT,KAAO,EAAA;AAAA,gBACL,WAAa,EAAA,QAAA;AAAA,gBACb,UAAY,EAAA,CAAA;AAAA,gBACZ,KAAO,EAAA;AAAA;AACT;AAAA,WACF;AAAA,8CAED,GACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,WAAS,KAAM,CAAA,EAClC,QACC,oBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,SAAA,EAAU,KAAM,EAAA,gBAAA,EAAA,EACjC,QACH,CAEJ;AAAA;AACF;AAEJ,KAGN;AAAA,GAEJ,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 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};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AAA,IAAA;AAAA,MACX,IAAA,EAAM,QAAQ,QAAQ,CAAA;AAAA,MACtB,OAAA,EAAS,MAAM,WAAA,CAAY,IAAI,CAAA;AAAA,MAC/B,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;;;;"}
@@ -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: {
@@ -47,34 +45,25 @@ 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
- )
62
+ title: label,
63
+ subTitle: subLabel
64
+ }
65
+ ),
66
+ type === "logout" && /* @__PURE__ */ React.createElement(Component, null)
78
67
  ))), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { margin: "8px 0" } }));
79
68
 
80
69
  export { MenuSection as default };
@@ -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,eAAgB,EAAA,EAAA,EAC7D,YACH,CAAA;AAAA,kBACA,KAAA,CAAA,aAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,SAAA,EAAW,EAAE,UAAA,EAAY,aAAc;AAAA,OACzC;AAAA,MACA,aAAa,EAAA,IAAA;AAAA,MACb,kBAAkB,EAAA,IAAA;AAAA,MAClB,OAAS,EAAA;AAAA,KAAA;AAAA,IAER,gBAAgB,iBACf,oBAAA,KA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AA,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 { HeaderLinkProps } from '../HeaderLinkComponent/HeaderLink';\n\n/**\n * Menu item configuration\n *\n * @public\n */\nexport interface MenuItemConfig {\n Component: React.ComponentType<HeaderLinkProps | {}>;\n type: string;\n label: string;\n icon?: string;\n subLabel?: string;\n link?: string;\n}\n\nexport interface MenuSectionConfig {\n sectionLabel?: string;\n optionalLink?: string;\n optionalLinkLabel?: string;\n items: MenuItemConfig[];\n hideDivider?: boolean;\n handleClose: () => void;\n}\n\nconst MenuSection: React.FC<MenuSectionConfig> = ({\n sectionLabel,\n optionalLink,\n optionalLinkLabel,\n items,\n hideDivider = false,\n handleClose,\n}) => (\n <Box>\n {sectionLabel && (\n <Box\n sx={{\n display: 'flex',\n justifyContent: 'space-between',\n alignItems: 'center',\n mx: 0,\n mt: '0.5rem',\n '&:hover': { background: 'transparent' },\n }}\n >\n <Typography variant=\"body2\" sx={{ pl: 2, color: 'text.disabled' }}>\n {sectionLabel}\n </Typography>\n <MenuItem\n sx={{\n '&:hover': { background: 'transparent' },\n }}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n >\n {optionalLink && optionalLinkLabel && (\n <Link\n to={optionalLink}\n underline=\"none\"\n style={{ fontSize: '0.875em' }}\n >\n {optionalLinkLabel}\n </Link>\n )}\n </MenuItem>\n </Box>\n )}\n <ul style={{ padding: 0, listStyle: 'none' }}>\n {items.map(({ type, icon, label, subLabel, link, Component }, index) => (\n <MenuItem\n key={`menu-item-${index.toString()}`}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n sx={{ py: 0.5, '&:hover': { background: 'transparent' } }}\n >\n {link && (\n <Component\n icon={icon}\n to={link}\n title={label}\n subTitle={subLabel}\n />\n )}\n {type === 'logout' && <Component />}\n </MenuItem>\n ))}\n </ul>\n {!hideDivider && <Divider sx={{ margin: '8px 0' }} />}\n </Box>\n);\n\nexport default MenuSection;\n"],"names":[],"mappings":";;;;;;;AA+CA,MAAM,cAA2C,CAAC;AAAA,EAChD,YAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAc,GAAA,KAAA;AAAA,EACd;AACF,CACE,qBAAA,KAAA,CAAA,aAAA,CAAC,WACE,YACC,oBAAA,KAAA,CAAA,aAAA;AAAA,EAAC,GAAA;AAAA,EAAA;AAAA,IACC,EAAI,EAAA;AAAA,MACF,OAAS,EAAA,MAAA;AAAA,MACT,cAAgB,EAAA,eAAA;AAAA,MAChB,UAAY,EAAA,QAAA;AAAA,MACZ,EAAI,EAAA,CAAA;AAAA,MACJ,EAAI,EAAA,QAAA;AAAA,MACJ,SAAA,EAAW,EAAE,UAAA,EAAY,aAAc;AAAA;AACzC,GAAA;AAAA,kBAEA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,OAAQ,EAAA,EAAA,EAAI,EAAE,EAAA,E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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,MAAA,EAAQ,OAAQ,EAAA,EAAG,CACrD;;;;"}
@@ -1,54 +1,42 @@
1
- import React from 'react';
1
+ import React, { useState, useEffect, useMemo } from 'react';
2
2
  import HeaderDropdownComponent from './HeaderDropdownComponent.esm.js';
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 { useApi, identityApiRef } from '@backstage/core-plugin-api';
7
+ import { useProfileDropdownMountPoints } from '../../hooks/useProfileDropdownMountPoints.esm.js';
8
+ import { ComponentType } from '../../types.esm.js';
9
+ import MenuSection from './MenuSection.esm.js';
10
10
 
11
11
  const ProfileDropdown = ({
12
12
  handleMenu,
13
13
  anchorEl,
14
14
  setAnchorEl
15
15
  }) => {
16
- const errorApi = useApi(errorApiRef);
17
16
  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)
40
- }
41
- ];
17
+ const [user, setUser] = useState();
18
+ const profileDropdownMountPoints = useProfileDropdownMountPoints();
19
+ useEffect(() => {
20
+ const fetchUser = async () => {
21
+ const userProfile = await identityApi.getProfileInfo();
22
+ setUser(userProfile);
23
+ };
24
+ fetchUser();
25
+ }, [identityApi]);
26
+ const menuItems = useMemo(() => {
27
+ return (profileDropdownMountPoints ?? []).map((mp) => ({
28
+ Component: mp.Component,
29
+ type: mp.config?.type ?? ComponentType.LINK,
30
+ icon: mp.config?.props?.icon ?? "",
31
+ label: mp.config?.props?.title ?? "",
32
+ link: mp.config?.props?.link ?? "",
33
+ priority: mp.config?.priority ?? 0
34
+ })).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
35
+ }, [profileDropdownMountPoints]);
42
36
  return /* @__PURE__ */ React.createElement(
43
37
  HeaderDropdownComponent,
44
38
  {
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(
39
+ 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
40
  KeyboardArrowDownOutlinedIcon,
53
41
  {
54
42
  sx: {
@@ -58,21 +46,27 @@ const ProfileDropdown = ({
58
46
  }
59
47
  }
60
48
  )),
61
- menuSections,
62
49
  buttonProps: {
63
50
  color: "inherit",
64
51
  sx: {
65
52
  display: "flex",
66
- alignItems: "center",
67
- ml: 1
53
+ alignItems: "center"
68
54
  }
69
55
  },
70
56
  buttonClick: handleMenu,
71
57
  anchorEl,
72
58
  setAnchorEl
73
- }
59
+ },
60
+ /* @__PURE__ */ React.createElement(
61
+ MenuSection,
62
+ {
63
+ hideDivider: true,
64
+ items: menuItems,
65
+ handleClose: () => setAnchorEl(null)
66
+ }
67
+ )
74
68
  );
75
69
  };
76
70
 
77
- export { ProfileDropdown as default };
71
+ export { ProfileDropdown, ProfileDropdown as default };
78
72
  //# 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;A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I,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, useState } from 'react';\nimport HeaderDropdownComponent from './HeaderDropdownComponent';\nimport AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined';\nimport KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';\nimport Typography from '@mui/material/Typography';\nimport {\n identityApiRef,\n useApi,\n ProfileInfo,\n} from '@backstage/core-plugin-api';\nimport { useProfileDropdownMountPoints } from '../../hooks/useProfileDropdownMountPoints';\nimport { ComponentType } from '../../types';\nimport MenuSection from './MenuSection';\n\n/**\n * @public\n * ProfileDropdown component properties\n */\nexport interface ProfileDropdownProps {\n handleMenu: (event: React.MouseEvent<HTMLElement>) => void;\n anchorEl: HTMLElement | null;\n setAnchorEl: React.Dispatch<React.SetStateAction<HTMLElement | null>>;\n}\n\nexport const ProfileDropdown = ({\n handleMenu,\n anchorEl,\n setAnchorEl,\n}: ProfileDropdownProps) => {\n const identityApi = useApi(identityApiRef);\n const [user, setUser] = useState<ProfileInfo>();\n const profileDropdownMountPoints = useProfileDropdownMountPoints();\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 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: '#383838',\n borderRadius: '25%',\n }}\n />\n </>\n }\n buttonProps={{\n color: 'inherit',\n sx: {\n display: 'flex',\n alignItems: 'center',\n },\n }}\n buttonClick={handleMenu}\n anchorEl={anchorEl}\n setAnchorEl={setAnchorEl}\n >\n <MenuSection\n hideDivider\n items={menuItems}\n handleClose={() => setAnchorEl(null)}\n />\n </HeaderDropdownComponent>\n );\n};\n\nexport default ProfileDropdown;\n"],"names":[],"mappings":";;;;;;;;;;AAwCO,MAAM,kBAAkB,CAAC;AAAA,EAC9B,UAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAA4B,KAAA;AAC1B,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,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,MAAM,YAAY,YAAY;AAC5B,MAAM,MAAA,WAAA,GAAc,MAAM,WAAA,CAAY,cAAe,EAAA;AACrD,MAAA,OAAA,CAAQ,WAAW,CAAA;AAAA,KACrB;AAEA,IAAU,SAAA,EAAA;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ACxB,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,WAAa,EAAA;AAAA,QACX,KAAO,EAAA,SAAA;AAAA,QACP,EAAI,EAAA;AAAA,UACF,OAAS,EAAA,MAAA;AAAA,UACT,UAAY,EAAA;AAAA;AACd,OACF;AAAA,MACA,WAAa,EAAA,UAAA;AAAA,MACb,QAAA;AAAA,MACA;AAAA,KAAA;AAAA,oBAEA,KAAA,CAAA,aAAA;AAAA,MAAC,WAAA;AAAA,MAAA;AAAA,QACC,WAAW,EAAA,IAAA;AAAA,QACX,KAAO,EAAA,SAAA;AAAA,QACP,WAAA,EAAa,MAAM,WAAA,CAAY,IAAI;AAAA;AAAA;AACrC,GACF;AAEJ;;;;"}
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import MenuSection from './MenuSection.esm.js';
3
+ import { HeaderLink } from '../HeaderLinkComponent/HeaderLink.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
+ link: "/catalog-import",
19
+ icon: "category",
20
+ Component: HeaderLink
21
+ }
22
+ ],
23
+ handleClose
24
+ }
25
+ );
26
+ };
27
+
28
+ export { RegisterAComponentSection };
29
+ //# 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 { HeaderLink } from '../HeaderLinkComponent/HeaderLink';\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 link: '/catalog-import',\n icon: 'category',\n Component: HeaderLink 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,IAAM,EAAA,iBAAA;AAAA,UACN,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA;AAAA;AACb,OACF;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -0,0 +1,23 @@
1
+ import React from 'react';
2
+ import MenuSection from './MenuSection.esm.js';
3
+
4
+ const SoftwareTemplatesSection = ({
5
+ items,
6
+ handleClose,
7
+ hideDivider
8
+ }) => {
9
+ return /* @__PURE__ */ React.createElement(
10
+ MenuSection,
11
+ {
12
+ hideDivider,
13
+ sectionLabel: "Use a template",
14
+ optionalLink: "/create",
15
+ optionalLinkLabel: "All templates",
16
+ items,
17
+ handleClose
18
+ }
19
+ );
20
+ };
21
+
22
+ export { SoftwareTemplatesSection };
23
+ //# 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 from 'react';\nimport MenuSection, { MenuItemConfig } from './MenuSection';\n\n/**\n * Software Templates Section properties\n *\n * @public\n */\nexport type SoftwareTemplatesSectionProps = {\n items: MenuItemConfig[];\n handleClose: () => void;\n hideDivider?: boolean;\n};\n\nexport const SoftwareTemplatesSection = ({\n items,\n handleClose,\n hideDivider,\n}: SoftwareTemplatesSectionProps) => {\n return (\n <MenuSection\n hideDivider={hideDivider}\n sectionLabel=\"Use a template\"\n optionalLink=\"/create\"\n optionalLinkLabel=\"All templates\"\n items={items}\n handleClose={handleClose}\n />\n );\n};\n"],"names":[],"mappings":";;;AA8BO,MAAM,2BAA2B,CAAC;AAAA,EACvC,KAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAqC,KAAA;AACnC,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,33 @@
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 = ({ icon, styles }) => {
7
+ const app = useApp();
8
+ if (!icon) {
9
+ return null;
10
+ }
11
+ const SystemIcon = app.getSystemIcon(icon);
12
+ if (SystemIcon) {
13
+ return /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex", alignItems: "center", ...styles } }, /* @__PURE__ */ React.createElement(SystemIcon, { fontSize: "small" }));
14
+ }
15
+ if (icon.startsWith("<svg")) {
16
+ const svgDataUri = `data:image/svg+xml;base64,${btoa(icon)}`;
17
+ return /* @__PURE__ */ React.createElement(MuiIcon, { style: { fontSize: 20, ...styles } }, /* @__PURE__ */ React.createElement("img", { src: svgDataUri, alt: "" }));
18
+ }
19
+ if (icon.startsWith("https://") || icon.startsWith("http://") || icon.startsWith("/")) {
20
+ return /* @__PURE__ */ React.createElement(
21
+ MuiIcon,
22
+ {
23
+ style: { fontSize: 20, ...styles },
24
+ baseClassName: "material-icons-outlined"
25
+ },
26
+ /* @__PURE__ */ React.createElement("img", { src: icon, alt: "" })
27
+ );
28
+ }
29
+ return /* @__PURE__ */ React.createElement(MuiIcon, { style: { fontSize: 20 }, baseClassName: "material-icons-outlined" }, icon);
30
+ };
31
+
32
+ export { HeaderIcon };
33
+ //# sourceMappingURL=HeaderIcon.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderIcon.esm.js","sources":["../../../src/components/HeaderIconButtonComponent/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\ninterface HeaderIconProps {\n icon: string;\n styles?: React.CSSProperties;\n}\n\nexport const HeaderIcon = ({ icon, styles }: HeaderIconProps) => {\n const app = useApp();\n if (!icon) {\n return null;\n }\n\n const SystemIcon = app.getSystemIcon(icon);\n\n if (SystemIcon) {\n return (\n <Box sx={{ display: 'flex', alignItems: 'center', ...styles }}>\n <SystemIcon fontSize=\"small\" />\n </Box>\n );\n }\n\n if (icon.startsWith('<svg')) {\n const svgDataUri = `data:image/svg+xml;base64,${btoa(icon)}`;\n return (\n <MuiIcon style={{ fontSize: 20, ...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 style={{ fontSize: 20, ...styles }}\n baseClassName=\"material-icons-outlined\"\n >\n <img src={icon} alt=\"\" />\n </MuiIcon>\n );\n }\n\n return (\n <MuiIcon style={{ fontSize: 20 }} baseClassName=\"material-icons-outlined\">\n {icon}\n </MuiIcon>\n );\n};\n"],"names":[],"mappings":";;;;;AAyBO,MAAM,UAAa,GAAA,CAAC,EAAE,IAAA,EAAM,QAA8B,KAAA;AAC/D,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;AAEzC,EAAA,IAAI,UAAY,EAAA;AACd,IAAA,uBACG,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,E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on.esm.js';
5
+ import { Link } from 'react-router-dom';
6
+
7
+ const HeaderIconButton = ({
8
+ icon,
9
+ tooltip,
10
+ to
11
+ }) => {
12
+ return /* @__PURE__ */ React.createElement(Tooltip, { title: tooltip ?? icon }, /* @__PURE__ */ React.createElement(
13
+ IconButton,
14
+ {
15
+ color: "inherit",
16
+ "aria-label": "help",
17
+ sx: { mr: 1.5 },
18
+ ...to ? { component: Link, to } : {}
19
+ },
20
+ tooltip !== "Support" && /* @__PURE__ */ React.createElement(HeaderIcon, { icon })
21
+ ));
22
+ };
23
+
24
+ export { HeaderIconButton };
25
+ //# sourceMappingURL=HeaderIconButton.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderIconButton.esm.js","sources":["../../../src/components/HeaderIconButtonComponent/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 Tooltip from '@mui/material/Tooltip';\nimport { HeaderIcon } from './HeaderIcon';\nimport { Link } from 'react-router-dom';\n\n/**\n * Header Icon Button properties\n * @public\n */\nexport interface HeaderIconButtonProps {\n icon: string;\n to?: string;\n tooltip?: string;\n}\n\nexport const HeaderIconButton = ({\n icon,\n tooltip,\n to,\n}: HeaderIconButtonProps) => {\n return (\n <Tooltip title={tooltip ?? icon}>\n <IconButton\n color=\"inherit\"\n aria-label=\"help\"\n sx={{ mr: 1.5 }}\n {...(to ? { component: Link, to } : {})}\n >\n {tooltip !== 'Support' && <HeaderIcon icon={icon} />}\n </IconButton>\n </Tooltip>\n );\n};\n"],"names":[],"mappings":";;;;;;AAgCO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,IAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAA6B,KAAA;AAC3B,EAAA,uBACG,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,KAAO,EAAA,OAAA,IAAW,IACzB,EAAA,kBAAA,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,MACb,GAAI,EAAK,GAAA,EAAE,WAAW,IAAM,EAAA,EAAA,KAAO;AAAC,KAAA;AAAA,IAEpC,OAAY,KAAA,SAAA,oBAAc,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,IAAY,EAAA;AAAA,GAEtD,CAAA;AAEJ;;;;"}
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import Typography from '@mui/material/Typography';
3
+ import Box from '@mui/material/Box';
4
+ import { HeaderIcon } from '../HeaderIconButtonComponent/HeaderIcon.esm.js';
5
+
6
+ const HeaderItemContent = ({
7
+ icon,
8
+ label,
9
+ subLabel
10
+ }) => /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex", alignItems: "center", margin: "8px 0" } }, icon && /* @__PURE__ */ React.createElement(
11
+ HeaderIcon,
12
+ {
13
+ icon,
14
+ styles: label ? { marginRight: "0.5rem", flexShrink: 0 } : {}
15
+ }
16
+ ), /* @__PURE__ */ React.createElement(Box, null, label && /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, label), subLabel && /* @__PURE__ */ React.createElement(Typography, { variant: "caption", color: "text.secondary" }, subLabel)));
17
+
18
+ export { HeaderItemContent as default };
19
+ //# sourceMappingURL=HeaderItemContent.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderItemContent.esm.js","sources":["../../../src/components/HeaderLinkComponent/HeaderItemContent.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 Typography from '@mui/material/Typography';\nimport Box from '@mui/material/Box';\nimport { HeaderIcon } from '../HeaderIconButtonComponent/HeaderIcon';\n\ninterface HeaderItemContentProps {\n icon?: string;\n label?: string;\n subLabel?: string;\n // styles?: React.CSSProperties; // Allow styles to be passed in\n}\n\nconst HeaderItemContent: React.FC<HeaderItemContentProps> = ({\n icon,\n label,\n subLabel,\n}) => (\n <Box sx={{ display: 'flex', alignItems: 'center', margin: '8px 0' }}>\n {icon && (\n <HeaderIcon\n icon={icon}\n styles={label ? { marginRight: '0.5rem', flexShrink: 0 } : {}}\n />\n )}\n <Box>\n {label && <Typography variant=\"body2\">{label}</Typography>}\n {subLabel && (\n <Typography variant=\"caption\" color=\"text.secondary\">\n {subLabel}\n </Typography>\n )}\n </Box>\n </Box>\n);\n\nexport default HeaderItemContent;\n"],"names":[],"mappings":";;;;;AA4BA,MAAM,oBAAsD,CAAC;AAAA,EAC3D,IAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CACE,qBAAA,KAAA,CAAA,aAAA,CAAC,GAAI,EAAA,EAAA,EAAA,EAAI,EAAE,OAAA,EAAS,MAAQ,EAAA,UAAA,EAAY,QAAU,EAAA,MAAA,EAAQ,OAAQ,EAAA,EAAA,EAC/D,IACC,oBAAA,KAAA,CAAA,aAAA;AAAA,EAAC,UAAA;AAAA,EAAA;AAAA,IACC,IAAA;AAAA,IACA,MAAA,EAAQ,QAAQ,EAAE,WAAA,EAAa,UAAU,UAAY,EAAA,CAAA,KAAM;AAAC;AAC9D,CAAA,sCAED,GACE,EAAA,IAAA,EAAA,KAAA,wCAAU,UAAW,EAAA,EAAA,OAAA,EAAQ,WAAS,KAAM,CAAA,EAC5C,QACC,oBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,OAAQ,EAAA,SAAA,EAAU,OAAM,gBACjC,EAAA,EAAA,QACH,CAEJ,CACF;;;;"}
@@ -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 HeaderItemContent from './HeaderItemContent.esm.js';
5
+
6
+ const HeaderLink = ({
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(HeaderItemContent, { icon, label: title, subLabel: subTitle })
24
+ );
25
+ return /* @__PURE__ */ React.createElement(React.Fragment, null, tooltip && /* @__PURE__ */ React.createElement(Tooltip, { title: tooltip }, headerLinkContent()), !tooltip && headerLinkContent());
26
+ };
27
+
28
+ export { HeaderLink };
29
+ //# sourceMappingURL=HeaderLink.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"HeaderLink.esm.js","sources":["../../../src/components/HeaderLinkComponent/HeaderLink.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 HeaderItemContent from './HeaderItemContent';\n\n/**\n * Header Icon Button properties\n * @public\n */\nexport interface HeaderLinkProps {\n to: string;\n title?: string;\n subTitle?: string;\n icon?: string;\n tooltip?: string;\n}\n\nexport const HeaderLink = ({\n to,\n title,\n subTitle,\n icon,\n tooltip,\n}: HeaderLinkProps) => {\n const headerLinkContent = () => (\n <Link\n to={to}\n style={{\n color: 'inherit',\n textDecoration: 'none',\n width: '100%',\n }}\n >\n <HeaderItemContent icon={icon} label={title} subLabel={subTitle} />\n </Link>\n );\n return (\n <>\n {tooltip && <Tooltip title={tooltip}>{headerLinkContent()}</Tooltip>}\n {!tooltip && headerLinkContent()}\n </>\n );\n};\n"],"names":[],"mappings":";;;;;AAiCO,MAAM,aAAa,CAAC;AAAA,EACzB,EAAA;AAAA,EACA,KAAA;AAAA,EACA,QAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAuB,KAAA;AACrB,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,iBAAkB,EAAA,EAAA,IAAA,EAAY,KAAO,EAAA,KAAA,EAAO,UAAU,QAAU,EAAA;AAAA,GACnE;AAEF,EAAA,uBAEK,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAA,OAAA,oBAAY,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,KAAO,EAAA,OAAA,EAAA,EAAU,iBAAkB,EAAE,CACzD,EAAA,CAAC,OAAW,IAAA,iBAAA,EACf,CAAA;AAEJ;;;;"}
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import Alert from '@mui/material/Alert';
3
+ import { MarkdownContent } from '@backstage/core-components';
4
+
5
+ const NotificationBanner = (props) => {
6
+ const [dismissed, setDismissed] = React.useState(() => {
7
+ if (props.dismiss === "localstorage") {
8
+ try {
9
+ const dismissedString = localStorage.getItem("global-header/NotificationBanner") ?? "{}";
10
+ const dismissedObject = JSON.parse(dismissedString);
11
+ return dismissedObject[props.id ?? props.title] === "dismissed";
12
+ } catch (error) {
13
+ return false;
14
+ }
15
+ } else {
16
+ return false;
17
+ }
18
+ });
19
+ const onClose = React.useMemo(() => {
20
+ if (!props.dismiss || props.dismiss === "none") {
21
+ return void 0;
22
+ } else if (props.dismiss === "session") {
23
+ return () => setDismissed(true);
24
+ } else if (props.dismiss === "localstorage") {
25
+ return () => {
26
+ try {
27
+ const dismissedString = localStorage.getItem("global-header/NotificationBanner") ?? "{}";
28
+ const dismissedObject = JSON.parse(dismissedString);
29
+ dismissedObject[props.id ?? props.title] = "dismissed";
30
+ localStorage.setItem(
31
+ "global-header/NotificationBanner",
32
+ JSON.stringify(dismissedObject)
33
+ );
34
+ } catch (error) {
35
+ }
36
+ setDismissed(true);
37
+ };
38
+ }
39
+ console.warn(
40
+ `Unsupported dismiss option "${props.dismiss}", currently supported "none", "session" or "localstorage"!`
41
+ );
42
+ return void 0;
43
+ }, [props.id, props.title, props.dismiss]);
44
+ if (dismissed || !props.title) {
45
+ return null;
46
+ }
47
+ return /* @__PURE__ */ React.createElement(
48
+ Alert,
49
+ {
50
+ icon: false,
51
+ onClose,
52
+ sx: {
53
+ color: props.textColor ?? "text.primary",
54
+ backgroundColor: props.backgroundColor ?? "background.paper",
55
+ border: props.border,
56
+ borderRadius: props.borderRadius,
57
+ justifyContent: "center",
58
+ textAlign: "center"
59
+ }
60
+ },
61
+ props.markdown ? /* @__PURE__ */ React.createElement(MarkdownContent, { content: props.title, dialect: "gfm" }) : props.title
62
+ );
63
+ };
64
+
65
+ export { NotificationBanner };
66
+ //# sourceMappingURL=NotificationBanner.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NotificationBanner.esm.js","sources":["../../src/components/NotificationBanner.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 Alert from '@mui/material/Alert';\nimport { MarkdownContent } from '@backstage/core-components';\n\n// export type NotificationBannerColor = 'success' | 'info' | 'warning' | 'error';\n// export type NotificationBannerIcon = 'success' | 'info' | 'warning' | 'error';\n// export type NotificationBannerVariant = 'standard' | 'filled' | 'outlined';\n\n/**\n * @public\n */\nexport type NotificationBannerDismiss = 'none' | 'session' | 'localstorage';\n\n/**\n * @public\n */\nexport interface NotificationBannerProps {\n id?: string;\n title: string;\n markdown?: boolean;\n\n textColor?: string;\n backgroundColor?: string;\n border?: string;\n borderRadius?: string;\n\n // color?: NotificationBannerColor;\n // icon?: NotificationBannerIcon;\n // variant?: NotificationBannerVariant;\n\n dismiss?: NotificationBannerDismiss;\n}\n\nexport const NotificationBanner = (props: NotificationBannerProps) => {\n const [dismissed, setDismissed] = React.useState<boolean>(() => {\n if (props.dismiss === 'localstorage') {\n try {\n const dismissedString =\n localStorage.getItem('global-header/NotificationBanner') ?? '{}';\n const dismissedObject = JSON.parse(dismissedString);\n return dismissedObject[props.id ?? props.title] === 'dismissed';\n } catch (error) {\n // nothing\n return false;\n }\n } else {\n return false;\n }\n });\n\n const onClose = React.useMemo<(() => void) | undefined>(() => {\n if (!props.dismiss || props.dismiss === 'none') {\n return undefined;\n } else if (props.dismiss === 'session') {\n return () => setDismissed(true);\n } else if (props.dismiss === 'localstorage') {\n return () => {\n try {\n const dismissedString =\n localStorage.getItem('global-header/NotificationBanner') ?? '{}';\n const dismissedObject = JSON.parse(dismissedString);\n dismissedObject[props.id ?? props.title] = 'dismissed';\n localStorage.setItem(\n 'global-header/NotificationBanner',\n JSON.stringify(dismissedObject),\n );\n } catch (error) {\n // nothing\n }\n setDismissed(true);\n };\n }\n // eslint-disable-next-line no-console\n console.warn(\n `Unsupported dismiss option \"${props.dismiss}\", currently supported \"none\", \"session\" or \"localstorage\"!`,\n );\n return undefined;\n }, [props.id, props.title, props.dismiss]);\n\n if (dismissed || !props.title) {\n return null;\n }\n\n return (\n <Alert\n // color={props.color}\n // severity={props.icon}\n icon={false}\n // variant={props.variant}\n onClose={onClose}\n sx={{\n color: props.textColor ?? 'text.primary',\n backgroundColor: props.backgroundColor ?? 'background.paper',\n border: props.border,\n borderRadius: props.borderRadius,\n justifyContent: 'center',\n textAlign: 'center',\n }}\n >\n {props.markdown ? (\n <MarkdownContent content={props.title} dialect=\"gfm\" />\n ) : (\n props.title\n )}\n </Alert>\n );\n};\n"],"names":[],"mappings":";;;;AAiDa,MAAA,kBAAA,GAAqB,CAAC,KAAmC,KAAA;AACpE,EAAA,MAAM,CAAC,SAAW,EAAA,YAAY,CAAI,GAAA,KAAA,CAAM,SAAkB,MAAM;AAC9D,IAAI,IAAA,KAAA,CAAM,YAAY,cAAgB,EAAA;AACpC,MAAI,IAAA;AACF,QAAA,MAAM,eACJ,GAAA,YAAA,CAAa,OAAQ,CAAA,kCAAkC,CAAK,IAAA,IAAA;AAC9D,QAAM,MAAA,eAAA,GAAkB,IAAK,CAAA,KAAA,CAAM,eAAe,CAAA;AAClD,QAAA,OAAO,eAAgB,CAAA,KAAA,CAAM,EAAM,IAAA,KAAA,CAAM,KAAK,CAAM,KAAA,WAAA;AAAA,eAC7C,KAAO,EAAA;AAEd,QAAO,OAAA,KAAA;AAAA;AACT,KACK,MAAA;AACL,MAAO,OAAA,KAAA;AAAA;AACT,GACD,CAAA;AAED,EAAM,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AAA;AAAA,QACF,KAAA,EAAO,MAAM,SAAa,IAAA,cAAA;AAAA,QAC1B,eAAA,EAAiB,MAAM,eAAmB,IAAA,kBAAA;AAAA,QAC1C,QAAQ,KAAM,CAAA,MAAA;AAAA,QACd,cAAc,KAAM,CAAA,YAAA;AAAA,QACpB,cAAgB,EAAA,QAAA;AAAA,QAChB,SAAW,EAAA;AAAA;AACb,KAAA;AAAA,IAEC,KAAA,CAAM,QACL,mBAAA,KAAA,CAAA,aAAA,CAAC,eAAgB,EAAA,EAAA,OAAA,EAAS,MAAM,KAAO,EAAA,OAAA,EAAQ,KAAM,EAAA,CAAA,GAErD,KAAM,CAAA;AAAA,GAEV;AAEJ;;;;"}
@@ -14,7 +14,7 @@ const SearchBar = (props) => {
14
14
  let options = [];
15
15
  if (results.length > 0) {
16
16
  options = [
17
- ...results.slice(0, 5).map((result) => result.document.title),
17
+ ...results.map((result) => result.document.title),
18
18
  `${query?.term}`
19
19
  ];
20
20
  } else if (query?.term) {
@@ -1 +1 @@
1
- {"version":3,"file":"SearchBar.esm.js","sources":["../../../src/components/SearchComponent/SearchBar.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 {\n SearchResultState,\n SearchResultProps,\n} from '@backstage/plugin-search-react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport { createSearchLink } from '../../utils/stringUtils';\nimport { useNavigate } from 'react-router-dom';\nimport { SearchInput } from './SearchInput';\nimport { SearchOption } from './SearchOption';\n\ninterface SearchBarProps {\n query: SearchResultProps['query'];\n setSearchTerm: (term: string) => void;\n}\nexport const SearchBar = (props: SearchBarProps) => {\n const { query, setSearchTerm } = props;\n const navigate = useNavigate();\n\n return (\n <SearchResultState {...props}>\n {({ loading, error, value }) => {\n const results = query?.term ? value?.results ?? [] : [];\n let options: string[] = [];\n if (results.length > 0) {\n options = [\n ...results.slice(0, 5).map(result => result.document.title),\n `${query?.term}`,\n ];\n } else if (query?.term) {\n options = ['No results found'];\n }\n const searchLink = createSearchLink(query?.term ?? '');\n\n return (\n <Autocomplete\n freeSolo\n options={options}\n loading={loading}\n getOptionLabel={option => option ?? ''}\n onInputChange={(_, inputValue) => setSearchTerm(inputValue)}\n sx={{ width: '100%' }}\n filterOptions={x => x}\n getOptionDisabled={option => option === 'No results found'}\n onKeyDown={event => {\n if (event.key === 'Enter') {\n event.preventDefault();\n if (query?.term) {\n navigate(searchLink);\n }\n }\n }}\n renderInput={params => (\n <SearchInput\n params={params}\n error={!!error}\n helperText={error ? 'Error fetching results' : ''}\n />\n )}\n renderOption={(renderProps, option, { index }) => (\n <SearchOption\n option={option}\n index={index}\n options={options}\n query={query}\n results={results}\n renderProps={renderProps}\n searchLink={searchLink}\n />\n )}\n ListboxProps={{\n style: { maxHeight: 600 },\n }}\n />\n );\n }}\n </SearchResultState>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA+Ba,MAAA,SAAA,GAAY,CAAC,KAA0B,KAAA;AAClD,EAAM,MAAA,EAAE,KAAO,EAAA,aAAA,EAAkB,GAAA,KAAA;AACjC,EAAA,MAAM,WAAW,WAAY,EAAA;AAE7B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,qBAAmB,GAAG,KAAA,EAAA,EACpB,CAAC,EAAE,OAAA,EAAS,KAAO,EAAA,KAAA,EAAY,KAAA;AAC9B,IAAA,MAAM,UAAU,KAAO,EAAA,IAAA,GAAO,OAAO,OAAW,IAAA,KAAK,EAAC;AACtD,IAAA,IAAI,UAAoB,EAAC;AACzB,IAAI,IAAA,OAAA,CAAQ,SAAS,CAAG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C,WAAA,EAAa,MAAQ,EAAA,EAAE,OACpC,qBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,YAAA;AAAA,UAAA;AAAA,YACC,MAAA;AAAA,YACA,KAAA;AAAA,YACA,OAAA;AAAA,YACA,KAAA;AAAA,YACA,OAAA;AAAA,YACA,WAAA;AAAA,YACA;AAAA;AAAA,SACF;AAAA,QAEF,YAAc,EAAA;AAAA,UACZ,KAAA,EAAO,EAAE,SAAA,EAAW,GAAI;AAAA;AAC1B;AAAA,KACF;AAAA,GAGN,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"SearchBar.esm.js","sources":["../../../src/components/SearchComponent/SearchBar.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 {\n SearchResultState,\n SearchResultProps,\n} from '@backstage/plugin-search-react';\nimport Autocomplete from '@mui/material/Autocomplete';\nimport { createSearchLink } from '../../utils/stringUtils';\nimport { useNavigate } from 'react-router-dom';\nimport { SearchInput } from './SearchInput';\nimport { SearchOption } from './SearchOption';\n\ninterface SearchBarProps {\n query: SearchResultProps['query'];\n setSearchTerm: (term: string) => void;\n}\nexport const SearchBar = (props: SearchBarProps) => {\n const { query, setSearchTerm } = props;\n const navigate = useNavigate();\n\n return (\n <SearchResultState {...props}>\n {({ loading, error, value }) => {\n const results = query?.term ? value?.results ?? [] : [];\n let options: string[] = [];\n if (results.length > 0) {\n options = [\n ...results.map(result => result.document.title),\n `${query?.term}`,\n ];\n } else if (query?.term) {\n options = ['No results found'];\n }\n const searchLink = createSearchLink(query?.term ?? '');\n\n return (\n <Autocomplete\n freeSolo\n options={options}\n loading={loading}\n getOptionLabel={option => option ?? ''}\n onInputChange={(_, inputValue) => setSearchTerm(inputValue)}\n sx={{ width: '100%' }}\n filterOptions={x => x}\n getOptionDisabled={option => option === 'No results found'}\n onKeyDown={event => {\n if (event.key === 'Enter') {\n event.preventDefault();\n if (query?.term) {\n navigate(searchLink);\n }\n }\n }}\n renderInput={params => (\n <SearchInput\n params={params}\n error={!!error}\n helperText={error ? 'Error fetching results' : ''}\n />\n )}\n renderOption={(renderProps, option, { index }) => (\n <SearchOption\n option={option}\n index={index}\n options={options}\n query={query}\n results={results}\n renderProps={renderProps}\n searchLink={searchLink}\n />\n )}\n ListboxProps={{\n style: { maxHeight: 600 },\n }}\n />\n );\n }}\n </SearchResultState>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA+Ba,MAAA,SAAA,GAAY,CAAC,KAA0B,KAAA;AAClD,EAAM,MAAA,EAAE,KAAO,EAAA,aAAA,EAAkB,GAAA,KAAA;AACjC,EAAA,MAAM,WAAW,WAAY,EAAA;AAE7B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,qBAAmB,GAAG,KAAA,EAAA,EACpB,CAAC,EAAE,OAAA,EAAS,KAAO,EAAA,KAAA,EAAY,KAAA;AAC9B,IAAA,MAAM,UAAU,KAAO,EAAA,IAAA,GAAO,OAAO,OAAW,IAAA,KAAK,EAAC;AACtD,IAAA,IAAI,UAAoB,EAAC;AACzB,IAAI,IAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AACtB,MAAU,OAAA,GAAA;AAAA,QACR,GAAG,OAAQ,CAAA,GAAA,CAAI,CAAU,MAAA,KAAA,MAAA,CAAO,SAAS,KAAK,CAAA;AAAA,QAC9C,CAAA,EAAG,OAAO,IAAI,CAAA;AAAA,OAChB;AAAA,KACF,MAAA,IAAW,OAAO,IAAM,EAAA;AACtB,MAAA,OAAA,GAAU,CAAC,kBAAkB,CAAA;AAAA;AAE/B,IAAA,MAAM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