@red-hat-developer-hub/backstage-plugin-global-header 1.15.0 → 1.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/dist/components/HeaderDropdownComponent/ApplicationLauncherDropdown.esm.js +7 -3
  3. package/dist/components/HeaderDropdownComponent/ApplicationLauncherDropdown.esm.js.map +1 -1
  4. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js +6 -1
  5. package/dist/components/HeaderDropdownComponent/CreateDropdown.esm.js.map +1 -1
  6. package/dist/components/HeaderDropdownComponent/DropdownEmptyState.esm.js +34 -25
  7. package/dist/components/HeaderDropdownComponent/DropdownEmptyState.esm.js.map +1 -1
  8. package/dist/components/HeaderDropdownComponent/HelpDropdown.esm.js +75 -17
  9. package/dist/components/HeaderDropdownComponent/HelpDropdown.esm.js.map +1 -1
  10. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js +4 -1
  11. package/dist/components/HeaderDropdownComponent/MenuSection.esm.js.map +1 -1
  12. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js +8 -4
  13. package/dist/components/HeaderDropdownComponent/ProfileDropdown.esm.js.map +1 -1
  14. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js +4 -2
  15. package/dist/components/HeaderDropdownComponent/RegisterAComponentSection.esm.js.map +1 -1
  16. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js +6 -4
  17. package/dist/components/HeaderDropdownComponent/SoftwareTemplatesSection.esm.js.map +1 -1
  18. package/dist/components/HeaderDropdownComponent/StarredDropdown.esm.js +10 -5
  19. package/dist/components/HeaderDropdownComponent/StarredDropdown.esm.js.map +1 -1
  20. package/dist/components/LogoutButton/LogoutButton.esm.js +19 -9
  21. package/dist/components/LogoutButton/LogoutButton.esm.js.map +1 -1
  22. package/dist/components/MenuItemLink/MenuItemLink.esm.js +5 -2
  23. package/dist/components/MenuItemLink/MenuItemLink.esm.js.map +1 -1
  24. package/dist/components/NotificationBanner.esm.js +6 -2
  25. package/dist/components/NotificationBanner.esm.js.map +1 -1
  26. package/dist/components/NotificationButton/NotificationButton.esm.js +6 -3
  27. package/dist/components/NotificationButton/NotificationButton.esm.js.map +1 -1
  28. package/dist/components/SearchComponent/SearchBar.esm.js +4 -2
  29. package/dist/components/SearchComponent/SearchBar.esm.js.map +1 -1
  30. package/dist/components/SearchComponent/SearchInput.esm.js +23 -19
  31. package/dist/components/SearchComponent/SearchInput.esm.js.map +1 -1
  32. package/dist/components/SupportButton/SupportButton.esm.js +5 -2
  33. package/dist/components/SupportButton/SupportButton.esm.js.map +1 -1
  34. package/dist/defaultMountPoints/defaultMountPoints.esm.js +7 -7
  35. package/dist/defaultMountPoints/defaultMountPoints.esm.js.map +1 -1
  36. package/dist/hooks/useTranslation.esm.js +8 -0
  37. package/dist/hooks/useTranslation.esm.js.map +1 -0
  38. package/dist/hooks/useValidComponentTracker.esm.js +39 -0
  39. package/dist/hooks/useValidComponentTracker.esm.js.map +1 -0
  40. package/dist/index.d.ts +49 -2
  41. package/dist/index.esm.js +2 -0
  42. package/dist/index.esm.js.map +1 -1
  43. package/dist/plugin.esm.js +4 -1
  44. package/dist/plugin.esm.js.map +1 -1
  45. package/dist/translations/de.esm.js +43 -0
  46. package/dist/translations/de.esm.js.map +1 -0
  47. package/dist/translations/es.esm.js +43 -0
  48. package/dist/translations/es.esm.js.map +1 -0
  49. package/dist/translations/fr.esm.js +43 -0
  50. package/dist/translations/fr.esm.js.map +1 -0
  51. package/dist/translations/index.esm.js +15 -0
  52. package/dist/translations/index.esm.js.map +1 -0
  53. package/dist/translations/it.esm.js +43 -0
  54. package/dist/translations/it.esm.js.map +1 -0
  55. package/dist/translations/ref.esm.js +63 -0
  56. package/dist/translations/ref.esm.js.map +1 -0
  57. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,22 @@
1
1
  # @red-hat-developer-hub/backstage-plugin-global-header
2
2
 
3
+ ## 1.16.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 6d86c5c: Add internationalization (i18n) support with German, French, Italian, and Spanish translations.
8
+
9
+ ### Patch Changes
10
+
11
+ - cf9f6d0: Fixed dropdown empty state corners by removing the border line
12
+
13
+ ## 1.15.1
14
+
15
+ ### Patch Changes
16
+
17
+ - aaaaf2d: Add divider above Sign out option in profile dropdown for better visual separation
18
+ - b991a8a: Show empty state when no help items available
19
+
3
20
  ## 1.15.0
4
21
 
5
22
  ### Minor Changes
@@ -4,12 +4,16 @@ import AppsIcon from '@mui/icons-material/Apps';
4
4
  import AppRegistrationIcon from '@mui/icons-material/AppRegistration';
5
5
  import { useApplicationLauncherDropdownMountPoints } from '../../hooks/useApplicationLauncherDropdownMountPoints.esm.js';
6
6
  import { useDropdownManager } from '../../hooks/useDropdownManager.esm.js';
7
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
8
+ import '@backstage/core-plugin-api';
9
+ import '@backstage/core-plugin-api/alpha';
7
10
  import { HeaderDropdownComponent } from './HeaderDropdownComponent.esm.js';
8
11
  import { MenuSection } from './MenuSection.esm.js';
9
12
  import { DropdownEmptyState } from './DropdownEmptyState.esm.js';
10
13
 
