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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/app-config.dynamic.yaml +4 -13
  3. package/dist/components/Divider/Divider.esm.js +16 -0
  4. package/dist/components/Divider/Divider.esm.js.map +1 -0
  5. package/dist/components/GlobalHeader.esm.js +5 -90
  6. package/dist/components/GlobalHeader.esm.js.map +1 -1
  7. package/dist/components/GlobalHeaderComponent.esm.js +25 -0
  8. package/dist/components/GlobalHeaderComponent.esm.js.map +1 -0
  9. package/dist/components/HeaderButton/HeaderButton.esm.js +41 -0
  10. package/dist/components/HeaderButton/HeaderButton.esm.js.map +1 -0
  11. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js +20 -53
  12. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js.map +1 -1
  13. package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js +13 -10
  14. package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js.map +1 -1
  15. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js +3 -3
  16. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
  17. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +34 -22
  18. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
  19. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +4 -3
  20. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -1
  21. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +50 -3
  22. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -1
  23. package/dist/components/{HeaderIconButtonComponent → HeaderIcon}/HeaderIcon.esm.js +10 -5
  24. package/dist/components/HeaderIcon/HeaderIcon.esm.js.map +1 -0
  25. package/dist/components/HeaderIconButton/HeaderIconButton.esm.js +37 -0
  26. package/dist/components/HeaderIconButton/HeaderIconButton.esm.js.map +1 -0
  27. package/dist/components/{HeaderButtonComponent → LogoutButton}/LogoutButton.esm.js +10 -2
  28. package/dist/components/LogoutButton/LogoutButton.esm.js.map +1 -0
  29. package/dist/components/{HeaderLinkComponent/HeaderLink.esm.js → MenuItemLink/MenuItemLink.esm.js} +6 -6
  30. package/dist/components/MenuItemLink/MenuItemLink.esm.js.map +1 -0
  31. package/dist/components/MenuItemLink/MenuItemLinkContent.esm.js +40 -0
  32. package/dist/components/MenuItemLink/MenuItemLinkContent.esm.js.map +1 -0
  33. package/dist/components/NotificationButton/NotificationButton.esm.js +36 -0
  34. package/dist/components/NotificationButton/NotificationButton.esm.js.map +1 -0
  35. package/dist/components/SearchComponent/SearchBar.esm.js +37 -7
  36. package/dist/components/SearchComponent/SearchBar.esm.js.map +1 -1
  37. package/dist/components/SearchComponent/SearchOption.esm.js +1 -1
  38. package/dist/components/SearchComponent/SearchOption.esm.js.map +1 -1
  39. package/dist/components/SearchComponent/SearchResultItem.esm.js +13 -1
  40. package/dist/components/SearchComponent/SearchResultItem.esm.js.map +1 -1
  41. package/dist/components/Spacer/Spacer.esm.js +16 -0
  42. package/dist/components/Spacer/Spacer.esm.js.map +1 -0
  43. package/dist/components/SupportButton/SupportButton.esm.js +36 -0
  44. package/dist/components/SupportButton/SupportButton.esm.js.map +1 -0
  45. package/dist/defaultMountPoints/defaultMountPoints.esm.js +93 -0
  46. package/dist/defaultMountPoints/defaultMountPoints.esm.js.map +1 -0
  47. package/dist/hooks/useCreateDropdownMountPoints.esm.js +4 -0
  48. package/dist/hooks/useCreateDropdownMountPoints.esm.js.map +1 -1
  49. package/dist/hooks/useDropdownManager.esm.js +7 -6
  50. package/dist/hooks/useDropdownManager.esm.js.map +1 -1
  51. package/dist/hooks/useNotificationCount.esm.js +54 -0
  52. package/dist/hooks/useNotificationCount.esm.js.map +1 -0
  53. package/dist/hooks/useProfileDropdownMountPoints.esm.js +4 -0
  54. package/dist/hooks/useProfileDropdownMountPoints.esm.js.map +1 -1
  55. package/dist/index.d.ts +190 -41
  56. package/dist/index.esm.js +2 -1
  57. package/dist/index.esm.js.map +1 -1
  58. package/dist/plugin.esm.js +81 -14
  59. package/dist/plugin.esm.js.map +1 -1
  60. package/dist/types.esm.js +3 -6
  61. package/dist/types.esm.js.map +1 -1
  62. package/package.json +6 -1
  63. package/dist/components/HeaderButtonComponent/HeaderButton.esm.js +0 -17
  64. package/dist/components/HeaderButtonComponent/HeaderButton.esm.js.map +0 -1
  65. package/dist/components/HeaderButtonComponent/LogoutButton.esm.js.map +0 -1
  66. package/dist/components/HeaderIconButtonComponent/HeaderIcon.esm.js.map +0 -1
  67. package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js +0 -25
  68. package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js.map +0 -1
  69. package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js +0 -19
  70. package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js.map +0 -1
  71. package/dist/components/HeaderLinkComponent/HeaderLink.esm.js.map +0 -1
