@red-hat-developer-hub/backstage-plugin-dynamic-home-page 1.7.0 → 1.8.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 +10 -0
- package/dist/components/CustomizableHomePage.esm.js +3 -7
- package/dist/components/CustomizableHomePage.esm.js.map +1 -1
- package/dist/components/EntitySection/EntitySection.esm.js +18 -13
- package/dist/components/EntitySection/EntitySection.esm.js.map +1 -1
- package/dist/components/FeaturedDocsCard.esm.js +9 -1
- package/dist/components/FeaturedDocsCard.esm.js.map +1 -1
- package/dist/components/Header.esm.js +24 -12
- package/dist/components/Header.esm.js.map +1 -1
- package/dist/components/HomePage.esm.js +4 -8
- package/dist/components/HomePage.esm.js.map +1 -1
- package/dist/components/OnboardingSection/OnboardingSection.esm.js +5 -3
- package/dist/components/OnboardingSection/OnboardingSection.esm.js.map +1 -1
- package/dist/components/QuickAccessCard.esm.js +5 -3
- package/dist/components/QuickAccessCard.esm.js.map +1 -1
- package/dist/components/SearchBar.esm.js +3 -1
- package/dist/components/SearchBar.esm.js.map +1 -1
- package/dist/components/TemplateSection/TemplateSection.esm.js +16 -12
- package/dist/components/TemplateSection/TemplateSection.esm.js.map +1 -1
- package/dist/components/Trans.esm.js +9 -0
- package/dist/components/Trans.esm.js.map +1 -0
- package/dist/hooks/useGreeting.esm.js +12 -8
- package/dist/hooks/useGreeting.esm.js.map +1 -1
- package/dist/hooks/useLanguage.esm.js +7 -0
- package/dist/hooks/useLanguage.esm.js.map +1 -0
- package/dist/hooks/useTranslation.esm.js +8 -0
- package/dist/hooks/useTranslation.esm.js.map +1 -0
- package/dist/index.d.ts +57 -1
- package/dist/index.esm.js +2 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/translations/de.esm.js +52 -0
- package/dist/translations/de.esm.js.map +1 -0
- package/dist/translations/es.esm.js +52 -0
- package/dist/translations/es.esm.js.map +1 -0
- package/dist/translations/fr.esm.js +52 -0
- package/dist/translations/fr.esm.js.map +1 -0
- package/dist/translations/index.esm.js +15 -0
- package/dist/translations/index.esm.js.map +1 -0
- package/dist/translations/it.esm.js +52 -0
- package/dist/translations/it.esm.js.map +1 -0
- package/dist/translations/ref.esm.js +76 -0
- package/dist/translations/ref.esm.js.map +1 -0
- package/dist/utils/constants.esm.js +14 -14
- package/dist/utils/constants.esm.js.map +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @red-hat-developer-hub/backstage-plugin-dynamic-home-page
|
|
2
2
|
|
|
3
|
+
## 1.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 8b64e16: Add internationalization (i18n) support with German, French, Italian, and Spanish translations.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- a994094: Updated dependency `@red-hat-developer-hub/backstage-plugin-theme` to `^0.10.0`.
|
|
12
|
+
|
|
3
13
|
## 1.7.0
|
|
4
14
|
|
|
5
15
|
### Minor Changes
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { Page, Content, EmptyState } from '@backstage/core-components';
|
|
4
|
+
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
4
5
|
import { Header } from './Header.esm.js';
|
|
5
6
|
import { CustomizableGrid } from './CustomizableGrid.esm.js';
|
|
6
7
|
|
|
7
8
|
const CustomizableHomePage = (props) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
8
10
|
const filteredAndSortedHomePageCards = useMemo(() => {
|
|
9
11
|
if (!props.cards) {
|
|
10
12
|
return [];
|
|
@@ -19,13 +21,7 @@ const CustomizableHomePage = (props) => {
|
|
|
19
21
|
}, [props.cards]);
|
|
20
22
|
return /* @__PURE__ */ jsxs(Page, { themeId: "home", children: [
|
|
21
23
|
/* @__PURE__ */ jsx(Header, { ...props }),
|
|
22
|
-
/* @__PURE__ */ jsx(Content, { children: filteredAndSortedHomePageCards.length === 0 ? /* @__PURE__ */ jsx(
|
|
23
|
-
EmptyState,
|
|
24
|
-
{
|
|
25
|
-
title: "No home page cards (mount points) configured or found.",
|
|
26
|
-
missing: "content"
|
|
27
|
-
}
|
|
28
|
-
) : /* @__PURE__ */ jsx(CustomizableGrid, { mountPoints: filteredAndSortedHomePageCards }) })
|
|
24
|
+
/* @__PURE__ */ jsx(Content, { children: filteredAndSortedHomePageCards.length === 0 ? /* @__PURE__ */ jsx(EmptyState, { title: t("homePage.empty"), missing: "content" }) : /* @__PURE__ */ jsx(CustomizableGrid, { mountPoints: filteredAndSortedHomePageCards }) })
|
|
29
25
|
] });
|
|
30
26
|
};
|
|
31
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomizableHomePage.esm.js","sources":["../../src/components/CustomizableHomePage.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';\n\nimport { Content, EmptyState, Page } from '@backstage/core-components';\n\nimport { HomePageCardMountPoint } from '../types';\n\nimport { Header, HeaderProps } from './Header';\nimport { CustomizableGrid } from './CustomizableGrid';\n\nexport interface HomePageProps extends HeaderProps {\n cards?: HomePageCardMountPoint[];\n}\n\nexport const CustomizableHomePage = (props: HomePageProps) => {\n const filteredAndSortedHomePageCards = useMemo(() => {\n if (!props.cards) {\n return [];\n }\n\n const filteredAndSorted = props.cards.filter(\n card =>\n card.enabled !== false &&\n (!card.config?.priority || card.config.priority >= 0),\n );\n\n filteredAndSorted.sort(\n (a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0),\n );\n\n return filteredAndSorted;\n }, [props.cards]);\n\n return (\n <Page themeId=\"home\">\n <Header {...props} />\n <Content>\n {filteredAndSortedHomePageCards.length === 0 ? (\n <EmptyState
|
|
1
|
+
{"version":3,"file":"CustomizableHomePage.esm.js","sources":["../../src/components/CustomizableHomePage.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';\n\nimport { Content, EmptyState, Page } from '@backstage/core-components';\n\nimport { HomePageCardMountPoint } from '../types';\nimport { useTranslation } from '../hooks/useTranslation';\n\nimport { Header, HeaderProps } from './Header';\nimport { CustomizableGrid } from './CustomizableGrid';\n\nexport interface HomePageProps extends HeaderProps {\n cards?: HomePageCardMountPoint[];\n}\n\nexport const CustomizableHomePage = (props: HomePageProps) => {\n const { t } = useTranslation();\n const filteredAndSortedHomePageCards = useMemo(() => {\n if (!props.cards) {\n return [];\n }\n\n const filteredAndSorted = props.cards.filter(\n card =>\n card.enabled !== false &&\n (!card.config?.priority || card.config.priority >= 0),\n );\n\n filteredAndSorted.sort(\n (a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0),\n );\n\n return filteredAndSorted;\n }, [props.cards]);\n\n return (\n <Page themeId=\"home\">\n <Header {...props} />\n <Content>\n {filteredAndSortedHomePageCards.length === 0 ? (\n <EmptyState title={t('homePage.empty')} missing=\"content\" />\n ) : (\n <CustomizableGrid mountPoints={filteredAndSortedHomePageCards} />\n )}\n </Content>\n </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../../images/homepage-entities-1.svg';
|
|
19
19
|
import { useEntities } from '../../hooks/useEntities.esm.js';
|
|
20
20
|
import { hasEntityIllustrationUserDismissed, addDismissedEntityIllustrationUsers } from '../../utils/utils.esm.js';
|
|
21
|
+
import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
22
|
+
import { Trans } from '../Trans.esm.js';
|
|
21
23
|
|
|
22
24
|
const StyledLink = styled(Link)(({ theme }) => ({
|
|
23
25
|
textDecoration: "none",
|
|
@@ -29,6 +31,7 @@ const StyledLink = styled(Link)(({ theme }) => ({
|
|
|
29
31
|
}));
|
|
30
32
|
const EntitySection = () => {
|
|
31
33
|
const theme = useTheme();
|
|
34
|
+
const { t } = useTranslation();
|
|
32
35
|
const { displayName, loading: profileLoading } = useUserProfile();
|
|
33
36
|
const [isRemoveFirstCard, setIsRemoveFirstCard] = useState(false);
|
|
34
37
|
const [showDiscoveryCard, setShowDiscoveryCard] = useState(true);
|
|
@@ -72,11 +75,11 @@ const EntitySection = () => {
|
|
|
72
75
|
}
|
|
73
76
|
);
|
|
74
77
|
} else if (!data) {
|
|
75
|
-
content = /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: "
|
|
78
|
+
content = /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: t("entities.fetchError"), children: /* @__PURE__ */ jsx(
|
|
76
79
|
CodeSnippet,
|
|
77
80
|
{
|
|
78
81
|
language: "text",
|
|
79
|
-
text: error?.toString() ?? "
|
|
82
|
+
text: error?.toString() ?? t("entities.error")
|
|
80
83
|
}
|
|
81
84
|
) });
|
|
82
85
|
} else {
|
|
@@ -123,12 +126,12 @@ const EntitySection = () => {
|
|
|
123
126
|
}
|
|
124
127
|
),
|
|
125
128
|
/* @__PURE__ */ jsxs(Box, { sx: { p: 2 }, children: [
|
|
126
|
-
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Typography, { variant: "body2", paragraph: true, children: "
|
|
129
|
+
/* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Typography, { variant: "body2", paragraph: true, children: t("entities.description") }) }),
|
|
127
130
|
entities?.length > 0 && /* @__PURE__ */ jsx(
|
|
128
131
|
IconButton,
|
|
129
132
|
{
|
|
130
133
|
onClick: handleClose,
|
|
131
|
-
"aria-label": "close",
|
|
134
|
+
"aria-label": t("entities.close"),
|
|
132
135
|
style: {
|
|
133
136
|
position: "absolute",
|
|
134
137
|
top: "8px",
|
|
@@ -175,7 +178,7 @@ const EntitySection = () => {
|
|
|
175
178
|
overflow: "hidden"
|
|
176
179
|
},
|
|
177
180
|
children: /* @__PURE__ */ jsxs(CardContent, { children: [
|
|
178
|
-
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: "1.125rem", fontWeight: 500 }, children: "
|
|
181
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: "1.125rem", fontWeight: 500 }, children: t("entities.empty") }),
|
|
179
182
|
/* @__PURE__ */ jsx(
|
|
180
183
|
Typography,
|
|
181
184
|
{
|
|
@@ -185,10 +188,10 @@ const EntitySection = () => {
|
|
|
185
188
|
mt: "20px",
|
|
186
189
|
mb: "16px"
|
|
187
190
|
},
|
|
188
|
-
children: "
|
|
191
|
+
children: t("entities.emptyDescription")
|
|
189
192
|
}
|
|
190
193
|
),
|
|
191
|
-
/* @__PURE__ */ jsx(StyledLink, { to: "/catalog-import", underline: "none", children: "
|
|
194
|
+
/* @__PURE__ */ jsx(StyledLink, { to: "/catalog-import", underline: "none", children: t("entities.register") })
|
|
192
195
|
] })
|
|
193
196
|
}
|
|
194
197
|
) })
|
|
@@ -214,15 +217,17 @@ const EntitySection = () => {
|
|
|
214
217
|
fontWeight: "500",
|
|
215
218
|
fontSize: "1.5rem"
|
|
216
219
|
},
|
|
217
|
-
children: "
|
|
220
|
+
children: t("entities.title")
|
|
218
221
|
}
|
|
219
222
|
),
|
|
220
223
|
content,
|
|
221
|
-
entities?.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { pt: 2 }, children: /* @__PURE__ */
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
224
|
+
entities?.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { pt: 2 }, children: /* @__PURE__ */ jsx(ViewMoreLink, { to: "/catalog", children: /* @__PURE__ */ jsx(
|
|
225
|
+
Trans,
|
|
226
|
+
{
|
|
227
|
+
message: "entities.viewAll",
|
|
228
|
+
params: { count: data?.totalItems?.toString() || "" }
|
|
229
|
+
}
|
|
230
|
+
) }) })
|
|
226
231
|
]
|
|
227
232
|
}
|
|
228
233
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntitySection.esm.js","sources":["../../../src/components/EntitySection/EntitySection.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 } from 'react';\n\nimport { useState, useEffect, Fragment } from 'react';\n\nimport {\n CodeSnippet,\n WarningPanel,\n Link as BackstageLink,\n} from '@backstage/core-components';\nimport { useUserProfile } from '@backstage/plugin-user-settings';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\nimport IconButton from '@mui/material/IconButton';\nimport Skeleton from '@mui/material/Skeleton';\nimport Typography from '@mui/material/Typography';\nimport CloseIcon from '@mui/icons-material/Close';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport CardContent from '@mui/material/CardContent';\nimport { useTheme, styled } from '@mui/material/styles';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport EntityCard from './EntityCard';\nimport { ViewMoreLink } from './ViewMoreLink';\nimport HomePageEntityIllustration from '../../images/homepage-entities-1.svg';\nimport { useEntities } from '../../hooks/useEntities';\nimport {\n addDismissedEntityIllustrationUsers,\n hasEntityIllustrationUserDismissed,\n} from '../../utils/utils';\n\nconst StyledLink = styled(BackstageLink)(({ theme }) => ({\n textDecoration: 'none',\n padding: theme.spacing(1, 1.5),\n fontSize: '16px',\n display: 'inline-flex',\n border: `1px solid ${theme.palette.primary.main}`,\n borderRadius: 4,\n}));\n\nexport const EntitySection = () => {\n const theme = useTheme();\n const { displayName, loading: profileLoading } = useUserProfile();\n const [isRemoveFirstCard, setIsRemoveFirstCard] = useState(false);\n const [showDiscoveryCard, setShowDiscoveryCard] = useState(true);\n const [imgLoaded, setImgLoaded] = useState(false);\n const [isMediumBreakpoint, setIsMediumBreakpoint] = useState(false);\n\n const isMd = useMediaQuery(theme.breakpoints.only('md'));\n\n useEffect(() => {\n if (isMd) {\n setIsMediumBreakpoint(true);\n } else {\n setIsMediumBreakpoint(false);\n }\n }, [isMd]);\n\n useEffect(() => {\n const isUserDismissedEntityIllustration =\n hasEntityIllustrationUserDismissed(displayName);\n setIsRemoveFirstCard(isUserDismissedEntityIllustration);\n }, [displayName]);\n\n const handleClose = () => {\n setShowDiscoveryCard(false);\n setTimeout(() => {\n addDismissedEntityIllustrationUsers(displayName);\n setIsRemoveFirstCard(true);\n }, 500);\n };\n\n const { data, error, isLoading } = useEntities({\n kind: ['Component', 'API', 'Resource', 'System'],\n });\n\n const entities = data?.items ?? [];\n\n let content: ReactNode;\n\n if (isLoading) {\n content = (\n <Box\n sx={{\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n }}\n >\n <CircularProgress />\n </Box>\n );\n } else if (!data) {\n content = (\n <WarningPanel severity=\"error\" title=\"Could not fetch data.\">\n <CodeSnippet\n language=\"text\"\n text={error?.toString() ?? 'Unknown error'}\n />\n </WarningPanel>\n );\n } else {\n let entityCardCount = 2;\n if (isMediumBreakpoint) entityCardCount = 3;\n\n content = (\n <Box sx={{ padding: '8px 8px 8px 0' }}>\n <Fragment>\n <Grid container spacing={1} alignItems=\"stretch\">\n {!isRemoveFirstCard && !profileLoading && (\n <Grid item xs={12} md={6} lg={5} key=\"entities illustration\">\n <Card\n elevation={0}\n sx={{\n border: `1px solid ${theme.palette.grey[400]}`,\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n position: 'relative',\n transition:\n 'opacity 0.5s ease-out, transform 0.5s ease-in-out',\n opacity: showDiscoveryCard ? 1 : 0,\n transform: showDiscoveryCard\n ? 'translateX(0)'\n : 'translateX(-50px)',\n }}\n >\n {!imgLoaded && (\n <Skeleton\n variant=\"rectangular\"\n height={300}\n sx={{\n borderRadius: 3,\n width: 'clamp(140px, 14vw, 266px)',\n }}\n />\n )}\n <Box\n component=\"img\"\n src={HomePageEntityIllustration}\n onLoad={() => setImgLoaded(true)}\n alt=\"\"\n height={300}\n sx={{\n width: 'clamp(140px, 14vw, 266px)',\n }}\n />\n <Box sx={{ p: 2 }}>\n <Box>\n <Typography variant=\"body2\" paragraph>\n Browse the Systems, Components, Resources, and APIs that\n are available in your organization.\n </Typography>\n </Box>\n {entities?.length > 0 && (\n <IconButton\n onClick={handleClose}\n aria-label=\"close\"\n style={{\n position: 'absolute',\n top: '8px',\n right: '8px',\n }}\n >\n <CloseIcon style={{ width: '16px', height: '16px' }} />\n </IconButton>\n )}\n </Box>\n </Card>\n </Grid>\n )}\n {entities\n ?.slice(0, isRemoveFirstCard ? 4 : entityCardCount)\n .map((item: any) => (\n <Grid\n item\n xs={12}\n md={6}\n lg={isRemoveFirstCard ? 3 : 3.5}\n key={item.metadata.name}\n >\n <EntityCard\n entity={item}\n title={\n item.spec?.profile?.displayName ?? item.metadata.name\n }\n version=\"latest\"\n description={item.metadata.description ?? ''}\n tags={item.metadata?.tags ?? []}\n kind={item.kind}\n />\n </Grid>\n ))}\n {entities?.length === 0 && (\n <Grid item md={isRemoveFirstCard ? 12 : 7}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 300,\n border: muiTheme =>\n `1px solid ${muiTheme.palette.grey[400]}`,\n borderRadius: 3,\n overflow: 'hidden',\n }}\n >\n <CardContent>\n <Typography sx={{ fontSize: '1.125rem', fontWeight: 500 }}>\n No software catalog added yet\n </Typography>\n <Typography\n sx={{\n fontSize: '0.875rem',\n fontWeight: 400,\n mt: '20px',\n mb: '16px',\n }}\n >\n Once software catalogs are added, this space will showcase\n relevant content tailored to your experience.\n </Typography>\n <StyledLink to=\"/catalog-import\" underline=\"none\">\n Register a component\n </StyledLink>\n </CardContent>\n </Box>\n </Grid>\n )}\n </Grid>\n </Fragment>\n </Box>\n );\n }\n\n return (\n <Card\n elevation={0}\n sx={{\n padding: '24px',\n border: muitheme => `1px solid ${muitheme.palette.grey[300]}`,\n overflow: 'auto',\n }}\n >\n <Typography\n variant=\"h3\"\n sx={{\n display: 'flex',\n alignItems: 'center',\n fontWeight: '500',\n fontSize: '1.5rem',\n }}\n >\n Explore Your Software Catalog\n </Typography>\n {content}\n {entities?.length > 0 && (\n <Box sx={{ pt: 2 }}>\n <ViewMoreLink to=\"/catalog\">\n View all {data?.totalItems ? data?.totalItems : ''} catalog entities\n </ViewMoreLink>\n </Box>\n )}\n </Card>\n );\n};\n"],"names":["BackstageLink"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,aAAa,MAAO,CAAAA,IAAa,EAAE,CAAC,EAAE,OAAa,MAAA;AAAA,EACvD,cAAgB,EAAA,MAAA;AAAA,EAChB,OAAS,EAAA,KAAA,CAAM,OAAQ,CAAA,CAAA,EAAG,GAAG,CAAA;AAAA,EAC7B,QAAU,EAAA,MAAA;AAAA,EACV,OAAS,EAAA,aAAA;AAAA,EACT,MAAQ,EAAA,CAAA,UAAA,EAAa,KAAM,CAAA,OAAA,CAAQ,QAAQ,IAAI,CAAA,CAAA;AAAA,EAC/C,YAAc,EAAA;AAChB,CAAE,CAAA,CAAA;AAEK,MAAM,gBAAgB,M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,OAAQ,CAAA,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAAA,QAC3D,QAAU,EAAA;AAAA,OACZ;AAAA,MAEA,QAAA,EAAA;AAAA,wBAAA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACC,OAAQ,EAAA,IAAA;AAAA,YACR,EAAI,EAAA;AAAA,cACF,OAAS,EAAA,MAAA;AAAA,cACT,UAAY,EAAA,QAAA;AAAA,cACZ,UAAY,EAAA,KAAA;AAAA,cACZ,QAAU,EAAA;AAAA,aACZ;AAAA,YACD,QAAA,EAAA;AAAA;AAAA,SAED;AAAA,QACC,OAAA;AAAA,QACA,QAAU,EAAA,MAAA,GAAS,CAClB,oBAAA,GAAA,CAAC,GAAI,EAAA,EAAA,EAAA,EAAI,EAAE,EAAA,EAAI,CAAE,EAAA,EACf,QAAC,kBAAA,IAAA,CAAA,YAAA,EAAA,EAAa,IAAG,UAAW,EAAA,QAAA,EAAA;AAAA,UAAA,WAAA;AAAA,UAChB,IAAA,EAAM,UAAa,GAAA,IAAA,EAAM,UAAa,GAAA,EAAA;AAAA,UAAG;AAAA,SAAA,EACrD,CACF,EAAA;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
1
|
+
{"version":3,"file":"EntitySection.esm.js","sources":["../../../src/components/EntitySection/EntitySection.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 } from 'react';\n\nimport { useState, useEffect, Fragment } from 'react';\n\nimport {\n CodeSnippet,\n WarningPanel,\n Link as BackstageLink,\n} from '@backstage/core-components';\nimport { useUserProfile } from '@backstage/plugin-user-settings';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\nimport IconButton from '@mui/material/IconButton';\nimport Skeleton from '@mui/material/Skeleton';\nimport Typography from '@mui/material/Typography';\nimport CloseIcon from '@mui/icons-material/Close';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport CardContent from '@mui/material/CardContent';\nimport { useTheme, styled } from '@mui/material/styles';\nimport useMediaQuery from '@mui/material/useMediaQuery';\n\nimport EntityCard from './EntityCard';\nimport { ViewMoreLink } from './ViewMoreLink';\nimport HomePageEntityIllustration from '../../images/homepage-entities-1.svg';\nimport { useEntities } from '../../hooks/useEntities';\nimport {\n addDismissedEntityIllustrationUsers,\n hasEntityIllustrationUserDismissed,\n} from '../../utils/utils';\nimport { useTranslation } from '../../hooks/useTranslation';\nimport { Trans } from '../Trans';\n\nconst StyledLink = styled(BackstageLink)(({ theme }) => ({\n textDecoration: 'none',\n padding: theme.spacing(1, 1.5),\n fontSize: '16px',\n display: 'inline-flex',\n border: `1px solid ${theme.palette.primary.main}`,\n borderRadius: 4,\n}));\n\nexport const EntitySection = () => {\n const theme = useTheme();\n const { t } = useTranslation();\n const { displayName, loading: profileLoading } = useUserProfile();\n const [isRemoveFirstCard, setIsRemoveFirstCard] = useState(false);\n const [showDiscoveryCard, setShowDiscoveryCard] = useState(true);\n const [imgLoaded, setImgLoaded] = useState(false);\n const [isMediumBreakpoint, setIsMediumBreakpoint] = useState(false);\n\n const isMd = useMediaQuery(theme.breakpoints.only('md'));\n\n useEffect(() => {\n if (isMd) {\n setIsMediumBreakpoint(true);\n } else {\n setIsMediumBreakpoint(false);\n }\n }, [isMd]);\n\n useEffect(() => {\n const isUserDismissedEntityIllustration =\n hasEntityIllustrationUserDismissed(displayName);\n setIsRemoveFirstCard(isUserDismissedEntityIllustration);\n }, [displayName]);\n\n const handleClose = () => {\n setShowDiscoveryCard(false);\n setTimeout(() => {\n addDismissedEntityIllustrationUsers(displayName);\n setIsRemoveFirstCard(true);\n }, 500);\n };\n\n const { data, error, isLoading } = useEntities({\n kind: ['Component', 'API', 'Resource', 'System'],\n });\n\n const entities = data?.items ?? [];\n\n let content: ReactNode;\n\n if (isLoading) {\n content = (\n <Box\n sx={{\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n }}\n >\n <CircularProgress />\n </Box>\n );\n } else if (!data) {\n content = (\n <WarningPanel severity=\"error\" title={t('entities.fetchError')}>\n <CodeSnippet\n language=\"text\"\n text={error?.toString() ?? t('entities.error')}\n />\n </WarningPanel>\n );\n } else {\n let entityCardCount = 2;\n if (isMediumBreakpoint) entityCardCount = 3;\n\n content = (\n <Box sx={{ padding: '8px 8px 8px 0' }}>\n <Fragment>\n <Grid container spacing={1} alignItems=\"stretch\">\n {!isRemoveFirstCard && !profileLoading && (\n <Grid item xs={12} md={6} lg={5} key=\"entities illustration\">\n <Card\n elevation={0}\n sx={{\n border: `1px solid ${theme.palette.grey[400]}`,\n display: 'flex',\n flexDirection: 'row',\n alignItems: 'center',\n position: 'relative',\n transition:\n 'opacity 0.5s ease-out, transform 0.5s ease-in-out',\n opacity: showDiscoveryCard ? 1 : 0,\n transform: showDiscoveryCard\n ? 'translateX(0)'\n : 'translateX(-50px)',\n }}\n >\n {!imgLoaded && (\n <Skeleton\n variant=\"rectangular\"\n height={300}\n sx={{\n borderRadius: 3,\n width: 'clamp(140px, 14vw, 266px)',\n }}\n />\n )}\n <Box\n component=\"img\"\n src={HomePageEntityIllustration}\n onLoad={() => setImgLoaded(true)}\n alt=\"\"\n height={300}\n sx={{\n width: 'clamp(140px, 14vw, 266px)',\n }}\n />\n <Box sx={{ p: 2 }}>\n <Box>\n <Typography variant=\"body2\" paragraph>\n {t('entities.description')}\n </Typography>\n </Box>\n {entities?.length > 0 && (\n <IconButton\n onClick={handleClose}\n aria-label={t('entities.close')}\n style={{\n position: 'absolute',\n top: '8px',\n right: '8px',\n }}\n >\n <CloseIcon style={{ width: '16px', height: '16px' }} />\n </IconButton>\n )}\n </Box>\n </Card>\n </Grid>\n )}\n {entities\n ?.slice(0, isRemoveFirstCard ? 4 : entityCardCount)\n .map((item: any) => (\n <Grid\n item\n xs={12}\n md={6}\n lg={isRemoveFirstCard ? 3 : 3.5}\n key={item.metadata.name}\n >\n <EntityCard\n entity={item}\n title={\n item.spec?.profile?.displayName ?? item.metadata.name\n }\n version=\"latest\"\n description={item.metadata.description ?? ''}\n tags={item.metadata?.tags ?? []}\n kind={item.kind}\n />\n </Grid>\n ))}\n {entities?.length === 0 && (\n <Grid item md={isRemoveFirstCard ? 12 : 7}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n minHeight: 300,\n border: muiTheme =>\n `1px solid ${muiTheme.palette.grey[400]}`,\n borderRadius: 3,\n overflow: 'hidden',\n }}\n >\n <CardContent>\n <Typography sx={{ fontSize: '1.125rem', fontWeight: 500 }}>\n {t('entities.empty')}\n </Typography>\n <Typography\n sx={{\n fontSize: '0.875rem',\n fontWeight: 400,\n mt: '20px',\n mb: '16px',\n }}\n >\n {t('entities.emptyDescription')}\n </Typography>\n <StyledLink to=\"/catalog-import\" underline=\"none\">\n {t('entities.register')}\n </StyledLink>\n </CardContent>\n </Box>\n </Grid>\n )}\n </Grid>\n </Fragment>\n </Box>\n );\n }\n\n return (\n <Card\n elevation={0}\n sx={{\n padding: '24px',\n border: muitheme => `1px solid ${muitheme.palette.grey[300]}`,\n overflow: 'auto',\n }}\n >\n <Typography\n variant=\"h3\"\n sx={{\n display: 'flex',\n alignItems: 'center',\n fontWeight: '500',\n fontSize: '1.5rem',\n }}\n >\n {t('entities.title')}\n </Typography>\n {content}\n {entities?.length > 0 && (\n <Box sx={{ pt: 2 }}>\n <ViewMoreLink to=\"/catalog\">\n <Trans\n message=\"entities.viewAll\"\n params={{ count: data?.totalItems?.toString() || '' }}\n />\n </ViewMoreLink>\n </Box>\n )}\n </Card>\n );\n};\n"],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,QAAA,kBAAA,GAAA;AAAA,UAAC,KAAA;AAAA,UAAA;AAAA,YACC,OAAQ,EAAA,kBAAA;AAAA,YACR,QAAQ,EAAE,KAAA,EAAO,MAAM,UAAY,EAAA,QAAA,MAAc,EAAG;AAAA;AAAA,WAExD,CACF,EAAA;AAAA;AAAA;AAAA,GAEJ;AAEJ;;;;"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { FeaturedDocsCard as FeaturedDocsCard$1 } from '@backstage/plugin-home';
|
|
3
|
+
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
3
4
|
|
|
4
5
|
const FeaturedDocsCard = (props) => {
|
|
5
|
-
|
|
6
|
+
const { t } = useTranslation();
|
|
7
|
+
return /* @__PURE__ */ jsx(
|
|
8
|
+
FeaturedDocsCard$1,
|
|
9
|
+
{
|
|
10
|
+
subLinkText: ` ${t("featuredDocs.learnMore")}`,
|
|
11
|
+
...props
|
|
12
|
+
}
|
|
13
|
+
);
|
|
6
14
|
};
|
|
7
15
|
|
|
8
16
|
export { FeaturedDocsCard };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FeaturedDocsCard.esm.js","sources":["../../src/components/FeaturedDocsCard.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 {\n FeaturedDocsCard as PluginHomeFeaturedDocsCard,\n FeaturedDocsCardProps,\n} from '@backstage/plugin-home';\n\n/**\n * Overrides `FeaturedDocsCard` from the home plugin, but overrides the\n * `subLinkText` prop to be \" Learn more\" instead of \"LEARN MORE\".\n *\n * 1. To fix the all uppercase that is used in home plugin\n * 2. To add a small missing gap between the title and the button\n */\nexport const FeaturedDocsCard = (props: FeaturedDocsCardProps) => {\n return <PluginHomeFeaturedDocsCard
|
|
1
|
+
{"version":3,"file":"FeaturedDocsCard.esm.js","sources":["../../src/components/FeaturedDocsCard.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 {\n FeaturedDocsCard as PluginHomeFeaturedDocsCard,\n FeaturedDocsCardProps,\n} from '@backstage/plugin-home';\n\nimport { useTranslation } from '../hooks/useTranslation';\n\n/**\n * Overrides `FeaturedDocsCard` from the home plugin, but overrides the\n * `subLinkText` prop to be \" Learn more\" instead of \"LEARN MORE\".\n *\n * 1. To fix the all uppercase that is used in home plugin\n * 2. To add a small missing gap between the title and the button\n */\nexport const FeaturedDocsCard = (props: FeaturedDocsCardProps) => {\n const { t } = useTranslation();\n return (\n <PluginHomeFeaturedDocsCard\n subLinkText={` ${t('featuredDocs.learnMore')}`}\n {...props}\n />\n );\n};\n"],"names":["PluginHomeFeaturedDocsCard"],"mappings":";;;;AA8Ba,MAAA,gBAAA,GAAmB,CAAC,KAAiC,KAAA;AAChE,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EACE,uBAAA,GAAA;AAAA,IAACA,kBAAA;AAAA,IAAA;AAAA,MACC,WAAa,EAAA,CAAA,CAAA,EAAI,CAAE,CAAA,wBAAwB,CAAC,CAAA,CAAA;AAAA,MAC3C,GAAG;AAAA;AAAA,GACN;AAEJ;;;;"}
|
|
@@ -5,25 +5,37 @@ import { Header as Header$1 } from '@backstage/core-components';
|
|
|
5
5
|
import { HeaderWorldClock } from '@backstage/plugin-home';
|
|
6
6
|
import useAsync from 'react-use/esm/useAsync';
|
|
7
7
|
import { LocalClock } from './LocalClock.esm.js';
|
|
8
|
+
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
8
9
|
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const interpolateUserTitle = (title, displayName) => {
|
|
11
|
+
if (!displayName) {
|
|
12
|
+
return title.replace(/\{\{(firstName|displayName)\}\}/g, "");
|
|
13
|
+
}
|
|
14
|
+
const firstName = displayName.split(" ")[0];
|
|
15
|
+
return title.replace(/\{\{firstName\}\}/g, firstName).replace(/\{\{displayName\}\}/g, displayName);
|
|
13
16
|
};
|
|
14
17
|
const Header = (props) => {
|
|
15
18
|
const identityApi = useApi(identityApiRef);
|
|
16
19
|
const { value: profile } = useAsync(() => identityApi.getProfileInfo());
|
|
20
|
+
const { t } = useTranslation();
|
|
17
21
|
const title = useMemo(() => {
|
|
22
|
+
const firstName = profile?.displayName?.split(" ")[0];
|
|
18
23
|
if (profile?.displayName && props.personalizedTitle) {
|
|
19
|
-
return
|
|
20
|
-
} else if (props.title) {
|
|
21
|
-
return getPersonalizedTitle(props.title, profile?.displayName);
|
|
24
|
+
return interpolateUserTitle(props.personalizedTitle, profile.displayName);
|
|
22
25
|
}
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
if (props.title) {
|
|
27
|
+
return interpolateUserTitle(props.title, profile?.displayName);
|
|
28
|
+
}
|
|
29
|
+
if (profile?.displayName && firstName) {
|
|
30
|
+
return t("header.welcomePersonalized", { name: firstName });
|
|
31
|
+
}
|
|
32
|
+
return t("header.welcome");
|
|
33
|
+
}, [profile?.displayName, props.personalizedTitle, props.title, t]);
|
|
25
34
|
const subtitle = useMemo(() => {
|
|
26
|
-
|
|
35
|
+
if (props.subtitle) {
|
|
36
|
+
return interpolateUserTitle(props.subtitle, profile?.displayName);
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
27
39
|
}, [props.subtitle, profile?.displayName]);
|
|
28
40
|
return /* @__PURE__ */ jsxs(
|
|
29
41
|
Header$1,
|
|
@@ -35,7 +47,7 @@ const Header = (props) => {
|
|
|
35
47
|
props.localClock?.format && props.localClock?.format !== "none" ? /* @__PURE__ */ jsx(
|
|
36
48
|
LocalClock,
|
|
37
49
|
{
|
|
38
|
-
label: props.localClock?.label ?? (props.worldClocks && props.worldClocks.length > 0 ? "
|
|
50
|
+
label: props.localClock?.label ?? (props.worldClocks && props.worldClocks.length > 0 ? t("header.local") : undefined),
|
|
39
51
|
format: props.localClock?.format ?? (props.worldClocks && props.worldClocks.length > 0 ? "time" : undefined),
|
|
40
52
|
lang: props.localClock?.lang
|
|
41
53
|
}
|
|
@@ -46,5 +58,5 @@ const Header = (props) => {
|
|
|
46
58
|
);
|
|
47
59
|
};
|
|
48
60
|
|
|
49
|
-
export { Header
|
|
61
|
+
export { Header };
|
|
50
62
|
//# sourceMappingURL=Header.esm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Header.esm.js","sources":["../../src/components/Header.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';\n\nimport { identityApiRef, useApi } from '@backstage/core-plugin-api';\nimport { Header as BackstageHeader } from '@backstage/core-components';\nimport { ClockConfig, HeaderWorldClock } from '@backstage/plugin-home';\n\nimport useAsync from 'react-use/esm/useAsync';\n\nimport { LocalClock, LocalClockProps } from './LocalClock';\n\nexport interface HeaderProps {\n title?: string;\n personalizedTitle?: string;\n pageTitle?: string;\n subtitle?: string;\n localClock?: LocalClockProps;\n worldClocks?: ClockConfig[];\n}\n\n// I kept this because I hope that we will add this soon or at least in Dynamic Home Page plugin 1.2 ~ RHDH 1.6.\n// const getTimeBasedTitle = (): string => {\n// const currentHour = new Date(Date.now()).getHours();\n// if (currentHour < 12) {\n// return 'Good morning {{firstName}}';\n// } else if (currentHour < 17) {\n// return 'Good afternoon {{firstName}}';\n// }\n// return 'Good evening {{firstName}}';\n// };\n\
|
|
1
|
+
{"version":3,"file":"Header.esm.js","sources":["../../src/components/Header.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';\n\nimport { identityApiRef, useApi } from '@backstage/core-plugin-api';\nimport { Header as BackstageHeader } from '@backstage/core-components';\nimport { ClockConfig, HeaderWorldClock } from '@backstage/plugin-home';\n\nimport useAsync from 'react-use/esm/useAsync';\n\nimport { LocalClock, LocalClockProps } from './LocalClock';\nimport { useTranslation } from '../hooks/useTranslation';\n\nexport interface HeaderProps {\n title?: string;\n personalizedTitle?: string;\n pageTitle?: string;\n subtitle?: string;\n localClock?: LocalClockProps;\n worldClocks?: ClockConfig[];\n}\n\n// I kept this because I hope that we will add this soon or at least in Dynamic Home Page plugin 1.2 ~ RHDH 1.6.\n// const getTimeBasedTitle = (): string => {\n// const currentHour = new Date(Date.now()).getHours();\n// if (currentHour < 12) {\n// return 'Good morning {{firstName}}';\n// } else if (currentHour < 17) {\n// return 'Good afternoon {{firstName}}';\n// }\n// return 'Good evening {{firstName}}';\n// };\n\n/**\n * Handles user-provided title customization with variable interpolation.\n *\n * When users provide custom titles in their configuration, they take responsibility\n * for internationalization at the configuration level. This function simply handles\n * the variable interpolation for their custom strings.\n *\n * Supports variables:\n * - {{firstName}} - First part of displayName (split by space)\n * - {{displayName}} - Full displayName from user profile\n *\n * @param title - User-provided title string with optional {{variables}}\n * @param displayName - User's displayName from profile, if available\n */\nconst interpolateUserTitle = (\n title: string,\n displayName: string | undefined,\n) => {\n if (!displayName) {\n // Remove variable placeholders when no displayName is available\n return title.replace(/\\{\\{(firstName|displayName)\\}\\}/g, '');\n }\n\n const firstName = displayName.split(' ')[0];\n return title\n .replace(/\\{\\{firstName\\}\\}/g, firstName)\n .replace(/\\{\\{displayName\\}\\}/g, displayName);\n};\n\nexport const Header = (props: HeaderProps) => {\n const identityApi = useApi(identityApiRef);\n const { value: profile } = useAsync(() => identityApi.getProfileInfo());\n const { t } = useTranslation();\n\n const title = useMemo<string>(() => {\n const firstName = profile?.displayName?.split(' ')[0];\n\n // Priority 1: User-provided personalized title (user handles i18n)\n if (profile?.displayName && props.personalizedTitle) {\n return interpolateUserTitle(props.personalizedTitle, profile.displayName);\n }\n\n // Priority 2: User-provided general title (user handles i18n)\n if (props.title) {\n return interpolateUserTitle(props.title, profile?.displayName);\n }\n\n // Default: Use plugin's translation system\n if (profile?.displayName && firstName) {\n return t('header.welcomePersonalized' as any, { name: firstName });\n }\n\n return t('header.welcome');\n }, [profile?.displayName, props.personalizedTitle, props.title, t]);\n\n const subtitle = useMemo<string | undefined>(() => {\n // User-provided subtitle (user handles i18n)\n if (props.subtitle) {\n return interpolateUserTitle(props.subtitle, profile?.displayName);\n }\n\n return undefined;\n }, [props.subtitle, profile?.displayName]);\n\n return (\n <BackstageHeader\n title={title}\n subtitle={subtitle}\n pageTitleOverride={props.pageTitle}\n >\n {props.localClock?.format && props.localClock?.format !== 'none' ? (\n <LocalClock\n label={\n props.localClock?.label ??\n (props.worldClocks && props.worldClocks.length > 0\n ? t('header.local')\n : undefined)\n }\n format={\n props.localClock?.format ??\n (props.worldClocks && props.worldClocks.length > 0\n ? 'time'\n : undefined)\n }\n lang={props.localClock?.lang}\n />\n ) : null}\n\n {props.worldClocks && props.worldClocks.length > 0 ? (\n <HeaderWorldClock clockConfigs={props.worldClocks} />\n ) : null}\n </BackstageHeader>\n );\n};\n"],"names":["BackstageHeader"],"mappings":";;;;;;;;;AA6DA,MAAM,oBAAA,GAAuB,CAC3B,KAAA,EACA,WACG,KAAA;AACH,EAAA,IAAI,CAAC,WAAa,EAAA;AAEhB,IAAO,OAAA,KAAA,CAAM,OAAQ,CAAA,kCAAA,EAAoC,EAAE,CAAA;AAAA;AAG7D,EAAA,MAAM,SAAY,GAAA,WAAA,CAAY,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAC1C,EAAA,OAAO,MACJ,OAAQ,CAAA,oBAAA,EAAsB,SAAS,CACvC,CAAA,OAAA,CAAQ,wBAAwB,WAAW,CAAA;AAChD,CAAA;AAEa,MAAA,MAAA,GAAS,CAAC,KAAuB,KAAA;AAC5C,EAAM,MAAA,WAAA,GAAc,OAAO,cAAc,CAAA;AACzC,EAAM,MAAA,EAAE,OAAO,OAAQ,EAAA,GAAI,SAAS,MAAM,WAAA,CAAY,gBAAgB,CAAA;AACtE,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAE7B,EAAM,MAAA,KAAA,GAAQ,QAAgB,MAAM;AAClC,IAAA,MAAM,YAAY,OAAS,EAAA,WAAA,EAAa,KAAM,CAAA,GAAG,EAAE,CAAC,CAAA;AAGpD,IAAI,IAAA,OAAA,EAAS,WAAe,IAAA,KAAA,CAAM,iBAAmB,EAAA;AACnD,MAAA,OAAO,oBAAqB,CAAA,KAAA,CAAM,iBAAmB,EAAA,OAAA,CAAQ,WAAW,CAAA;AAAA;AAI1E,IAAA,IAAI,MAAM,KAAO,EAAA;AACf,M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AEN,IAAA,EAAM,MAAM,UAAY,EAAA;AAAA;AAAA,SAExB,GAAA,IAAA;AAAA,QAEH,KAAA,CAAM,WAAe,IAAA,KAAA,CAAM,WAAY,CAAA,MAAA,GAAS,CAC/C,mBAAA,GAAA,CAAC,gBAAiB,EAAA,EAAA,YAAA,EAAc,KAAM,CAAA,WAAA,EAAa,CACjD,GAAA;AAAA;AAAA;AAAA,GACN;AAEJ;;;;"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
3
|
import { Page, Content, EmptyState } from '@backstage/core-components';
|
|
4
|
+
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
4
5
|
import { Header } from './Header.esm.js';
|
|
5
6
|
import { ReadOnlyGrid } from './ReadOnlyGrid.esm.js';
|
|
6
7
|
|
|
7
8
|
const HomePage = (props) => {
|
|
9
|
+
const { t } = useTranslation();
|
|
8
10
|
const filteredAndSortedHomePageCards = useMemo(() => {
|
|
9
11
|
if (!props.cards) {
|
|
10
12
|
return [];
|
|
@@ -18,14 +20,8 @@ const HomePage = (props) => {
|
|
|
18
20
|
return filteredAndSorted;
|
|
19
21
|
}, [props.cards]);
|
|
20
22
|
return /* @__PURE__ */ jsxs(Page, { themeId: "home", children: [
|
|
21
|
-
/* @__PURE__ */ jsx(Header, { title: "
|
|
22
|
-
/* @__PURE__ */ jsx(Content, { children: filteredAndSortedHomePageCards.length === 0 ? /* @__PURE__ */ jsx(
|
|
23
|
-
EmptyState,
|
|
24
|
-
{
|
|
25
|
-
title: "No home page cards (mount points) configured or found.",
|
|
26
|
-
missing: "content"
|
|
27
|
-
}
|
|
28
|
-
) : /* @__PURE__ */ jsx(ReadOnlyGrid, { mountPoints: filteredAndSortedHomePageCards }) })
|
|
23
|
+
/* @__PURE__ */ jsx(Header, { title: t("header.welcome"), ...props }),
|
|
24
|
+
/* @__PURE__ */ jsx(Content, { children: filteredAndSortedHomePageCards.length === 0 ? /* @__PURE__ */ jsx(EmptyState, { title: t("homePage.empty"), missing: "content" }) : /* @__PURE__ */ jsx(ReadOnlyGrid, { mountPoints: filteredAndSortedHomePageCards }) })
|
|
29
25
|
] });
|
|
30
26
|
};
|
|
31
27
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HomePage.esm.js","sources":["../../src/components/HomePage.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';\n\nimport { Content, EmptyState, Page } from '@backstage/core-components';\n\nimport { HomePageCardMountPoint } from '../types';\n\nimport { Header, HeaderProps } from './Header';\nimport { ReadOnlyGrid } from './ReadOnlyGrid';\n\nexport interface HomePageProps extends HeaderProps {\n cards?: HomePageCardMountPoint[];\n}\n\nexport const HomePage = (props: HomePageProps) => {\n const filteredAndSortedHomePageCards = useMemo(() => {\n if (!props.cards) {\n return [];\n }\n\n const filteredAndSorted = props.cards.filter(\n card =>\n card.enabled !== false &&\n (!card.config?.priority || card.config.priority >= 0),\n );\n\n filteredAndSorted.sort(\n (a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0),\n );\n\n return filteredAndSorted;\n }, [props.cards]);\n\n return (\n <Page themeId=\"home\">\n <Header title
|
|
1
|
+
{"version":3,"file":"HomePage.esm.js","sources":["../../src/components/HomePage.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';\n\nimport { Content, EmptyState, Page } from '@backstage/core-components';\n\nimport { HomePageCardMountPoint } from '../types';\nimport { useTranslation } from '../hooks/useTranslation';\n\nimport { Header, HeaderProps } from './Header';\nimport { ReadOnlyGrid } from './ReadOnlyGrid';\n\nexport interface HomePageProps extends HeaderProps {\n cards?: HomePageCardMountPoint[];\n}\n\nexport const HomePage = (props: HomePageProps) => {\n const { t } = useTranslation();\n const filteredAndSortedHomePageCards = useMemo(() => {\n if (!props.cards) {\n return [];\n }\n\n const filteredAndSorted = props.cards.filter(\n card =>\n card.enabled !== false &&\n (!card.config?.priority || card.config.priority >= 0),\n );\n\n filteredAndSorted.sort(\n (a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0),\n );\n\n return filteredAndSorted;\n }, [props.cards]);\n\n return (\n <Page themeId=\"home\">\n <Header title={t('header.welcome')} {...props} />\n <Content>\n {filteredAndSortedHomePageCards.length === 0 ? (\n <EmptyState title={t('homePage.empty')} missing=\"content\" />\n ) : (\n <ReadOnlyGrid mountPoints={filteredAndSortedHomePageCards} />\n )}\n </Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA8Ba,MAAA,QAAA,GAAW,CAAC,KAAyB,KAAA;AAChD,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EAAM,MAAA,8BAAA,GAAiC,QAAQ,MAAM;AACnD,IAAI,IAAA,CAAC,MAAM,KAAO,EAAA;AAChB,MAAA,OAAO,EAAC;AAAA;AAGV,IAAM,MAAA,iBAAA,GAAoB,MAAM,KAAM,CAAA,MAAA;AAAA,MACpC,CAAA,IAAA,KACE,IAAK,CAAA,OAAA,KAAY,KAChB,KAAA,CAAC,KAAK,MAAQ,EAAA,QAAA,IAAY,IAAK,CAAA,MAAA,CAAO,QAAY,IAAA,CAAA;AAAA,KACvD;AAEA,IAAkB,iBAAA,CAAA,IAAA;AAAA,MAChB,CAAC,GAAG,CAAO,KAAA,CAAA,CAAA,CAAE,QAAQ,QAAY,IAAA,CAAA,KAAM,CAAE,CAAA,MAAA,EAAQ,QAAY,IAAA,CAAA;AAAA,KAC/D;AAEA,IAAO,OAAA,iBAAA;AAAA,GACN,EAAA,CAAC,KAAM,CAAA,KAAK,CAAC,CAAA;AAEhB,EACE,uBAAA,IAAA,CAAC,IAAK,EAAA,EAAA,OAAA,EAAQ,MACZ,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA,CAAC,UAAO,KAAO,EAAA,CAAA,CAAE,gBAAgB,CAAA,EAAI,GAAG,KAAO,EAAA,CAAA;AAAA,wBAC9C,OACE,EAAA,EAAA,QAAA,EAAA,8BAAA,CAA+B,WAAW,CACzC,mBAAA,GAAA,CAAC,cAAW,KAAO,EAAA,CAAA,CAAE,gBAAgB,CAAA,EAAG,SAAQ,SAAU,EAAA,CAAA,uBAEzD,YAAa,EAAA,EAAA,WAAA,EAAa,gCAAgC,CAE/D,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -11,14 +11,16 @@ import { useTheme } from '@mui/material/styles';
|
|
|
11
11
|
import OnboardingCard from './OnboardingCard.esm.js';
|
|
12
12
|
import HomePageIllustrationDark from '../../images/homepage-illustration-dark.svg';
|
|
13
13
|
import HomePageIllustrationLight from '../../images/homepage-illustration-light.svg';
|
|
14
|
-
import {
|
|
14
|
+
import { getLearningItems } from '../../utils/constants.esm.js';
|
|
15
15
|
import useGreeting from '../../hooks/useGreeting.esm.js';
|
|
16
|
+
import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
16
17
|
|
|
17
18
|
const OnboardingSection = () => {
|
|
18
19
|
const [user, setUser] = useState();
|
|
19
20
|
const theme = useTheme();
|
|
20
21
|
const isDarkMode = theme.palette.mode === "dark";
|
|
21
22
|
const greeting = useGreeting();
|
|
23
|
+
const { t } = useTranslation();
|
|
22
24
|
const {
|
|
23
25
|
displayName,
|
|
24
26
|
backstageIdentity,
|
|
@@ -75,7 +77,7 @@ const OnboardingSection = () => {
|
|
|
75
77
|
)
|
|
76
78
|
}
|
|
77
79
|
),
|
|
78
|
-
|
|
80
|
+
getLearningItems(t).map((item) => /* @__PURE__ */ jsx(
|
|
79
81
|
Grid,
|
|
80
82
|
{
|
|
81
83
|
item: true,
|
|
@@ -121,7 +123,7 @@ const OnboardingSection = () => {
|
|
|
121
123
|
fontWeight: "500",
|
|
122
124
|
fontSize: "1.5rem"
|
|
123
125
|
},
|
|
124
|
-
children: `${greeting}, ${profileDisplayName() || "
|
|
126
|
+
children: `${greeting}, ${profileDisplayName() || t("onboarding.guest")}!`
|
|
125
127
|
}
|
|
126
128
|
),
|
|
127
129
|
content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OnboardingSection.esm.js","sources":["../../../src/components/OnboardingSection/OnboardingSection.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 { useState, useEffect } from 'react';\n\nimport { useUserProfile } from '@backstage/plugin-user-settings';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { UserEntity } from '@backstage/catalog-model';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport Card from '@mui/material/Card';\nimport { useTheme } from '@mui/material/styles';\n\nimport OnboardingCard from './OnboardingCard';\nimport HomePageIllustrationDark from '../../images/homepage-illustration-dark.svg';\nimport HomePageIllustrationLight from '../../images/homepage-illustration-light.svg';\nimport {
|
|
1
|
+
{"version":3,"file":"OnboardingSection.esm.js","sources":["../../../src/components/OnboardingSection/OnboardingSection.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 { useState, useEffect } from 'react';\n\nimport { useUserProfile } from '@backstage/plugin-user-settings';\nimport { useApi } from '@backstage/core-plugin-api';\nimport { UserEntity } from '@backstage/catalog-model';\nimport { catalogApiRef } from '@backstage/plugin-catalog-react';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport Card from '@mui/material/Card';\nimport { useTheme } from '@mui/material/styles';\n\nimport OnboardingCard from './OnboardingCard';\nimport HomePageIllustrationDark from '../../images/homepage-illustration-dark.svg';\nimport HomePageIllustrationLight from '../../images/homepage-illustration-light.svg';\nimport { getLearningItems } from '../../utils/constants';\nimport useGreeting from '../../hooks/useGreeting';\nimport { LearningSectionItem } from '../../types';\nimport { useTranslation } from '../../hooks/useTranslation';\n\nexport const OnboardingSection = () => {\n const [user, setUser] = useState<string | null>();\n const theme = useTheme();\n const isDarkMode = theme.palette.mode === 'dark';\n const greeting = useGreeting();\n const { t } = useTranslation();\n const {\n displayName,\n backstageIdentity,\n loading: profileLoading,\n } = useUserProfile();\n const catalogApi = useApi(catalogApiRef);\n\n useEffect(() => {\n const fetchUserEntity = async () => {\n if (!backstageIdentity?.userEntityRef) {\n return;\n }\n try {\n const userEntity = (await catalogApi.getEntityByRef(\n backstageIdentity.userEntityRef,\n )) as unknown as UserEntity;\n setUser(\n userEntity?.spec?.profile?.displayName ?? userEntity?.metadata?.title,\n );\n } catch (_err) {\n setUser(null);\n }\n };\n\n fetchUserEntity();\n }, [backstageIdentity, catalogApi]);\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 const content = (\n <Box>\n <Grid container margin=\"auto\">\n <Grid\n item\n xs={12}\n md={6}\n lg={3}\n display=\"flex\"\n justifyContent=\"left\"\n alignItems=\"center\"\n >\n <Box\n component=\"img\"\n src={\n isDarkMode ? HomePageIllustrationDark : HomePageIllustrationLight\n }\n alt=\"\"\n sx={{\n width: 'clamp(200px, 20vw, 264px)',\n }}\n />\n </Grid>\n {getLearningItems(t).map((item: LearningSectionItem) => (\n <Grid\n item\n xs={12}\n md={6}\n lg={3}\n key={item.title}\n display=\"flex\"\n justifyContent=\"left\"\n alignItems=\"center\"\n >\n <OnboardingCard\n title={item.title}\n description={item.description}\n buttonText={item.buttonText}\n buttonLink={item.buttonLink}\n target={item.target}\n ariaLabel={item.ariaLabel}\n endIcon={<item.endIcon />}\n />\n </Grid>\n ))}\n </Grid>\n </Box>\n );\n\n return (\n <Card\n elevation={0}\n sx={{\n padding: '24px',\n border: muiTheme => `1px solid ${muiTheme.palette.grey[300]}`,\n overflow: 'auto',\n }}\n >\n {!profileLoading && (\n <Typography\n variant=\"h3\"\n sx={{\n display: 'flex',\n alignItems: 'center',\n fontWeight: '500',\n fontSize: '1.5rem',\n }}\n >\n {`${greeting}, ${profileDisplayName() || t('onboarding.guest')}!`}\n </Typography>\n )}\n {content}\n </Card>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAoCO,MAAM,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AY,IAAK,CAAA,UAAA;AAAA,YACjB,YAAY,IAAK,CAAA,UAAA;AAAA,YACjB,QAAQ,IAAK,CAAA,MAAA;AAAA,YACb,WAAW,IAAK,CAAA,SAAA;AAAA,YAChB,OAAS,kBAAA,GAAA,CAAC,IAAK,CAAA,OAAA,EAAL,EAAa;AAAA;AAAA;AACzB,OAAA;AAAA,MAbK,IAAK,CAAA;AAAA,KAeb;AAAA,GAAA,EACH,CACF,EAAA,CAAA;AAGF,EACE,uBAAA,IAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,CAAA;AAAA,MACX,EAAI,EAAA;AAAA,QACF,OAAS,EAAA,MAAA;AAAA,QACT,QAAQ,CAAY,QAAA,KAAA,CAAA,UAAA,EAAa,SAAS,OAAQ,CAAA,IAAA,CAAK,GAAG,CAAC,CAAA,CAAA;AAAA,QAC3D,QAAU,EAAA;AAAA,OACZ;AAAA,MAEC,QAAA,EAAA;AAAA,QAAA,CAAC,cACA,oBAAA,GAAA;AAAA,UAAC,UAAA;AAAA,UAAA;AAAA,YACC,OAAQ,EAAA,IAAA;AAAA,YACR,EAAI,EAAA;AAAA,cACF,OAAS,EAAA,MAAA;AAAA,cACT,UAAY,EAAA,QAAA;AAAA,cACZ,UAAY,EAAA,KAAA;AAAA,cACZ,QAAU,EAAA;AAAA,aACZ;AAAA,YAEC,aAAG,QAAQ,CAAA,EAAA,EAAK,oBAAwB,IAAA,CAAA,CAAE,kBAAkB,CAAC,CAAA,CAAA;AAAA;AAAA,SAChE;AAAA,QAED;AAAA;AAAA;AAAA,GACH;AAEJ;;;;"}
|
|
@@ -4,6 +4,7 @@ import { HomePageToolkit, ComponentAccordion } from '@backstage/plugin-home';
|
|
|
4
4
|
import CircularProgress from '@mui/material/CircularProgress';
|
|
5
5
|
import { makeStyles } from 'tss-react/mui';
|
|
6
6
|
import { useQuickAccessLinks } from '../hooks/useQuickAccessLinks.esm.js';
|
|
7
|
+
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
7
8
|
|
|
8
9
|
const useStyles = makeStyles()({
|
|
9
10
|
center: {
|
|
@@ -24,16 +25,17 @@ const useStyles = makeStyles()({
|
|
|
24
25
|
});
|
|
25
26
|
const QuickAccessCard = (props) => {
|
|
26
27
|
const { classes } = useStyles();
|
|
28
|
+
const { t } = useTranslation();
|
|
27
29
|
const { data, error, isLoading } = useQuickAccessLinks(props.path);
|
|
28
30
|
let content;
|
|
29
31
|
if (isLoading) {
|
|
30
32
|
content = /* @__PURE__ */ jsx("div", { className: classes.center, children: /* @__PURE__ */ jsx(CircularProgress, {}) });
|
|
31
33
|
} else if (!data) {
|
|
32
|
-
content = /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: "
|
|
34
|
+
content = /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: t("quickAccess.fetchError"), children: /* @__PURE__ */ jsx(
|
|
33
35
|
CodeSnippet,
|
|
34
36
|
{
|
|
35
37
|
language: "text",
|
|
36
|
-
text: error?.toString() ?? "
|
|
38
|
+
text: error?.toString() ?? t("quickAccess.error")
|
|
37
39
|
}
|
|
38
40
|
) });
|
|
39
41
|
} else {
|
|
@@ -60,7 +62,7 @@ const QuickAccessCard = (props) => {
|
|
|
60
62
|
return /* @__PURE__ */ jsx(
|
|
61
63
|
InfoCard,
|
|
62
64
|
{
|
|
63
|
-
title: props.title ?? "
|
|
65
|
+
title: props.title ?? t("quickAccess.title"),
|
|
64
66
|
noPadding: true,
|
|
65
67
|
className: classes.title,
|
|
66
68
|
children: content
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QuickAccessCard.esm.js","sources":["../../src/components/QuickAccessCard.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReactNode } from 'react';\n\nimport {\n CodeSnippet,\n InfoCard,\n WarningPanel,\n} from '@backstage/core-components';\nimport { ComponentAccordion, HomePageToolkit } from '@backstage/plugin-home';\n\nimport CircularProgress from '@mui/material/CircularProgress';\nimport { makeStyles } from 'tss-react/mui';\n\nimport { useQuickAccessLinks } from '../hooks/useQuickAccessLinks';\n\nconst useStyles = makeStyles()({\n center: {\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n img: {\n height: '40px',\n width: 'auto',\n },\n title: {\n '& div > div > div > div > p': {\n textTransform: 'uppercase',\n },\n },\n});\n\n/**\n * @public\n */\nexport interface QuickAccessCardProps {\n title?: string;\n path?: string;\n}\n\n/**\n * @public\n */\nexport const QuickAccessCard = (props: QuickAccessCardProps) => {\n const { classes } = useStyles();\n const { data, error, isLoading } = useQuickAccessLinks(props.path);\n\n let content: ReactNode;\n\n if (isLoading) {\n content = (\n <div className={classes.center}>\n <CircularProgress />\n </div>\n );\n } else if (!data) {\n content = (\n <WarningPanel severity=\"error\" title
|
|
1
|
+
{"version":3,"file":"QuickAccessCard.esm.js","sources":["../../src/components/QuickAccessCard.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type { ReactNode } from 'react';\n\nimport {\n CodeSnippet,\n InfoCard,\n WarningPanel,\n} from '@backstage/core-components';\nimport { ComponentAccordion, HomePageToolkit } from '@backstage/plugin-home';\n\nimport CircularProgress from '@mui/material/CircularProgress';\nimport { makeStyles } from 'tss-react/mui';\n\nimport { useQuickAccessLinks } from '../hooks/useQuickAccessLinks';\nimport { useTranslation } from '../hooks/useTranslation';\n\nconst useStyles = makeStyles()({\n center: {\n height: '100%',\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n },\n img: {\n height: '40px',\n width: 'auto',\n },\n title: {\n '& div > div > div > div > p': {\n textTransform: 'uppercase',\n },\n },\n});\n\n/**\n * @public\n */\nexport interface QuickAccessCardProps {\n title?: string;\n path?: string;\n}\n\n/**\n * @public\n */\nexport const QuickAccessCard = (props: QuickAccessCardProps) => {\n const { classes } = useStyles();\n const { t } = useTranslation();\n const { data, error, isLoading } = useQuickAccessLinks(props.path);\n\n let content: ReactNode;\n\n if (isLoading) {\n content = (\n <div className={classes.center}>\n <CircularProgress />\n </div>\n );\n } else if (!data) {\n content = (\n <WarningPanel severity=\"error\" title={t('quickAccess.fetchError')}>\n <CodeSnippet\n language=\"text\"\n text={error?.toString() ?? t('quickAccess.error')}\n />\n </WarningPanel>\n );\n } else {\n content = (\n <>\n {data.map(item => (\n <HomePageToolkit\n key={item.title}\n title={item.title}\n tools={item.links.map(link => ({\n ...link,\n icon: (\n <img\n className={classes.img}\n src={link.iconUrl}\n alt={link.label}\n />\n ),\n }))}\n // Component creation is allowed inside component props only\n // if prop name starts with `render`.\n // We accept it here since the upstream package use `Renderer` instead.\n Renderer={(\n renderProps, // NOSONAR\n ) => (\n <ComponentAccordion expanded={item.isExpanded} {...renderProps} />\n )}\n />\n ))}\n </>\n );\n }\n\n return (\n <InfoCard\n title={props.title ?? t('quickAccess.title')}\n noPadding\n className={classes.title}\n >\n {content}\n </InfoCard>\n );\n};\n"],"names":[],"mappings":";;;;;;;;AA+BA,MAAM,SAAA,GAAY,YAAa,CAAA;AAAA,EAC7B,MAAQ,EAAA;AAAA,IACN,MAAQ,EAAA,MAAA;AAAA,IACR,OAAS,EAAA,M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O,EAAA,IAAA,CAAK,KAAM,CAAA,GAAA,CAAI,CAAS,IAAA,MAAA;AAAA,UAC7B,GAAG,IAAA;AAAA,UACH,IACE,kBAAA,GAAA;AAAA,YAAC,KAAA;AAAA,YAAA;AAAA,cACC,WAAW,OAAQ,CAAA,GAAA;AAAA,cACnB,KAAK,IAAK,CAAA,OAAA;AAAA,cACV,KAAK,IAAK,CAAA;AAAA;AAAA;AACZ,SAEF,CAAA,CAAA;AAAA,QAIF,QAAA,EAAU,CACR,WAEA,qBAAA,GAAA,CAAC,sBAAmB,QAAU,EAAA,IAAA,CAAK,UAAa,EAAA,GAAG,WAAa,EAAA;AAAA,OAAA;AAAA,MAlB7D,IAAK,CAAA;AAAA,KAqBb,CACH,EAAA,CAAA;AAAA;AAIJ,EACE,uBAAA,GAAA;AAAA,IAAC,QAAA;AAAA,IAAA;AAAA,MACC,KAAO,EAAA,KAAA,CAAM,KAAS,IAAA,CAAA,CAAE,mBAAmB,CAAA;AAAA,MAC3C,SAAS,EAAA,IAAA;AAAA,MACT,WAAW,OAAQ,CAAA,KAAA;AAAA,MAElB,QAAA,EAAA;AAAA;AAAA,GACH;AAEJ;;;;"}
|
|
@@ -3,6 +3,7 @@ import { useState, useRef, useCallback } from 'react';
|
|
|
3
3
|
import { useNavigate } from 'react-router-dom';
|
|
4
4
|
import { SearchBarBase } from '@backstage/plugin-search-react';
|
|
5
5
|
import { makeStyles } from 'tss-react/mui';
|
|
6
|
+
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
6
7
|
|
|
7
8
|
const useStyles = makeStyles()((theme) => ({
|
|
8
9
|
searchBar: {
|
|
@@ -22,6 +23,7 @@ const useStyles = makeStyles()((theme) => ({
|
|
|
22
23
|
}));
|
|
23
24
|
const SearchBar = ({ path, queryParam }) => {
|
|
24
25
|
const { classes } = useStyles();
|
|
26
|
+
const { t } = useTranslation();
|
|
25
27
|
const [value, setValue] = useState("");
|
|
26
28
|
const ref = useRef(null);
|
|
27
29
|
const navigate = useNavigate();
|
|
@@ -36,7 +38,7 @@ const SearchBar = ({ path, queryParam }) => {
|
|
|
36
38
|
return /* @__PURE__ */ jsx(
|
|
37
39
|
SearchBarBase,
|
|
38
40
|
{
|
|
39
|
-
placeholder: "
|
|
41
|
+
placeholder: t("search.placeholder"),
|
|
40
42
|
value,
|
|
41
43
|
onChange: setValue,
|
|
42
44
|
onSubmit: handleSubmit,
|