@red-hat-developer-hub/backstage-plugin-global-header 0.0.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/app-config.dynamic.yaml +31 -38
- package/dist/components/Divider/Divider.esm.js +16 -0
- package/dist/components/Divider/Divider.esm.js.map +1 -0
- package/dist/components/GlobalHeader.esm.js +5 -90
- package/dist/components/GlobalHeader.esm.js.map +1 -1
- package/dist/components/GlobalHeaderComponent.esm.js +26 -0
- package/dist/components/GlobalHeaderComponent.esm.js.map +1 -0
- package/dist/components/HeaderButton/HeaderButton.esm.js +41 -0
- package/dist/components/HeaderButton/HeaderButton.esm.js.map +1 -0
- package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js +22 -56
- package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js +13 -10
- package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/MenuSection.esm.js +5 -14
- package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +47 -26
- package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +4 -5
- package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +48 -3
- package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -1
- package/dist/components/{HeaderIconButtonComponent → HeaderIcon}/HeaderIcon.esm.js +19 -6
- package/dist/components/HeaderIcon/HeaderIcon.esm.js.map +1 -0
- package/dist/components/HeaderIconButton/HeaderIconButton.esm.js +37 -0
- package/dist/components/HeaderIconButton/HeaderIconButton.esm.js.map +1 -0
- package/dist/components/{HeaderButtonComponent → LogoutButton}/LogoutButton.esm.js +10 -2
- package/dist/components/LogoutButton/LogoutButton.esm.js.map +1 -0
- package/dist/components/{HeaderLinkComponent/HeaderLink.esm.js → MenuItemLink/MenuItemLink.esm.js} +6 -6
- package/dist/components/MenuItemLink/MenuItemLink.esm.js.map +1 -0
- package/dist/components/MenuItemLink/MenuItemLinkContent.esm.js +40 -0
- package/dist/components/MenuItemLink/MenuItemLinkContent.esm.js.map +1 -0
- package/dist/components/NotificationButton/NotificationButton.esm.js +38 -0
- package/dist/components/NotificationButton/NotificationButton.esm.js.map +1 -0
- package/dist/components/SearchComponent/SearchBar.esm.js +37 -7
- package/dist/components/SearchComponent/SearchBar.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchComponent.esm.js +1 -2
- package/dist/components/SearchComponent/SearchComponent.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchInput.esm.js +0 -1
- package/dist/components/SearchComponent/SearchInput.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchOption.esm.js +1 -1
- package/dist/components/SearchComponent/SearchOption.esm.js.map +1 -1
- package/dist/components/SearchComponent/SearchResultItem.esm.js +13 -1
- package/dist/components/SearchComponent/SearchResultItem.esm.js.map +1 -1
- package/dist/components/Spacer/Spacer.esm.js +21 -0
- package/dist/components/Spacer/Spacer.esm.js.map +1 -0
- package/dist/components/SupportButton/SupportButton.esm.js +45 -0
- package/dist/components/SupportButton/SupportButton.esm.js.map +1 -0
- package/dist/defaultMountPoints/defaultMountPoints.esm.js +107 -0
- package/dist/defaultMountPoints/defaultMountPoints.esm.js.map +1 -0
- package/dist/hooks/useCreateDropdownMountPoints.esm.js +4 -0
- package/dist/hooks/useCreateDropdownMountPoints.esm.js.map +1 -1
- package/dist/hooks/useDropdownManager.esm.js +7 -6
- package/dist/hooks/useDropdownManager.esm.js.map +1 -1
- package/dist/hooks/useNotificationCount.esm.js +51 -0
- package/dist/hooks/useNotificationCount.esm.js.map +1 -0
- package/dist/hooks/useProfileDropdownMountPoints.esm.js +4 -0
- package/dist/hooks/useProfileDropdownMountPoints.esm.js.map +1 -1
- package/dist/index.d.ts +177 -41
- package/dist/index.esm.js +2 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +109 -14
- package/dist/plugin.esm.js.map +1 -1
- package/package.json +6 -1
- package/dist/components/HeaderButtonComponent/HeaderButton.esm.js +0 -17
- package/dist/components/HeaderButtonComponent/HeaderButton.esm.js.map +0 -1
- package/dist/components/HeaderButtonComponent/LogoutButton.esm.js.map +0 -1
- package/dist/components/HeaderIconButtonComponent/HeaderIcon.esm.js.map +0 -1
- package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js +0 -25
- package/dist/components/HeaderIconButtonComponent/HeaderIconButton.esm.js.map +0 -1
- package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js +0 -19
- package/dist/components/HeaderLinkComponent/HeaderItemContent.esm.js.map +0 -1
- package/dist/components/HeaderLinkComponent/HeaderLink.esm.js.map +0 -1
- package/dist/types.esm.js +0 -17
- package/dist/types.esm.js.map +0 -1
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useState, useRef, useEffect } from 'react';
|
|
2
2
|
import { SearchResultState } from '@backstage/plugin-search-react';
|
|
3
3
|
import Autocomplete from '@mui/material/Autocomplete';
|
|
4
4
|
import { createSearchLink } from '../../utils/stringUtils.esm.js';
|
|
5
5
|
import { useNavigate } from 'react-router-dom';
|
|
6
6
|
import { SearchInput } from './SearchInput.esm.js';
|
|
7
7
|
import { SearchOption } from './SearchOption.esm.js';
|
|
8
|
+
import { useTheme } from '@mui/material/styles';
|
|
8
9
|
|
|
9
10
|
const SearchBar = (props) => {
|
|
10
11
|
const { query, setSearchTerm } = props;
|
|
11
12
|
const navigate = useNavigate();
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
const [highlightedIndex, setHighlightedIndex] = useState(-1);
|
|
15
|
+
const highlightedIndexRef = useRef(highlightedIndex);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
highlightedIndexRef.current = highlightedIndex;
|
|
18
|
+
}, [highlightedIndex]);
|
|
12
19
|
return /* @__PURE__ */ React.createElement(SearchResultState, { ...props }, ({ loading, error, value }) => {
|
|
13
20
|
const results = query?.term ? value?.results ?? [] : [];
|
|
14
21
|
let options = [];
|
|
22
|
+
if (query?.term && results.length === 0) {
|
|
23
|
+
options = ["No results found"];
|
|
24
|
+
}
|
|
15
25
|
if (results.length > 0) {
|
|
16
26
|
options = [
|
|
17
27
|
...results.map((result) => result.document.title),
|
|
18
28
|
`${query?.term}`
|
|
19
29
|
];
|
|
20
|
-
} else if (query?.term) {
|
|
21
|
-
options = ["No results found"];
|
|
22
30
|
}
|
|
23
31
|
const searchLink = createSearchLink(query?.term ?? "");
|
|
24
32
|
return /* @__PURE__ */ React.createElement(
|
|
@@ -27,17 +35,39 @@ const SearchBar = (props) => {
|
|
|
27
35
|
freeSolo: true,
|
|
28
36
|
options,
|
|
29
37
|
loading,
|
|
38
|
+
value: query?.term ?? "",
|
|
30
39
|
getOptionLabel: (option) => option ?? "",
|
|
31
40
|
onInputChange: (_, inputValue) => setSearchTerm(inputValue),
|
|
32
|
-
|
|
41
|
+
onHighlightChange: (_, option) => setHighlightedIndex(options.indexOf(option ?? "")),
|
|
42
|
+
componentsProps: {
|
|
43
|
+
paper: {
|
|
44
|
+
sx: {
|
|
45
|
+
borderRadius: "4px",
|
|
46
|
+
outline: "unset",
|
|
47
|
+
border: `1px solid ${theme.palette.divider}`,
|
|
48
|
+
boxShadow: theme.palette.mode === "dark" ? `0 2px 6px 2px rgba(0, 0, 0, 0.50), 0 1px 2px 0 rgba(0, 0, 0, 0.50)` : "0 2px 6px 2px rgba(0, 0, 0, 0.15), 0 1px 2px 0 rgba(0, 0, 0, 0.30)"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
sx: {
|
|
53
|
+
width: "100%",
|
|
54
|
+
'& [class*="MuiAutocomplete-clearIndicator"]': {
|
|
55
|
+
visibility: query?.term ? "visible" : "hidden"
|
|
56
|
+
}
|
|
57
|
+
},
|
|
33
58
|
filterOptions: (x) => x,
|
|
34
|
-
getOptionDisabled: (option) => option === "No results found",
|
|
35
59
|
onKeyDown: (event) => {
|
|
60
|
+
const currentHighlight = highlightedIndexRef.current;
|
|
36
61
|
if (event.key === "Enter") {
|
|
37
62
|
event.preventDefault();
|
|
38
|
-
if (query?.term) {
|
|
63
|
+
if (currentHighlight === -1 && query?.term) {
|
|
39
64
|
navigate(searchLink);
|
|
65
|
+
} else if (currentHighlight !== -1) {
|
|
66
|
+
navigate(
|
|
67
|
+
results[highlightedIndex]?.document?.location ?? searchLink
|
|
68
|
+
);
|
|
40
69
|
}
|
|
70
|
+
setHighlightedIndex(-1);
|
|
41
71
|
}
|
|
42
72
|
},
|
|
43
73
|
renderInput: (params) => /* @__PURE__ */ React.createElement(
|
|
@@ -61,7 +91,7 @@ const SearchBar = (props) => {
|
|
|
61
91
|
}
|
|
62
92
|
),
|
|
63
93
|
ListboxProps: {
|
|
64
|
-
|
|
94
|
+
sx: { maxHeight: "60vh" }
|
|
65
95
|
}
|
|
66
96
|
}
|
|
67
97
|
);
|
|
@@ -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 }
|
|
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 );\n};\n"],"names":[],"mappings":";;;;;;;;;AAgCa,MAAA,SAAA,GAAY,CAAC,KAA0B,KAAA;AAClD,EAAM,MAAA,EAAE,KAAO,EAAA,aAAA,EAAkB,GAAA,KAAA;AACjC,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAA,MAAM,CAAC,gBAAA,EAAkB,mBAAmB,CAAA,GAAI,SAAS,CAAE,CAAA,CAAA;AAC3D,EAAM,MAAA,mBAAA,GAAsB,OAAO,gBAAgB,CAAA;AAEnD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,mBAAA,CAAoB,OAAU,GAAA,gBAAA;AAAA,GAChC,EAAG,CAAC,gBAAgB,CAAC,CAAA;AAErB,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,qBAAmB,GAAG,KAAA,EAAA,EACpB,CAAC,EAAE,OAAA,EAAS,KAAO,EAAA,KAAA,EAAY,KAAA;AAC9B,IAAA,MAAM,UAAU,KAAO,EAAA,IAAA,GAAO,OAAO,OAAW,IAAA,KAAK,EAAC;AACtD,IAAA,IAAI,UAAoB,EAAC;AACzB,IAAA,IAAI,KAAO,EAAA,IAAA,IAAQ,OAAQ,CAAA,MAAA,KAAW,CAAG,EAAA;AACvC,MAAA,OAAA,GAAU,CAAC,kBAAkB,CAAA;AAAA;AAE/B,IAAI,IAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AACtB,MAAU,OAAA,GAAA;AAAA,QACR,GAAG,OAAQ,CAAA,GAAA,CAAI,CAAU,MAAA,KAAA,MAAA,CAAO,SAAS,KAAK,CAAA;AAAA,QAC9C,CAAA,EAAG,OAAO,IAAI,CAAA;AAAA,OAChB;AAAA;AAEF,IAAA,MAAM,UAAa,GAAA,gBAAA,CAAiB,KAAO,EAAA,IAAA,IAAQ,EAAE,CAAA;AAErD,IACE,uBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,QAAQ,EAAA,IAAA;AAAA,QACR,OAAA;AAAA,QACA,OAAA;AAAA,QACA,KAAA,EAAO,OAAO,IAAQ,IAAA,EAAA;AAAA,QACtB,cAAA,EAAgB,YAAU,MAAU,IAAA,EAAA;AAAA,QACpC,aAAe,EAAA,CAAC,CAAG,EAAA,UAAA,KAAe,cAAc,UAAU,CAAA;AAAA,QAC1D,iBAAA,EAAmB,CAAC,CAAG,EAAA,MAAA,KACrB,oBAAoB,OAAQ,CAAA,OAAA,CAAQ,MAAU,IAAA,EAAE,CAAC,CAAA;AAAA,QAEnD,eAAiB,EAAA;AAAA,UACf,KAAO,EAAA;AAAA,YACL,EAAI,EAAA;AAAA,cACF,YAAc,EAAA,KAAA;AAAA,cACd,OAAS,EAAA,OAAA;AAAA,cACT,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,OAAO,CAAA,CAAA;AAAA,cAC1C,SACE,EAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,KAAS,SACnB,CACA,kEAAA,CAAA,GAAA;AAAA;AACR;AACF,SACF;AAAA,QACA,EAAI,EAAA;AAAA,UACF,KAAO,EAAA,MAAA;AAAA,UACP,6CAA+C,EAAA;AAAA,YAC7C,UAAA,EAAY,KAAO,EAAA,IAAA,GAAO,SAAY,GAAA;AAAA;AACxC,SACF;AAAA,QACA,eAAe,CAAK,CAAA,KAAA,CAAA;AAAA,QACpB,WAAW,CAAS,KAAA,KAAA;AAClB,UAAA,MAAM,mBAAmB,mBAAoB,CAAA,OAAA;AAC7C,UAAI,IAAA,KAAA,CAAM,QAAQ,OAAS,EAAA;AACzB,YAAA,KAAA,CAAM,cAAe,EAAA;AACrB,YAAI,IAAA,gBAAA,KAAqB,CAAM,CAAA,IAAA,KAAA,EAAO,IAAM,EAAA;AAC1C,cAAA,QAAA,CAAS,UAAU,CAAA;AAAA,aACrB,MAAA,IAAW,qBAAqB,CAAI,CAAA,EAAA;AAClC,cAAA,QAAA;AAAA,gBACE,OAAQ,CAAA,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;;;;"}
|
|
@@ -14,8 +14,7 @@ const SearchComponent = () => {
|
|
|
14
14
|
display: "flex",
|
|
15
15
|
flexDirection: "row",
|
|
16
16
|
justifyContent: "start",
|
|
17
|
-
direction: "ltr"
|
|
18
|
-
mr: 4
|
|
17
|
+
direction: "ltr"
|
|
19
18
|
}
|
|
20
19
|
},
|
|
21
20
|
/* @__PURE__ */ React.createElement(SearchBar, { query: { term: searchTerm }, setSearchTerm })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchComponent.esm.js","sources":["../../../src/components/SearchComponent/SearchComponent.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, { useState } from 'react';\nimport Box from '@mui/material/Box';\nimport { SearchBar } from './SearchBar';\nimport { SearchContextProvider } from '@backstage/plugin-search-react';\n\nexport const SearchComponent = () => {\n const [searchTerm, setSearchTerm] = useState<string>('');\n\n return (\n <SearchContextProvider>\n <Box\n sx={{\n position: 'relative',\n flexGrow: 1,\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'start',\n direction: 'ltr',\n
|
|
1
|
+
{"version":3,"file":"SearchComponent.esm.js","sources":["../../../src/components/SearchComponent/SearchComponent.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, { useState } from 'react';\nimport Box from '@mui/material/Box';\nimport { SearchBar } from './SearchBar';\nimport { SearchContextProvider } from '@backstage/plugin-search-react';\n\nexport const SearchComponent = () => {\n const [searchTerm, setSearchTerm] = useState<string>('');\n\n return (\n <SearchContextProvider>\n <Box\n sx={{\n position: 'relative',\n flexGrow: 1,\n display: 'flex',\n flexDirection: 'row',\n justifyContent: 'start',\n direction: 'ltr',\n }}\n >\n <SearchBar query={{ term: searchTerm }} setSearchTerm={setSearchTerm} />\n </Box>\n </SearchContextProvider>\n );\n};\n"],"names":[],"mappings":";;;;;AAqBO,MAAM,kBAAkB,MAAM;AACnC,EAAA,MAAM,CAAC,UAAA,EAAY,aAAa,CAAA,GAAI,SAAiB,EAAE,CAAA;AAEvD,EAAA,2CACG,qBACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,QAAU,EAAA,UAAA;AAAA,QACV,QAAU,EAAA,CAAA;AAAA,QACV,OAAS,EAAA,MAAA;AAAA,QACT,aAAe,EAAA,KAAA;AAAA,QACf,cAAgB,EAAA,OAAA;AAAA,QAChB,SAAW,EAAA;AAAA;AACb,KAAA;AAAA,wCAEC,SAAU,EAAA,EAAA,KAAA,EAAO,EAAE,IAAM,EAAA,UAAA,IAAc,aAA8B,EAAA;AAAA,GAE1E,CAAA;AAEJ;;;;"}
|
|
@@ -21,7 +21,6 @@ const SearchInput = ({
|
|
|
21
21
|
startAdornment: /* @__PURE__ */ React.createElement(InputAdornment, { position: "start" }, /* @__PURE__ */ React.createElement(SearchIcon, { style: { color: "#fff" } }))
|
|
22
22
|
},
|
|
23
23
|
sx: {
|
|
24
|
-
pt: "6px",
|
|
25
24
|
input: { color: "#fff" },
|
|
26
25
|
button: { color: "#fff" },
|
|
27
26
|
"& fieldset": { border: "none" }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchInput.esm.js","sources":["../../../src/components/SearchComponent/SearchInput.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 TextField from '@mui/material/TextField';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport SearchIcon from '@mui/icons-material/Search';\n\ninterface SearchInputProps {\n params: any;\n error: boolean;\n helperText: string;\n}\n\nexport const SearchInput = ({\n params,\n error,\n helperText,\n}: SearchInputProps) => (\n <TextField\n {...params}\n placeholder=\"Search...\"\n variant=\"standard\"\n error={error}\n helperText={helperText}\n InputProps={{\n ...params.InputProps,\n disableUnderline: true,\n startAdornment: (\n <InputAdornment position=\"start\">\n <SearchIcon style={{ color: '#fff' }} />\n </InputAdornment>\n ),\n }}\n sx={{\n
|
|
1
|
+
{"version":3,"file":"SearchInput.esm.js","sources":["../../../src/components/SearchComponent/SearchInput.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 TextField from '@mui/material/TextField';\nimport InputAdornment from '@mui/material/InputAdornment';\nimport SearchIcon from '@mui/icons-material/Search';\n\ninterface SearchInputProps {\n params: any;\n error: boolean;\n helperText: string;\n}\n\nexport const SearchInput = ({\n params,\n error,\n helperText,\n}: SearchInputProps) => (\n <TextField\n {...params}\n placeholder=\"Search...\"\n variant=\"standard\"\n error={error}\n helperText={helperText}\n InputProps={{\n ...params.InputProps,\n disableUnderline: true,\n startAdornment: (\n <InputAdornment position=\"start\">\n <SearchIcon style={{ color: '#fff' }} />\n </InputAdornment>\n ),\n }}\n sx={{\n input: { color: '#fff' },\n button: { color: '#fff' },\n '& fieldset': { border: 'none' },\n }}\n />\n);\n"],"names":[],"mappings":";;;;;AA2BO,MAAM,cAAc,CAAC;AAAA,EAC1B,MAAA;AAAA,EACA,KAAA;AAAA,EACA;AACF,CACE,qBAAA,KAAA,CAAA,aAAA;AAAA,EAAC,SAAA;AAAA,EAAA;AAAA,IACE,GAAG,MAAA;AAAA,IACJ,WAAY,EAAA,WAAA;AAAA,IACZ,OAAQ,EAAA,UAAA;AAAA,IACR,KAAA;AAAA,IACA,UAAA;AAAA,IACA,UAAY,EAAA;AAAA,MACV,GAAG,MAAO,CAAA,UAAA;AAAA,MACV,gBAAkB,EAAA,IAAA;AAAA,MAClB,cACE,kBAAA,KAAA,CAAA,aAAA,CAAC,cAAe,EAAA,EAAA,QAAA,EAAS,OACvB,EAAA,kBAAA,KAAA,CAAA,aAAA,CAAC,UAAW,EAAA,EAAA,KAAA,EAAO,EAAE,KAAA,EAAO,MAAO,EAAA,EAAG,CACxC;AAAA,KAEJ;AAAA,IACA,EAAI,EAAA;AAAA,MACF,KAAA,EAAO,EAAE,KAAA,EAAO,MAAO,EAAA;AAAA,MACvB,MAAA,EAAQ,EAAE,KAAA,EAAO,MAAO,EAAA;AAAA,MACxB,YAAA,EAAc,EAAE,MAAA,EAAQ,MAAO;AAAA;AACjC;AACF;;;;"}
|
|
@@ -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
|
|
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
|
|
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":";;;;;;;;;AAqCO,MAAM,eAAe,CAAC;AAAA,EAC3B,MAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAA;AAAA,EACA,OAAA;AAAA,EACA,WAAA;AAAA,EACA;AACF,CAAyB,KAAA;AACvB,EAAA,IAAI,WAAW,KAAO,EAAA,IAAA,IAAQ,KAAU,KAAA,OAAA,CAAQ,SAAS,CAAG,EAAA;AAC1D,IAAA,2CACG,GAAI,EAAA,EAAA,GAAA,EAAI,eAAc,EAAG,EAAA,aAAA,EAAA,sCACvB,OAAQ,EAAA,EAAA,EAAA,EAAI,EAAE,EAAI,EAAA,GAAA,IAAO,CAC1B,kBAAA,KAAA,CAAA,aAAA,CAAC,QAAK,EAAI,EAAA,UAAA,EAAY,WAAU,MAC9B,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QACE,GAAG,WAAA;AAAA,QACJ,EAAA,EAAI,EAAE,EAAA,EAAI,CAAE,EAAA;AAAA,QACZ,SAAU,EAAA;AAAA,OAAA;AAAA,sBAEV,KAAA,CAAA,aAAA,CAAC,OAAI,EAAI,EAAA,EAAE,SAAS,MAAQ,EAAA,UAAA,EAAY,QAAS,EAAA,EAAA,kBAC9C,KAAA,CAAA,aAAA,CAAA,UAAA,EAAA,EAAW,IAAI,EAAE,QAAA,EAAU,GAAK,EAAA,EAAA,aAAW,mBAC3C,KAAA,CAAA,aAAA,CAAA,gBAAA,EAAA,EAAiB,QAAS,EAAA,OAAA,EAAQ,CACrC;AAAA,KAEJ,CACF,CAAA;AAAA;AAIJ,EAAA,MAAM,SAAS,OAAQ,CAAA,IAAA,CAAK,OAAK,CAAE,CAAA,QAAA,CAAS,UAAU,MAAM,CAAA;AAC5D,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,gBAAA;AAAA,IAAA;AAAA,MACC,GAAK,EAAA,KAAA;AAAA,MACL,MAAA;AAAA,MACA,KAAA;AAAA,MACA,MAAA;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -10,7 +10,19 @@ const SearchResultItem = ({
|
|
|
10
10
|
query,
|
|
11
11
|
result,
|
|
12
12
|
renderProps
|
|
13
|
-
}) =>
|
|
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
|
|
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,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const Spacer = ({
|
|
4
|
+
growFactor = 1,
|
|
5
|
+
minWidth = 1,
|
|
6
|
+
layout
|
|
7
|
+
}) => {
|
|
8
|
+
return /* @__PURE__ */ React.createElement(
|
|
9
|
+
"div",
|
|
10
|
+
{
|
|
11
|
+
style: {
|
|
12
|
+
flexGrow: growFactor,
|
|
13
|
+
minWidth: typeof minWidth === "number" ? minWidth * 8 : minWidth,
|
|
14
|
+
...layout
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { Spacer };
|
|
21
|
+
//# 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 layout?: React.CSSProperties;\n}\n\n/**\n * @public\n */\nexport const Spacer = ({\n growFactor = 1,\n minWidth = 1,\n layout,\n}: SpacerProps) => {\n return (\n <div\n style={{\n flexGrow: growFactor,\n minWidth: typeof minWidth === 'number' ? minWidth * 8 : minWidth,\n ...layout,\n }}\n />\n );\n};\n"],"names":[],"mappings":";;AA8BO,MAAM,SAAS,CAAC;AAAA,EACrB,UAAa,GAAA,CAAA;AAAA,EACb,QAAW,GAAA,CAAA;AAAA,EACX;AACF,CAAmB,KAAA;AACjB,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,QAAA;AAAA,QACxD,GAAG;AAAA;AACL;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -0,0 +1,45 @@
|
|
|
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 Box from '@mui/material/Box';
|
|
5
|
+
import IconButton from '@mui/material/IconButton';
|
|
6
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
7
|
+
import HelpIcon from '@mui/icons-material/HelpOutline';
|
|
8
|
+
|
|
9
|
+
const Link = (props) => /* @__PURE__ */ React.createElement(Link$1, { ...props, color: "inherit", externalLinkIcon: false });
|
|
10
|
+
const SupportButton = ({
|
|
11
|
+
title = "Support",
|
|
12
|
+
tooltip,
|
|
13
|
+
color = "inherit",
|
|
14
|
+
size = "small",
|
|
15
|
+
to,
|
|
16
|
+
layout
|
|
17
|
+
}) => {
|
|
18
|
+
const apiHolder = useApiHolder();
|
|
19
|
+
const config = apiHolder.get(configApiRef);
|
|
20
|
+
const supportUrl = to ?? config?.getOptionalString("app.support.url");
|
|
21
|
+
if (!supportUrl) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const isExternalLink = supportUrl.startsWith("http") || supportUrl.startsWith("https");
|
|
25
|
+
return /* @__PURE__ */ React.createElement(Box, { sx: layout }, /* @__PURE__ */ React.createElement(
|
|
26
|
+
Tooltip,
|
|
27
|
+
{
|
|
28
|
+
title: tooltip ?? `${title}${isExternalLink ? " (external link)" : ""}`
|
|
29
|
+
},
|
|
30
|
+
/* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement(
|
|
31
|
+
IconButton,
|
|
32
|
+
{
|
|
33
|
+
component: Link,
|
|
34
|
+
color,
|
|
35
|
+
size,
|
|
36
|
+
to: supportUrl,
|
|
37
|
+
"aria-label": title
|
|
38
|
+
},
|
|
39
|
+
/* @__PURE__ */ React.createElement(HelpIcon, { fontSize: size })
|
|
40
|
+
))
|
|
41
|
+
));
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export { SupportButton };
|
|
45
|
+
//# 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 Box from '@mui/material/Box';\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 layout?: React.CSSProperties;\n}\n\n// Backstage Link automatically detects external links and emits analytic events.\nconst Link = (props: any) => (\n <BackstageLink {...props} color=\"inherit\" externalLinkIcon={false} />\n);\n\n/**\n * @public\n */\nexport const SupportButton = ({\n title = 'Support',\n tooltip,\n color = 'inherit',\n size = 'small',\n to,\n layout,\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 const isExternalLink =\n supportUrl.startsWith('http') || supportUrl.startsWith('https');\n\n return (\n <Box sx={layout}>\n <Tooltip\n title={tooltip ?? `${title}${isExternalLink ? ' (external link)' : ''}`}\n >\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 </Box>\n );\n};\n"],"names":["BackstageLink"],"mappings":";;;;;;;;AA+CA,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,EAAA;AAAA,EACA;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,MAAM,iBACJ,UAAW,CAAA,UAAA,CAAW,MAAM,CAAK,IAAA,UAAA,CAAW,WAAW,OAAO,CAAA;AAEhE,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,GAAI,EAAA,EAAA,EAAA,EAAI,MACP,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,OAAA;AAAA,IAAA;AAAA,MACC,OAAO,OAAW,IAAA,CAAA,EAAG,KAAK,CAAG,EAAA,cAAA,GAAiB,qBAAqB,EAAE,CAAA;AAAA,KAAA;AAAA,wCAEpE,KACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACC,SAAW,EAAA,IAAA;AAAA,QACX,KAAA;AAAA,QACA,IAAA;AAAA,QACA,EAAI,EAAA,UAAA;AAAA,QACJ,YAAY,EAAA;AAAA,OAAA;AAAA,sBAEZ,KAAA,CAAA,aAAA,CAAC,QAAS,EAAA,EAAA,QAAA,EAAU,IAAM,EAAA;AAAA,KAE9B;AAAA,GAEJ,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,107 @@
|
|
|
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 { NotificationButton } from '../components/NotificationButton/NotificationButton.esm.js';
|
|
9
|
+
import { Divider } from '../components/Divider/Divider.esm.js';
|
|
10
|
+
import { MenuItemLink } from '../components/MenuItemLink/MenuItemLink.esm.js';
|
|
11
|
+
import { Spacer } from '../components/Spacer/Spacer.esm.js';
|
|
12
|
+
|
|
13
|
+
const defaultGlobalHeaderComponentsMountPoints = [
|
|
14
|
+
{
|
|
15
|
+
Component: SearchComponent,
|
|
16
|
+
config: {
|
|
17
|
+
priority: 100
|
|
18
|
+
// the greater the number, the more to the left it will be
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
Component: Spacer,
|
|
23
|
+
config: {
|
|
24
|
+
priority: 99,
|
|
25
|
+
// the greater the number, the more to the left it will be
|
|
26
|
+
props: {
|
|
27
|
+
growFactor: 0
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
// Notice: 1.5 ships with a Create link instead of a dropdown!!!
|
|
32
|
+
{
|
|
33
|
+
Component: CreateDropdown,
|
|
34
|
+
config: {
|
|
35
|
+
priority: 90,
|
|
36
|
+
layout: {
|
|
37
|
+
display: {
|
|
38
|
+
sm: "none",
|
|
39
|
+
md: "block"
|
|
40
|
+
},
|
|
41
|
+
mr: 1.5
|
|
42
|
+
}
|
|
43
|
+
// I don't used MUI v5 specific `sx` types here to allow us changing the implementation later
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
Component: SupportButton,
|
|
48
|
+
config: {
|
|
49
|
+
priority: 80
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
Component: NotificationButton,
|
|
54
|
+
config: {
|
|
55
|
+
priority: 70
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
Component: Divider,
|
|
60
|
+
config: {
|
|
61
|
+
priority: 50
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
Component: ProfileDropdown,
|
|
66
|
+
config: {
|
|
67
|
+
priority: 10
|
|
68
|
+
// the greater the number, the more to the left it will be
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
const defaultCreateDropdownMountPoints = [
|
|
73
|
+
{
|
|
74
|
+
Component: SoftwareTemplatesSection,
|
|
75
|
+
config: {
|
|
76
|
+
priority: 200
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
Component: RegisterAComponentSection,
|
|
81
|
+
config: {
|
|
82
|
+
priority: 100
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
];
|
|
86
|
+
const defaultProfileDropdownMountPoints = [
|
|
87
|
+
{
|
|
88
|
+
Component: MenuItemLink,
|
|
89
|
+
config: {
|
|
90
|
+
priority: 200,
|
|
91
|
+
props: {
|
|
92
|
+
title: "Settings",
|
|
93
|
+
icon: "manageAccounts",
|
|
94
|
+
link: "/settings"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
Component: LogoutButton,
|
|
100
|
+
config: {
|
|
101
|
+
priority: 100
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
export { defaultCreateDropdownMountPoints, defaultGlobalHeaderComponentsMountPoints, defaultProfileDropdownMountPoints };
|
|
107
|
+
//# 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 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';\nimport { Spacer } from '../components/Spacer/Spacer';\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 priority: 100, // the greater the number, the more to the left it will be\n },\n },\n {\n Component: Spacer,\n config: {\n priority: 99, // the greater the number, the more to the left it will be\n props: {\n growFactor: 0,\n },\n },\n },\n // Notice: 1.5 ships with a Create link instead of a dropdown!!!\n {\n Component: CreateDropdown,\n config: {\n priority: 90,\n layout: {\n display: {\n sm: 'none',\n md: 'block',\n },\n mr: 1.5,\n } as any as React.CSSProperties, // I don't used MUI v5 specific `sx` types here to allow us changing the implementation later\n },\n },\n {\n Component: SupportButton,\n config: {\n priority: 80,\n },\n },\n {\n Component: NotificationButton,\n config: {\n priority: 70,\n },\n },\n {\n Component: Divider,\n config: {\n priority: 50,\n },\n },\n {\n Component: ProfileDropdown,\n config: {\n priority: 10, // 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 priority: 200,\n },\n },\n {\n Component: RegisterAComponentSection as React.ComponentType,\n config: {\n priority: 100,\n },\n },\n];\n\nexport const defaultProfileDropdownMountPoints: ProfileDropdownMountPoint[] = [\n {\n Component: MenuItemLink as React.ComponentType,\n config: {\n priority: 200,\n props: {\n title: 'Settings',\n icon: 'manageAccounts',\n link: '/settings',\n },\n },\n },\n {\n Component: LogoutButton,\n config: {\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,QAAU,EAAA;AAAA;AAAA;AACZ,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,MAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,QAAU,EAAA,EAAA;AAAA;AAAA,MACV,KAAO,EAAA;AAAA,QACL,UAAY,EAAA;AAAA;AACd;AACF,GACF;AAAA;AAAA,EAEA;AAAA,IACE,SAAW,EAAA,cAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,QAAU,EAAA,EAAA;AAAA,MACV,MAAQ,EAAA;AAAA,QACN,OAAS,EAAA;AAAA,UACP,EAAI,EAAA,MAAA;AAAA,UACJ,EAAI,EAAA;AAAA,SACN;AAAA,QACA,EAAI,EAAA;AAAA;AACN;AAAA;AACF,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,QAAU,EAAA;AAAA;AACZ,GACF;AAAA,EACA;AAAA,IACE,SAAW,EAAA,yBAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,QAAU,EAAA;AAAA;AACZ;AAEJ;AAEO,MAAM,iCAAiE,GAAA;AAAA,EAC5E;AAAA,IACE,SAAW,EAAA,YAAA;AAAA,IACX,MAAQ,EAAA;AAAA,MACN,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,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":"
|
|
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 [
|
|
5
|
-
const handleOpen = (
|
|
6
|
-
|
|
4
|
+
const [anchorEl, setAnchorEl] = React.useState(null);
|
|
5
|
+
const handleOpen = (event) => {
|
|
6
|
+
setAnchorEl(event.currentTarget);
|
|
7
7
|
};
|
|
8
|
-
const handleClose = (
|
|
9
|
-
|
|
8
|
+
const handleClose = () => {
|
|
9
|
+
setAnchorEl(null);
|
|
10
10
|
};
|
|
11
11
|
return {
|
|
12
|
-
|
|
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 [
|
|
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,51 @@
|
|
|
1
|
+
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useApiHolder } 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
|
+
useEffect(() => {
|
|
12
|
+
const notificationsApi = apiHolder.get(notificationsApiRef);
|
|
13
|
+
if (!notificationsApi) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!available) {
|
|
17
|
+
setAvailable(true);
|
|
18
|
+
}
|
|
19
|
+
const fetchUnreadCount = async () => {
|
|
20
|
+
try {
|
|
21
|
+
const { notifications } = await notificationsApi.getNotifications({
|
|
22
|
+
read: false
|
|
23
|
+
});
|
|
24
|
+
setUnreadCount(notifications.length);
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error("Failed to fetch unread notifications:", error);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
fetchUnreadCount();
|
|
30
|
+
}, [apiHolder]);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (!lastSignal) return;
|
|
33
|
+
switch (lastSignal.action) {
|
|
34
|
+
case "notification_read":
|
|
35
|
+
setUnreadCount(
|
|
36
|
+
(prev) => Math.max(0, prev - lastSignal.notification_ids.length)
|
|
37
|
+
);
|
|
38
|
+
break;
|
|
39
|
+
case "notification_unread":
|
|
40
|
+
setUnreadCount((prev) => prev + lastSignal.notification_ids.length);
|
|
41
|
+
break;
|
|
42
|
+
case "new_notification":
|
|
43
|
+
setUnreadCount((prev) => prev + 1);
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
}, [lastSignal]);
|
|
47
|
+
return { available, unreadCount };
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export { useNotificationCount };
|
|
51
|
+
//# 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 { 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 useEffect(() => {\n const notificationsApi = apiHolder.get(notificationsApiRef);\n if (!notificationsApi) {\n return;\n }\n if (!available) {\n setAvailable(true);\n }\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 return { available, unreadCount };\n};\n"],"names":[],"mappings":";;;;;AAsBO,MAAM,uBAAuB,MAAM;AACxC,EAAA,MAAM,YAAY,YAAa,EAAA;AAC/B,EAAA,MAAM,EAAE,UAAA,EAAe,GAAA,SAAA,CAA8B,eAAe,CAAA;AACpE,EAAA,MAAM,CAAC,SAAA,EAAW,YAAY,CAAA,GAAI,SAAS,KAAK,CAAA;AAChD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,SAAS,CAAC,CAAA;AAEhD,EAAA,SAAA,CAAU,MAAM;AACd,IAAM,MAAA,gBAAA,GAAmB,SAAU,CAAA,GAAA,CAAI,mBAAmB,CAAA;AAC1D,IAAA,IAAI,CAAC,gBAAkB,EAAA;AACrB,MAAA;AAAA;AAEF,IAAA,IAAI,CAAC,SAAW,EAAA;AACd,MAAA,YAAA,CAAa,IAAI,CAAA;AAAA;AAGnB,IAAA,MAAM,mBAAmB,YAAY;AACnC,MAAI,IAAA;AACF,QAAA,MAAM,EAAE,aAAA,EAAkB,GAAA,MAAM,iBAAiB,gBAAiB,CAAA;AAAA,UAChE,IAAM,EAAA;AAAA,SACP,CAAA;AACD,QAAA,cAAA,CAAe,cAAc,MAAM,CAAA;AAAA,eAC5B,KAAO,EAAA;AAEd,QAAQ,OAAA,CAAA,KAAA,CAAM,yCAAyC,KAAK,CAAA;AAAA;AAC9D,KACF;AAEA,IAAiB,gBAAA,EAAA;AAAA,GAEnB,EAAG,CAAC,SAAS,CAAC,CAAA;AAEd,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,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":"
|
|
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;;;;"}
|