@@ -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.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,IAA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GAAA;AAAA;AAAA,SACjD;AAAA,QAEF,cAAc,CAAC,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, { useEffect, useRef, useState } 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';\nimport { useTheme } from '@mui/material/styles';\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 const theme = useTheme();\n const [highlightedIndex, setHighlightedIndex] = useState(-1);\n const highlightedIndexRef = useRef(highlightedIndex);\n\n useEffect(() => {\n highlightedIndexRef.current = highlightedIndex;\n }, [highlightedIndex]);\n\n return (\n <SearchResultState {...props}>\n {({ loading, error, value }) => {\n const results = query?.term ? value?.results ?? [] : [];\n let options: string[] = [];\n if (query?.term && results.length === 0) {\n options = ['No results found'];\n }\n if (results.length > 0) {\n options = [\n ...results.map(result => result.document.title),\n `${query?.term}`,\n ];\n }\n const searchLink = createSearchLink(query?.term ?? '');\n\n return (\n <Autocomplete\n freeSolo\n options={options}\n loading={loading}\n value={query?.term ?? ''}\n getOptionLabel={option => option ?? ''}\n onInputChange={(_, inputValue) => setSearchTerm(inputValue)}\n onHighlightChange={(_, option) =>\n setHighlightedIndex(options.indexOf(option ?? ''))\n }\n componentsProps={{\n paper: {\n sx: {\n borderRadius: '4px',\n outline: 'unset',\n border: `1px solid ${theme.palette.divider}`,\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 },\n },\n }}\n sx={{\n width: '100%',\n '& [class*=\"MuiAutocomplete-clearIndicator\"]': {\n visibility: query?.term ? 'visible' : 'hidden',\n },\n }}\n filterOptions={x => x}\n onKeyDown={event => {\n const currentHighlight = highlightedIndexRef.current;\n if (event.key === 'Enter') {\n event.preventDefault();\n if (currentHighlight === -1 && query?.term) {\n navigate(searchLink);\n } else if (currentHighlight !== -1) {\n navigate(\n results[highlightedIndex]?.document?.location ?? searchLink,\n );\n }\n setHighlightedIndex(-1);\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 sx: { maxHeight: '60vh' },\n }}\n />\n );\n }}\n </SearchResultState>\n );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AAA,gBAAgB,CAAG,EAAA,QAAA,EAAU,QAAY,IAAA;AAAA,eACnD;AAAA;AAEF,YAAA,mBAAA,CAAoB,CAAE,CAAA,CAAA;AAAA;AACxB,SACF;AAAA,QACA,aAAa,CACX,MAAA,qBAAA,KAAA,CAAA,aAAA;AAAA,UAAC,WAAA;AAAA,UAAA;AAAA,YACC,MAAA;AAAA,YACA,KAAA,EAAO,CAAC,CAAC,KAAA;AAAA,YACT,UAAA,EAAY,QAAQ,wBAA2B,GAAA;AAAA;AAAA,SACjD;AAAA,QAEF,cAAc,CAAC,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,EAAA,EAAI,EAAE,SAAA,EAAW,MAAO;AAAA;AAC1B;AAAA,KACF;AAAA,GAGN,CAAA;AAEJ;;;;"}
@@ -24,7 +24,7 @@ const SearchOption = ({
24
24
  sx: { my: 0 },
25
25
  className: "allResultsOption"
26
26
  },
27
- /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ React.createElement(Typography, { sx: { flexGrow: 1, mr: 1 } }, "All results"), /* @__PURE__ */ React.createElement(ArrowForwardIcon, { fontSize: "small" }))
27
+ /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex", alignItems: "center" } }, /* @__PURE__ */ React.createElement(Typography, { sx: { flexGrow: 1 } }, "All results"), /* @__PURE__ */ React.createElement(ArrowForwardIcon, { fontSize: "small" }))
28
28
  )));
29
29
  }
30
30
  const result = results.find((r) => r.document.title === option);
@@ -1 +1 @@
1
- {"version":3,"file":"SearchOption.esm.js","sources":["../../../src/components/SearchComponent/SearchOption.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 Box from '@mui/material/Box';\nimport Divider from '@mui/material/Divider';\nimport { Link } from '@backstage/core-components';\nimport ListItem from '@mui/material/ListItem';\nimport Typography from '@mui/material/Typography';\nimport ArrowForwardIcon from '@mui/icons-material/ArrowForward';\nimport { SearchResultItem } from './SearchResultItem';\nimport { Result, SearchDocument } from '@backstage/plugin-search-common';\nimport { SearchResultProps } from '@backstage/plugin-search-react';\n\ninterface SearchOptionProps {\n option: string;\n index: number;\n options: string[];\n query: SearchResultProps['query'];\n results: Result<SearchDocument>[];\n renderProps: any;\n searchLink: string;\n}\n\nexport const SearchOption = ({\n option,\n index,\n options,\n query,\n results,\n renderProps,\n searchLink,\n}: SearchOptionProps) => {\n if (option === query?.term && index === options.length - 1) {\n return (\n <Box key=\"all-results\" id=\"all-results\">\n <Divider sx={{ my: 0.5 }} />\n <Link to={searchLink} underline=\"none\">\n <ListItem\n {...renderProps}\n sx={{ my: 0 }}\n className=\"allResultsOption\"\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <Typography sx={{ flexGrow: 1, mr: 1 }}>All results</Typography>\n <ArrowForwardIcon fontSize=\"small\" />\n </Box>\n </ListItem>\n </Link>\n </Box>\n );\n }\n\n const result = results.find(r => r.document.title === option);\n return (\n <SearchResultItem\n key={index}\n option={option}\n query={query}\n result={result}\n renderProps={renderProps}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;;;AAqCO,MAAM,eAAe,CAAC;AAAA,EAC3B,MAAA;AAAA,EACA,KAAA;AAAA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AAEJ;;;;"}
1
+ {"version":3,"file":"SearchOption.esm.js","sources":["../../../src/components/SearchComponent/SearchOption.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 Box from '@mui/material/Box';\nimport Divider from '@mui/material/Divider';\nimport { Link } from '@backstage/core-components';\nimport ListItem from '@mui/material/ListItem';\nimport Typography from '@mui/material/Typography';\nimport ArrowForwardIcon from '@mui/icons-material/ArrowForward';\nimport { SearchResultItem } from './SearchResultItem';\nimport { Result, SearchDocument } from '@backstage/plugin-search-common';\nimport { SearchResultProps } from '@backstage/plugin-search-react';\n\ninterface SearchOptionProps {\n option: string;\n index: number;\n options: string[];\n query: SearchResultProps['query'];\n results: Result<SearchDocument>[];\n renderProps: any;\n searchLink: string;\n}\n\nexport const SearchOption = ({\n option,\n index,\n options,\n query,\n results,\n renderProps,\n searchLink,\n}: SearchOptionProps) => {\n if (option === query?.term && index === options.length - 1) {\n return (\n <Box key=\"all-results\" id=\"all-results\">\n <Divider sx={{ my: 0.5 }} />\n <Link to={searchLink} underline=\"none\">\n <ListItem\n {...renderProps}\n sx={{ my: 0 }}\n className=\"allResultsOption\"\n >\n <Box sx={{ display: 'flex', alignItems: 'center' }}>\n <Typography sx={{ flexGrow: 1 }}>All results</Typography>\n <ArrowForwardIcon fontSize=\"small\" />\n </Box>\n </ListItem>\n </Link>\n </Box>\n );\n }\n\n const result = results.find(r => r.document.title === option);\n return (\n <SearchResultItem\n key={index}\n option={option}\n query={query}\n result={result}\n renderProps={renderProps}\n />\n );\n};\n"],"names":[],"mappings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AAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -10,7 +10,19 @@ const SearchResultItem = ({
10
10
  query,
11
11
  result,
12
12
  renderProps
13
- }) => /* @__PURE__ */ React.createElement(Link, { to: result?.document.location ?? "#", underline: "none" }, /* @__PURE__ */ React.createElement(ListItem, { key: option, ...renderProps, sx: { cursor: "pointer", py: 2 } }, /* @__PURE__ */ React.createElement(Box, { sx: { display: "flex", width: "100%" } }, /* @__PURE__ */ React.createElement(Typography, { sx: { color: "text.primary", py: 0.5, flexGrow: 1 } }, option === "No results found" ? option : highlightMatch(option, query?.term ?? "")))));
13
+ }) => {
14
+ const isNoResultsFound = option === "No results found";
15
+ return /* @__PURE__ */ React.createElement(
16
+ Box,
17
+ {
18
+ component: isNoResultsFound ? "div" : Link,
19
+ to: result?.document.location,
20
+ underline: "none",
21
+ sx: { width: "100%", ...isNoResultsFound ? {} : { cursor: "pointer" } }
22
+ },
23
+ /* @__PURE__ */ React.createElement(ListItem, { ...renderProps, sx: { py: 1 } }, /* @__PURE__ */ React.createElement(Typography, { sx: { color: "text.primary", flexGrow: 1 } }, isNoResultsFound ? option : highlightMatch(option, query?.term ?? "")))
24
+ );
25
+ };
14
26
 
