@red-hat-developer-hub/backstage-plugin-global-header 1.8.0 → 1.10.1
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.
- package/CHANGELOG.md +20 -0
- package/dist/components/CompanyLogo/CompanyLogo.esm.js +21 -21
- package/dist/components/CompanyLogo/CompanyLogo.esm.js.map +1 -1
- package/dist/components/CompanyLogo/DefaultLogo.esm.js +199 -154
- package/dist/components/CompanyLogo/DefaultLogo.esm.js.map +1 -1
- package/dist/components/Divider/Divider.esm.js +3 -3
- package/dist/components/Divider/Divider.esm.js.map +1 -1
- package/dist/components/GlobalHeader.esm.js +2 -2
- package/dist/components/GlobalHeader.esm.js.map +1 -1
- package/dist/components/GlobalHeaderComponent.esm.js +13 -12
- package/dist/components/GlobalHeaderComponent.esm.js.map +1 -1
- package/dist/components/HeaderButton/HeaderButton.esm.js +9 -9
- package/dist/components/HeaderButton/HeaderButton.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/ApplicationLauncherDropdown.esm.js +29 -28
- package/dist/components/HeaderDropdownComponent/ApplicationLauncherDropdown.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js +17 -13
- package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/DropdownEmptyState.esm.js +16 -14
- package/dist/components/HeaderDropdownComponent/DropdownEmptyState.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js +32 -28
- package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/MenuSection.esm.js +55 -48
- package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +38 -31
- package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +2 -2
- package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +15 -11
- package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/StarredDropdown.esm.js +55 -50
- package/dist/components/HeaderDropdownComponent/StarredDropdown.esm.js.map +1 -1
- package/dist/components/HeaderIcon/HeaderIcon.esm.js +11 -11
- package/dist/components/HeaderIcon/HeaderIcon.esm.js.map +1 -1
- package/dist/components/HeaderIconButton/HeaderIconButton.esm.js +7 -7
- package/dist/components/HeaderIconButton/HeaderIconButton.esm.js.map +1 -1
- package/dist/components/LogoutButton/LogoutButton.esm.js +5 -5
- package/dist/components/LogoutButton/LogoutButton.esm.js.map +1 -1
- package/dist/components/MenuItemLink/MenuItemLink.esm.js +6 -3
- package/dist/components/MenuItemLink/MenuItemLink.esm.js.map +1 -1
- package/dist/components/MenuItemLink/MenuItemLinkContent.esm.js +46 -39
- package/dist/components/MenuItemLink/MenuItemLinkContent.esm.js.map +1 -1
- package/dist/components/NotificationBanner.esm.js +9 -8
- package/dist/components/NotificationBanner.esm.js.map +1 -1
- package/dist/components/NotificationButton/NotificationButton.esm.js +7 -7
- package/dist/components/NotificationButton/NotificationButton.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchBar.esm.js +9 -6
- package/dist/components/SearchComponent/SearchBar.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchComponent.esm.js +7 -6
- package/dist/components/SearchComponent/SearchComponent.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchInput.esm.js +3 -3
- package/dist/components/SearchComponent/SearchInput.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchOption.esm.js +19 -13
- package/dist/components/SearchComponent/SearchOption.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchResultItem.esm.js +18 -18
- package/dist/components/SearchComponent/SearchResultItem.esm.js.map +1 -1
- package/dist/components/Spacer/Spacer.esm.js +2 -2
- package/dist/components/Spacer/Spacer.esm.js.map +1 -1
- package/dist/components/SupportButton/SupportButton.esm.js +17 -17
- package/dist/components/SupportButton/SupportButton.esm.js.map +1 -1
- package/dist/defaultMountPoints/defaultMountPoints.esm.js.map +1 -1
- package/dist/hooks/useDebouncedCallback.esm.js +4 -4
- package/dist/hooks/useDebouncedCallback.esm.js.map +1 -1
- package/dist/hooks/useDropdownManager.esm.js +2 -2
- package/dist/hooks/useDropdownManager.esm.js.map +1 -1
- package/dist/index.d.ts +38 -38
- package/dist/plugin.esm.js +2 -1
- package/dist/plugin.esm.js.map +1 -1
- package/dist/utils/stringUtils.esm.js +12 -12
- package/dist/utils/stringUtils.esm.js.map +1 -1
- package/package.json +25 -25
|
@@ -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
|
|
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 { useId } from 'react';\nimport type { ReactNode, ComponentProps, MouseEvent, FC } from 'react';\nimport Menu from '@mui/material/Menu';\nimport Button from '@mui/material/Button';\nimport { Theme } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\nimport IconButton, { IconButtonProps } from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\nimport { MenuItemConfig, MenuSectionConfig } from './MenuSection';\n\ninterface HeaderDropdownProps {\n buttonContent: ReactNode;\n children: ReactNode;\n menuSections?: MenuSectionConfig[];\n menuBottomItems?: MenuItemConfig[];\n buttonProps?: ComponentProps<typeof Button>;\n onOpen: (event: MouseEvent<HTMLElement>) => void;\n onClose: () => void;\n anchorEl: HTMLElement | null;\n isIconButton?: boolean;\n tooltip?: string;\n size?: IconButtonProps['size'];\n}\n\nconst menuListStyle = (theme: Theme) => ({\n fontSize: '0.875rem',\n boxSizing: 'border-box',\n padding: 0,\n margin: 0,\n minWidth: '160px',\n borderRadius: '4px',\n textDecoration: 'none',\n listStyle: 'none',\n overflow: 'auto',\n outline: '1px solid transparent',\n background: theme.palette.background.paper,\n border: `1px solid ${theme.palette.divider}`,\n color:\n theme.palette.mode === 'dark'\n ? theme.palette.text.disabled\n : theme.palette.text.primary,\n boxShadow:\n theme.palette.mode === 'dark'\n ? '0 2px 6px 2px rgba(0,0,0,0.50), 0 1px 2px 0 rgba(0,0,0,0.50)'\n : '0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30)',\n maxHeight: '60vh',\n zIndex: 1,\n});\n\nexport const HeaderDropdownComponent: FC<HeaderDropdownProps> = ({\n buttonContent,\n children,\n buttonProps,\n onOpen,\n onClose,\n anchorEl,\n isIconButton = false,\n size = 'small',\n tooltip,\n}) => {\n const id = useId();\n\n const commonButtonProps = {\n ...buttonProps,\n onClick: (event: MouseEvent<HTMLElement>) => {\n onOpen(event);\n // focus the menu when opened\n // TODO: investigate why MUI isn't doing this for us\n setTimeout(() => {\n document\n .getElementById(`${id}-menu`)\n ?.getElementsByTagName('a')[0]\n ?.focus();\n }, 0);\n },\n 'aria-haspopup': true,\n 'aria-controls': id,\n 'aria-expanded': anchorEl ? true : undefined,\n };\n\n return (\n <Box>\n <Tooltip title={tooltip}>\n {isIconButton ? (\n <IconButton {...commonButtonProps} color=\"inherit\" size={size}>\n {buttonContent}\n </IconButton>\n ) : (\n <Button disableRipple disableTouchRipple {...commonButtonProps}>\n {buttonContent}\n </Button>\n )}\n </Tooltip>\n <Menu\n id={`${id}-menu`}\n anchorEl={anchorEl}\n keepMounted\n open={Boolean(anchorEl)}\n onClose={onClose}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'center',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'center',\n }}\n sx={{\n '& ul[class*=\"MuiMenu-list\"]': {\n py: 0,\n },\n }}\n MenuListProps={{\n 'aria-labelledby': id,\n sx: theme => menuListStyle(theme),\n }}\n >\n {children}\n </Menu>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAwCA,MAAM,aAAA,GAAgB,CAAC,KAAkB,MAAA;AAAA,EACvC,QAAU,EAAA,UAAA;AAAA,EACV,SAAW,EAAA,YAAA;AAAA,EACX,OAAS,EAAA,CAAA;AAAA,EACT,MAAQ,EAAA,CAAA;AAAA,EACR,QAAU,EAAA,OAAA;AAAA,EACV,YAAc,EAAA,KAAA;AAAA,EACd,cAAgB,EAAA,MAAA;AAAA,EAChB,SAAW,EAAA,MAAA;AAAA,EACX,QAAU,EAAA,MAAA;AAAA,EACV,OAAS,EAAA,uBAAA;AAAA,EACT,UAAA,EAAY,KAAM,CAAA,OAAA,CAAQ,UAAW,CAAA,KAAA;AAAA,EACrC,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,EAC1C,KAAA,EACE,KAAM,CAAA,OAAA,CAAQ,IAAS,KAAA,M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IAAA,EAAC,oBAAkB,IAAE,EAAA,GAAG,iBAC1C,EAAA,QAAA,EAAA,aAAA,EACH,CAEJ,EAAA,CAAA;AAAA,oBACA,GAAA;AAAA,MAAC,IAAA;AAAA,MAAA;AAAA,QACC,EAAA,EAAI,GAAG,EAAE,CAAA,KAAA,CAAA;AAAA,QACT,QAAA;AAAA,QACA,WAAW,EAAA,IAAA;AAAA,QACX,IAAA,EAAM,QAAQ,QAAQ,CAAA;AAAA,QACtB,OAAA;AAAA,QACA,YAAc,EAAA;AAAA,UACZ,QAAU,EAAA,QAAA;AAAA,UACV,UAAY,EAAA;AAAA,SACd;AAAA,QACA,eAAiB,EAAA;AAAA,UACf,QAAU,EAAA,KAAA;AAAA,UACV,UAAY,EAAA;AAAA,SACd;AAAA,QACA,EAAI,EAAA;AAAA,UACF,6BAA+B,EAAA;AAAA,YAC7B,EAAI,EAAA;AAAA;AACN,SACF;AAAA,QACA,aAAe,EAAA;AAAA,UACb,iBAAmB,EAAA,EAAA;AAAA,UACnB,EAAA,EAAI,CAAS,KAAA,KAAA,aAAA,CAAc,KAAK;AAAA,SAClC;AAAA,QAEC;AAAA;AAAA;AACH,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsxs, Fragment, jsx } from 'react/jsx-runtime';
|
|
2
|
+
import { Fragment as Fragment$1 } from 'react';
|
|
2
3
|
import Divider from '@mui/material/Divider';
|
|
3
4
|
import Box from '@mui/material/Box';
|
|
4
5
|
import MenuItem from '@mui/material/MenuItem';
|
|
@@ -14,58 +15,64 @@ const MenuSection = ({
|
|
|
14
15
|
handleClose
|
|
15
16
|
}) => {
|
|
16
17
|
const hasClickableSubheader = optionalLink && optionalLinkLabel && items.length > 0;
|
|
17
|
-
return /* @__PURE__ */
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
sx: {
|
|
21
|
-
p: 0
|
|
22
|
-
},
|
|
23
|
-
disableRipple: true,
|
|
24
|
-
disableTouchRipple: true,
|
|
25
|
-
component: hasClickableSubheader ? Link : Fragment,
|
|
26
|
-
to: optionalLink,
|
|
27
|
-
onClick: handleClose
|
|
28
|
-
},
|
|
29
|
-
/* @__PURE__ */ React.createElement(
|
|
30
|
-
ListSubheader,
|
|
18
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
19
|
+
sectionLabel && /* @__PURE__ */ jsxs(
|
|
20
|
+
MenuItem,
|
|
31
21
|
{
|
|
32
22
|
sx: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
23
|
+
p: 0
|
|
24
|
+
},
|
|
25
|
+
disableRipple: true,
|
|
26
|
+
disableTouchRipple: true,
|
|
27
|
+
component: hasClickableSubheader ? Link : Fragment$1,
|
|
28
|
+
to: optionalLink,
|
|
29
|
+
onClick: handleClose,
|
|
30
|
+
children: [
|
|
31
|
+
/* @__PURE__ */ jsx(
|
|
32
|
+
ListSubheader,
|
|
33
|
+
{
|
|
34
|
+
sx: {
|
|
35
|
+
backgroundColor: "transparent",
|
|
36
|
+
m: 0,
|
|
37
|
+
color: "text.disabled",
|
|
38
|
+
lineHeight: 2,
|
|
39
|
+
mt: "0.5rem",
|
|
40
|
+
fontWeight: 400
|
|
41
|
+
},
|
|
42
|
+
children: sectionLabel
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
optionalLinkLabel && /* @__PURE__ */ jsx(
|
|
46
|
+
Box,
|
|
47
|
+
{
|
|
48
|
+
sx: {
|
|
49
|
+
fontSize: "0.875em",
|
|
50
|
+
mr: 2,
|
|
51
|
+
flexGrow: 1,
|
|
52
|
+
textAlign: "right",
|
|
53
|
+
mt: "0.5rem"
|
|
54
|
+
},
|
|
55
|
+
children: optionalLinkLabel
|
|
56
|
+
}
|
|
57
|
+
)
|
|
58
|
+
]
|
|
59
|
+
}
|
|
42
60
|
),
|
|
43
|
-
|
|
44
|
-
|
|
61
|
+
items.map(({ icon, label, subLabel, link, Component }, index) => /* @__PURE__ */ jsx(
|
|
62
|
+
MenuItem,
|
|
45
63
|
{
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
64
|
+
disableRipple: true,
|
|
65
|
+
disableTouchRipple: true,
|
|
66
|
+
onClick: handleClose,
|
|
67
|
+
sx: { py: 0.5 },
|
|
68
|
+
component: link ? Link : Fragment$1,
|
|
69
|
+
to: link,
|
|
70
|
+
children: /* @__PURE__ */ jsx(Component, { icon, to: link, title: label, subTitle: subLabel })
|
|
53
71
|
},
|
|
54
|
-
|
|
55
|
-
)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
key: `menu-item-${index.toString()}`,
|
|
60
|
-
disableRipple: true,
|
|
61
|
-
disableTouchRipple: true,
|
|
62
|
-
onClick: handleClose,
|
|
63
|
-
sx: { py: 0.5 },
|
|
64
|
-
component: link ? Link : Fragment,
|
|
65
|
-
to: link
|
|
66
|
-
},
|
|
67
|
-
/* @__PURE__ */ React.createElement(Component, { icon, to: link, title: label, subTitle: subLabel })
|
|
68
|
-
)), !hideDivider && /* @__PURE__ */ React.createElement(Divider, { sx: { my: 0.5 } }));
|
|
72
|
+
`menu-item-${index.toString()}`
|
|
73
|
+
)),
|
|
74
|
+
!hideDivider && /* @__PURE__ */ jsx(Divider, { sx: { my: 0.5 } })
|
|
75
|
+
] });
|
|
69
76
|
};
|
|
70
77
|
|
|
71
78
|
export { MenuSection };
|
|
@@ -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
|
|
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 { Fragment } from 'react';\nimport type { ComponentType, FC } from 'react';\nimport Divider from '@mui/material/Divider';\nimport Box from '@mui/material/Box';\nimport MenuItem from '@mui/material/MenuItem';\nimport { Link } from '@backstage/core-components';\nimport { MenuItemLinkProps } from '../MenuItemLink/MenuItemLink';\nimport ListSubheader from '@mui/material/ListSubheader';\n\n/**\n * Menu item configuration\n *\n * @public\n */\nexport interface MenuItemConfig {\n Component: ComponentType<MenuItemLinkProps | {}>;\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: FC<MenuSectionConfig> = ({\n sectionLabel,\n optionalLink,\n optionalLinkLabel,\n items,\n hideDivider = false,\n handleClose,\n}) => {\n const hasClickableSubheader =\n optionalLink && optionalLinkLabel && items.length > 0;\n\n return (\n <>\n {sectionLabel && (\n <MenuItem\n sx={{\n p: 0,\n }}\n disableRipple\n disableTouchRipple\n component={hasClickableSubheader ? Link : Fragment}\n to={optionalLink}\n onClick={handleClose}\n >\n <ListSubheader\n sx={{\n backgroundColor: 'transparent',\n m: 0,\n color: 'text.disabled',\n lineHeight: 2,\n mt: '0.5rem',\n fontWeight: 400,\n }}\n >\n {sectionLabel}\n </ListSubheader>\n\n {optionalLinkLabel && (\n <Box\n sx={{\n fontSize: '0.875em',\n mr: 2,\n flexGrow: 1,\n textAlign: 'right',\n mt: '0.5rem',\n }}\n >\n {optionalLinkLabel}\n </Box>\n )}\n </MenuItem>\n )}\n\n {items.map(({ 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 }}\n component={link ? Link : Fragment}\n to={link}\n >\n <Component icon={icon} to={link!} title={label} subTitle={subLabel} />\n </MenuItem>\n ))}\n {!hideDivider && <Divider sx={{ my: 0.5 }} />}\n </>\n );\n};\n"],"names":["Fragment"],"mappings":";;;;;;;;AA+CO,MAAM,cAAqC,CAAC;AAAA,EACjD,YAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAc,GAAA,KAAA;AAAA,EACd;AACF,CAAM,KAAA;AACJ,EAAA,MAAM,qBACJ,GAAA,YAAA,IAAgB,iBAAqB,IAAA,KAAA,CAAM,MAAS,GAAA,CAAA;AAEtD,EAAA,uBAEK,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,IACC,YAAA,oBAAA,IAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACC,EAAI,EAAA;AAAA,UACF,CAAG,EAAA;AAAA,SACL;AAAA,QACA,aAAa,EAAA,IAAA;AAAA,QACb,kBAAkB,EAAA,IAAA;AAAA,QAClB,SAAA,EAAW,wBAAwB,IAAOA,GAAAA,UAAAA;AAAA,QAC1C,EAAI,EAAA,YAAA;AAAA,QACJ,OAAS,EAAA,WAAA;AAAA,QAET,QAAA,EAAA;AAAA,0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EAAA,EAAQ,IAAI,EAAE,EAAA,EAAI,KAAO,EAAA;AAAA,GAC7C,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useRef, useEffect, useMemo } from 'react';
|
|
2
3
|
import { useUserProfile } from '@backstage/plugin-user-settings';
|
|
3
4
|
import { useApi } from '@backstage/core-plugin-api';
|
|
4
5
|
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
@@ -79,36 +80,42 @@ const ProfileDropdown = ({ layout }) => {
|
|
|
79
80
|
}
|
|
80
81
|
return name;
|
|
81
82
|
};
|
|
82
|
-
return /* @__PURE__ */
|
|
83
|
+
return /* @__PURE__ */ jsx(
|
|
83
84
|
HeaderDropdownComponent,
|
|
84
85
|
{
|
|
85
|
-
buttonContent: /* @__PURE__ */
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
86
|
+
buttonContent: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center", ...layout }, children: [
|
|
87
|
+
!profileLoading && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
88
|
+
profile.picture ? /* @__PURE__ */ jsx(
|
|
89
|
+
Avatar,
|
|
90
|
+
{
|
|
91
|
+
src: profile.picture,
|
|
92
|
+
sx: { mr: 2, height: "32px", width: "32px" },
|
|
93
|
+
alt: "Profile picture"
|
|
94
|
+
}
|
|
95
|
+
) : /* @__PURE__ */ jsx(AccountCircleOutlinedIcon, { fontSize: "small", sx: { mr: 1 } }),
|
|
96
|
+
/* @__PURE__ */ jsx(
|
|
97
|
+
Typography,
|
|
98
|
+
{
|
|
99
|
+
variant: "body2",
|
|
100
|
+
sx: {
|
|
101
|
+
display: { xs: "none", md: "block" },
|
|
102
|
+
fontWeight: 500,
|
|
103
|
+
mr: "1rem"
|
|
104
|
+
},
|
|
105
|
+
children: profileDisplayName()
|
|
106
|
+
}
|
|
107
|
+
)
|
|
108
|
+
] }),
|
|
109
|
+
/* @__PURE__ */ jsx(
|
|
110
|
+
KeyboardArrowDownOutlinedIcon,
|
|
111
|
+
{
|
|
112
|
+
sx: {
|
|
113
|
+
bgcolor: bgColor,
|
|
114
|
+
borderRadius: "25%"
|
|
115
|
+
}
|
|
109
116
|
}
|
|
110
|
-
|
|
111
|
-
)
|
|
117
|
+
)
|
|
118
|
+
] }),
|
|
112
119
|
buttonProps: {
|
|
113
120
|
color: "inherit",
|
|
114
121
|
sx: {
|
|
@@ -118,9 +125,9 @@ const ProfileDropdown = ({ layout }) => {
|
|
|
118
125
|
},
|
|
119
126
|
onOpen: handleOpen,
|
|
120
127
|
onClose: handleClose,
|
|
121
|
-
anchorEl
|
|
122
|
-
|
|
123
|
-
|
|
128
|
+
anchorEl,
|
|
129
|
+
children: /* @__PURE__ */ jsx(MenuSection, { hideDivider: true, items: menuItems, handleClose })
|
|
130
|
+
}
|
|
124
131
|
);
|
|
125
132
|
};
|
|
126
133
|
|
|
@@ -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
|
|
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 { useEffect, useMemo, useRef, useState } from 'react';\nimport type { CSSProperties } from 'react';\nimport { useUserProfile } from '@backstage/plugin-user-settings';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { UserEntity } from '@backstage/catalog-model';\nimport AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined';\nimport KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';\nimport Avatar from '@mui/material/Avatar';\nimport Typography from '@mui/material/Typography';\nimport { lighten } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\n\nimport { MenuSection } from './MenuSection';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { useProfileDropdownMountPoints } from '../../hooks/useProfileDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\n\n/**\n * @public\n * Props for Profile Dropdown\n */\nexport interface ProfileDropdownProps {\n layout?: CSSProperties;\n}\n\nexport const ProfileDropdown = ({ layout }: ProfileDropdownProps) => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n const [user, setUser] = useState<string | null>();\n const {\n displayName,\n backstageIdentity,\n profile,\n loading: profileLoading,\n } = useUserProfile();\n const catalogApi = useApi(catalogApiRef);\n\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 fetchUserEntity = async () => {\n let userProfile;\n try {\n if (backstageIdentity?.userEntityRef) {\n userProfile = (await catalogApi.getEntityByRef(\n backstageIdentity.userEntityRef,\n )) as unknown as UserEntity;\n }\n setUser(\n userProfile?.spec?.profile?.displayName ??\n userProfile?.metadata?.title,\n );\n } catch (_err) {\n setUser(null);\n }\n };\n\n fetchUserEntity();\n }, [backstageIdentity, catalogApi]);\n\n const menuItems = useMemo(() => {\n return (profileDropdownMountPoints ?? [])\n .map(mp => ({\n Component: mp.Component,\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 const profileDisplayName = () => {\n const name = user ?? displayName;\n const regex = /^[^:/]+:[^/]+\\/[^/]+$/;\n if (regex.test(name)) {\n return name\n .charAt(name.indexOf('/') + 1)\n .toLocaleUpperCase('en-US')\n .concat(name.substring(name.indexOf('/') + 2));\n }\n return name;\n };\n\n return (\n <HeaderDropdownComponent\n buttonContent={\n <Box sx={{ display: 'flex', alignItems: 'center', ...layout }}>\n {!profileLoading && (\n <>\n {profile.picture ? (\n <Avatar\n src={profile.picture}\n sx={{ mr: 2, height: '32px', width: '32px' }}\n alt=\"Profile picture\"\n />\n ) : (\n <AccountCircleOutlinedIcon fontSize=\"small\" sx={{ mr: 1 }} />\n )}\n <Typography\n variant=\"body2\"\n sx={{\n display: { xs: 'none', md: 'block' },\n fontWeight: 500,\n mr: '1rem',\n }}\n >\n {profileDisplayName()}\n </Typography>\n </>\n )}\n <KeyboardArrowDownOutlinedIcon\n sx={{\n bgcolor: bgColor,\n borderRadius: '25%',\n }}\n />\n </Box>\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":";;;;;;;;;;;;;;;;AA0CO,MAAM,eAAkB,GAAA,CAAC,EAAE,MAAA,EAAmC,KAAA;AACnE,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AACjE,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAwB,EAAA;AAChD,EAAM,MAAA;AAAA,IACJ,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,cAAe,EAAA;AACnB,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA;AAEvC,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,MAAW,UAAA,CAAA,OAAA,CAAQ,SAAW,EAAA,GAAG,CAAC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A,EAAI,GAAG,MAAQ,EAAA,MAAA,EAAQ,OAAO,MAAO,EAAA;AAAA,cAC3C,GAAI,EAAA;AAAA;AAAA,WACN,uBAEC,yBAA0B,EAAA,EAAA,QAAA,EAAS,SAAQ,EAAI,EAAA,EAAE,EAAI,EAAA,CAAA,EAAK,EAAA,CAAA;AAAA,0BAE7D,GAAA;AAAA,YAAC,UAAA;AAAA,YAAA;AAAA,cACC,OAAQ,EAAA,OAAA;AAAA,cACR,EAAI,EAAA;AAAA,gBACF,OAAS,EAAA,EAAE,EAAI,EAAA,MAAA,EAAQ,IAAI,OAAQ,EAAA;AAAA,gBACnC,UAAY,EAAA,GAAA;AAAA,gBACZ,EAAI,EAAA;AAAA,eACN;AAAA,cAEC,QAAmB,EAAA,kBAAA;AAAA;AAAA;AACtB,SACF,EAAA,CAAA;AAAA,wBAEF,GAAA;AAAA,UAAC,6BAAA;AAAA,UAAA;AAAA,YACC,EAAI,EAAA;AAAA,cACF,OAAS,EAAA,OAAA;AAAA,cACT,YAAc,EAAA;AAAA;AAChB;AAAA;AACF,OACF,EAAA,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,MAAQ,EAAA,UAAA;AAAA,MACR,OAAS,EAAA,WAAA;AAAA,MACT,QAAA;AAAA,MAEA,8BAAC,WAAY,EAAA,EAAA,WAAA,EAAW,IAAC,EAAA,KAAA,EAAO,WAAW,WAA0B,EAAA;AAAA;AAAA,GACvE;AAEJ;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { MenuSection } from './MenuSection.esm.js';
|
|
3
3
|
import { MenuItemLink } from '../MenuItemLink/MenuItemLink.esm.js';
|
|
4
4
|
|
|
@@ -6,7 +6,7 @@ const RegisterAComponentSection = ({
|
|
|
6
6
|
hideDivider,
|
|
7
7
|
handleClose
|
|
8
8
|
}) => {
|
|
9
|
-
return /* @__PURE__ */
|
|
9
|
+
return /* @__PURE__ */ jsx(
|
|
10
10
|
MenuSection,
|
|
11
11
|
{
|
|
12
12
|
hideDivider,
|
|
@@ -1 +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 */\
|
|
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 */\nimport type { ComponentType } from 'react';\nimport { MenuSection } from './MenuSection';\nimport { MenuItemLink } from '../MenuItemLink/MenuItemLink';\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 label: 'Register a component',\n subLabel: 'Import it to the catalog page',\n link: '/catalog-import',\n icon: 'category',\n Component: MenuItemLink as ComponentType,\n },\n ]}\n handleClose={handleClose}\n />\n );\n};\n"],"names":[],"mappings":";;;;AA6BO,MAAM,4BAA4B,CAAC;AAAA,EACxC,WAAA;AAAA,EACA;AACF,CAAsC,KAAA;AACpC,EACE,uBAAA,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,WAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACL;AAAA,UACE,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;;;;"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
2
3
|
import { useApi } from '@backstage/core-plugin-api';
|
|
3
4
|
import { catalogApiRef } from '@backstage/plugin-catalog-react';
|
|
4
5
|
import Box from '@mui/material/Box';
|
|
@@ -39,19 +40,22 @@ const SoftwareTemplatesSection = ({
|
|
|
39
40
|
}));
|
|
40
41
|
}, [entities]);
|
|
41
42
|
if (error) {
|
|
42
|
-
return /* @__PURE__ */
|
|
43
|
+
return /* @__PURE__ */ jsx(Box, { display: "flex", justifyContent: "center", alignItems: "center", p: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "body1", color: "error", children: "Error fetching templates" }) });
|
|
43
44
|
}
|
|
44
45
|
if (items.length === 0) {
|
|
45
|
-
return /* @__PURE__ */
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
46
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
47
|
+
/* @__PURE__ */ jsx(
|
|
48
|
+
Typography,
|
|
49
|
+
{
|
|
50
|
+
variant: "body2",
|
|
51
|
+
sx: { mx: 2, my: 1, color: "text.disabled" },
|
|
52
|
+
children: "No templates available"
|
|
53
|
+
}
|
|
54
|
+
),
|
|
55
|
+
!hideDivider && /* @__PURE__ */ jsx(Divider, { sx: { my: 0.5 } })
|
|
56
|
+
] });
|
|
53
57
|
}
|
|
54
|
-
return /* @__PURE__ */
|
|
58
|
+
return /* @__PURE__ */ jsx(
|
|
55
59
|
MenuSection,
|
|
56
60
|
{
|
|
57
61
|
hideDivider,
|
|
@@ -1 +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
|
|
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 { useEffect, useMemo, useState } from 'react';\nimport type { ComponentType } 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';\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 ComponentType,\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 optionalLinkLabel=\"All templates\"\n items={items}\n handleClose={handleClose}\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A,KAClD,CAAA,CAAA;AAAA,GACN,EAAG,CAAC,QAAQ,CAAC,CAAA;AAEb,EAAA,IAAI,KAAO,EAAA;AACT,IAAA,2BACG,GAAI,EAAA,EAAA,OAAA,EAAQ,MAAO,EAAA,cAAA,EAAe,UAAS,UAAW,EAAA,QAAA,EAAS,CAAG,EAAA,CAAA,EACjE,8BAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,SAAQ,KAAM,EAAA,OAAA,EAAQ,sCAE1C,CACF,EAAA,CAAA;AAAA;AAIJ,EAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACtB,IAAA,uBAEI,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,sBAAA,GAAA;AAAA,QAAC,UAAA;AAAA,QAAA;AAAA,UACC,OAAQ,EAAA,OAAA;AAAA,UACR,IAAI,EAAE,EAAA,EAAI,GAAG,EAAI,EAAA,CAAA,EAAG,OAAO,eAAgB,EAAA;AAAA,UAC5C,QAAA,EAAA;AAAA;AAAA,OAED;AAAA,MACC,CAAC,+BAAgB,GAAA,CAAA,OAAA,EAAA,EAAQ,IAAI,EAAE,EAAA,EAAI,KAAO,EAAA;AAAA,KAC7C,EAAA,CAAA;AAAA;AAGJ,EACE,uBAAA,GAAA;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;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useStarredEntities, useEntityPresentation } from '@backstage/plugin-catalog-react';
|
|
3
3
|
import { Link } from '@backstage/core-components';
|
|
4
4
|
import { parseEntityRef } from '@backstage/catalog-model';
|
|
@@ -24,73 +24,78 @@ const StarredItem = ({
|
|
|
24
24
|
const { Icon, primaryTitle, secondaryTitle } = useEntityPresentation(entityRef);
|
|
25
25
|
const { name, kind, namespace } = parseEntityRef(entityRef);
|
|
26
26
|
const theme = useTheme();
|
|
27
|
-
return /* @__PURE__ */
|
|
27
|
+
return /* @__PURE__ */ jsxs(
|
|
28
28
|
MenuItem,
|
|
29
29
|
{
|
|
30
30
|
component: Link,
|
|
31
31
|
to: `/catalog/${namespace || "default"}/${kind}/${name}`,
|
|
32
32
|
onClick: handleClose,
|
|
33
33
|
disableRipple: true,
|
|
34
|
-
disableTouchRipple: true
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
34
|
+
disableTouchRipple: true,
|
|
35
|
+
children: [
|
|
36
|
+
Icon && /* @__PURE__ */ jsx(ListItemIcon, { sx: { minWidth: 36 }, children: /* @__PURE__ */ jsx(Icon, {}) }),
|
|
37
|
+
/* @__PURE__ */ jsx(
|
|
38
|
+
ListItemText,
|
|
39
|
+
{
|
|
40
|
+
primary: /* @__PURE__ */ jsx(Typography, { sx: { color: theme.palette.text.primary }, children: primaryTitle || secondaryTitle }),
|
|
41
|
+
secondary: kind.toLocaleUpperCase(),
|
|
42
|
+
sx: { ml: 1, mr: 1 }
|
|
43
|
+
}
|
|
44
|
+
),
|
|
45
|
+
/* @__PURE__ */ jsx(Tooltip, { title: "Remove from list", children: /* @__PURE__ */ jsx(
|
|
46
|
+
IconButton,
|
|
47
|
+
{
|
|
48
|
+
onClick: (e) => {
|
|
49
|
+
e.preventDefault();
|
|
50
|
+
e.stopPropagation();
|
|
51
|
+
toggleStarredEntity(entityRef);
|
|
52
|
+
},
|
|
53
|
+
children: /* @__PURE__ */ jsx(Star, { color: "warning" })
|
|
54
|
+
}
|
|
55
|
+
) })
|
|
56
|
+
]
|
|
57
|
+
}
|
|
56
58
|
);
|
|
57
59
|
};
|
|
58
60
|
const StarredDropdown = () => {
|
|
59
61
|
const { anchorEl, handleOpen, handleClose } = useDropdownManager();
|
|
60
62
|
const { starredEntities, toggleStarredEntity } = useStarredEntities();
|
|
61
63
|
const entitiesArray = Array.from(starredEntities);
|
|
62
|
-
return /* @__PURE__ */
|
|
64
|
+
return /* @__PURE__ */ jsx(
|
|
63
65
|
HeaderDropdownComponent,
|
|
64
66
|
{
|
|
65
|
-
buttonContent: /* @__PURE__ */
|
|
67
|
+
buttonContent: /* @__PURE__ */ jsx(StarBorderIcon, {}),
|
|
66
68
|
onOpen: handleOpen,
|
|
67
69
|
onClose: handleClose,
|
|
68
70
|
anchorEl,
|
|
69
71
|
tooltip: "Your starred items",
|
|
70
|
-
isIconButton: true
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
72
|
+
isIconButton: true,
|
|
73
|
+
children: entitiesArray.length > 0 ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
74
|
+
/* @__PURE__ */ jsx(
|
|
75
|
+
ListItemText,
|
|
76
|
+
{
|
|
77
|
+
primary: "Your starred items",
|
|
78
|
+
sx: { pl: 2, mt: 1, fontWeight: "bold", color: "text.secondary" }
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
entitiesArray.map((enitityRef) => /* @__PURE__ */ jsx(
|
|
82
|
+
StarredItem,
|
|
83
|
+
{
|
|
84
|
+
entityRef: enitityRef,
|
|
85
|
+
toggleStarredEntity,
|
|
86
|
+
handleClose
|
|
87
|
+
},
|
|
88
|
+
enitityRef
|
|
89
|
+
))
|
|
90
|
+
] }) : /* @__PURE__ */ jsx(
|
|
91
|
+
DropdownEmptyState,
|
|
92
|
+
{
|
|
93
|
+
title: "No starred items yet",
|
|
94
|
+
subTitle: "Click the star icon next to an entity's name to save it here for quick access.",
|
|
95
|
+
icon: /* @__PURE__ */ jsx(AutoAwesomeIcon, { sx: { fontSize: 64 }, color: "disabled" })
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
}
|
|
94
99
|
);
|
|
95
100
|
};
|
|
96
101
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StarredDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/StarredDropdown.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
|
|
1
|
+
{"version":3,"file":"StarredDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/StarredDropdown.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 type { FC } from 'react';\nimport {\n useEntityPresentation,\n useStarredEntities,\n} from '@backstage/plugin-catalog-react';\nimport { Link } from '@backstage/core-components';\nimport {\n CompoundEntityRef,\n Entity,\n parseEntityRef,\n} from '@backstage/catalog-model';\nimport StarBorderIcon from '@mui/icons-material/StarBorder';\nimport Star from '@mui/icons-material/Star';\nimport AutoAwesomeIcon from '@mui/icons-material/AutoAwesome';\nimport ListItemIcon from '@mui/material/ListItemIcon';\nimport ListItemText from '@mui/material/ListItemText';\n\nimport { useTheme } from '@mui/material/styles';\nimport MenuItem from '@mui/material/MenuItem';\nimport Typography from '@mui/material/Typography';\nimport IconButton from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\n\nimport { useDropdownManager } from '../../hooks';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { DropdownEmptyState } from './DropdownEmptyState';\n\n/**\n * @public\n * Props for each starred entitify item\n */\ninterface SectionComponentProps {\n entityRef: string | CompoundEntityRef | Entity;\n toggleStarredEntity: (\n entityOrRef: Entity | CompoundEntityRef | string,\n ) => void;\n handleClose: () => void;\n}\n\nconst StarredItem: FC<SectionComponentProps> = ({\n entityRef,\n toggleStarredEntity,\n handleClose,\n}) => {\n const { Icon, primaryTitle, secondaryTitle } =\n useEntityPresentation(entityRef);\n const { name, kind, namespace } = parseEntityRef(entityRef as string);\n const theme = useTheme();\n\n return (\n <MenuItem\n component={Link}\n to={`/catalog/${namespace || 'default'}/${kind}/${name}`}\n onClick={handleClose}\n disableRipple\n disableTouchRipple\n >\n {Icon && (\n <ListItemIcon sx={{ minWidth: 36 }}>\n <Icon />\n </ListItemIcon>\n )}\n <ListItemText\n primary={\n <Typography sx={{ color: theme.palette.text.primary }}>\n {primaryTitle || secondaryTitle}\n </Typography>\n }\n secondary={kind.toLocaleUpperCase()}\n // inset={!Icon}\n sx={{ ml: 1, mr: 1 }}\n />\n <Tooltip title=\"Remove from list\">\n <IconButton\n onClick={e => {\n e.preventDefault();\n e.stopPropagation();\n toggleStarredEntity(entityRef);\n }}\n >\n <Star color=\"warning\" />\n </IconButton>\n </Tooltip>\n </MenuItem>\n );\n};\n\nexport const StarredDropdown = () => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n const { starredEntities, toggleStarredEntity } = useStarredEntities();\n\n const entitiesArray = Array.from(starredEntities);\n\n return (\n <HeaderDropdownComponent\n buttonContent={<StarBorderIcon />}\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n tooltip=\"Your starred items\"\n isIconButton\n >\n {entitiesArray.length > 0 ? (\n <>\n <ListItemText\n primary=\"Your starred items\"\n sx={{ pl: 2, mt: 1, fontWeight: 'bold', color: 'text.secondary' }}\n />\n {entitiesArray.map(enitityRef => (\n <StarredItem\n key={enitityRef}\n entityRef={enitityRef}\n toggleStarredEntity={toggleStarredEntity}\n handleClose={handleClose}\n />\n ))}\n </>\n ) : (\n <DropdownEmptyState\n title=\"No starred items yet\"\n subTitle=\"Click the star icon next to an entity's name to save it here for quick access.\"\n icon={<AutoAwesomeIcon sx={{ fontSize: 64 }} color=\"disabled\" />}\n />\n )}\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAuDA,MAAM,cAAyC,CAAC;AAAA,EAC9C,SAAA;AAAA,EACA,mBAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EAAA,MAAM,EAAE,IAAM,EAAA,YAAA,EAAc,cAAe,EAAA,GACzC,sBAAsB,SAAS,CAAA;AACjC,EAAA,MAAM,EAAE,IAAM,EAAA,IAAA,EAAM,SAAU,EAAA,GAAI,eAAe,SAAmB,CAAA;AACpE,EAAA,MAAM,QAAQ,QAAS,EAAA;AAEvB,EACE,uBAAA,IAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,IAAA;AAAA,MACX,IAAI,CAAY,SAAA,EAAA,SAAA,IAAa,SAAS,CAAI,CAAA,EAAA,IAAI,IAAI,IAAI,CAAA,CAAA;AAAA,MACtD,OAAS,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