@red-hat-developer-hub/backstage-plugin-global-header 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/app-config.dynamic.yaml +54 -2
- 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 +6 -77
- package/dist/components/GlobalHeader.esm.js.map +1 -1
- package/dist/components/GlobalHeaderComponent.esm.js +25 -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 +39 -67
- package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js +15 -59
- package/dist/components/HeaderDropdownComponent/HeaderDropdownComponent.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/MenuSection.esm.js +14 -25
- package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +57 -51
- package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
- package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +30 -0
- package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -0
- package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +70 -0
- package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -0
- package/dist/components/HeaderIcon/HeaderIcon.esm.js +38 -0
- package/dist/components/HeaderIcon/HeaderIcon.esm.js.map +1 -0
- package/dist/components/HeaderIconButton/HeaderIconButton.esm.js +25 -10
- package/dist/components/HeaderIconButton/HeaderIconButton.esm.js.map +1 -1
- package/dist/components/LogoutButton/LogoutButton.esm.js +23 -0
- package/dist/components/LogoutButton/LogoutButton.esm.js.map +1 -0
- package/dist/components/MenuItemLink/MenuItemLink.esm.js +29 -0
- 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 +36 -0
- package/dist/components/NotificationButton/NotificationButton.esm.js.map +1 -0
- package/dist/components/SearchComponent/SearchBar.esm.js +38 -8
- package/dist/components/SearchComponent/SearchBar.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 +16 -0
- package/dist/components/Spacer/Spacer.esm.js.map +1 -0
- package/dist/components/SupportButton/SupportButton.esm.js +36 -0
- package/dist/components/SupportButton/SupportButton.esm.js.map +1 -0
- package/dist/defaultMountPoints/defaultMountPoints.esm.js +93 -0
- package/dist/defaultMountPoints/defaultMountPoints.esm.js.map +1 -0
- package/dist/hooks/useCreateDropdownMountPoints.esm.js +14 -0
- package/dist/hooks/useCreateDropdownMountPoints.esm.js.map +1 -0
- package/dist/hooks/useDropdownManager.esm.js +7 -6
- package/dist/hooks/useDropdownManager.esm.js.map +1 -1
- package/dist/hooks/useGlobalHeaderMountPoints.esm.js +10 -0
- package/dist/hooks/useGlobalHeaderMountPoints.esm.js.map +1 -0
- package/dist/hooks/useNotificationCount.esm.js +54 -0
- package/dist/hooks/useNotificationCount.esm.js.map +1 -0
- package/dist/hooks/useProfileDropdownMountPoints.esm.js +14 -0
- package/dist/hooks/useProfileDropdownMountPoints.esm.js.map +1 -0
- package/dist/index.d.ts +277 -4
- package/dist/index.esm.js +2 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +142 -1
- package/dist/plugin.esm.js.map +1 -1
- package/dist/types.esm.js +14 -0
- package/dist/types.esm.js.map +1 -0
- package/package.json +31 -16
- package/dist/components/HeaderDropdownComponent/MenuItemContent.esm.js +0 -15
- package/dist/components/HeaderDropdownComponent/MenuItemContent.esm.js.map +0 -1
- package/dist/components/HeaderIconButton/SmallIconWrapper.esm.js +0 -11
- package/dist/components/HeaderIconButton/SmallIconWrapper.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# @red-hat-developer-hub/backstage-plugin-global-header
|
|
2
2
|
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f35b797: First version of Global Header plugin with the following components:
|
|
8
|
+
|
|
9
|
+
- GlobalHeaderComponent
|
|
10
|
+
- SearchComponent
|
|
11
|
+
- CreateDropdown
|
|
12
|
+
- SoftwareTemplatesSection
|
|
13
|
+
- RegisterAComponentSection
|
|
14
|
+
- ProfileDropdown
|
|
15
|
+
- LogoutButton
|
|
16
|
+
- HeaderButton
|
|
17
|
+
- HeaderIcon
|
|
18
|
+
- HeaderIconButton
|
|
19
|
+
- MenuItemLink
|
|
20
|
+
- Spacer
|
|
21
|
+
- Divider
|
|
22
|
+
- NotificationBanner
|
|
23
|
+
|
|
24
|
+
## 0.0.4
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- a07a84a: Update dependencies to Backstage 1.35.0
|
|
29
|
+
- 02cd530: add new mountpoints for the search, create dropdown, profile dropdown, software templates, register a component, logout button, header link and header icon
|
|
30
|
+
|
|
3
31
|
## 0.0.3
|
|
4
32
|
|
|
5
33
|
### Patch Changes
|
package/app-config.dynamic.yaml
CHANGED
|
@@ -6,5 +6,57 @@ dynamicPlugins:
|
|
|
6
6
|
- mountPoint: application/header
|
|
7
7
|
importName: GlobalHeader
|
|
8
8
|
config:
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
position: above-main-content # above-main-content | below-main-content
|
|
10
|
+
- mountPoint: global.header/component
|
|
11
|
+
importName: SearchComponent
|
|
12
|
+
config:
|
|
13
|
+
type: search
|
|
14
|
+
priority: 100
|
|
15
|
+
- mountPoint: global.header/component
|
|
16
|
+
importName: CreateDropdown
|
|
17
|
+
config:
|
|
18
|
+
type: dropdown_button
|
|
19
|
+
priority: 90
|
|
20
|
+
- mountPoint: global.header/create
|
|
21
|
+
importName: SoftwareTemplatesSection
|
|
22
|
+
config:
|
|
23
|
+
type: list
|
|
24
|
+
priority: 10
|
|
25
|
+
- mountPoint: global.header/create
|
|
26
|
+
importName: RegisterAComponentSection
|
|
27
|
+
config:
|
|
28
|
+
type: link
|
|
29
|
+
- mountPoint: global.header/component
|
|
30
|
+
importName: HeaderIconButton
|
|
31
|
+
config:
|
|
32
|
+
type: icon_button
|
|
33
|
+
priority: 80
|
|
34
|
+
props:
|
|
35
|
+
icon: support
|
|
36
|
+
tooltip: 'Support'
|
|
37
|
+
- mountPoint: global.header/component
|
|
38
|
+
importName: HeaderIconButton
|
|
39
|
+
config:
|
|
40
|
+
type: icon_button
|
|
41
|
+
priority: 70
|
|
42
|
+
props:
|
|
43
|
+
icon: notifications
|
|
44
|
+
tooltip: 'Notifications'
|
|
45
|
+
- mountPoint: global.header/component
|
|
46
|
+
importName: ProfileDropdown
|
|
47
|
+
config:
|
|
48
|
+
type: dropdown_button
|
|
49
|
+
priority: 0
|
|
50
|
+
- mountPoint: global.header/profile
|
|
51
|
+
importName: MenuItemLink
|
|
52
|
+
config:
|
|
53
|
+
type: link
|
|
54
|
+
priority: 200
|
|
55
|
+
props:
|
|
56
|
+
title: Settings
|
|
57
|
+
link: /settings
|
|
58
|
+
icon: manageAccounts
|
|
59
|
+
- mountPoint: global.header/profile
|
|
60
|
+
importName: LogoutButton
|
|
61
|
+
config:
|
|
62
|
+
priority: 100
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import Divider$1 from '@mui/material/Divider';
|
|
3
|
+
|
|
4
|
+
const Divider = () => {
|
|
5
|
+
return /* @__PURE__ */ React.createElement(
|
|
6
|
+
Divider$1,
|
|
7
|
+
{
|
|
8
|
+
orientation: "vertical",
|
|
9
|
+
flexItem: true,
|
|
10
|
+
sx: { borderColor: "#383838", marginX: 1 }
|
|
11
|
+
}
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { Divider };
|
|
16
|
+
//# sourceMappingURL=Divider.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Divider.esm.js","sources":["../../../src/components/Divider/Divider.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 MUIDivider from '@mui/material/Divider';\n\n/**\n * @public\n */\nexport const Divider = () => {\n return (\n <MUIDivider\n orientation=\"vertical\"\n flexItem\n sx={{ borderColor: '#383838', marginX: 1 }}\n />\n );\n};\n"],"names":["MUIDivider"],"mappings":";;;AAuBO,MAAM,UAAU,MAAM;AAC3B,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAACA,SAAA;AAAA,IAAA;AAAA,MACC,WAAY,EAAA,UAAA;AAAA,MACZ,QAAQ,EAAA,IAAA;AAAA,MACR,EAAI,EAAA,EAAE,WAAa,EAAA,SAAA,EAAW,SAAS,CAAE;AAAA;AAAA,GAC3C;AAEJ;;;;"}
|
|
@@ -1,85 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { SearchComponent } from './SearchComponent/SearchComponent.esm.js';
|
|
5
|
-
import { HeaderIconButton } from './HeaderIconButton/HeaderIconButton.esm.js';
|
|
6
|
-
import CreateDropdown from './HeaderDropdownComponent/CreateDropdown.esm.js';
|
|
7
|
-
import ProfileDropdown from './HeaderDropdownComponent/ProfileDropdown.esm.js';
|
|
8
|
-
import Divider from '@mui/material/Divider';
|
|
9
|
-
import HelpOutlineOutlinedIcon from '@mui/icons-material/HelpOutlineRounded';
|
|
10
|
-
import NotificationsOutlinedIcon from '@mui/icons-material/NotificationsOutlined';
|
|
11
|
-
import { useDropdownManager } from '../hooks/useDropdownManager.esm.js';
|
|
2
|
+
import { useGlobalHeaderMountPoints } from '../hooks/useGlobalHeaderMountPoints.esm.js';
|
|
3
|
+
import { GlobalHeaderComponent } from './GlobalHeaderComponent.esm.js';
|
|
12
4
|
|
|
13
|
-
const iconButtons = [
|
|
14
|
-
{
|
|
15
|
-
key: "help",
|
|
16
|
-
Icon: HelpOutlineOutlinedIcon,
|
|
17
|
-
onClick: () => {
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
{
|
|
21
|
-
key: "notification",
|
|
22
|
-
Icon: NotificationsOutlinedIcon,
|
|
23
|
-
onClick: () => {
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
];
|
|
27
5
|
const GlobalHeader = () => {
|
|
28
|
-
const
|
|
29
|
-
const dropdownConfigs = [
|
|
30
|
-
{
|
|
31
|
-
key: "create",
|
|
32
|
-
component: CreateDropdown,
|
|
33
|
-
buttonProps: {
|
|
34
|
-
handleMenu: handleOpen("create"),
|
|
35
|
-
anchorEl: menuStates.create,
|
|
36
|
-
setAnchorEl: handleClose("create")
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
key: "profile",
|
|
41
|
-
component: ProfileDropdown,
|
|
42
|
-
buttonProps: {
|
|
43
|
-
handleMenu: handleOpen("profile"),
|
|
44
|
-
anchorEl: menuStates.profile,
|
|
45
|
-
setAnchorEl: handleClose("profile")
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
];
|
|
6
|
+
const allGlobalHeaderMountPoints = useGlobalHeaderMountPoints();
|
|
49
7
|
return /* @__PURE__ */ React.createElement(
|
|
50
|
-
|
|
8
|
+
GlobalHeaderComponent,
|
|
51
9
|
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
sx: { backgroundColor: "#212427" }
|
|
55
|
-
},
|
|
56
|
-
/* @__PURE__ */ React.createElement(Toolbar, null, /* @__PURE__ */ React.createElement(SearchComponent, null), /* @__PURE__ */ React.createElement(
|
|
57
|
-
CreateDropdown,
|
|
58
|
-
{
|
|
59
|
-
key: dropdownConfigs[0].key,
|
|
60
|
-
...dropdownConfigs[0].buttonProps
|
|
61
|
-
}
|
|
62
|
-
), iconButtons.map(({ key, Icon, onClick }) => /* @__PURE__ */ React.createElement(
|
|
63
|
-
HeaderIconButton,
|
|
64
|
-
{
|
|
65
|
-
key: `header-icon-button-${key}`,
|
|
66
|
-
Icon,
|
|
67
|
-
onClick
|
|
68
|
-
}
|
|
69
|
-
)), /* @__PURE__ */ React.createElement(
|
|
70
|
-
Divider,
|
|
71
|
-
{
|
|
72
|
-
orientation: "vertical",
|
|
73
|
-
flexItem: true,
|
|
74
|
-
sx: { borderColor: "#373A40" }
|
|
75
|
-
}
|
|
76
|
-
), /* @__PURE__ */ React.createElement(
|
|
77
|
-
ProfileDropdown,
|
|
78
|
-
{
|
|
79
|
-
key: dropdownConfigs[1].key,
|
|
80
|
-
...dropdownConfigs[1].buttonProps
|
|
81
|
-
}
|
|
82
|
-
))
|
|
10
|
+
globalHeaderMountPoints: allGlobalHeaderMountPoints ?? []
|
|
11
|
+
}
|
|
83
12
|
);
|
|
84
13
|
};
|
|
85
14
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GlobalHeader.esm.js","sources":["../../src/components/GlobalHeader.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
|
|
1
|
+
{"version":3,"file":"GlobalHeader.esm.js","sources":["../../src/components/GlobalHeader.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 { useGlobalHeaderMountPoints } from '../hooks/useGlobalHeaderMountPoints';\nimport { GlobalHeaderComponent } from './GlobalHeaderComponent';\n\nexport const GlobalHeader = () => {\n const allGlobalHeaderMountPoints = useGlobalHeaderMountPoints();\n\n return (\n <GlobalHeaderComponent\n globalHeaderMountPoints={allGlobalHeaderMountPoints ?? []}\n />\n );\n};\n"],"names":[],"mappings":";;;;AAoBO,MAAM,eAAe,MAAM;AAChC,EAAA,MAAM,6BAA6B,0BAA2B,EAAA;AAE9D,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,qBAAA;AAAA,IAAA;AAAA,MACC,uBAAA,EAAyB,8BAA8B;AAAC;AAAA,GAC1D;AAEJ;;;;"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { ErrorBoundary } from '@backstage/core-components';
|
|
3
|
+
import AppBar from '@mui/material/AppBar';
|
|
4
|
+
import Toolbar from '@mui/material/Toolbar';
|
|
5
|
+
|
|
6
|
+
const GlobalHeaderComponent = ({
|
|
7
|
+
globalHeaderMountPoints
|
|
8
|
+
}) => {
|
|
9
|
+
const mountPoints = useMemo(() => {
|
|
10
|
+
if (!globalHeaderMountPoints) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const filteredAndSorted = globalHeaderMountPoints.filter((component) => (component.config?.priority ?? 0) > -1).sort((a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0));
|
|
14
|
+
return filteredAndSorted;
|
|
15
|
+
}, [globalHeaderMountPoints]);
|
|
16
|
+
return /* @__PURE__ */ React.createElement(AppBar, { position: "sticky", component: "nav", id: "global-header" }, /* @__PURE__ */ React.createElement(Toolbar, { sx: { gap: 1 } }, mountPoints.map((mountPoint, index) => /* @__PURE__ */ React.createElement(ErrorBoundary, { key: `header-component-${index}` }, /* @__PURE__ */ React.createElement(
|
|
17
|
+
mountPoint.Component,
|
|
18
|
+
{
|
|
19
|
+
...mountPoint.config?.props
|
|
20
|
+
}
|
|
21
|
+
)))));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { GlobalHeaderComponent };
|
|
25
|
+
//# sourceMappingURL=GlobalHeaderComponent.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GlobalHeaderComponent.esm.js","sources":["../../src/components/GlobalHeaderComponent.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, { useMemo } from 'react';\n\nimport { ErrorBoundary } from '@backstage/core-components';\n\nimport AppBar from '@mui/material/AppBar';\nimport Toolbar from '@mui/material/Toolbar';\n\nimport { GlobalHeaderComponentMountPoint } from '../types';\n\n/**\n * @public\n * Global Header Component properties\n */\nexport interface GlobalHeaderComponentProps {\n globalHeaderMountPoints: GlobalHeaderComponentMountPoint[];\n}\n\nexport const GlobalHeaderComponent = ({\n globalHeaderMountPoints,\n}: GlobalHeaderComponentProps) => {\n const mountPoints = useMemo(() => {\n if (!globalHeaderMountPoints) {\n return [];\n }\n\n const filteredAndSorted = globalHeaderMountPoints\n .filter(component => (component.config?.priority ?? 0) > -1)\n .sort((a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0));\n\n return filteredAndSorted;\n }, [globalHeaderMountPoints]);\n\n return (\n <AppBar position=\"sticky\" component=\"nav\" id=\"global-header\">\n <Toolbar sx={{ gap: 1 }}>\n {mountPoints.map((mountPoint, index) => (\n <ErrorBoundary key={`header-component-${index}`}>\n <mountPoint.Component\n {...mountPoint.config?.props}\n // sx={mountPoint.config.layout}\n />\n </ErrorBoundary>\n ))}\n </Toolbar>\n </AppBar>\n );\n};\n"],"names":[],"mappings":";;;;;AAiCO,MAAM,wBAAwB,CAAC;AAAA,EACpC;AACF,CAAkC,KAAA;AAChC,EAAM,MAAA,WAAA,GAAc,QAAQ,MAAM;AAChC,IAAA,IAAI,CAAC,uBAAyB,EAAA;AAC5B,MAAA,OAAO,EAAC;AAAA;AAGV,IAAM,MAAA,iBAAA,GAAoB,wBACvB,MAAO,CAAA,CAAA,SAAA,KAAA,CAAc,UAAU,MAAQ,EAAA,QAAA,IAAY,KAAK,CAAE,CAAA,CAAA,CAC1D,KAAK,CAAC,CAAA,EAAG,OAAO,CAAE,CAAA,MAAA,EAAQ,YAAY,CAAM,KAAA,CAAA,CAAE,MAAQ,EAAA,QAAA,IAAY,CAAE,CAAA,CAAA;AAEvE,IAAO,OAAA,iBAAA;AAAA,GACT,EAAG,CAAC,uBAAuB,CAAC,CAAA;AAE5B,EACE,uBAAA,KAAA,CAAA,aAAA,CAAC,MAAO,EAAA,EAAA,QAAA,EAAS,QAAS,EAAA,SAAA,EAAU,OAAM,EAAG,EAAA,eAAA,EAAA,kBAC1C,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,EAAI,EAAA,EAAE,KAAK,CAAE,EAAA,EAAA,EACnB,WAAY,CAAA,GAAA,CAAI,CAAC,UAAA,EAAY,KAC5B,qBAAA,KAAA,CAAA,aAAA,CAAC,aAAc,EAAA,EAAA,GAAA,EAAK,CAAoB,iBAAA,EAAA,KAAK,CAC3C,CAAA,EAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAW,CAAA,SAAA;AAAA,IAAX;AAAA,MACE,GAAG,WAAW,MAAQ,EAAA;AAAA;AAAA,GAG3B,CACD,CACH,CACF,CAAA;AAEJ;;;;"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { LinkButton } from '@backstage/core-components';
|
|
3
|
+
import Tooltip from '@mui/material/Tooltip';
|
|
4
|
+
import { HeaderIcon } from '../HeaderIcon/HeaderIcon.esm.js';
|
|
5
|
+
|
|
6
|
+
const HeaderButton = ({
|
|
7
|
+
title,
|
|
8
|
+
tooltip,
|
|
9
|
+
color = "inherit",
|
|
10
|
+
size = "small",
|
|
11
|
+
variant,
|
|
12
|
+
ariaLabel,
|
|
13
|
+
startIcon,
|
|
14
|
+
endIcon,
|
|
15
|
+
externalLinkIcon = true,
|
|
16
|
+
to,
|
|
17
|
+
style
|
|
18
|
+
}) => {
|
|
19
|
+
const button = /* @__PURE__ */ React.createElement(
|
|
20
|
+
LinkButton,
|
|
21
|
+
{
|
|
22
|
+
color,
|
|
23
|
+
size,
|
|
24
|
+
variant,
|
|
25
|
+
"aria-label": ariaLabel,
|
|
26
|
+
startIcon: startIcon ? /* @__PURE__ */ React.createElement(HeaderIcon, { icon: startIcon, size }) : null,
|
|
27
|
+
endIcon: endIcon ? /* @__PURE__ */ React.createElement(HeaderIcon, { icon: endIcon, size }) : null,
|
|
28
|
+
externalLinkIcon,
|
|
29
|
+
to,
|
|
30
|
+
style
|
|
31
|
+
},
|
|
32
|
+
title
|
|
33
|
+
);
|
|
34
|
+
if (tooltip) {
|
|
35
|
+
return /* @__PURE__ */ React.createElement(Tooltip, { title: tooltip }, /* @__PURE__ */ React.createElement("div", null, button));
|
|
36
|
+
}
|
|
37
|
+
return button;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export { HeaderButton };
|
|
41
|
+
//# sourceMappingURL=HeaderButton.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"HeaderButton.esm.js","sources":["../../../src/components/HeaderButton/HeaderButton.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 { LinkButton } from '@backstage/core-components';\n\nimport Tooltip from '@mui/material/Tooltip';\nimport { HeaderIcon } from '../HeaderIcon/HeaderIcon';\n\n/**\n * @public\n */\nexport interface HeaderButtonProps {\n title: string;\n tooltip?: string;\n color?: 'inherit' | 'primary' | 'secondary' | 'default';\n size?: 'small' | 'medium' | 'large';\n variant?: 'text' | 'outlined' | 'contained';\n ariaLabel?: string;\n startIcon?: string;\n endIcon?: string;\n externalLinkIcon?: boolean;\n to: string;\n style?: React.CSSProperties;\n}\n\n/**\n * @public\n */\nexport const HeaderButton = ({\n title,\n tooltip,\n color = 'inherit',\n size = 'small',\n variant,\n ariaLabel,\n startIcon,\n endIcon,\n externalLinkIcon = true,\n to,\n style,\n}: HeaderButtonProps) => {\n const button = (\n <LinkButton\n color={color}\n size={size}\n variant={variant}\n aria-label={ariaLabel}\n startIcon={startIcon ? <HeaderIcon icon={startIcon} size={size} /> : null}\n endIcon={endIcon ? <HeaderIcon icon={endIcon} size={size} /> : null}\n externalLinkIcon={externalLinkIcon}\n to={to}\n style={style}\n >\n {title}\n </LinkButton>\n );\n\n if (tooltip) {\n return (\n <Tooltip title={tooltip}>\n <div>{button}</div>\n </Tooltip>\n );\n }\n\n return button;\n};\n"],"names":[],"mappings":";;;;;AA2CO,MAAM,eAAe,CAAC;AAAA,EAC3B,KAAA;AAAA,EACA,OAAA;AAAA,EACA,KAAQ,GAAA,SAAA;AAAA,EACR,IAAO,GAAA,OAAA;AAAA,EACP,OAAA;AAAA,EACA,SAAA;AAAA,EACA,SAAA;AAAA,EACA,OAAA;AAAA,EACA,gBAAmB,GAAA,IAAA;AAAA,EACnB,EAAA;AAAA,EACA;AACF,CAAyB,KAAA;AACvB,EAAA,MAAM,MACJ,mBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,UAAA;AAAA,IAAA;AAAA,MACC,KAAA;AAAA,MACA,IAAA;AAAA,MACA,OAAA;AAAA,MACA,YAAY,EAAA,SAAA;AAAA,MACZ,WAAW,SAAY,mBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,IAAM,EAAA,SAAA,EAAW,MAAY,CAAK,GAAA,IAAA;AAAA,MACrE,SAAS,OAAU,mBAAA,KAAA,CAAA,aAAA,CAAC,cAAW,IAAM,EAAA,OAAA,EAAS,MAAY,CAAK,GAAA,IAAA;AAAA,MAC/D,gBAAA;AAAA,MACA,EAAA;AAAA,MACA;AAAA,KAAA;AAAA,IAEC;AAAA,GACH;AAGF,EAAA,IAAI,OAAS,EAAA;AACX,IAAA,2CACG,OAAQ,EAAA,EAAA,KAAA,EAAO,2BACb,KAAA,CAAA,aAAA,CAAA,KAAA,EAAA,IAAA,EAAK,MAAO,CACf,CAAA;AAAA;AAIJ,EAAO,OAAA,MAAA;AACT;;;;"}
|
|
@@ -1,80 +1,52 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import HeaderDropdownComponent from './HeaderDropdownComponent.esm.js';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
3
2
|
import ArrowDropDownOutlinedIcon from '@mui/icons-material/ArrowDropDownOutlined';
|
|
4
|
-
import
|
|
3
|
+
import { ComponentType } from '../../types.esm.js';
|
|
4
|
+
import { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints.esm.js';
|
|
5
|
+
import { useDropdownManager } from '../../hooks/useDropdownManager.esm.js';
|
|
6
|
+
import { HeaderDropdownComponent } from './HeaderDropdownComponent.esm.js';
|
|
5
7
|
|
|
6
|
-
const
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
key: "key-3",
|
|
19
|
-
value: "create-frontend-plugin",
|
|
20
|
-
label: "Create Frontend Plugin Template"
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
key: "key-4",
|
|
24
|
-
value: "create-react-app-template-test-annotator",
|
|
25
|
-
label: "Create React App Template with annotations"
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
key: "key-5",
|
|
29
|
-
value: "define-ansible-job-template",
|
|
30
|
-
label: "Ansible Job Template"
|
|
8
|
+
const CreateDropdown = () => {
|
|
9
|
+
const { anchorEl, handleOpen, handleClose } = useDropdownManager();
|
|
10
|
+
const createDropdownMountPoints = useCreateDropdownMountPoints();
|
|
11
|
+
const menuSections = useMemo(() => {
|
|
12
|
+
return (createDropdownMountPoints ?? []).map((mp) => ({
|
|
13
|
+
Component: mp.Component,
|
|
14
|
+
type: mp.config?.type ?? ComponentType.LINK,
|
|
15
|
+
priority: mp.config?.priority ?? 0
|
|
16
|
+
})).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
17
|
+
}, [createDropdownMountPoints]);
|
|
18
|
+
if (menuSections.length === 0) {
|
|
19
|
+
return null;
|
|
31
20
|
}
|
|
32
|
-
];
|
|
33
|
-
const menuBottomItems = [
|
|
34
|
-
{
|
|
35
|
-
itemKey: "custom",
|
|
36
|
-
icon: CategoryOutlinedIcon,
|
|
37
|
-
label: "Register a component",
|
|
38
|
-
subLabel: "Import it to the catalog page",
|
|
39
|
-
link: "/catalog-import"
|
|
40
|
-
}
|
|
41
|
-
];
|
|
42
|
-
const CreateDropdown = ({
|
|
43
|
-
handleMenu,
|
|
44
|
-
anchorEl,
|
|
45
|
-
setAnchorEl
|
|
46
|
-
}) => {
|
|
47
|
-
const menuSections = [
|
|
48
|
-
{
|
|
49
|
-
sectionKey: "templates",
|
|
50
|
-
sectionLabel: "Use a template",
|
|
51
|
-
optionalLinkLabel: "All templates",
|
|
52
|
-
optionalLink: "/create",
|
|
53
|
-
items: models.map((m) => ({
|
|
54
|
-
itemKey: m.key,
|
|
55
|
-
label: m.label,
|
|
56
|
-
link: `/create/templates/default/${m.value}`
|
|
57
|
-
})),
|
|
58
|
-
handleClose: () => setAnchorEl(null)
|
|
59
|
-
}
|
|
60
|
-
];
|
|
61
21
|
return /* @__PURE__ */ React.createElement(
|
|
62
22
|
HeaderDropdownComponent,
|
|
63
23
|
{
|
|
64
24
|
buttonContent: /* @__PURE__ */ React.createElement(React.Fragment, null, "Create ", /* @__PURE__ */ React.createElement(ArrowDropDownOutlinedIcon, { sx: { ml: 1 } })),
|
|
65
|
-
menuSections,
|
|
66
|
-
menuBottomItems,
|
|
67
25
|
buttonProps: {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
26
|
+
variant: "outlined",
|
|
27
|
+
sx: {
|
|
28
|
+
color: "#fff",
|
|
29
|
+
border: "1px solid rgba(255, 255, 255, 0.5)",
|
|
30
|
+
"&:hover, &.Mui-focusVisible": {
|
|
31
|
+
border: "1px solid #fff"
|
|
32
|
+
},
|
|
33
|
+
mr: 1.5
|
|
34
|
+
}
|
|
71
35
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}
|
|
36
|
+
onOpen: handleOpen,
|
|
37
|
+
onClose: handleClose,
|
|
38
|
+
anchorEl
|
|
39
|
+
},
|
|
40
|
+
menuSections.map((section, index) => /* @__PURE__ */ React.createElement(
|
|
41
|
+
section.Component,
|
|
42
|
+
{
|
|
43
|
+
key: `menu-section-${index.toString()}`,
|
|
44
|
+
hideDivider: index === menuSections.length - 1,
|
|
45
|
+
handleClose
|
|
46
|
+
}
|
|
47
|
+
))
|
|
76
48
|
);
|
|
77
49
|
};
|
|
78
50
|
|
|
79
|
-
export { CreateDropdown
|
|
51
|
+
export { CreateDropdown };
|
|
80
52
|
//# sourceMappingURL=CreateDropdown.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreateDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/CreateDropdown.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
|
|
1
|
+
{"version":3,"file":"CreateDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/CreateDropdown.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, { useMemo } from 'react';\n\nimport ArrowDropDownOutlinedIcon from '@mui/icons-material/ArrowDropDownOutlined';\n\nimport { ComponentType } from '../../types';\nimport { MenuItemConfig } from './MenuSection';\nimport { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\n\n/**\n * @public\n * Props for each dropdown section component\n */\ninterface SectionComponentProps {\n handleClose: () => void;\n hideDivider: boolean;\n items?: MenuItemConfig[];\n}\n\nexport const CreateDropdown = () => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n\n const createDropdownMountPoints = useCreateDropdownMountPoints();\n\n const menuSections = useMemo(() => {\n return (createDropdownMountPoints ?? [])\n .map(mp => ({\n Component: mp.Component as React.ComponentType<SectionComponentProps>,\n type: mp.config?.type ?? ComponentType.LINK,\n priority: mp.config?.priority ?? 0,\n }))\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }, [createDropdownMountPoints]);\n\n if (menuSections.length === 0) {\n return null;\n }\n\n return (\n <HeaderDropdownComponent\n buttonContent={\n <>\n Create <ArrowDropDownOutlinedIcon sx={{ ml: 1 }} />\n </>\n }\n buttonProps={{\n variant: 'outlined',\n sx: {\n color: '#fff',\n border: '1px solid rgba(255, 255, 255, 0.5)',\n '&:hover, &.Mui-focusVisible': {\n border: '1px solid #fff',\n },\n mr: 1.5,\n },\n }}\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n {menuSections.map((section, index) => (\n <section.Component\n key={`menu-section-${index.toString()}`}\n hideDivider={index === menuSections.length - 1}\n handleClose={handleClose}\n />\n ))}\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;AAoCO,MAAM,iBAAiB,MAAM;AAClC,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AAEjE,EAAA,MAAM,4BAA4B,4BAA6B,EAAA;AAE/D,EAAM,MAAA,YAAA,GAAe,QAAQ,MAAM;AACjC,IAAA,OAAA,CAAQ,yBAA6B,IAAA,EAClC,EAAA,GAAA,CAAI,CAAO,EAAA,MAAA;AAAA,MACV,WAAW,EAAG,CAAA,SAAA;AAAA,MACd,IAAM,EAAA,EAAA,CAAG,MAAQ,EAAA,IAAA,IAAQ,aAAc,CAAA,IAAA;AAAA,MACvC,QAAA,EAAU,EAAG,CAAA,MAAA,EAAQ,QAAY,IAAA;AAAA,KACnC,CAAE,CACD,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAO,KAAA,CAAA,CAAA,CAAE,QAAY,IAAA,CAAA,KAAM,CAAE,CAAA,QAAA,IAAY,CAAE,CAAA,CAAA;AAAA,GACzD,EAAG,CAAC,yBAAyB,CAAC,CAAA;AAE9B,EAAI,IAAA,YAAA,CAAa,WAAW,CAAG,EAAA;AAC7B,IAAO,OAAA,IAAA;AAAA;AAGT,EACE,uBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,uBAAA;AAAA,IAAA;AAAA,MACC,aAAA,kBACI,KAAA,CAAA,aAAA,CAAA,KAAA,CAAA,QAAA,EAAA,IAAA,EAAA,SAAA,kBACQ,KAAA,CAAA,aAAA,CAAA,yBAAA,EAAA,EAA0B,IAAI,EAAE,EAAA,EAAI,CAAE,EAAA,EAAG,CACnD,CAAA;AAAA,MAEF,WAAa,EAAA;AAAA,QACX,OAAS,EAAA,UAAA;AAAA,QACT,EAAI,EAAA;AAAA,UACF,KAAO,EAAA,MAAA;AAAA,UACP,MAAQ,EAAA,oCAAA;AAAA,UACR,6BAA+B,EAAA;AAAA,YAC7B,MAAQ,EAAA;AAAA,WACV;AAAA,UACA,EAAI,EAAA;AAAA;AACN,OACF;AAAA,MACA,MAAQ,EAAA,UAAA;AAAA,MACR,OAAS,EAAA,WAAA;AAAA,MACT;AAAA,KAAA;AAAA,IAEC,YAAa,CAAA,GAAA,CAAI,CAAC,OAAA,EAAS,KAC1B,qBAAA,KAAA,CAAA,aAAA;AAAA,MAAC,OAAQ,CAAA,SAAA;AAAA,MAAR;AAAA,QACC,GAAK,EAAA,CAAA,aAAA,EAAgB,KAAM,CAAA,QAAA,EAAU,CAAA,CAAA;AAAA,QACrC,WAAA,EAAa,KAAU,KAAA,YAAA,CAAa,MAAS,GAAA,CAAA;AAAA,QAC7C;AAAA;AAAA,KAEH;AAAA,GACH;AAEJ;;;;"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Menu from '@mui/material/Menu';
|
|
3
|
-
import MenuItem from '@mui/material/MenuItem';
|
|
4
3
|
import Button from '@mui/material/Button';
|
|
5
|
-
import Typography from '@mui/material/Typography';
|
|
6
|
-
import { Link } from '@backstage/core-components';
|
|
7
4
|
import { styled } from '@mui/material/styles';
|
|
8
5
|
import Box from '@mui/material/Box';
|
|
9
|
-
import MenuSection from './MenuSection.esm.js';
|
|
10
6
|
|
|
11
7
|
const Listbox = styled("ul")(
|
|
12
8
|
({ theme }) => `
|
|
@@ -15,35 +11,36 @@ const Listbox = styled("ul")(
|
|
|
15
11
|
padding: 0;
|
|
16
12
|
margin: 0;
|
|
17
13
|
min-width: 160px;
|
|
18
|
-
border-radius:
|
|
14
|
+
border-radius: 4px;
|
|
19
15
|
text-decoration: none;
|
|
20
16
|
list-style: none;
|
|
21
17
|
overflow: auto;
|
|
22
18
|
outline: 1;
|
|
23
|
-
background: ${theme.palette.
|
|
24
|
-
border: 1px solid ${theme.palette.
|
|
19
|
+
background: ${theme.palette.background.paper};
|
|
20
|
+
border: 1px solid ${theme.palette.divider};
|
|
25
21
|
color: ${theme.palette.mode === "dark" ? theme.palette.text.disabled : theme.palette.text.primary};
|
|
26
|
-
|
|
22
|
+
boxShadow: theme.palette.mode === 'dark'
|
|
23
|
+
? '0 2px 6px 2px rgba(0,0,0,0.50), 0 1px 2px 0 rgba(0,0,0,0.50)'
|
|
24
|
+
: '0 2px 6px 2px rgba(0,0,0,0.15), 0 1px 2px 0 rgba(0,0,0,0.30)',
|
|
25
|
+
max-height: 60vh;
|
|
27
26
|
z-index: 1;
|
|
28
27
|
`
|
|
29
28
|
);
|
|
30
29
|
const HeaderDropdownComponent = ({
|
|
31
30
|
buttonContent,
|
|
32
|
-
|
|
33
|
-
menuBottomItems = [],
|
|
31
|
+
children,
|
|
34
32
|
buttonProps,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
33
|
+
onOpen,
|
|
34
|
+
onClose,
|
|
35
|
+
anchorEl
|
|
38
36
|
}) => {
|
|
39
|
-
const shouldHideDivider = (index) => menuSections.length === 1 && index === menuSections.length - 1 && menuBottomItems.length === 0;
|
|
40
37
|
return /* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(
|
|
41
38
|
Button,
|
|
42
39
|
{
|
|
43
40
|
disableRipple: true,
|
|
44
41
|
disableTouchRipple: true,
|
|
45
42
|
...buttonProps,
|
|
46
|
-
onClick:
|
|
43
|
+
onClick: onOpen
|
|
47
44
|
},
|
|
48
45
|
buttonContent
|
|
49
46
|
), /* @__PURE__ */ React.createElement(
|
|
@@ -53,7 +50,7 @@ const HeaderDropdownComponent = ({
|
|
|
53
50
|
anchorEl,
|
|
54
51
|
keepMounted: true,
|
|
55
52
|
open: Boolean(anchorEl),
|
|
56
|
-
onClose
|
|
53
|
+
onClose,
|
|
57
54
|
anchorOrigin: {
|
|
58
55
|
vertical: "bottom",
|
|
59
56
|
horizontal: "center"
|
|
@@ -68,50 +65,9 @@ const HeaderDropdownComponent = ({
|
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
67
|
},
|
|
71
|
-
/* @__PURE__ */ React.createElement(Listbox, { role: "menu" },
|
|
72
|
-
MenuSection,
|
|
73
|
-
{
|
|
74
|
-
key: `menu-section-${section.sectionKey}`,
|
|
75
|
-
...{ hideDivider: shouldHideDivider(index), ...section },
|
|
76
|
-
handleClose: section.handleClose
|
|
77
|
-
}
|
|
78
|
-
)), menuBottomItems.map(
|
|
79
|
-
({ itemKey, icon: Icon, label, subLabel, link }) => /* @__PURE__ */ React.createElement(
|
|
80
|
-
MenuItem,
|
|
81
|
-
{
|
|
82
|
-
key: `menu-item-${itemKey}`,
|
|
83
|
-
sx: { my: "8px", "&:hover": { background: "transparent" } },
|
|
84
|
-
onClick: () => setAnchorEl(null),
|
|
85
|
-
disableRipple: true
|
|
86
|
-
},
|
|
87
|
-
link && /* @__PURE__ */ React.createElement(
|
|
88
|
-
Link,
|
|
89
|
-
{
|
|
90
|
-
to: link,
|
|
91
|
-
style: {
|
|
92
|
-
display: "flex",
|
|
93
|
-
color: "inherit",
|
|
94
|
-
alignItems: "center",
|
|
95
|
-
textDecoration: "none"
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
Icon && /* @__PURE__ */ React.createElement(
|
|
99
|
-
Icon,
|
|
100
|
-
{
|
|
101
|
-
fontSize: "small",
|
|
102
|
-
style: {
|
|
103
|
-
marginRight: "0.5rem",
|
|
104
|
-
flexShrink: 0,
|
|
105
|
-
color: "slategray"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
),
|
|
109
|
-
/* @__PURE__ */ React.createElement(Box, null, /* @__PURE__ */ React.createElement(Typography, { variant: "body2" }, label), subLabel && /* @__PURE__ */ React.createElement(Typography, { variant: "caption", color: "text.secondary" }, subLabel))
|
|
110
|
-
)
|
|
111
|
-
)
|
|
112
|
-
))
|
|
68
|
+
/* @__PURE__ */ React.createElement(Listbox, { role: "menu" }, children)
|
|
113
69
|
));
|
|
114
70
|
};
|
|
115
71
|
|
|
116
|
-
export { HeaderDropdownComponent
|
|
72
|
+
export { HeaderDropdownComponent };
|
|
117
73
|
//# sourceMappingURL=HeaderDropdownComponent.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderDropdownComponent.esm.js","sources":["../../../src/components/HeaderDropdownComponent/HeaderDropdownComponent.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Menu from '@mui/material/Menu';\nimport
|
|
1
|
+
{"version":3,"file":"HeaderDropdownComponent.esm.js","sources":["../../../src/components/HeaderDropdownComponent/HeaderDropdownComponent.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport React from 'react';\nimport Menu from '@mui/material/Menu';\nimport Button from '@mui/material/Button';\nimport { styled } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\nimport { MenuItemConfig, MenuSectionConfig } from './MenuSection';\n\ninterface HeaderDropdownProps {\n buttonContent: React.ReactNode;\n children: React.ReactNode;\n menuSections?: MenuSectionConfig[];\n menuBottomItems?: MenuItemConfig[];\n buttonProps?: React.ComponentProps<typeof Button>;\n onOpen: (event: React.MouseEvent<HTMLElement>) => void;\n onClose: () => void;\n anchorEl: HTMLElement | null;\n}\n\nconst Listbox = styled('ul')(\n ({ theme }) => `\n font-size: 0.875rem;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n min-width: 160px;\n border-radius: 4px;\n text-decoration: none;\n list-style: none;\n overflow: auto;\n outline: 1;\n background: ${theme.palette.background.paper};\n border: 1px solid ${theme.palette.divider};\n color: ${\n theme.palette.mode === 'dark'\n ? theme.palette.text.disabled\n : theme.palette.text.primary\n };\n boxShadow: 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 max-height: 60vh;\n z-index: 1;\n `,\n);\n\nexport const HeaderDropdownComponent: React.FC<HeaderDropdownProps> = ({\n buttonContent,\n children,\n buttonProps,\n onOpen,\n onClose,\n anchorEl,\n}) => {\n return (\n <Box>\n <Button\n disableRipple\n disableTouchRipple\n {...buttonProps}\n onClick={onOpen}\n >\n {buttonContent}\n </Button>\n <Menu\n id=\"menu-appbar\"\n anchorEl={anchorEl}\n keepMounted\n open={Boolean(anchorEl)}\n onClose={onClose}\n anchorOrigin={{\n vertical: 'bottom',\n horizontal: 'center',\n }}\n transformOrigin={{\n vertical: 'top',\n horizontal: 'center',\n }}\n sx={{\n '& ul[class*=\"MuiMenu-list\"]': {\n py: 0,\n },\n }}\n >\n <Listbox role=\"menu\">{children}</Listbox>\n </Menu>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;;AAkCA,MAAM,OAAA,GAAU,OAAO,IAAI,CAAA;AAAA,EACzB,CAAC,EAAE,KAAA,EAAY,KAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,cAWD,EAAA,KAAA,CAAM,OAAQ,CAAA,UAAA,CAAW,KAAK,CAAA;AAAA,oBACxB,EAAA,KAAA,CAAM,QAAQ,OAAO,CAAA;AAAA,SAEvC,EAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,KAAS,MACnB,GAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,CAAK,QACnB,GAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,CAAK,OACzB,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAAA;AAOF,CAAA;AAEO,MAAM,0BAAyD,CAAC;AAAA,EACrE,aAAA;AAAA,EACA,QAAA;AAAA,EACA,WAAA;AAAA,EACA,MAAA;AAAA,EACA,OAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EAAA,2CACG,GACC,EAAA,IAAA,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,MAAA;AAAA,IAAA;AAAA,MACC,aAAa,EAAA,IAAA;AAAA,MACb,kBAAkB,EAAA,IAAA;AAAA,MACjB,GAAG,WAAA;AAAA,MACJ,OAAS,EAAA;AAAA,KAAA;AAAA,IAER;AAAA,GAEH,kBAAA,KAAA,CAAA,aAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,EAAG,EAAA,aAAA;AAAA,MACH,QAAA;AAAA,MACA,WAAW,EAAA,IAAA;AAAA,MACX,IAAA,EAAM,QAAQ,QAAQ,CAAA;AAAA,MACtB,OAAA;AAAA,MACA,YAAc,EAAA;AAAA,QACZ,QAAU,EAAA,QAAA;AAAA,QACV,UAAY,EAAA;AAAA,OACd;AAAA,MACA,eAAiB,EAAA;AAAA,QACf,QAAU,EAAA,KAAA;AAAA,QACV,UAAY,EAAA;AAAA,OACd;AAAA,MACA,EAAI,EAAA;AAAA,QACF,6BAA+B,EAAA;AAAA,UAC7B,EAAI,EAAA;AAAA;AACN;AACF,KAAA;AAAA,oBAEC,KAAA,CAAA,aAAA,CAAA,OAAA,EAAA,EAAQ,IAAK,EAAA,MAAA,EAAA,EAAQ,QAAS;AAAA,GAEnC,CAAA;AAEJ;;;;"}
|