15
27
  export { SearchResultItem };
16
28
  //# sourceMappingURL=SearchResultItem.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SearchResultItem.esm.js","sources":["../../../src/components/SearchComponent/SearchResultItem.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 { Link } from '@backstage/core-components';\nimport ListItem from '@mui/material/ListItem';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport { highlightMatch } from '../../utils/stringUtils';\nimport { SearchResultProps } from '@backstage/plugin-search-react';\nimport { Result, SearchDocument } from '@backstage/plugin-search-common';\n\ninterface SearchResultItemProps {\n option: string;\n query: SearchResultProps['query'];\n result: Result<SearchDocument> | undefined;\n renderProps: any;\n}\n\nexport const SearchResultItem = ({\n option,\n query,\n result,\n renderProps,\n}: SearchResultItemProps) => (\n <Link to={result?.document.location ?? '#'} underline=\"none\">\n <ListItem key={option} {...renderProps} sx={{ cursor: 'pointer', py: 2 }}>\n <Box sx={{ display: 'flex', width: '100%' }}>\n <Typography sx={{ color: 'text.primary', py: 0.5, flexGrow: 1 }}>\n {option === 'No results found'\n ? option\n : highlightMatch(option, query?.term ?? '')}\n </Typography>\n </Box>\n </ListItem>\n </Link>\n);\n"],"names":[],"mappings":";;;;;;;AAgCO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,MAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CACE,qBAAA,KAAA,CAAA,aAAA,CAAC,IAAK,EAAA,EAAA,EAAA,EAAI,MAAQ,EAAA,QAAA,CAAS,YAAY,GAAK,EAAA,SAAA,EAAU,MACpD,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,GAAA,EAAK,QAAS,GAAG,WAAA,EAAa,EAAI,EAAA,EAAE,MAAQ,EAAA,SAAA,EAAW,IAAI,CAAE,EAAA,EAAA,kBACpE,KAAA,CAAA,aAAA,CAAA,GAAA,EAAA,EAAI,EAAI,EAAA,EAAE,SAAS,MAAQ,EAAA,KAAA,EAAO,MAAO,EAAA,EAAA,kBACvC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,IAAI,EAAE,KAAA,EAAO,cAAgB,EAAA,EAAA,EAAI,GAAK,EAAA,QAAA,EAAU,GACzD,EAAA,EAAA,MAAA,KAAW,kBACR,GAAA,MAAA,GACA,cAAe,CAAA,MAAA,EAAQ,KAAO,EAAA,IAAA,IAAQ,EAAE,CAC9C,CACF,CACF,CACF;;;;"}