11
14
  const ApplicationLauncherDropdown = () => {
12
15
  const { anchorEl, handleOpen, handleClose } = useDropdownManager();
16
+ const { t } = useTranslation();
13
17
  const mountPoints = useApplicationLauncherDropdownMountPoints();
14
18
  const sectionsObject = useMemo(() => {
15
19
  const groupedSections = {};
@@ -39,7 +43,7 @@ const ApplicationLauncherDropdown = () => {
39
43
  HeaderDropdownComponent,
40
44
  {
41
45
  buttonContent: /* @__PURE__ */ jsx(AppsIcon, {}),
42
- tooltip: "Application launcher",
46
+ tooltip: t("applicationLauncher.tooltip"),
43
47
  isIconButton: true,
44
48
  onOpen: handleOpen,
45
49
  onClose: handleClose,
@@ -60,8 +64,8 @@ const ApplicationLauncherDropdown = () => {
60
64
  ) : /* @__PURE__ */ jsx(
61
65
  DropdownEmptyState,
62
66
  {
63
- title: "No application links configured",
64
- subTitle: "Configure application links in dynamic plugin config for quick access from here.",
67
+ title: t("applicationLauncher.noLinksTitle"),
68
+ subTitle: t("applicationLauncher.noLinksSubtitle"),
65
69
  icon: /* @__PURE__ */ jsx(
66
70
  AppRegistrationIcon,
67
71
  {
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationLauncherDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/ApplicationLauncherDropdown.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 { useMemo } from 'react';\n\nimport AppsIcon from '@mui/icons-material/Apps';\nimport AppRegistrationIcon from '@mui/icons-material/AppRegistration';\n\nimport { useApplicationLauncherDropdownMountPoints } from '../../hooks/useApplicationLauncherDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { MenuSection } from './MenuSection';\nimport { DropdownEmptyState } from './DropdownEmptyState';\n\nexport const ApplicationLauncherDropdown = () => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n\n const mountPoints = useApplicationLauncherDropdownMountPoints();\n\n const sectionsObject = useMemo(() => {\n const groupedSections: Record<\n string,\n { sectionLink?: string; sectionLinkLabel?: string; items: any[] }\n > = {};\n\n (mountPoints ?? []).forEach(mp => {\n const section = mp.config?.section ?? '';\n const sectionLink = mp.config?.sectionLink ?? '';\n const sectionLinkLabel = mp.config?.sectionLinkLabel ?? '';\n\n if (!groupedSections[section]) {\n groupedSections[section] = { sectionLink, sectionLinkLabel, items: [] };\n }\n groupedSections[section].items.push({\n Component: mp.Component,\n icon: mp.config?.props?.icon,\n label: mp.config?.props?.title,\n link: mp.config?.props?.link,\n external: mp.config?.props?.external ?? false,\n priority: mp.config?.priority ?? 0,\n });\n });\n\n Object.values(groupedSections).forEach(section => {\n section.items.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n });\n\n return groupedSections;\n }, [mountPoints]);\n\n const sections = Object.entries(sectionsObject);\n\n return (\n <HeaderDropdownComponent\n buttonContent={<AppsIcon />}\n tooltip=\"Application launcher\"\n isIconButton\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n {sections.length > 0 ? (\n sections.map(\n ([section, { sectionLink, sectionLinkLabel, items }], index) => (\n <MenuSection\n key={section}\n sectionLabel={section}\n optionalLink={sectionLink}\n optionalLinkLabel={sectionLinkLabel}\n items={items}\n handleClose={handleClose}\n hideDivider={index === sections.length - 1}\n />\n ),\n )\n ) : (\n <DropdownEmptyState\n title=\"No application links configured\"\n subTitle=\"Configure application links in dynamic plugin config for quick access from here.\"\n icon={\n <AppRegistrationIcon\n sx={{ fontSize: 64, color: 'text.disabled' }}\n />\n }\n />\n )}\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;AA0BO,MAAM,8BAA8B,MAAM;AAC/C,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AAEjE,EAAA,MAAM,cAAc,yCAA0C,EAAA;AAE9D,EAAM,MAAA,cAAA,GAAiB,QAAQ,MAAM;AACnC,IAAA,MAAM,kBAGF,EAAC;AAEL,IAAA,CAAC,WAAe,IAAA,EAAI,EAAA,OAAA,CAAQ,CAAM,EAAA,KAAA;AAChC,MAAM,MAAA,OAAA,GAAU,EAAG,CAAA,MAAA,EAAQ,OAAW,IAAA,EAAA;AACtC,MAAM,MAAA,WAAA,GAAc,EAAG,CAAA,MAAA,EAAQ,WAAe,IAAA,EAAA;AAC9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A,sBAAA;AAAA,MACR,YAAY,EAAA,IAAA;AAAA,MACZ,MAAQ,EAAA,UAAA;AAAA,MACR,OAAS,EAAA,WAAA;AAAA,MACT,QAAA;AAAA,MAEC,QAAA,EAAA,QAAA,CAAS,MAAS,GAAA,CAAA,GACjB,QAAS,CAAA,GAAA;AAAA,QACP,CAAC,CAAC,OAAS,EAAA,EAAE,aAAa,gBAAkB,EAAA,KAAA,EAAO,CAAA,EAAG,KACpD,qBAAA,GAAA;AAAA,UAAC,WAAA;AAAA,UAAA;AAAA,YAEC,YAAc,EAAA,OAAA;AAAA,YACd,YAAc,EAAA,WAAA;AAAA,YACd,iBAAmB,EAAA,gBAAA;AAAA,YACnB,KAAA;AAAA,YACA,WAAA;AAAA,YACA,WAAA,EAAa,KAAU,KAAA,QAAA,CAAS,MAAS,GAAA;AAAA,WAAA;AAAA,UANpC;AAAA;AAOP,OAIJ,mBAAA,GAAA;AAAA,QAAC,kBAAA;AAAA,QAAA;AAAA,UACC,KAAM,EAAA,iCAAA;AAAA,UACN,QAAS,EAAA,kFAAA;AAAA,UACT,IACE,kBAAA,GAAA;AAAA,YAAC,mBAAA;AAAA,YAAA;AAAA,cACC,EAAI,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,OAAO,eAAgB;AAAA;AAAA;AAC7C;AAAA;AAEJ;AAAA,GAEJ;AAEJ;;;;"}
1
+ {"version":3,"file":"ApplicationLauncherDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/ApplicationLauncherDropdown.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 { useMemo } from 'react';\n\nimport AppsIcon from '@mui/icons-material/Apps';\nimport AppRegistrationIcon from '@mui/icons-material/AppRegistration';\n\nimport { useApplicationLauncherDropdownMountPoints } from '../../hooks/useApplicationLauncherDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { MenuSection } from './MenuSection';\nimport { DropdownEmptyState } from './DropdownEmptyState';\nimport { useTranslation } from '../../hooks/useTranslation';\n\nexport const ApplicationLauncherDropdown = () => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n const { t } = useTranslation();\n\n const mountPoints = useApplicationLauncherDropdownMountPoints();\n\n const sectionsObject = useMemo(() => {\n const groupedSections: Record<\n string,\n { sectionLink?: string; sectionLinkLabel?: string; items: any[] }\n > = {};\n\n (mountPoints ?? []).forEach(mp => {\n const section = mp.config?.section ?? '';\n const sectionLink = mp.config?.sectionLink ?? '';\n const sectionLinkLabel = mp.config?.sectionLinkLabel ?? '';\n\n if (!groupedSections[section]) {\n groupedSections[section] = { sectionLink, sectionLinkLabel, items: [] };\n }\n groupedSections[section].items.push({\n Component: mp.Component,\n icon: mp.config?.props?.icon,\n label: mp.config?.props?.title,\n link: mp.config?.props?.link,\n external: mp.config?.props?.external ?? false,\n priority: mp.config?.priority ?? 0,\n });\n });\n\n Object.values(groupedSections).forEach(section => {\n section.items.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n });\n\n return groupedSections;\n }, [mountPoints]);\n\n const sections = Object.entries(sectionsObject);\n\n return (\n <HeaderDropdownComponent\n buttonContent={<AppsIcon />}\n tooltip={t('applicationLauncher.tooltip')}\n isIconButton\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n {sections.length > 0 ? (\n sections.map(\n ([section, { sectionLink, sectionLinkLabel, items }], index) => (\n <MenuSection\n key={section}\n sectionLabel={section}\n optionalLink={sectionLink}\n optionalLinkLabel={sectionLinkLabel}\n items={items}\n handleClose={handleClose}\n hideDivider={index === sections.length - 1}\n />\n ),\n )\n ) : (\n <DropdownEmptyState\n title={t('applicationLauncher.noLinksTitle')}\n subTitle={t('applicationLauncher.noLinksSubtitle')}\n icon={\n <AppRegistrationIcon\n sx={{ fontSize: 64, color: 'text.disabled' }}\n />\n }\n />\n )}\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;AA2BO,MAAM,8BAA8B,MAAM;AAC/C,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AACjE,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAE7B,EAAA,MAAM,cAAc,yCAA0C,EAAA;AAE9D,EAAM,MAAA,cAAA,GAAiB,QAAQ,MAAM;AACnC,IAAA,MAAM,kBAGF,EAAC;AAEL,IAAA,CAAC,WAAe,IAAA,EAAI,EAAA,OAAA,CAAQ,CAAM,EAAA,KAAA;AAChC,MAAM,MAAA,OAAA,GAAU,EAAG,CAAA,MAAA,EAAQ,OAAW,IAAA,EAAA;AACtC,MAAM,MAAA,WAAA,GAAc,EAAG,CAAA,MAAA,EAAQ,WAAe,IAAA,EAAA;AAC9C,MAAM,MAAA,gBAAA,GAAmB,EAAG,CAAA,MAAA,EAAQ,gBAAoB,IAAA,EAAA;AAExD,MAAI,IAAA,CAAC,eAAgB,CAAA,OAAO,CAAG,EAAA;AAC7B,QAAA,eAAA,CAAgB,OAAO,CAAI,GAAA,EAAE,aAAa,gBAAkB,EAAA,KAAA,EAAO,EAAG,EAAA;AAAA;AAExE,MAAgB,eAAA,CAAA,OAAO,CAAE,CAAA,KAAA,CAAM,IAAK,CAAA;AAAA,QAClC,WAAW,EAAG,CAAA,SAAA;AAAA,QACd,IAAA,EAAM,EAAG,CAAA,MAAA,EAAQ,KAAO,EAAA,IAAA;AAAA,QACxB,KAAA,EAAO,EAAG,CAAA,MAAA,EAAQ,KAAO,EAAA,KAAA;AAAA,QACzB,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AAA,EAAa,KAAU,KAAA,QAAA,CAAS,MAAS,GAAA;AAAA,WAAA;AAAA,UANpC;AAAA;AAOP,OAIJ,mBAAA,GAAA;AAAA,QAAC,kBAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAO,EAAE,kCAAkC,CAAA;AAAA,UAC3C,QAAA,EAAU,EAAE,qCAAqC,CAAA;AAAA,UACjD,IACE,kBAAA,GAAA;AAAA,YAAC,mBAAA;AAAA,YAAA;AAAA,cACC,EAAI,EAAA,EAAE,QAAU,EAAA,EAAA,EAAI,OAAO,eAAgB;AAAA;AAAA;AAC7C;AAAA;AAEJ;AAAA,GAEJ;AAEJ;;;;"}
@@ -2,11 +2,15 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import { useMemo } from 'react';
3
3
  import ArrowDropDownOutlinedIcon from '@mui/icons-material/ArrowDropDownOutlined';
4
4
  import { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints.esm.js';
5
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
5
6
  import { useDropdownManager } from '../../hooks/useDropdownManager.esm.js';
7
+ import '@backstage/core-plugin-api';
8
+ import '@backstage/core-plugin-api/alpha';
6
9
  import { HeaderDropdownComponent } from './HeaderDropdownComponent.esm.js';
7
10
  import Box from '@mui/material/Box';
8
11
 
9
12
  const CreateDropdown = ({ layout }) => {
13
+ const { t } = useTranslation();
10
14
  const { anchorEl, handleOpen, handleClose } = useDropdownManager();
11
15
  const createDropdownMountPoints = useCreateDropdownMountPoints();
12
16
  const menuSections = useMemo(() => {
@@ -22,7 +26,8 @@ const CreateDropdown = ({ layout }) => {
22
26
  HeaderDropdownComponent,
23
27
  {
24
28
  buttonContent: /* @__PURE__ */ jsxs(Box, { sx: { display: "flex", alignItems: "center" }, children: [
25
- "Self-service ",
29
+ t("create.title"),
30
+ " ",
26
31
  /* @__PURE__ */ jsx(ArrowDropDownOutlinedIcon, { sx: { ml: 1 } })
27
32
  ] }),
28
33
  buttonProps: {
@@ -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 { useMemo } from 'react';\nimport type { CSSProperties, ComponentType } from 'react';\n\nimport ArrowDropDownOutlinedIcon from '@mui/icons-material/ArrowDropDownOutlined';\n\nimport { MenuItemConfig } from './MenuSection';\nimport { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport Box from '@mui/material/Box';\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\n/**\n * @public\n * Props for Create Dropdown\n */\nexport interface CreateDropdownProps {\n layout?: CSSProperties;\n}\n\nexport const CreateDropdown = ({ layout }: CreateDropdownProps) => {\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 ComponentType<SectionComponentProps>,\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 <Box sx={{ display: 'flex', alignItems: 'center' }}>\n Self-service <ArrowDropDownOutlinedIcon sx={{ ml: 1 }} />\n </Box>\n }\n buttonProps={{\n variant: 'outlined',\n sx: {\n color: 'inherit',\n ...layout,\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":";;;;;;;;AA6CO,MAAM,cAAiB,GAAA,CAAC,EAAE,MAAA,EAAkC,KAAA;AACjE,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,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,GAAA;AAAA,IAAC,uBAAA;AAAA,IAAA;AAAA,MACC,aAAA,uBACG,GAAI,EAAA,EAAA,EAAA,EAAI,EAAE,OAAS,EAAA,MAAA,EAAQ,UAAY,EAAA,QAAA,EAAY,EAAA,QAAA,EAAA;AAAA,QAAA,eAAA;AAAA,4BACpC,yBAA0B,EAAA,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,GAAK,EAAA;AAAA,OACzD,EAAA,CAAA;AAAA,MAEF,WAAa,EAAA;AAAA,QACX,OAAS,EAAA,UAAA;AAAA,QACT,EAAI,EAAA;AAAA,UACF,KAAO,EAAA,SAAA;AAAA,UACP,GAAG;AAAA;AACL,OACF;AAAA,MACA,MAAQ,EAAA,UAAA;AAAA,MACR,OAAS,EAAA,WAAA;AAAA,MACT,QAAA;AAAA,MAEC,QAAa,EAAA,YAAA,CAAA,GAAA,CAAI,CAAC,OAAA,EAAS,KAC1B,qBAAA,GAAA;AAAA,QAAC,OAAQ,CAAA,SAAA;AAAA,QAAR;AAAA,UAEC,WAAA,EAAa,KAAU,KAAA,YAAA,CAAa,MAAS,GAAA,CAAA;AAAA,UAC7C;AAAA,SAAA;AAAA,QAFK,CAAA,aAAA,EAAgB,KAAM,CAAA,QAAA,EAAU,CAAA;AAAA,OAIxC;AAAA;AAAA,GACH;AAEJ;;;;"}
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 { useMemo } from 'react';\nimport type { CSSProperties, ComponentType } from 'react';\n\nimport ArrowDropDownOutlinedIcon from '@mui/icons-material/ArrowDropDownOutlined';\n\nimport { MenuItemConfig } from './MenuSection';\nimport { useCreateDropdownMountPoints } from '../../hooks/useCreateDropdownMountPoints';\nimport { useTranslation } from '../../hooks/useTranslation';\nimport { useDropdownManager } from '../../hooks';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport Box from '@mui/material/Box';\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\n/**\n * @public\n * Props for Create Dropdown\n */\nexport interface CreateDropdownProps {\n layout?: CSSProperties;\n}\n\nexport const CreateDropdown = ({ layout }: CreateDropdownProps) => {\n const { t } = useTranslation();\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 ComponentType<SectionComponentProps>,\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 <Box sx={{ display: 'flex', alignItems: 'center' }}>\n {t('create.title')} <ArrowDropDownOutlinedIcon sx={{ ml: 1 }} />\n </Box>\n }\n buttonProps={{\n variant: 'outlined',\n sx: {\n color: 'inherit',\n ...layout,\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":";;;;;;;;;;;AA8CO,MAAM,cAAiB,GAAA,CAAC,EAAE,MAAA,EAAkC,KAAA;AACjE,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,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,GA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A;AAAA,OAIxC;AAAA;AAAA,GACH;AAEJ;;;;"}
@@ -8,36 +8,45 @@ const DropdownEmptyState = ({
8
8
  subTitle,
9
9
  icon
10
10
  }) => {
11
- return /* @__PURE__ */ jsx(InfoCard, { children: /* @__PURE__ */ jsxs(
11
+ return /* @__PURE__ */ jsx(
12
12
  Box,
13
13
  {
14
14
  sx: {
15
- display: "flex",
16
- flexDirection: "column",
17
- alignItems: "center",
18
- justifyContent: "center",
19
- textAlign: "center",
20
- py: 4,
21
- px: 2,
22
- // Added padding to control width
23
- maxWidth: 300,
24
- // Set max width to constrain text expansion
25
- mx: "auto"
15
+ borderRadius: (theme) => theme.spacing(2.5),
16
+ overflow: "hidden"
26
17
  },
27
- children: [
28
- icon,
29
- /* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { mt: 2, color: "text.primary" }, children: title }),
30
- /* @__PURE__ */ jsx(
31
- Typography,
32
- {
33
- variant: "body2",
34
- sx: { mt: 1, color: "text.secondary", maxWidth: 250 },
35
- children: subTitle
36
- }
37
- )
38
- ]
18
+ children: /* @__PURE__ */ jsx(InfoCard, { children: /* @__PURE__ */ jsxs(
19
+ Box,
20
+ {
21
+ sx: {
22
+ display: "flex",
23
+ flexDirection: "column",
24
+ alignItems: "center",
25
+ justifyContent: "center",
26
+ textAlign: "center",
27
+ py: 4,
28
+ px: 2,
29
+ // Added padding to control width
30
+ maxWidth: 300,
31
+ // Set max width to constrain text expansion
32
+ mx: "auto"
33
+ },
34
+ children: [
35
+ icon,
36
+ /* @__PURE__ */ jsx(Typography, { variant: "h6", sx: { mt: 2, color: "text.primary" }, children: title }),
37
+ /* @__PURE__ */ jsx(
38
+ Typography,
39
+ {
40
+ variant: "body2",
41
+ sx: { mt: 1, color: "text.secondary", maxWidth: 250 },
42
+ children: subTitle
43
+ }
44
+ )
45
+ ]
46
+ }
47
+ ) })
39
48
  }
40
- ) });
49
+ );
41
50
  };
42
51
 
43
52
  export { DropdownEmptyState };
@@ -1 +1 @@
1
- {"version":3,"file":"DropdownEmptyState.esm.js","sources":["../../../src/components/HeaderDropdownComponent/DropdownEmptyState.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { ReactNode, FC } from 'react';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport { InfoCard } from '@backstage/core-components';\n\n/**\n * @public\n * Props for dropdown empty state\n */\ninterface DropdownEmptyStateProps {\n title: string;\n subTitle: string;\n icon: ReactNode;\n}\n\nexport const DropdownEmptyState: FC<DropdownEmptyStateProps> = ({\n title,\n subTitle,\n icon,\n}) => {\n return (\n <InfoCard>\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center',\n py: 4,\n px: 2, // Added padding to control width\n maxWidth: 300, // Set max width to constrain text expansion\n mx: 'auto',\n }}\n >\n {icon}\n <Typography variant=\"h6\" sx={{ mt: 2, color: 'text.primary' }}>\n {title}\n </Typography>\n <Typography\n variant=\"body2\"\n sx={{ mt: 1, color: 'text.secondary', maxWidth: 250 }}\n >\n {subTitle}\n </Typography>\n </Box>\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;AA8BO,MAAM,qBAAkD,CAAC;AAAA,EAC9D,KAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EAAA,2BACG,QACC,EAAA,EAAA,QAAA,kBAAA,IAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,OAAS,EAAA,MAAA;AAAA,QACT,aAAe,EAAA,QAAA;AAAA,QACf,UAAY,EAAA,QAAA;AAAA,QACZ,cAAgB,EAAA,QAAA;AAAA,QAChB,SAAW,EAAA,QAAA;AAAA,QACX,EAAI,EAAA,CAAA;AAAA,QACJ,EAAI,EAAA,CAAA;AAAA;AAAA,QACJ,QAAU,EAAA,GAAA;AAAA;AAAA,QACV,EAAI,EAAA;AAAA,OACN;AAAA,MAEC,QAAA,EAAA;AAAA,QAAA,IAAA;AAAA,wBACD,GAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,IAAK,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,CAAG,EAAA,KAAA,EAAO,cAAe,EAAA,EACzD,QACH,EAAA,KAAA,EAAA,CAAA;AAAA,wBACA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACC,OAAQ,EAAA,OAAA;AAAA,YACR,IAAI,EAAE,EAAA,EAAI,GAAG,KAAO,EAAA,gBAAA,EAAkB,UAAU,GAAI,EAAA;AAAA,YAEnD,QAAA,EAAA;AAAA;AAAA;AACH;AAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"DropdownEmptyState.esm.js","sources":["../../../src/components/HeaderDropdownComponent/DropdownEmptyState.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { ReactNode, FC } from 'react';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport { InfoCard } from '@backstage/core-components';\n\n/**\n * @public\n * Props for dropdown empty state\n */\ninterface DropdownEmptyStateProps {\n title: string;\n subTitle: string;\n icon: ReactNode;\n}\n\nexport const DropdownEmptyState: FC<DropdownEmptyStateProps> = ({\n title,\n subTitle,\n icon,\n}) => {\n return (\n <Box\n sx={{\n borderRadius: theme => theme.spacing(2.5),\n overflow: 'hidden',\n }}\n >\n <InfoCard>\n <Box\n sx={{\n display: 'flex',\n flexDirection: 'column',\n alignItems: 'center',\n justifyContent: 'center',\n textAlign: 'center',\n py: 4,\n px: 2, // Added padding to control width\n maxWidth: 300, // Set max width to constrain text expansion\n mx: 'auto',\n }}\n >\n {icon}\n <Typography variant=\"h6\" sx={{ mt: 2, color: 'text.primary' }}>\n {title}\n </Typography>\n <Typography\n variant=\"body2\"\n sx={{ mt: 1, color: 'text.secondary', maxWidth: 250 }}\n >\n {subTitle}\n </Typography>\n </Box>\n </InfoCard>\n </Box>\n );\n};\n"],"names":[],"mappings":";;;;;AA8BO,MAAM,qBAAkD,CAAC;AAAA,EAC9D,KAAA;AAAA,EACA,QAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EACE,uBAAA,GAAA;AAAA,IAAC,GAAA;AAAA,IAAA;AAAA,MACC,EAAI,EAAA;AAAA,QACF,YAAc,EAAA,CAAA,KAAA,KAAS,KAAM,CAAA,OAAA,CAAQ,GAAG,CAAA;AAAA,QACxC,QAAU,EAAA;AAAA,OACZ;AAAA,MAEA,8BAAC,QACC,EAAA,EAAA,QAAA,kBAAA,IAAA;AAAA,QAAC,GAAA;AAAA,QAAA;AAAA,UACC,EAAI,EAAA;AAAA,YACF,OAAS,EAAA,MAAA;AAAA,YACT,aAAe,EAAA,QAAA;AAAA,YACf,UAAY,EAAA,QAAA;AAAA,YACZ,cAAgB,EAAA,QAAA;AAAA,YAChB,SAAW,EAAA,QAAA;AAAA,YACX,EAAI,EAAA,CAAA;AAAA,YACJ,EAAI,EAAA,CAAA;AAAA;AAAA,YACJ,QAAU,EAAA,GAAA;AAAA;AAAA,YACV,EAAI,EAAA;AAAA,WACN;AAAA,UAEC,QAAA,EAAA;AAAA,YAAA,IAAA;AAAA,4BACD,GAAA,CAAC,UAAW,EAAA,EAAA,OAAA,EAAQ,IAAK,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,CAAG,EAAA,KAAA,EAAO,cAAe,EAAA,EACzD,QACH,EAAA,KAAA,EAAA,CAAA;AAAA,4BACA,GAAA;AAAA,cAAC,UAAA;AAAA,cAAA;AAAA,gBACC,OAAQ,EAAA,OAAA;AAAA,gBACR,IAAI,EAAE,EAAA,EAAI,GAAG,KAAO,EAAA,gBAAA,EAAkB,UAAU,GAAI,EAAA;AAAA,gBAEnD,QAAA,EAAA;AAAA;AAAA;AACH;AAAA;AAAA,OAEJ,EAAA;AAAA;AAAA,GACF;AAEJ;;;;"}
@@ -1,33 +1,84 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
- import { useMemo } from 'react';
2
+ import { useMemo, useRef, useEffect } from 'react';
3
3
  import { HeaderDropdownComponent } from './HeaderDropdownComponent.esm.js';
4
4
  import { useDropdownManager } from '../../hooks/useDropdownManager.esm.js';
5
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
6
+ import '@backstage/core-plugin-api';
7
+ import '@backstage/core-plugin-api/alpha';
5
8
  import HelpOutlineIcon from '@mui/icons-material/HelpOutline';
6
9
  import { useHelpDropdownMountPoints } from '../../hooks/useHelpDropdownMountPoints.esm.js';
7
10
  import { MenuSection } from './MenuSection.esm.js';
11
+ import { DropdownEmptyState } from './DropdownEmptyState.esm.js';
12
+ import SupportAgentIcon from '@mui/icons-material/SupportAgent';
13
+ import { useValidComponentTracker } from '../../hooks/useValidComponentTracker.esm.js';
8
14
 
15
+ const ValidityTracker = ({
16
+ Component,
17
+ props,
18
+ componentId,
19
+ onValidityChange
20
+ }) => {
21
+ const contentRef = useRef(null);
22
+ useEffect(() => {
23
+ const checkContent = () => {
24
+ if (!contentRef.current) return;
25
+ const element = contentRef.current;
26
+ const hasText = (element.textContent?.trim().length ?? 0) > 0;
27
+ const hasChildren = element.children.length > 0;
28
+ const hasChildNodes = element.childNodes.length > 0;
29
+ const componentIsValid = hasText || hasChildren || hasChildNodes;
30
+ onValidityChange(componentId, componentIsValid);
31
+ };
32
+ const timer1 = setTimeout(checkContent, 500);
33
+ const timer2 = setTimeout(checkContent, 1500);
34
+ return () => {
35
+ clearTimeout(timer1);
36
+ clearTimeout(timer2);
37
+ };
38
+ }, [componentId, onValidityChange]);
39
+ try {
40
+ return /* @__PURE__ */ jsx("div", { ref: contentRef, children: /* @__PURE__ */ jsx(Component, { ...props }) });
41
+ } catch (error) {
42
+ onValidityChange(componentId, false);
43
+ return null;
44
+ }
45
+ };
9
46
  const HelpDropdown = ({ layout }) => {
10
47
  const { anchorEl, handleOpen, handleClose } = useDropdownManager();
11
48
  const helpDropdownMountPoints = useHelpDropdownMountPoints();
12
- const menuItems = useMemo(() => {
13
- return (helpDropdownMountPoints ?? []).map((mp) => ({
14
- Component: mp.Component,
15
- icon: mp.config?.props?.icon,
16
- label: mp.config?.props?.title,
17
- link: mp.config?.props?.link,
18
- tooltip: mp.config?.props?.tooltip,
19
- style: mp.config?.style,
20
- priority: mp.config?.priority ?? 0
21
- })).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
22
- }, [helpDropdownMountPoints]);
23
- if (menuItems.length === 0) {
24
- return null;
25
- }
49
+ const { t } = useTranslation();
50
+ const { shouldShowEmpty, updateComponentValidity } = useValidComponentTracker(
51
+ helpDropdownMountPoints?.length ?? 0
52
+ );
53
+ const allMenuItems = useMemo(() => {
54
+ return (helpDropdownMountPoints ?? []).map((mp, index) => {
55
+ const componentId = `${mp.config?.props?.title || "helpItem"}-${mp.config?.priority || 0}-${index}`;
56
+ return {
57
+ componentId,
58
+ Component: () => /* @__PURE__ */ jsx(
59
+ ValidityTracker,
60
+ {
61
+ Component: mp.Component,
62
+ props: mp.config?.props || {},
63
+ componentId,
64
+ onValidityChange: updateComponentValidity
65
+ }
66
+ ),
67
+ icon: mp.config?.props?.icon,
68
+ label: mp.config?.props?.title,
69
+ link: mp.config?.props?.link,
70
+ tooltip: mp.config?.props?.tooltip,
71
+ style: mp.config?.style,
72
+ priority: mp.config?.priority ?? 0
73
+ };
74
+ }).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
75
+ }, [helpDropdownMountPoints, updateComponentValidity]);
76
+ const menuItems = allMenuItems;
26
77
  return /* @__PURE__ */ jsx(
27
78
  HeaderDropdownComponent,
28
79
  {
29
80
  isIconButton: true,
30
- tooltip: "Help",
81
+ tooltip: t("help.tooltip"),
31
82
  buttonContent: /* @__PURE__ */ jsx(HelpOutlineIcon, {}),
32
83
  buttonProps: {
33
84
  color: "inherit",
@@ -36,7 +87,14 @@ const HelpDropdown = ({ layout }) => {
36
87
  onOpen: handleOpen,
37
88
  onClose: handleClose,
38
89
  anchorEl,
39
- children: /* @__PURE__ */ jsx(MenuSection, { hideDivider: true, items: menuItems, handleClose })
90
+ children: !shouldShowEmpty ? /* @__PURE__ */ jsx(MenuSection, { hideDivider: true, items: menuItems, handleClose }) : /* @__PURE__ */ jsx(
91
+ DropdownEmptyState,
92
+ {
93
+ title: t("help.noSupportLinks"),
94
+ subTitle: t("help.noSupportLinksSubtitle"),
95
+ icon: /* @__PURE__ */ jsx(SupportAgentIcon, { sx: { fontSize: 64, color: "text.disabled" } })
96
+ }
97
+ )
40
98
  }
41
99
  );
42
100
  };
@@ -1 +1 @@
1
- {"version":3,"file":"HelpDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/HelpDropdown.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 { useMemo } from 'react';\nimport type { CSSProperties } from 'react';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { useDropdownManager } from '../../hooks';\nimport HelpOutlineIcon from '@mui/icons-material/HelpOutline';\nimport { useHelpDropdownMountPoints } from '../../hooks/useHelpDropdownMountPoints';\nimport { MenuSection } from './MenuSection';\n\n/**\n * @public\n * Props for Help Dropdown\n */\nexport interface HelpDropdownProps {\n layout?: CSSProperties;\n}\n\nexport const HelpDropdown = ({ layout }: HelpDropdownProps) => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n\n const helpDropdownMountPoints = useHelpDropdownMountPoints();\n\n const menuItems = useMemo(() => {\n return (helpDropdownMountPoints ?? [])\n .map(mp => ({\n Component: mp.Component,\n icon: mp.config?.props?.icon,\n label: mp.config?.props?.title,\n link: mp.config?.props?.link,\n tooltip: mp.config?.props?.tooltip,\n style: mp.config?.style,\n priority: mp.config?.priority ?? 0,\n }))\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }, [helpDropdownMountPoints]);\n\n if (menuItems.length === 0) {\n return null;\n }\n\n return (\n <HeaderDropdownComponent\n isIconButton\n tooltip=\"Help\"\n buttonContent={<HelpOutlineIcon />}\n buttonProps={{\n color: 'inherit',\n sx: layout,\n }}\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n <MenuSection hideDivider items={menuItems} handleClose={handleClose} />\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AAgCO,MAAM,YAAe,GAAA,CAAC,EAAE,MAAA,EAAgC,KAAA;AAC7D,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AAEjE,EAAA,MAAM,0BAA0B,0BAA2B,EAAA;AAE3D,EAAM,MAAA,SAAA,GAAY,QAAQ,MAAM;AAC9B,IAAA,OAAA,CAAQ,uBAA2B,IAAA,EAChC,EAAA,GAAA,CAAI,CAAO,EAAA,MAAA;AAAA,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\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useMemo, useRef } from 'react';\nimport type { ComponentType, CSSProperties } from 'react';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { useDropdownManager } from '../../hooks';\nimport HelpOutlineIcon from '@mui/icons-material/HelpOutline';\nimport { useHelpDropdownMountPoints } from '../../hooks/useHelpDropdownMountPoints';\nimport { MenuSection } from './MenuSection';\nimport { DropdownEmptyState } from './DropdownEmptyState';\nimport SupportAgentIcon from '@mui/icons-material/SupportAgent';\nimport { useValidComponentTracker } from '../../hooks/useValidComponentTracker';\nimport { useTranslation } from '../../hooks/useTranslation';\n\n/**\n * @public\n */\nexport interface HelpDropdownProps {\n layout?: CSSProperties;\n}\n\nconst ValidityTracker = ({\n Component,\n props,\n componentId,\n onValidityChange,\n}: {\n Component: ComponentType<any>;\n props: any;\n componentId: string;\n onValidityChange: (componentId: string, isValid: boolean) => void;\n}) => {\n const contentRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n const checkContent = () => {\n if (!contentRef.current) return;\n\n const element = contentRef.current;\n const hasText = (element.textContent?.trim().length ?? 0) > 0;\n const hasChildren = element.children.length > 0;\n const hasChildNodes = element.childNodes.length > 0;\n\n // A component is valid if it renders ANY content at all\n const componentIsValid = hasText || hasChildren || hasChildNodes;\n\n onValidityChange(componentId, componentIsValid);\n };\n\n // Check after component has had time to render (longer timeout for lazy components)\n const timer1 = setTimeout(checkContent, 500);\n const timer2 = setTimeout(checkContent, 1500); // Double check later\n\n return () => {\n clearTimeout(timer1);\n clearTimeout(timer2);\n };\n }, [componentId, onValidityChange]);\n\n try {\n return (\n <div ref={contentRef}>\n <Component {...props} />\n </div>\n );\n } catch (error) {\n onValidityChange(componentId, false);\n return null;\n }\n};\n\nexport const HelpDropdown = ({ layout }: HelpDropdownProps) => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n const helpDropdownMountPoints = useHelpDropdownMountPoints();\n const { t } = useTranslation();\n\n const { shouldShowEmpty, updateComponentValidity } = useValidComponentTracker(\n helpDropdownMountPoints?.length ?? 0,\n );\n\n // Create all mount point items with validity tracking\n const allMenuItems = useMemo(() => {\n return (helpDropdownMountPoints ?? [])\n .map((mp, index) => {\n const componentId = `${mp.config?.props?.title || 'helpItem'}-${\n mp.config?.priority || 0\n }-${index}`;\n\n return {\n componentId,\n Component: () => (\n <ValidityTracker\n Component={mp.Component}\n props={mp.config?.props || {}}\n componentId={componentId}\n onValidityChange={updateComponentValidity}\n />\n ),\n icon: mp.config?.props?.icon,\n label: mp.config?.props?.title,\n link: mp.config?.props?.link,\n tooltip: mp.config?.props?.tooltip,\n style: mp.config?.style,\n priority: mp.config?.priority ?? 0,\n };\n })\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }, [helpDropdownMountPoints, updateComponentValidity]);\n\n const menuItems = allMenuItems;\n\n return (\n <HeaderDropdownComponent\n isIconButton\n tooltip={t('help.tooltip')}\n buttonContent={<HelpOutlineIcon />}\n buttonProps={{\n color: 'inherit',\n sx: layout,\n }}\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n {!shouldShowEmpty ? (\n <MenuSection hideDivider items={menuItems} handleClose={handleClose} />\n ) : (\n <DropdownEmptyState\n title={t('help.noSupportLinks')}\n subTitle={t('help.noSupportLinksSubtitle')}\n icon={\n <SupportAgentIcon sx={{ fontSize: 64, color: 'text.disabled' }} />\n }\n />\n )}\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAmCA,MAAM,kBAAkB,CAAC;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,OACnC;AAAA,KACD,CACA,CAAA,IAAA,CAAK,CAAC,CAAA,EAAG,CAAO,KAAA,CAAA,CAAA,CAAE,QAAY,IAAA,CAAA,KAAM,CAAE,CAAA,QAAA,IAAY,CAAE,CAAA,CAAA;AAAA,GACtD,EAAA,CAAC,uBAAyB,EAAA,uBAAuB,CAAC,CAAA;AAErD,EAAA,MAAM,SAAY,GAAA,YAAA;AAElB,EACE,uBAAA,GAAA;AAAA,IAAC,uBAAA;AAAA,IAAA;AAAA,MACC,YAAY,EAAA,IAAA;AAAA,MACZ,OAAA,EAAS,EAAE,cAAc,CAAA;AAAA,MACzB,aAAA,sBAAgB,eAAgB,EAAA,EAAA,CAAA;AAAA,MAChC,WAAa,EAAA;AAAA,QACX,KAAO,EAAA,SAAA;AAAA,QACP,EAAI,EAAA;AAAA,OACN;AAAA,MACA,MAAQ,EAAA,UAAA;AAAA,MACR,OAAS,EAAA,WAAA;AAAA,MACT,QAAA;AAAA,MAEC,QAAA,EAAA,CAAC,kCACC,GAAA,CAAA,WAAA,EAAA,EAAY,aAAW,IAAC,EAAA,KAAA,EAAO,SAAW,EAAA,WAAA,EAA0B,CAErE,mBAAA,GAAA;AAAA,QAAC,kBAAA;AAAA,QAAA;AAAA,UACC,KAAA,EAAO,EAAE,qBAAqB,CAAA;AAAA,UAC9B,QAAA,EAAU,EAAE,6BAA6B,CAAA;AAAA,UACzC,IAAA,sBACG,gBAAiB,EAAA,EAAA,EAAA,EAAI,EAAE,QAAU,EAAA,EAAA,EAAI,KAAO,EAAA,eAAA,EAAmB,EAAA;AAAA;AAAA;AAEpE;AAAA,GAEJ;AAEJ;;;;"}
@@ -5,6 +5,7 @@ import Box from '@mui/material/Box';
5
5
  import MenuItem from '@mui/material/MenuItem';
6
6
  import { Link } from '@backstage/core-components';
7
7
  import ListSubheader from '@mui/material/ListSubheader';
8
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
8
9
 
9
10
  const MenuSection = ({
10
11
  sectionLabel,
@@ -14,7 +15,9 @@ const MenuSection = ({
14
15
  hideDivider = false,
15
16
  handleClose
16
17
  }) => {
18
+ const { t } = useTranslation();
17
19
  const hasClickableSubheader = optionalLink && optionalLinkLabel && items.length > 0;
20
+ const translatedSectionLabel = sectionLabel && sectionLabel.includes(".") ? t(sectionLabel, {}) || sectionLabel : sectionLabel;
18
21
  return /* @__PURE__ */ jsxs(Fragment, { children: [
19
22
  sectionLabel && /* @__PURE__ */ jsxs(
20
23
  MenuItem,
@@ -39,7 +42,7 @@ const MenuSection = ({
39
42
  mt: "0.5rem",
40
43
  fontWeight: 400
41
44
  },
42
- children: sectionLabel
45
+ children: translatedSectionLabel
43
46
  }
44
47
  ),
45
48
  optionalLinkLabel && /* @__PURE__ */ jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"MenuSection.esm.js","sources":["../../../src/components/HeaderDropdownComponent/MenuSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment } from 'react';\nimport type { ComponentType, FC } from 'react';\nimport Divider from '@mui/material/Divider';\nimport Box from '@mui/material/Box';\nimport MenuItem, { MenuItemProps } from '@mui/material/MenuItem';\nimport { Link } from '@backstage/core-components';\nimport { MenuItemLinkProps } from '../MenuItemLink/MenuItemLink';\nimport ListSubheader from '@mui/material/ListSubheader';\n\n/**\n * Menu item configuration\n *\n * @public\n */\nexport interface MenuItemConfig {\n Component: ComponentType<MenuItemLinkProps | MenuItemProps | {}>;\n label: string;\n icon?: string;\n subLabel?: string;\n link?: string;\n}\n\nexport interface MenuSectionConfig {\n sectionLabel?: string;\n optionalLink?: string;\n optionalLinkLabel?: string;\n items: MenuItemConfig[];\n hideDivider?: boolean;\n handleClose: () => void;\n}\n\nexport const MenuSection: FC<MenuSectionConfig> = ({\n sectionLabel,\n optionalLink,\n optionalLinkLabel,\n items,\n hideDivider = false,\n handleClose,\n}) => {\n const hasClickableSubheader =\n optionalLink && optionalLinkLabel && items.length > 0;\n\n return (\n <>\n {sectionLabel && (\n <MenuItem\n sx={{\n p: 0,\n }}\n disableRipple\n disableTouchRipple\n component={hasClickableSubheader ? Link : Fragment}\n to={optionalLink}\n onClick={handleClose}\n >\n <ListSubheader\n sx={{\n backgroundColor: 'transparent',\n m: 0,\n color: 'text.disabled',\n lineHeight: 2,\n mt: '0.5rem',\n fontWeight: 400,\n }}\n >\n {sectionLabel}\n </ListSubheader>\n\n {optionalLinkLabel && (\n <Box\n sx={{\n fontSize: '0.875em',\n mr: 2,\n flexGrow: 1,\n textAlign: 'right',\n mt: '0.5rem',\n }}\n >\n {optionalLinkLabel}\n </Box>\n )}\n </MenuItem>\n )}\n\n {items.map(({ icon, label, subLabel, link, Component }, index) => (\n <MenuItem\n key={`menu-item-${index.toString()}`}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n sx={{ py: 0.5 }}\n component={link ? Link : Fragment}\n to={link}\n >\n <Component\n icon={icon}\n to={link!}\n title={label}\n subTitle={subLabel}\n onClick={handleClose}\n />\n </MenuItem>\n ))}\n {!hideDivider && <Divider sx={{ my: 0.5 }} />}\n </>\n );\n};\n"],"names":["Fragment"],"mappings":";;;;;;;;AA+CO,MAAM,cAAqC,CAAC;AAAA,EACjD,YAAA;AAAA,EACA,YAAA;AAAA,EACA,iBAAA;AAAA,EACA,KAAA;AAAA,EACA,WAAc,GAAA,KAAA;AAAA,EACd;AACF,CAAM,KAAA;AACJ,EAAA,MAAM,qBACJ,GAAA,YAAA,IAAgB,iBAAqB,IAAA,KAAA,CAAM,MAAS,GAAA,CAAA;AAEtD,EAAA,uBAEK,IAAA,CAAA,QAAA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I,GAAI,EAAA;AAAA,QACd,SAAA,EAAW,OAAO,IAAOA,GAAAA,UAAAA;AAAA,QACzB,EAAI,EAAA,IAAA;AAAA,QAEJ,QAAA,kBAAA,GAAA;AAAA,UAAC,SAAA;AAAA,UAAA;AAAA,YACC,IAAA;AAAA,YACA,EAAI,EAAA,IAAA;AAAA,YACJ,KAAO,EAAA,KAAA;AAAA,YACP,QAAU,EAAA,QAAA;AAAA,YACV,OAAS,EAAA;AAAA;AAAA;AACX,OAAA;AAAA,MAdK,CAAA,UAAA,EAAa,KAAM,CAAA,QAAA,EAAU,CAAA;AAAA,KAgBrC,CAAA;AAAA,IACA,CAAC,+BAAgB,GAAA,CAAA,OAAA,EAAA,EAAQ,IAAI,EAAE,EAAA,EAAI,KAAO,EAAA;AAAA,GAC7C,EAAA,CAAA;AAEJ;;;;"}
1
+ {"version":3,"file":"MenuSection.esm.js","sources":["../../../src/components/HeaderDropdownComponent/MenuSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Fragment } from 'react';\nimport type { ComponentType, FC } from 'react';\nimport Divider from '@mui/material/Divider';\nimport Box from '@mui/material/Box';\nimport MenuItem, { MenuItemProps } from '@mui/material/MenuItem';\nimport { Link } from '@backstage/core-components';\nimport { MenuItemLinkProps } from '../MenuItemLink/MenuItemLink';\nimport ListSubheader from '@mui/material/ListSubheader';\nimport { useTranslation } from '../../hooks/useTranslation';\n\n/**\n * Menu item configuration\n *\n * @public\n */\nexport interface MenuItemConfig {\n Component: ComponentType<MenuItemLinkProps | MenuItemProps | {}>;\n label: string;\n icon?: string;\n subLabel?: string;\n link?: string;\n}\n\nexport interface MenuSectionConfig {\n sectionLabel?: string;\n optionalLink?: string;\n optionalLinkLabel?: string;\n items: MenuItemConfig[];\n hideDivider?: boolean;\n handleClose: () => void;\n}\n\nexport const MenuSection: FC<MenuSectionConfig> = ({\n sectionLabel,\n optionalLink,\n optionalLinkLabel,\n items,\n hideDivider = false,\n handleClose,\n}) => {\n const { t } = useTranslation();\n const hasClickableSubheader =\n optionalLink && optionalLinkLabel && items.length > 0;\n\n // Check if sectionLabel looks like a translation key (contains dots)\n const translatedSectionLabel =\n sectionLabel && sectionLabel.includes('.')\n ? t(sectionLabel as any, {}) || sectionLabel // Fallback to original if translation fails\n : sectionLabel;\n\n return (\n <>\n {sectionLabel && (\n <MenuItem\n sx={{\n p: 0,\n }}\n disableRipple\n disableTouchRipple\n component={hasClickableSubheader ? Link : Fragment}\n to={optionalLink}\n onClick={handleClose}\n >\n <ListSubheader\n sx={{\n backgroundColor: 'transparent',\n m: 0,\n color: 'text.disabled',\n lineHeight: 2,\n mt: '0.5rem',\n fontWeight: 400,\n }}\n >\n {translatedSectionLabel}\n </ListSubheader>\n\n {optionalLinkLabel && (\n <Box\n sx={{\n fontSize: '0.875em',\n mr: 2,\n flexGrow: 1,\n textAlign: 'right',\n mt: '0.5rem',\n }}\n >\n {optionalLinkLabel}\n </Box>\n )}\n </MenuItem>\n )}\n\n {items.map(({ icon, label, subLabel, link, Component }, index) => (\n <MenuItem\n key={`menu-item-${index.toString()}`}\n disableRipple\n disableTouchRipple\n onClick={handleClose}\n sx={{ py: 0.5 }}\n component={link ? Link : Fragment}\n to={link}\n >\n <Component\n icon={icon}\n to={link!}\n title={label}\n subTitle={subLabel}\n onClick={handleClose}\n />\n </MenuItem>\n ))}\n {!hideDivider && <Divider sx={{ my: 0.5 }} />}\n </>\n );\n};\n"],"names":["Fragment"],"mappings":";;;;;;;;;AAgDO,MAAM,cAAqC,CAAC;AAAA,EACjD,YAAA;AAAA,EAC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QAAU,EAAA,CAAA;AAAA,gBACV,SAAW,EAAA,OAAA;AAAA,gBACX,EAAI,EAAA;AAAA,eACN;AAAA,cAEC,QAAA,EAAA;AAAA;AAAA;AACH;AAAA;AAAA,KAEJ;AAAA,IAGD,KAAA,CAAM,GAAI,CAAA,CAAC,EAAE,IAAA,EAAM,OAAO,QAAU,EAAA,IAAA,EAAM,SAAU,EAAA,EAAG,KACtD,qBAAA,GAAA;AAAA,MAAC,QAAA;AAAA,MAAA;AAAA,QAEC,aAAa,EAAA,IAAA;AAAA,QACb,kBAAkB,EAAA,IAAA;AAAA,QAClB,OAAS,EAAA,WAAA;AAAA,QACT,EAAA,EAAI,EAAE,EAAA,EAAI,GAAI,EAAA;AAAA,QACd,SAAA,EAAW,OAAO,IAAOA,GAAAA,UAAAA;AAAA,QACzB,EAAI,EAAA,IAAA;AAAA,QAEJ,QAAA,kBAAA,GAAA;AAAA,UAAC,SAAA;AAAA,UAAA;AAAA,YACC,IAAA;AAAA,YACA,EAAI,EAAA,IAAA;AAAA,YACJ,KAAO,EAAA,KAAA;AAAA,YACP,QAAU,EAAA,QAAA;AAAA,YACV,OAAS,EAAA;AAAA;AAAA;AACX,OAAA;AAAA,MAdK,CAAA,UAAA,EAAa,KAAM,CAAA,QAAA,EAAU,CAAA;AAAA,KAgBrC,CAAA;AAAA,IACA,CAAC,+BAAgB,GAAA,CAAA,OAAA,EAAA,EAAQ,IAAI,EAAE,EAAA,EAAI,KAAO,EAAA;AAAA,GAC7C,EAAA,CAAA;AAEJ;;;;"}
@@ -14,11 +14,14 @@ import { MenuSection } from './MenuSection.esm.js';
14
14
  import { HeaderDropdownComponent } from './HeaderDropdownComponent.esm.js';
15
15
  import { useProfileDropdownMountPoints } from '../../hooks/useProfileDropdownMountPoints.esm.js';
16
16
  import { useDropdownManager } from '../../hooks/useDropdownManager.esm.js';
17
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
18
+ import '@backstage/core-plugin-api/alpha';
17
19
 
18
20
  const ProfileDropdown = ({ layout }) => {
19
21
  const { anchorEl, handleOpen, handleClose } = useDropdownManager();
20
22
  const [user, setUser] = useState();
21
23
  const [profileLink, setProfileLink] = useState();
24
+ const { t } = useTranslation();
22
25
  const {
23
26
  displayName,
24
27
  backstageIdentity,
@@ -79,20 +82,21 @@ const ProfileDropdown = ({ layout }) => {
79
82
  icon = "",
80
83
  link: staticLink = ""
81
84
  } = mp.config?.props ?? {};
82
- const isMyProfile = title.toLowerCase() === "my profile";
85
+ const isMyProfile = title === "profile.myProfile";
83
86
  const link = isMyProfile ? profileLink ?? "" : staticLink;
84
87
  if (!link && title) {
85
88
  return null;
86
89
  }
90
+ const translatedTitle = title && title.includes(".") ? t(title, {}) || title : title;
87
91
  return {
88
92
  Component: mp.Component,
89
- label: title,
93
+ label: translatedTitle,
90
94
  link,
91
95
  priority: mp.config?.priority ?? 0,
92
96
  ...icon && { icon }
93
97
  };
94
98
  }).filter((item) => item !== null).sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
95
- }, [profileDropdownMountPoints, profileLink]);
99
+ }, [profileDropdownMountPoints, profileLink, t]);
96
100
  if (menuItems.length === 0) {
97
101
  return null;
98
102
  }
@@ -114,7 +118,7 @@ const ProfileDropdown = ({ layout }) => {
114
118
  {
115
119
  src: profile.picture,
116
120
  sx: { mr: 2, height: "32px", width: "32px" },
117
- alt: "Profile picture"
121
+ alt: t("profile.picture")
118
122
  }
119
123
  ) : /* @__PURE__ */ jsx(AccountCircleOutlinedIcon, { fontSize: "small", sx: { mr: 1 } }),
120
124
  /* @__PURE__ */ jsx(
@@ -1 +1 @@
1
- {"version":3,"file":"ProfileDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/ProfileDropdown.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport type { CSSProperties } from 'react';\nimport { useUserProfile } from '@backstage/plugin-user-settings';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { parseEntityRef, UserEntity } from '@backstage/catalog-model';\nimport AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined';\nimport KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';\nimport Avatar from '@mui/material/Avatar';\nimport Typography from '@mui/material/Typography';\nimport { lighten } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\n\nimport { MenuItemConfig, MenuSection } from './MenuSection';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { useProfileDropdownMountPoints } from '../../hooks/useProfileDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\n\n/**\n * @public\n * Props for Profile Dropdown\n */\nexport interface ProfileDropdownProps {\n layout?: CSSProperties;\n}\n\nexport const ProfileDropdown = ({ layout }: ProfileDropdownProps) => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n const [user, setUser] = useState<string | null>();\n const [profileLink, setProfileLink] = useState<string | null>();\n const {\n displayName,\n backstageIdentity,\n profile,\n loading: profileLoading,\n } = useUserProfile();\n const catalogApi = useApi(catalogApiRef);\n\n const profileDropdownMountPoints = useProfileDropdownMountPoints();\n\n const headerRef = useRef<HTMLElement | null>(null);\n const [bgColor, setBgColor] = useState('#3C3F42');\n\n useEffect(() => {\n if (headerRef.current) {\n const computedStyle = window.getComputedStyle(headerRef.current);\n const baseColor = computedStyle.backgroundColor;\n setBgColor(lighten(baseColor, 0.2));\n }\n }, []);\n\n useEffect(() => {\n const container = document.getElementById('global-header');\n if (container) {\n const computedStyle = window.getComputedStyle(container);\n const baseColor = computedStyle.backgroundColor;\n setBgColor(lighten(baseColor, 0.2));\n }\n }, []);\n\n useEffect(() => {\n const fetchUserEntity = async () => {\n let userProfile;\n let profileUrl: string | null = null;\n\n try {\n if (backstageIdentity?.userEntityRef) {\n const { namespace = 'default', name } = parseEntityRef(\n backstageIdentity.userEntityRef,\n );\n profileUrl = `/catalog/${namespace}/user/${name}`;\n\n userProfile = (await catalogApi.getEntityByRef(\n backstageIdentity.userEntityRef,\n )) as unknown as UserEntity;\n setUser(\n userProfile?.spec?.profile?.displayName ??\n userProfile?.metadata?.title,\n );\n setProfileLink(profileUrl);\n } else {\n setUser(null);\n setProfileLink(null);\n }\n } catch (_err) {\n setUser(null);\n setProfileLink(null);\n }\n };\n\n fetchUserEntity();\n }, [backstageIdentity, catalogApi]);\n\n const menuItems = useMemo(() => {\n return (profileDropdownMountPoints ?? [])\n .map(mp => {\n const {\n title = '',\n icon = '',\n link: staticLink = '',\n } = mp.config?.props ?? {};\n const isMyProfile = title.toLowerCase() === 'my profile';\n const link = isMyProfile ? profileLink ?? '' : staticLink;\n\n if (!link && title) {\n return null;\n }\n\n return {\n Component: mp.Component,\n label: title,\n link,\n priority: mp.config?.priority ?? 0,\n ...(icon && { icon }),\n };\n })\n .filter((item: MenuItemConfig) => item !== null)\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }, [profileDropdownMountPoints, profileLink]);\n\n if (menuItems.length === 0) {\n return null;\n }\n\n const profileDisplayName = () => {\n const name = user ?? displayName;\n const regex = /^[^:/]+:[^/]+\\/[^/]+$/;\n if (regex.test(name)) {\n return name\n .charAt(name.indexOf('/') + 1)\n .toLocaleUpperCase('en-US')\n .concat(name.substring(name.indexOf('/') + 2));\n }\n return name;\n };\n\n return (\n <HeaderDropdownComponent\n buttonContent={\n <Box sx={{ display: 'flex', alignItems: 'center', ...layout }}>\n {!profileLoading && (\n <>\n {profile.picture ? (\n <Avatar\n src={profile.picture}\n sx={{ mr: 2, height: '32px', width: '32px' }}\n alt=\"Profile picture\"\n />\n ) : (\n <AccountCircleOutlinedIcon fontSize=\"small\" sx={{ mr: 1 }} />\n )}\n <Typography\n variant=\"body2\"\n sx={{\n display: { xs: 'none', md: 'block' },\n fontWeight: 500,\n mr: '1rem',\n }}\n >\n {profileDisplayName()}\n </Typography>\n </>\n )}\n <KeyboardArrowDownOutlinedIcon\n sx={{\n bgcolor: bgColor,\n borderRadius: '25%',\n }}\n />\n </Box>\n }\n buttonProps={{\n color: 'inherit',\n sx: {\n display: 'flex',\n alignItems: 'center',\n },\n }}\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n <MenuSection hideDivider items={menuItems} handleClose={handleClose} />\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA0CO,MAAM,eAAkB,GAAA,CAAC,EAAE,MAAA,EAAmC,KAAA;AACnE,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AACjE,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAwB,EAAA;AAChD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAwB,EAAA;AAC9D,EAAM,MAAA;AAAA,IACJ,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,cAAe,EAAA;AACnB,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA;AAEvC,EAAA,MAAM,6BAA6B,6BAA8B,EAAA;AAEjE,EAAM,MAAA,SAAA,GAAY,OAA2B,IAAI,CAAA;AACjD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,SAAS,CAAA;AAEhD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,UAAU,OAAS,EAAA;AACrB,MAAA,MAAM,aAAgB,GAAA,MAAA,CAAO,gBAAiB,CA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AY,EAAA,GAAA;AAAA,gBACZ,EAAI,EAAA;AAAA,eACN;AAAA,cAEC,QAAmB,EAAA,kBAAA;AAAA;AAAA;AACtB,SACF,EAAA,CAAA;AAAA,wBAEF,GAAA;AAAA,UAAC,6BAAA;AAAA,UAAA;AAAA,YACC,EAAI,EAAA;AAAA,cACF,OAAS,EAAA,OAAA;AAAA,cACT,YAAc,EAAA;AAAA;AAChB;AAAA;AACF,OACF,EAAA,CAAA;AAAA,MAEF,WAAa,EAAA;AAAA,QACX,KAAO,EAAA,SAAA;AAAA,QACP,EAAI,EAAA;AAAA,UACF,OAAS,EAAA,MAAA;AAAA,UACT,UAAY,EAAA;AAAA;AACd,OACF;AAAA,MACA,MAAQ,EAAA,UAAA;AAAA,MACR,OAAS,EAAA,WAAA;AAAA,MACT,QAAA;AAAA,MAEA,8BAAC,WAAY,EAAA,EAAA,WAAA,EAAW,IAAC,EAAA,KAAA,EAAO,WAAW,WAA0B,EAAA;AAAA;AAAA,GACvE;AAEJ;;;;"}
1
+ {"version":3,"file":"ProfileDropdown.esm.js","sources":["../../../src/components/HeaderDropdownComponent/ProfileDropdown.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport type { CSSProperties } from 'react';\nimport { useUserProfile } from '@backstage/plugin-user-settings';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\nimport { parseEntityRef, UserEntity } from '@backstage/catalog-model';\nimport AccountCircleOutlinedIcon from '@mui/icons-material/AccountCircleOutlined';\nimport KeyboardArrowDownOutlinedIcon from '@mui/icons-material/KeyboardArrowDownOutlined';\nimport Avatar from '@mui/material/Avatar';\nimport Typography from '@mui/material/Typography';\nimport { lighten } from '@mui/material/styles';\nimport Box from '@mui/material/Box';\n\nimport { MenuItemConfig, MenuSection } from './MenuSection';\nimport { HeaderDropdownComponent } from './HeaderDropdownComponent';\nimport { useProfileDropdownMountPoints } from '../../hooks/useProfileDropdownMountPoints';\nimport { useDropdownManager } from '../../hooks';\nimport { useTranslation } from '../../hooks/useTranslation';\n\n/**\n * @public\n * Props for Profile Dropdown\n */\nexport interface ProfileDropdownProps {\n layout?: CSSProperties;\n}\n\nexport const ProfileDropdown = ({ layout }: ProfileDropdownProps) => {\n const { anchorEl, handleOpen, handleClose } = useDropdownManager();\n const [user, setUser] = useState<string | null>();\n const [profileLink, setProfileLink] = useState<string | null>();\n const { t } = useTranslation();\n const {\n displayName,\n backstageIdentity,\n profile,\n loading: profileLoading,\n } = useUserProfile();\n const catalogApi = useApi(catalogApiRef);\n\n const profileDropdownMountPoints = useProfileDropdownMountPoints();\n\n const headerRef = useRef<HTMLElement | null>(null);\n const [bgColor, setBgColor] = useState('#3C3F42');\n\n useEffect(() => {\n if (headerRef.current) {\n const computedStyle = window.getComputedStyle(headerRef.current);\n const baseColor = computedStyle.backgroundColor;\n setBgColor(lighten(baseColor, 0.2));\n }\n }, []);\n\n useEffect(() => {\n const container = document.getElementById('global-header');\n if (container) {\n const computedStyle = window.getComputedStyle(container);\n const baseColor = computedStyle.backgroundColor;\n setBgColor(lighten(baseColor, 0.2));\n }\n }, []);\n\n useEffect(() => {\n const fetchUserEntity = async () => {\n let userProfile;\n let profileUrl: string | null = null;\n\n try {\n if (backstageIdentity?.userEntityRef) {\n const { namespace = 'default', name } = parseEntityRef(\n backstageIdentity.userEntityRef,\n );\n profileUrl = `/catalog/${namespace}/user/${name}`;\n\n userProfile = (await catalogApi.getEntityByRef(\n backstageIdentity.userEntityRef,\n )) as unknown as UserEntity;\n setUser(\n userProfile?.spec?.profile?.displayName ??\n userProfile?.metadata?.title,\n );\n setProfileLink(profileUrl);\n } else {\n setUser(null);\n setProfileLink(null);\n }\n } catch (_err) {\n setUser(null);\n setProfileLink(null);\n }\n };\n\n fetchUserEntity();\n }, [backstageIdentity, catalogApi]);\n\n const menuItems = useMemo(() => {\n return (profileDropdownMountPoints ?? [])\n .map(mp => {\n const {\n title = '',\n icon = '',\n link: staticLink = '',\n } = mp.config?.props ?? {};\n const isMyProfile = title === 'profile.myProfile';\n const link = isMyProfile ? profileLink ?? '' : staticLink;\n\n if (!link && title) {\n return null;\n }\n\n // Check if title looks like a translation key (contains dots)\n const translatedTitle =\n title && title.includes('.')\n ? t(title as any, {}) || title // Fallback to original title if translation fails\n : title;\n\n return {\n Component: mp.Component,\n label: translatedTitle,\n link,\n priority: mp.config?.priority ?? 0,\n ...(icon && { icon }),\n };\n })\n .filter((item: MenuItemConfig) => item !== null)\n .sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));\n }, [profileDropdownMountPoints, profileLink, t]);\n\n if (menuItems.length === 0) {\n return null;\n }\n\n const profileDisplayName = () => {\n const name = user ?? displayName;\n const regex = /^[^:/]+:[^/]+\\/[^/]+$/;\n if (regex.test(name)) {\n return name\n .charAt(name.indexOf('/') + 1)\n .toLocaleUpperCase('en-US')\n .concat(name.substring(name.indexOf('/') + 2));\n }\n return name;\n };\n\n return (\n <HeaderDropdownComponent\n buttonContent={\n <Box sx={{ display: 'flex', alignItems: 'center', ...layout }}>\n {!profileLoading && (\n <>\n {profile.picture ? (\n <Avatar\n src={profile.picture}\n sx={{ mr: 2, height: '32px', width: '32px' }}\n alt={t('profile.picture')}\n />\n ) : (\n <AccountCircleOutlinedIcon fontSize=\"small\" sx={{ mr: 1 }} />\n )}\n <Typography\n variant=\"body2\"\n sx={{\n display: { xs: 'none', md: 'block' },\n fontWeight: 500,\n mr: '1rem',\n }}\n >\n {profileDisplayName()}\n </Typography>\n </>\n )}\n <KeyboardArrowDownOutlinedIcon\n sx={{\n bgcolor: bgColor,\n borderRadius: '25%',\n }}\n />\n </Box>\n }\n buttonProps={{\n color: 'inherit',\n sx: {\n display: 'flex',\n alignItems: 'center',\n },\n }}\n onOpen={handleOpen}\n onClose={handleClose}\n anchorEl={anchorEl}\n >\n <MenuSection hideDivider items={menuItems} handleClose={handleClose} />\n </HeaderDropdownComponent>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;AA2CO,MAAM,eAAkB,GAAA,CAAC,EAAE,MAAA,EAAmC,KAAA;AACnE,EAAA,MAAM,EAAE,QAAA,EAAU,UAAY,EAAA,WAAA,KAAgB,kBAAmB,EAAA;AACjE,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAwB,EAAA;AAChD,EAAA,MAAM,CAAC,WAAA,EAAa,cAAc,CAAA,GAAI,QAAwB,EAAA;AAC9D,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EAAM,MAAA;AAAA,IACJ,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,cAAe,EAAA;AACnB,EAAM,MAAA,UAAA,GAAa,OAAO,aAAa,CAAA;AAEvC,EAAA,MAAM,6BAA6B,6BAA8B,EAAA;AAEjE,EAAM,MAAA,SAAA,GAAY,OAA2B,IAAI,CAAA;AACjD,EAAA,MAAM,CAAC,OAAA,EAAS,UAAU,CAAA,GAAI,SAAS,SAAS,CAAA;AAEhD,EAAA,SAAA,CAAU,MAAM;AACd,IAAA,IAAI,UAAU,OAAS,EAAA;AACrB,MAAA,MAAM,aAAgB,GAAA,MAAA,CAAO,gBAAiB,CAAA,SAAA,CAAU,OAAO,CAAA;AAC/D,MAAA,MAAM,YAAY,aAAc,CAAA,eAAA;AAChC,MAAW,UAAA,CAAA,OAAA,CAAQ,SAAW,EAAA,GAAG,CAAC,CAAA;AAAA;AACpC,GACF,EAAG,EAA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AAAA,gBACZ,EAAI,EAAA;AAAA,eACN;AAAA,cAEC,QAAmB,EAAA,kBAAA;AAAA;AAAA;AACtB,SACF,EAAA,CAAA;AAAA,wBAEF,GAAA;AAAA,UAAC,6BAAA;AAAA,UAAA;AAAA,YACC,EAAI,EAAA;AAAA,cACF,OAAS,EAAA,OAAA;AAAA,cACT,YAAc,EAAA;AAAA;AAChB;AAAA;AACF,OACF,EAAA,CAAA;AAAA,MAEF,WAAa,EAAA;AAAA,QACX,KAAO,EAAA,SAAA;AAAA,QACP,EAAI,EAAA;AAAA,UACF,OAAS,EAAA,MAAA;AAAA,UACT,UAAY,EAAA;AAAA;AACd,OACF;AAAA,MACA,MAAQ,EAAA,UAAA;AAAA,MACR,OAAS,EAAA,WAAA;AAAA,MACT,QAAA;AAAA,MAEA,8BAAC,WAAY,EAAA,EAAA,WAAA,EAAW,IAAC,EAAA,KAAA,EAAO,WAAW,WAA0B,EAAA;AAAA;AAAA,GACvE;AAEJ;;;;"}
@@ -1,19 +1,21 @@
1
1
  import { jsx } from 'react/jsx-runtime';
2
2
  import { MenuSection } from './MenuSection.esm.js';
3
3
  import { MenuItemLink } from '../MenuItemLink/MenuItemLink.esm.js';
4
+ import { useTranslation } from '../../hooks/useTranslation.esm.js';
4
5
 
5
6
  const RegisterAComponentSection = ({
6
7
  hideDivider,
7
8
  handleClose
8
9
  }) => {
10
+ const { t } = useTranslation();
9
11
  return /* @__PURE__ */ jsx(
10
12
  MenuSection,
11
13
  {
12
14
  hideDivider,
13
15
  items: [
14
16
  {
15
- label: "Register a component",
16
- subLabel: "Import it to the catalog page",
17
+ label: t("create.registerComponent.title"),
18
+ subLabel: t("create.registerComponent.subtitle"),
17
19
  link: "/catalog-import",
18
20
  icon: "category",
19
21
  Component: MenuItemLink
@@ -1 +1 @@
1
- {"version":3,"file":"RegisterAComponentSection.esm.js","sources":["../../../src/components/HeaderDropdownComponent/RegisterAComponentSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { ComponentType } from 'react';\nimport { MenuSection } from './MenuSection';\nimport { MenuItemLink } from '../MenuItemLink/MenuItemLink';\n\n/**\n * Register A Component Section properties\n *\n * @public\n */\nexport type RegisterAComponentSectionProps = {\n hideDivider: boolean;\n handleClose: () => void;\n};\n\nexport const RegisterAComponentSection = ({\n hideDivider,\n handleClose,\n}: RegisterAComponentSectionProps) => {\n return (\n <MenuSection\n hideDivider={hideDivider}\n items={[\n {\n label: 'Register a component',\n subLabel: 'Import it to the catalog page',\n link: '/catalog-import',\n icon: 'category',\n Component: MenuItemLink as ComponentType,\n },\n ]}\n handleClose={handleClose}\n />\n );\n};\n"],"names":[],"mappings":";;;;AA6BO,MAAM,4BAA4B,CAAC;AAAA,EACxC,WAAA;AAAA,EACA;AACF,CAAsC,KAAA;AACpC,EACE,uBAAA,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,WAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACL;AAAA,UACE,KAAO,EAAA,sBAAA;AAAA,UACP,QAAU,EAAA,+BAAA;AAAA,UACV,IAAM,EAAA,iBAAA;AAAA,UACN,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA;AAAA;AACb,OACF;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"RegisterAComponentSection.esm.js","sources":["../../../src/components/HeaderDropdownComponent/RegisterAComponentSection.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport type { ComponentType } from 'react';\nimport { MenuSection } from './MenuSection';\nimport { MenuItemLink } from '../MenuItemLink/MenuItemLink';\nimport { useTranslation } from '../../hooks/useTranslation';\n\n/**\n * Register A Component Section properties\n *\n * @public\n */\nexport type RegisterAComponentSectionProps = {\n hideDivider: boolean;\n handleClose: () => void;\n};\n\nexport const RegisterAComponentSection = ({\n hideDivider,\n handleClose,\n}: RegisterAComponentSectionProps) => {\n const { t } = useTranslation();\n\n return (\n <MenuSection\n hideDivider={hideDivider}\n items={[\n {\n label: t('create.registerComponent.title'),\n subLabel: t('create.registerComponent.subtitle'),\n link: '/catalog-import',\n icon: 'category',\n Component: MenuItemLink as ComponentType,\n },\n ]}\n handleClose={handleClose}\n />\n );\n};\n"],"names":[],"mappings":";;;;;AA8BO,MAAM,4BAA4B,CAAC;AAAA,EACxC,WAAA;AAAA,EACA;AACF,CAAsC,KAAA;AACpC,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAE7B,EACE,uBAAA,GAAA;AAAA,IAAC,WAAA;AAAA,IAAA;AAAA,MACC,WAAA;AAAA,MACA,KAAO,EAAA;AAAA,QACL;AAAA,UACE,KAAA,EAAO,EAAE,gCAAgC,CAAA;AAAA,UACzC,QAAA,EAAU,EAAE,mCAAmC,CAAA;AAAA,UAC/C,IAAM,EAAA,iBAAA;AAAA,UACN,IAAM,EAAA,UAAA;AAAA,UACN,SAAW,EAAA;AAAA;AACb,OACF;AAAA,MACA;AAAA;AAAA,GACF;AAEJ;;;;"}