1
+ {"version":3,"file":"SearchResultItem.esm.js","sources":["../../../src/components/SearchComponent/SearchResultItem.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 { Link } from '@backstage/core-components';\nimport ListItem from '@mui/material/ListItem';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport { highlightMatch } from '../../utils/stringUtils';\nimport { SearchResultProps } from '@backstage/plugin-search-react';\nimport { Result, SearchDocument } from '@backstage/plugin-search-common';\n\ninterface SearchResultItemProps {\n option: string;\n query: SearchResultProps['query'];\n result: Result<SearchDocument> | undefined;\n renderProps: any;\n}\n\nexport const SearchResultItem = ({\n option,\n query,\n result,\n renderProps,\n}: SearchResultItemProps) => {\n const isNoResultsFound = option === 'No results found';\n return (\n <Box\n component={isNoResultsFound ? 'div' : Link}\n to={result?.document.location}\n underline=\"none\"\n sx={{ width: '100%', ...(isNoResultsFound ? {} : { cursor: 'pointer' }) }}\n >\n <ListItem {...renderProps} sx={{ py: 1 }}>\n <Typography sx={{ color: 'text.primary', flexGrow: 1 }}>\n {isNoResultsFound\n ? option\n : highlightMatch(option, query?.term ?? '')}\n </Typography>\n </ListItem>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAgCO,MAAM,mBAAmB,CAAC;AAAA,EAC/B,MAAA;AAAA,EACA,KAAA;AAAA,EACA,MAAA;AAAA,EACA;AACF,CAA6B,KAAA;AAC3B,EAAA,MAAM,mBAAmB,MAAW,KAAA,kBAAA;AACpC,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,SAAA,EAAW,mBAAmB,KAAQ,GAAA,IAAA;AAAA,MACtC,EAAA,EAAI,QAAQ,QAAS,CAAA,QAAA;AAAA,MACrB,SAAU,EAAA,MAAA;AAAA,MACV,EAAA,EAAI,EAAE,KAAA,EAAO,MAAQ,EAAA,GAAI,gBAAmB,GAAA,EAAK,GAAA,EAAE,MAAQ,EAAA,SAAA,EAAa;AAAA,KAAA;AAAA,oBAExE,KAAA,CAAA,aAAA,CAAC,QAAU,EAAA,EAAA,GAAG,WAAa,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,CAAE,EAAA,EAAA,kBACpC,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,EAAI,EAAA,EAAE,OAAO,cAAgB,EAAA,QAAA,EAAU,CAAE,EAAA,EAAA,EAClD,gBACG,GAAA,MAAA,GACA,cAAe,CAAA,MAAA,EAAQ,KAAO,EAAA,IAAA,IAAQ,EAAE,CAC9C,CACF;AAAA,GACF;AAEJ;;;;"}
@@ -0,0 +1,16 @@
1
+ import React from 'react';
2
+
3
+ const Spacer = ({ growFactor = 1, minWidth = 1 }) => {
4
+ return /* @__PURE__ */ React.createElement(
5
+ "div",
6
+ {
7
+ style: {
8
+ flexGrow: growFactor,
9
+ minWidth: typeof minWidth === "number" ? minWidth * 8 : minWidth
10
+ }
11
+ }
12
+ );
13
+ };
14
+
15
+ export { Spacer };
16
+ //# sourceMappingURL=Spacer.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Spacer.esm.js","sources":["../../../src/components/Spacer/Spacer.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\n/**\n * @public\n */\nexport interface SpacerProps {\n growFactor?: number;\n minWidth?: number | string;\n}\n\n/**\n * @public\n */\nexport const Spacer = ({ growFactor = 1, minWidth = 1 }: SpacerProps) => {\n return (\n <div\n style={{\n flexGrow: growFactor,\n minWidth: typeof minWidth === 'number' ? minWidth * 8 : minWidth,\n }}\n />\n );\n};\n"],"names":[],"mappings":";;AA6BO,MAAM,SAAS,CAAC,EAAE,aAAa,CAAG,EAAA,QAAA,GAAW,GAAqB,KAAA;AACvE,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,KAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA;AAAA,QACL,QAAU,EAAA,UAAA;AAAA,QACV,QAAU,EAAA,OAAO,QAAa,KAAA,QAAA,GAAW,WAAW,CAAI,GAAA;AAAA;AAC1D;AAAA,GACF;AAEJ;;;;"}
@@ -0,0 +1,36 @@
1
+ import React from 'react';
2
+ import { useApiHolder, configApiRef } from '@backstage/core-plugin-api';
3
+ import { Link as Link$1 } from '@backstage/core-components';
4
+ import IconButton from '@mui/material/IconButton';
5
+ import Tooltip from '@mui/material/Tooltip';
6
+ import HelpIcon from '@mui/icons-material/HelpOutline';
7
+
8
+ const Link = (props) => /* @__PURE__ */ React.createElement(Link$1, { ...props, color: "inherit", externalLinkIcon: false });
9
+ const SupportButton = ({
10
+ title = "Support",
11
+ tooltip,
12
+ color = "inherit",
13
+ size = "small",
14
+ to
15
+ }) => {
16
+ const apiHolder = useApiHolder();
17
+ const config = apiHolder.get(configApiRef);
18
+ const supportUrl = to ?? config?.getOptionalString("app.support.url");
19
+ if (!supportUrl) {
20
+ return null;
21
+ }
22
+ return /* @__PURE__ */ React.createElement(Tooltip, { title: tooltip ?? title }, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
23
+ IconButton,
24
+ {
25
+ component: Link,
26
+ color,
27
+ size,
28
+ to: supportUrl,
29
+ "aria-label": title
30
+ },
31
+ /* @__PURE__ */ React.createElement(HelpIcon, { fontSize: size })
32
+ )));
33
+ };
34
+
35
+ export { SupportButton };
36
+ //# sourceMappingURL=SupportButton.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SupportButton.esm.js","sources":["../../../src/components/SupportButton/SupportButton.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nimport { configApiRef, useApiHolder } from '@backstage/core-plugin-api';\nimport { Link as BackstageLink } from '@backstage/core-components';\n\nimport IconButton from '@mui/material/IconButton';\nimport Tooltip from '@mui/material/Tooltip';\nimport HelpIcon from '@mui/icons-material/HelpOutline';\n\n/**\n * @public\n */\nexport interface SupportButtonProps {\n title?: string;\n tooltip?: string;\n color?:\n | 'inherit'\n | 'default'\n | 'primary'\n | 'secondary'\n | 'error'\n | 'info'\n | 'success'\n | 'warning';\n size?: 'small' | 'medium' | 'large';\n to?: string;\n}\n\n// Backstage Link automatically detects external links and emits analytic events.\nconst Link = (props: any) => (\n <BackstageLink {...props} color=\"inherit\" externalLinkIcon={false} />\n);\n\n/**\n * @public\n */\nexport const SupportButton = ({\n title = 'Support',\n tooltip,\n color = 'inherit',\n size = 'small',\n to,\n}: SupportButtonProps) => {\n const apiHolder = useApiHolder();\n const config = apiHolder.get(configApiRef);\n const supportUrl = to ?? config?.getOptionalString('app.support.url');\n\n if (!supportUrl) {\n return null;\n }\n\n return (\n <Tooltip title={tooltip ?? title}>\n <div>\n <IconButton\n component={Link}\n color={color}\n size={size}\n to={supportUrl}\n aria-label={title}\n >\n <HelpIcon fontSize={size} />\n </IconButton>\n </div>\n </Tooltip>\n );\n};\n"],"names":["BackstageLink"],"mappings":";;;;;;;AA6CA,MAAM,IAAA,GAAO,CAAC,KAAA,qBACX,KAAA,CAAA,aAAA,CAAAA,MAAA,EAAA,EAAe,GAAG,KAAO,EAAA,KAAA,EAAM,SAAU,EAAA,gBAAA,EAAkB,KAAO,EAAA,CAAA;AAM9D,MAAM,gBAAgB,CAAC;AAAA,EAC5B,KAAQ,GAAA,SAAA;AAAA,EACR,OAAA;AAAA,EACA,KAAQ,GAAA,SAAA;AAAA,EACR,IAAO,GAAA,OAAA;AAAA,EACP;AACF,CAA0B,KAAA;AACxB,EAAA,MAAM,YAAY,YAAa,EAAA;AAC/B,EAAM,MAAA,MAAA,GAAS,SAAU,CAAA,GAAA,CAAI,YAAY,CAAA;AACzC,EAAA,MAAM,UAAa,GAAA,EAAA,IAAM,MAAQ,EAAA,iBAAA,CAAkB,iBAAiB,CAAA;AAEpE,EAAA,IAAI,CAAC,UAAY,EAAA;AACf,IAAO,OAAA,IAAA;AAAA;AAGT,EAAA,2CACG,OAAQ,EAAA,EAAA,KAAA,EAAO,OAAW,IAAA,KAAA,EAAA,sCACxB,KACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,IAAA;AAAA,MACX,KAAA;AAAA,MACA,IAAA;AAAA,MACA,EAAI,EAAA,UAAA;AAAA,MACJ,YAAY,EAAA;AAAA,KAAA;AAAA,oBAEZ,KAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,QAAA,EAAU,IAAM,EAAA;AAAA,GAE9B,CACF,CAAA;AAEJ;;;;"}
@@ -0,0 +1,93 @@
1
+ import { LogoutButton } from '../components/LogoutButton/LogoutButton.esm.js';
2
+ import { CreateDropdown } from '../components/HeaderDropdownComponent/CreateDropdown.esm.js';
3
+ import { ProfileDropdown } from '../components/HeaderDropdownComponent/ProfileDropdown.esm.js';
4
+ import { RegisterAComponentSection } from '../components/HeaderDropdownComponent/RegisterAComponentSection.esm.js';
5
+ import { SoftwareTemplatesSection } from '../components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js';
6
+ import { SearchComponent } from '../components/SearchComponent/SearchComponent.esm.js';
7
+ import { SupportButton } from '../components/SupportButton/SupportButton.esm.js';
8
+ import { ComponentType } from '../types.esm.js';
9
+ import { NotificationButton } from '../components/NotificationButton/NotificationButton.esm.js';
10
+ import { Divider } from '../components/Divider/Divider.esm.js';
11
+ import { MenuItemLink } from '../components/MenuItemLink/MenuItemLink.esm.js';
12
+
13
+ const defaultGlobalHeaderComponentsMountPoints = [
14
+ {
15
+ Component: SearchComponent,
16
+ config: {
17
+ type: ComponentType.SEARCH,
18
+ priority: 1e3
19
+ // the greater the number, the more to the left it will be
20
+ }
21
+ },
22
+ {
23
+ Component: CreateDropdown,
24
+ config: {
25
+ priority: 900
26
+ }
27
+ },
28
+ {
29
+ Component: SupportButton,
30
+ config: {
31
+ priority: 800
32
+ }
33
+ },
34
+ {
35
+ Component: NotificationButton,
36
+ config: {
37
+ priority: 700
38
+ }
39
+ },
40
+ {
41
+ Component: Divider,
42
+ config: {
43
+ priority: 200
44
+ }
45
+ },
46
+ {
47
+ Component: ProfileDropdown,
48
+ config: {
49
+ priority: 100
50
+ // the greater the number, the more to the left it will be
51
+ }
52
+ }
53
+ ];
54
+ const defaultCreateDropdownMountPoints = [
55
+ {
56
+ Component: SoftwareTemplatesSection,
57
+ config: {
58
+ type: ComponentType.LIST,
59
+ priority: 200
60
+ }
61
+ },
62
+ {
63
+ Component: RegisterAComponentSection,
64
+ config: {
65
+ type: ComponentType.LINK,
66
+ priority: 100
67
+ }
68
+ }
69
+ ];
70
+ const defaultProfileDropdownMountPoints = [
71
+ {
72
+ Component: MenuItemLink,
73
+ config: {
74
+ type: ComponentType.LINK,
75
+ priority: 200,
76
+ props: {
77
+ title: "Settings",
78
+ icon: "manageAccounts",
79
+ link: "/settings"
80
+ }
81
+ }
82
+ },
83
+ {
84
+ Component: LogoutButton,
85
+ config: {
86
+ type: ComponentType.LOGOUT,
87
+ priority: 100
88
+ }
89
+ }
90
+ ];
91
+
92
+ export { defaultCreateDropdownMountPoints, defaultGlobalHeaderComponentsMountPoints, defaultProfileDropdownMountPoints };
93
+ //# sourceMappingURL=defaultMountPoints.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"defaultMountPoints.esm.js","sources":["../../src/defaultMountPoints/defaultMountPoints.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 { LogoutButton } from '../components/LogoutButton/LogoutButton';\nimport { CreateDropdown } from '../components/HeaderDropdownComponent/CreateDropdown';\nimport { ProfileDropdown } from '../components/HeaderDropdownComponent/ProfileDropdown';\nimport { RegisterAComponentSection } from '../components/HeaderDropdownComponent/RegisterAComponentSection';\nimport { SoftwareTemplatesSection } from '../components/HeaderDropdownComponent/SoftwareTemplatesSection';\nimport { SearchComponent } from '../components/SearchComponent/SearchComponent';\nimport { SupportButton } from '../components/SupportButton/SupportButton';\nimport {\n ComponentType,\n CreateDropdownMountPoint,\n GlobalHeaderComponentMountPoint,\n ProfileDropdownMountPoint,\n} from '../types';\nimport { NotificationButton } from '../components/NotificationButton/NotificationButton';\nimport { Divider } from '../components/Divider/Divider';\nimport { MenuItemLink } from '../components/MenuItemLink/MenuItemLink';\n\n/**\n * default Global Header Components mount points\n *\n * @public\n */\nexport const defaultGlobalHeaderComponentsMountPoints: GlobalHeaderComponentMountPoint[] =\n [\n {\n Component: SearchComponent,\n config: {\n type: ComponentType.SEARCH,\n priority: 1000, // the greater the number, the more to the left it will be\n },\n },\n {\n Component: CreateDropdown,\n config: {\n priority: 900,\n },\n },\n {\n Component: SupportButton,\n config: {\n priority: 800,\n },\n },\n {\n Component: NotificationButton,\n config: {\n priority: 700,\n },\n },\n {\n Component: Divider,\n config: {\n priority: 200,\n },\n },\n {\n Component: ProfileDropdown,\n config: {\n priority: 100, // the greater the number, the more to the left it will be\n },\n },\n ];\n\nexport const defaultCreateDropdownMountPoints: CreateDropdownMountPoint[] = [\n {\n Component: SoftwareTemplatesSection as React.ComponentType,\n config: {\n type: ComponentType.LIST,\n priority: 200,\n },\n },\n {\n Component: RegisterAComponentSection as React.ComponentType,\n config: {\n type: ComponentType.LINK,\n priority: 100,\n },\n },\n];\n\nexport const defaultProfileDropdownMountPoints: ProfileDropdownMountPoint[] = [\n {\n Component: MenuItemLink as React.ComponentType,\n config: {\n type: ComponentType.LINK,\n priority: 200,\n props: {\n title: 'Settings',\n icon: 'manageAccounts',\n link: '/settings',\n },\n },\n },\n {\n Component: LogoutButton,\n config: {\n type: ComponentType.LOGOUT,\n priority: 100,\n },\n },\n];\n"],"names":[],"mappings":";;;;;;;;;;;;AAqCO,MAAM,wCACX,GAAA;AAAA,EACE;AAAA,IACE,SAAW,EAAA,eAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,MAAM,aAAc,CAAA,MAAA;AAAA,MACpB,QAAU,EAAA;AAAA;AAAA;AACZ,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,cAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,QAAU,EAAA;AAAA;AACZ,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,aAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,QAAU,EAAA;AAAA;AACZ,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,kBAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,QAAU,EAAA;AAAA;AACZ,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,OAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,QAAU,EAAA;AAAA;AACZ,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,eAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,QAAU,EAAA;AAAA;AAAA;AACZ;AAEJ;AAEK,MAAM,gCAA+D,GAAA;AAAA,EAC1E;AAAA,IACE,SAAW,EAAA,wBAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,MAAM,aAAc,CAAA,IAAA;AAAA,MACpB,QAAU,EAAA;AAAA;AACZ,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,yBAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,MAAM,aAAc,CAAA,IAAA;AAAA,MACpB,QAAU,EAAA;AAAA;AACZ;AAEJ;AAEO,MAAM,iCAAiE,GAAA;AAAA,EAC5E;AAAA,IACE,SAAW,EAAA,YAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,MAAM,aAAc,CAAA,IAAA;AAAA,MACpB,QAAU,EAAA,GAAA;AAAA,MACV,KAAO,EAAA;AAAA,QACL,KAAO,EAAA,UAAA;AAAA,QACP,IAAM,EAAA,gBAAA;AAAA,QACN,IAAM,EAAA;AAAA;AACR;AACF,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,YAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,MAAM,aAAc,CAAA,MAAA;AAAA,MACpB,QAAU,EAAA;AAAA;AACZ;AAEJ;;;;"}
@@ -1,8 +1,12 @@
1
+ import { defaultCreateDropdownMountPoints } from '../defaultMountPoints/defaultMountPoints.esm.js';
1
2
  import { useScalprum } from '@scalprum/react-core';
2
3
 
3
4
  const useCreateDropdownMountPoints = () => {
4
5
  const scalprum = useScalprum();
5
6
  const createDropdownMountPoints = scalprum?.api?.dynamicRootConfig?.mountPoints?.["global.header/create"];
7
+ if (Object.keys(scalprum?.api || {}).length === 0) {
8
+ return defaultCreateDropdownMountPoints;
9
+ }
6
10
  return createDropdownMountPoints ?? [];
7
11
  };
8
12
 
@@ -1 +1 @@
1
- {"version":3,"file":"useCreateDropdownMountPoints.esm.js","sources":["../../src/hooks/useCreateDropdownMountPoints.ts"],"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 { CreateDropdownMountPoint, ScalprumState } from '../types';\nimport { useScalprum } from '@scalprum/react-core';\n\nexport const useCreateDropdownMountPoints = ():\n | CreateDropdownMountPoint[]\n | undefined => {\n const scalprum = useScalprum<ScalprumState>();\n\n const createDropdownMountPoints =\n scalprum?.api?.dynamicRootConfig?.mountPoints?.['global.header/create'];\n\n return createDropdownMountPoints ?? [];\n};\n"],"names":[],"mappings":";;AAmBO,MAAM,+BAA+B,MAE3B;AACf,EAAA,MAAM,WAAW,WAA2B,EAAA;AAE5C,EAAA,MAAM,yBACJ,GAAA,QAAA,EAAU,GAAK,EAAA,iBAAA,EAAmB,cAAc,sBAAsB,CAAA;AAExE,EAAA,OAAO,6BAA6B,EAAC;AACvC;;;;"}
1
+ {"version":3,"file":"useCreateDropdownMountPoints.esm.js","sources":["../../src/hooks/useCreateDropdownMountPoints.ts"],"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 { defaultCreateDropdownMountPoints } from '../defaultMountPoints/defaultMountPoints';\nimport { CreateDropdownMountPoint, ScalprumState } from '../types';\nimport { useScalprum } from '@scalprum/react-core';\n\nexport const useCreateDropdownMountPoints = ():\n | CreateDropdownMountPoint[]\n | undefined => {\n const scalprum = useScalprum<ScalprumState>();\n\n const createDropdownMountPoints =\n scalprum?.api?.dynamicRootConfig?.mountPoints?.['global.header/create'];\n\n // default profile dropdown components for dev env\n if (Object.keys(scalprum?.api || {}).length === 0) {\n return defaultCreateDropdownMountPoints;\n }\n\n return createDropdownMountPoints ?? [];\n};\n"],"names":[],"mappings":";;;AAoBO,MAAM,+BAA+B,MAE3B;AACf,EAAA,MAAM,WAAW,WAA2B,EAAA;AAE5C,EAAA,MAAM,yBACJ,GAAA,QAAA,EAAU,GAAK,EAAA,iBAAA,EAAmB,cAAc,sBAAsB,CAAA;AAGxE,EAAI,IAAA,MAAA,CAAO,KAAK,QAAU,EAAA,GAAA,IAAO,EAAE,CAAA,CAAE,WAAW,CAAG,EAAA;AACjD,IAAO,OAAA,gCAAA;AAAA;AAGT,EAAA,OAAO,6BAA6B,EAAC;AACvC;;;;"}
@@ -1,15 +1,16 @@
1
1
  import React from 'react';
2
2
 
3
3
  const useDropdownManager = () => {
4
- const [menuStates, setMenuStates] = React.useState({});
5
- const handleOpen = (key) => (event) => {
6
- setMenuStates((prev) => ({ ...prev, [key]: event.currentTarget }));
4
+ const [anchorEl, setAnchorEl] = React.useState(null);
5
+ const handleOpen = (event) => {
6
+ setAnchorEl(event.currentTarget);
7
7
  };
8
- const handleClose = (key) => () => {
9
- setMenuStates((prev) => ({ ...prev, [key]: null }));
8
+ const handleClose = () => {
9
+ setAnchorEl(null);
10
10
  };
11
11
  return {
12
- menuStates,
12
+ anchorEl,
13
+ open: !!anchorEl,
13
14
  handleOpen,
14
15
  handleClose
15
16
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useDropdownManager.esm.js","sources":["../../src/hooks/useDropdownManager.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nexport const useDropdownManager = () => {\n const [menuStates, setMenuStates] = React.useState<\n Record<string, HTMLElement | null>\n >({});\n\n const handleOpen =\n (key: string) => (event: React.MouseEvent<HTMLElement>) => {\n setMenuStates(prev => ({ ...prev, [key]: event.currentTarget }));\n };\n\n const handleClose = (key: string) => () => {\n setMenuStates(prev => ({ ...prev, [key]: null }));\n };\n\n return {\n menuStates,\n handleOpen,\n handleClose,\n };\n};\n"],"names":[],"mappings":";;AAkBO,MAAM,qBAAqB,MAAM;AACtC,EAAA,MAAM,CAAC,UAAY,EAAA,aAAa,IAAI,KAAM,CAAA,QAAA,CAExC,EAAE,CAAA;AAEJ,EAAA,MAAM,UACJ,GAAA,CAAC,GAAgB,KAAA,CAAC,KAAyC,KAAA;AACzD,IAAc,aAAA,CAAA,CAAA,IAAA,MAAS,EAAE,GAAG,IAAA,EAAM,CAAC,GAAG,GAAG,KAAM,CAAA,aAAA,EAAgB,CAAA,CAAA;AAAA,GACjE;AAEF,EAAM,MAAA,WAAA,GAAc,CAAC,GAAA,KAAgB,MAAM;AACzC,IAAc,aAAA,CAAA,CAAA,IAAA,MAAS,EAAE,GAAG,IAAA,EAAM,CAAC,GAAG,GAAG,MAAO,CAAA,CAAA;AAAA,GAClD;AAEA,EAAO,OAAA;AAAA,IACL,UAAA;AAAA,IACA,UAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
1
+ {"version":3,"file":"useDropdownManager.esm.js","sources":["../../src/hooks/useDropdownManager.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\n\nexport const useDropdownManager = () => {\n const [anchorEl, setAnchorEl] = React.useState<HTMLElement | null>(null);\n\n const handleOpen = (event: React.MouseEvent<HTMLElement>) => {\n setAnchorEl(event.currentTarget);\n };\n\n const handleClose = () => {\n setAnchorEl(null);\n };\n\n return {\n anchorEl,\n open: !!anchorEl,\n handleOpen,\n handleClose,\n };\n};\n"],"names":[],"mappings":";;AAkBO,MAAM,qBAAqB,MAAM;AACtC,EAAA,MAAM,CAAC,QAAU,EAAA,WAAW,CAAI,GAAA,KAAA,CAAM,SAA6B,IAAI,CAAA;AAEvE,EAAM,MAAA,UAAA,GAAa,CAAC,KAAyC,KAAA;AAC3D,IAAA,WAAA,CAAY,MAAM,aAAa,CAAA;AAAA,GACjC;AAEA,EAAA,MAAM,cAAc,MAAM;AACxB,IAAA,WAAA,CAAY,IAAI,CAAA;AAAA,GAClB;AAEA,EAAO,OAAA;AAAA,IACL,QAAA;AAAA,IACA,IAAA,EAAM,CAAC,CAAC,QAAA;AAAA,IACR,UAAA;AAAA,IACA;AAAA,GACF;AACF;;;;"}
@@ -0,0 +1,54 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { useApiHolder, useApi, configApiRef } from '@backstage/core-plugin-api';
3
+ import { notificationsApiRef } from '@backstage/plugin-notifications';
4
+ import { useSignal } from '@backstage/plugin-signals-react';
5
+
6
+ const useNotificationCount = () => {
7
+ const apiHolder = useApiHolder();
8
+ const { lastSignal } = useSignal("notifications");
9
+ const [available, setAvailable] = useState(false);
10
+ const [unreadCount, setUnreadCount] = useState(0);
11
+ const config = useApi(configApiRef);
12
+ const frontendPackages = config.getOptionalConfig("dynamicPlugins.frontend")?.get() ?? {};
13
+ const displayNotifications = frontendPackages["backstage.plugin-notifications"]?.dynamicRoutes?.some(
14
+ ({ path }) => path === "/notifications"
15
+ ) ?? false;
16
+ useEffect(() => {
17
+ const notificationsApi = apiHolder.get(notificationsApiRef);
18
+ if (!notificationsApi) {
19
+ return;
20
+ }
21
+ setAvailable(displayNotifications);
22
+ const fetchUnreadCount = async () => {
23
+ try {
24
+ const { notifications } = await notificationsApi.getNotifications({
25
+ read: false
26
+ });
27
+ setUnreadCount(notifications.length);
28
+ } catch (error) {
29
+ console.error("Failed to fetch unread notifications:", error);
30
+ }
31
+ };
32
+ fetchUnreadCount();
33
+ }, [apiHolder]);
34
+ useEffect(() => {
35
+ if (!lastSignal) return;
36
+ switch (lastSignal.action) {
37
+ case "notification_read":
38
+ setUnreadCount(
39
+ (prev) => Math.max(0, prev - lastSignal.notification_ids.length)
40
+ );
41
+ break;
42
+ case "notification_unread":
43
+ setUnreadCount((prev) => prev + lastSignal.notification_ids.length);
44
+ break;
45
+ case "new_notification":
46
+ setUnreadCount((prev) => prev + 1);
47
+ break;
48
+ }
49
+ }, [lastSignal]);
50
+ return { available, unreadCount };
51
+ };
52
+
53
+ export { useNotificationCount };
54
+ //# sourceMappingURL=useNotificationCount.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useNotificationCount.esm.js","sources":["../../src/hooks/useNotificationCount.ts"],"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, useState } from 'react';\nimport { configApiRef, useApi, useApiHolder } from '@backstage/core-plugin-api';\nimport { notificationsApiRef } from '@backstage/plugin-notifications';\nimport { useSignal } from '@backstage/plugin-signals-react';\nimport { NotificationSignal } from '@backstage/plugin-notifications-common';\n\nexport const useNotificationCount = () => {\n const apiHolder = useApiHolder();\n const { lastSignal } = useSignal<NotificationSignal>('notifications');\n const [available, setAvailable] = useState(false);\n const [unreadCount, setUnreadCount] = useState(0);\n\n const config = useApi(configApiRef);\n const frontendPackages =\n (config.getOptionalConfig('dynamicPlugins.frontend')?.get() as Record<\n string,\n any\n >) ?? {};\n const displayNotifications =\n frontendPackages['backstage.plugin-notifications']?.dynamicRoutes?.some(\n ({ path }: { path: string }) => path === '/notifications',\n ) ?? false;\n\n useEffect(() => {\n const notificationsApi = apiHolder.get(notificationsApiRef);\n if (!notificationsApi) {\n return;\n }\n\n setAvailable(displayNotifications);\n\n const fetchUnreadCount = async () => {\n try {\n const { notifications } = await notificationsApi.getNotifications({\n read: false,\n });\n setUnreadCount(notifications.length);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error('Failed to fetch unread notifications:', error);\n }\n };\n\n fetchUnreadCount();\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [apiHolder]);\n\n useEffect(() => {\n if (!lastSignal) return;\n\n switch (lastSignal.action) {\n case 'notification_read':\n setUnreadCount(prev =>\n Math.max(0, prev - lastSignal.notification_ids.length),\n );\n break;\n case 'notification_unread':\n setUnreadCount(prev => prev + lastSignal.notification_ids.length);\n break;\n case 'new_notification':\n setUnreadCount(prev => prev + 1);\n break;\n default:\n break;\n }\n }, [lastSignal]);\n\n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AI,CAAC,UAAY,EAAA;AAEjB,IAAA,QAAQ,WAAW,MAAQ;AAAA,MACzB,KAAK,mBAAA;AACH,QAAA,cAAA;AAAA,UAAe,UACb,IAAK,CAAA,GAAA,CAAI,GAAG,IAAO,GAAA,UAAA,CAAW,iBAAiB,MAAM;AAAA,SACvD;AACA,QAAA;AAAA,MACF,KAAK,qBAAA;AACH,QAAA,cAAA,CAAe,CAAQ,IAAA,KAAA,IAAA,GAAO,UAAW,CAAA,gBAAA,CAAiB,MAAM,CAAA;AAChE,QAAA;AAAA,MACF,KAAK,kBAAA;AACH,QAAe,cAAA,CAAA,CAAA,IAAA,KAAQ,OAAO,CAAC,CAAA;AAC/B,QAAA;AAEA;AACJ,GACF,EAAG,CAAC,UAAU,CAAC,CAAA;AAEf,EAAO,OAAA,EAAE,WAAW,WAAY,EAAA;AAClC;;;;"}
@@ -1,8 +1,12 @@
1
+ import { defaultProfileDropdownMountPoints } from '../defaultMountPoints/defaultMountPoints.esm.js';
1
2
  import { useScalprum } from '@scalprum/react-core';
2
3
 
3
4
  const useProfileDropdownMountPoints = () => {
4
5
  const scalprum = useScalprum();
5
6
  const profileDropdownMountPoints = scalprum?.api?.dynamicRootConfig?.mountPoints?.["global.header/profile"];
7
+ if (Object.keys(scalprum?.api || {}).length === 0) {
8
+ return defaultProfileDropdownMountPoints;
9
+ }
6
10
  return profileDropdownMountPoints ?? [];
7
11
  };
8
12
 
@@ -1 +1 @@
1
- {"version":3,"file":"useProfileDropdownMountPoints.esm.js","sources":["../../src/hooks/useProfileDropdownMountPoints.ts"],"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 { ProfileDropdownMountPoint, ScalprumState } from '../types';\nimport { useScalprum } from '@scalprum/react-core';\n\nexport const useProfileDropdownMountPoints = ():\n | ProfileDropdownMountPoint[]\n | undefined => {\n const scalprum = useScalprum<ScalprumState>();\n\n const profileDropdownMountPoints =\n scalprum?.api?.dynamicRootConfig?.mountPoints?.['global.header/profile'];\n\n return profileDropdownMountPoints ?? [];\n};\n"],"names":[],"mappings":";;AAmBO,MAAM,gCAAgC,MAE5B;AACf,EAAA,MAAM,WAAW,WAA2B,EAAA;AAE5C,EAAA,MAAM,0BACJ,GAAA,QAAA,EAAU,GAAK,EAAA,iBAAA,EAAmB,cAAc,uBAAuB,CAAA;AAEzE,EAAA,OAAO,8BAA8B,EAAC;AACxC;;;;"}
1
+ {"version":3,"file":"useProfileDropdownMountPoints.esm.js","sources":["../../src/hooks/useProfileDropdownMountPoints.ts"],"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 { defaultProfileDropdownMountPoints } from '../defaultMountPoints/defaultMountPoints';\nimport { ProfileDropdownMountPoint, ScalprumState } from '../types';\nimport { useScalprum } from '@scalprum/react-core';\n\nexport const useProfileDropdownMountPoints = ():\n | ProfileDropdownMountPoint[]\n | undefined => {\n const scalprum = useScalprum<ScalprumState>();\n\n const profileDropdownMountPoints =\n scalprum?.api?.dynamicRootConfig?.mountPoints?.['global.header/profile'];\n\n // default profile dropdown components for dev env\n if (Object.keys(scalprum?.api || {}).length === 0) {\n return defaultProfileDropdownMountPoints;\n }\n\n return profileDropdownMountPoints ?? [];\n};\n"],"names":[],"mappings":";;;AAoBO,MAAM,gCAAgC,MAE5B;AACf,EAAA,MAAM,WAAW,WAA2B,EAAA;AAE5C,EAAA,MAAM,0BACJ,GAAA,QAAA,EAAU,GAAK,EAAA,iBAAA,EAAmB,cAAc,uBAAuB,CAAA;AAGzE,EAAI,IAAA,MAAA,CAAO,KAAK,QAAU,EAAA,GAAA,IAAO,EAAE,CAAA,CAAE,WAAW,CAAG,EAAA;AACjD,IAAO,OAAA,iCAAA;AAAA;AAGT,EAAA,OAAO,8BAA8B,EAAC;AACxC;;;;"}