@red-hat-developer-hub/backstage-plugin-dynamic-home-page 1.7.0 → 1.9.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 +16 -0
- package/app-config.dynamic.yaml +12 -12
- package/dist/components/CustomizableGrid.esm.js +48 -6
- package/dist/components/CustomizableGrid.esm.js.map +1 -1
- 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/defaults.esm.js +29 -0
- package/dist/defaults.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 +142 -1
- package/dist/index.esm.js +3 -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
|
@@ -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,oBAAoB,MAAM;AACrC,EAAA,MAAM,CAAC,IAAA,EAAM,OAAO,CAAA,GAAI,QAAwB,EAAA;AAChD,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,UAAA,GAAa,KAAM,CAAA,OAAA,CAAQ,IAAS,KAAA,MAAA;AAC1C,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EAAM,MAAA;AAAA,IACJ,WAAA;AAAA,IACA,iBAAA;AAAA,IACA,OAAS,EAAA;AAAA,MACP,cAAe,EAAA;AACnB,E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AA;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,MAAA;AAAA,IACT,UAAY,EAAA,QAAA;AAAA,IACZ,cAAgB,EAAA;AAAA,GAClB;AAAA,EACA,GAAK,EAAA;AAAA,IACH,MAAQ,EAAA,MAAA;AAAA,IACR,KAAO,EAAA;AAAA,GACT;AAAA,EACA,KAAO,EAAA;AAAA,IACL,6BAA+B,EAAA;AAAA,MAC7B,aAAe,EAAA;AAAA;AACjB;AAEJ,CAAC,CAAA;AAaY,MAAA,eAAA,GAAkB,CAAC,KAAgC,KAAA;AAC9D,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,SAAU,EAAA;AAC9B,EAAM,MAAA,EAAE,CAAE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,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,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SearchBar.esm.js","sources":["../../src/components/SearchBar.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useRef, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\n\nimport { SearchBarBase } from '@backstage/plugin-search-react';\n\nimport { makeStyles } from 'tss-react/mui';\n\nconst useStyles = makeStyles()(theme => ({\n searchBar: {\n '&&': {\n backgroundColor: theme.palette.mode === 'dark' ? '#36373A' : '#FFFFFF',\n boxShadow: 'none',\n border: `1px solid ${\n theme.palette.mode === 'dark' ? '#57585a' : '#E4E4E4'\n }`,\n borderRadius: '50px',\n margin: 0,\n },\n },\n notchedOutline: {\n '&&': {\n borderStyle: 'none',\n },\n },\n}));\n\n/**\n * @public\n */\nexport interface SearchBarProps {\n path?: string;\n queryParam?: string;\n}\n\n/**\n * @public\n */\nexport const SearchBar = ({ path, queryParam }: SearchBarProps) => {\n const { classes } = useStyles();\n const [value, setValue] = useState('');\n const ref = useRef<HTMLInputElement | null>(null);\n const navigate = useNavigate();\n\n // This handler is called when \"enter\" is pressed\n const handleSubmit = useCallback(() => {\n const query = ref.current?.value ?? '';\n\n const url = new URL(window.location.toString());\n url.pathname = path ?? '/search';\n url.searchParams.set(queryParam ?? 'query', query);\n const search = url.searchParams.toString();\n\n navigate(`${url.pathname}${search ? '?' : ''}${search}`);\n }, [navigate, path, queryParam]);\n\n return (\n <SearchBarBase\n placeholder
|
|
1
|
+
{"version":3,"file":"SearchBar.esm.js","sources":["../../src/components/SearchBar.tsx"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useCallback, useRef, useState } from 'react';\nimport { useNavigate } from 'react-router-dom';\n\nimport { SearchBarBase } from '@backstage/plugin-search-react';\n\nimport { makeStyles } from 'tss-react/mui';\n\nimport { useTranslation } from '../hooks/useTranslation';\n\nconst useStyles = makeStyles()(theme => ({\n searchBar: {\n '&&': {\n backgroundColor: theme.palette.mode === 'dark' ? '#36373A' : '#FFFFFF',\n boxShadow: 'none',\n border: `1px solid ${\n theme.palette.mode === 'dark' ? '#57585a' : '#E4E4E4'\n }`,\n borderRadius: '50px',\n margin: 0,\n },\n },\n notchedOutline: {\n '&&': {\n borderStyle: 'none',\n },\n },\n}));\n\n/**\n * @public\n */\nexport interface SearchBarProps {\n path?: string;\n queryParam?: string;\n}\n\n/**\n * @public\n */\nexport const SearchBar = ({ path, queryParam }: SearchBarProps) => {\n const { classes } = useStyles();\n const { t } = useTranslation();\n const [value, setValue] = useState('');\n const ref = useRef<HTMLInputElement | null>(null);\n const navigate = useNavigate();\n\n // This handler is called when \"enter\" is pressed\n const handleSubmit = useCallback(() => {\n const query = ref.current?.value ?? '';\n\n const url = new URL(window.location.toString());\n url.pathname = path ?? '/search';\n url.searchParams.set(queryParam ?? 'query', query);\n const search = url.searchParams.toString();\n\n navigate(`${url.pathname}${search ? '?' : ''}${search}`);\n }, [navigate, path, queryParam]);\n\n return (\n <SearchBarBase\n placeholder={t('search.placeholder')}\n value={value}\n onChange={setValue}\n onSubmit={handleSubmit}\n inputProps={{ ref }}\n classes={{\n root: classes.searchBar,\n }}\n InputProps={{\n classes: {\n notchedOutline: classes.notchedOutline,\n },\n }}\n />\n );\n};\n"],"names":[],"mappings":";;;;;;;AAyBA,MAAM,SAAA,GAAY,UAAW,EAAA,CAAE,CAAU,KAA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CAAA,EAAG,SAAS,GAAM,GAAA,EAAE,CAAG,EAAA,MAAM,CAAE,CAAA,CAAA;AAAA,GACtD,EAAA,CAAC,QAAU,EAAA,IAAA,EAAM,UAAU,CAAC,CAAA;AAE/B,EACE,uBAAA,GAAA;AAAA,IAAC,aAAA;AAAA,IAAA;AAAA,MACC,WAAA,EAAa,EAAE,oBAAoB,CAAA;AAAA,MACnC,KAAA;AAAA,MACA,QAAU,EAAA,QAAA;AAAA,MACV,QAAU,EAAA,YAAA;AAAA,MACV,UAAA,EAAY,EAAE,GAAI,EAAA;AAAA,MAClB,OAAS,EAAA;AAAA,QACP,MAAM,OAAQ,CAAA;AAAA,OAChB;AAAA,MACA,UAAY,EAAA;AAAA,QACV,OAAS,EAAA;AAAA,UACP,gBAAgB,OAAQ,CAAA;AAAA;AAC1B;AACF;AAAA,GACF;AAEJ;;;;"}
|
|
@@ -11,6 +11,8 @@ import Typography from '@mui/material/Typography';
|
|
|
11
11
|
import TemplateCard from './TemplateCard.esm.js';
|
|
12
12
|
import { useEntities } from '../../hooks/useEntities.esm.js';
|
|
13
13
|
import { ViewMoreLink } from './ViewMoreLink.esm.js';
|
|
14
|
+
import { useTranslation } from '../../hooks/useTranslation.esm.js';
|
|
15
|
+
import { Trans } from '../Trans.esm.js';
|
|
14
16
|
|
|
15
17
|
const StyledLink = styled(Link)(({ theme }) => ({
|
|
16
18
|
textDecoration: "none",
|
|
@@ -21,6 +23,7 @@ const StyledLink = styled(Link)(({ theme }) => ({
|
|
|
21
23
|
borderRadius: 4
|
|
22
24
|
}));
|
|
23
25
|
const TemplateSection = () => {
|
|
26
|
+
const { t } = useTranslation();
|
|
24
27
|
const {
|
|
25
28
|
data: templates,
|
|
26
29
|
error,
|
|
@@ -46,11 +49,11 @@ const TemplateSection = () => {
|
|
|
46
49
|
}
|
|
47
50
|
);
|
|
48
51
|
} else if (!templates) {
|
|
49
|
-
content = /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: "
|
|
52
|
+
content = /* @__PURE__ */ jsx(WarningPanel, { severity: "error", title: t("templates.fetchError"), children: /* @__PURE__ */ jsx(
|
|
50
53
|
CodeSnippet,
|
|
51
54
|
{
|
|
52
55
|
language: "text",
|
|
53
|
-
text: error?.toString() ?? "
|
|
56
|
+
text: error?.toString() ?? t("templates.error")
|
|
54
57
|
}
|
|
55
58
|
) });
|
|
56
59
|
} else {
|
|
@@ -82,7 +85,7 @@ const TemplateSection = () => {
|
|
|
82
85
|
margin: "1rem"
|
|
83
86
|
},
|
|
84
87
|
children: [
|
|
85
|
-
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: "1.125rem", fontWeight: 500 }, children: "
|
|
88
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontSize: "1.125rem", fontWeight: 500 }, children: t("templates.empty") }),
|
|
86
89
|
/* @__PURE__ */ jsx(
|
|
87
90
|
Typography,
|
|
88
91
|
{
|
|
@@ -92,10 +95,10 @@ const TemplateSection = () => {
|
|
|
92
95
|
mt: "20px",
|
|
93
96
|
mb: "16px"
|
|
94
97
|
},
|
|
95
|
-
children: "
|
|
98
|
+
children: t("templates.emptyDescription")
|
|
96
99
|
}
|
|
97
100
|
),
|
|
98
|
-
/* @__PURE__ */ jsx(StyledLink, { to: "/catalog-import", underline: "none", children: "
|
|
101
|
+
/* @__PURE__ */ jsx(StyledLink, { to: "/catalog-import", underline: "none", children: t("templates.register") })
|
|
99
102
|
]
|
|
100
103
|
}
|
|
101
104
|
)
|
|
@@ -123,16 +126,17 @@ const TemplateSection = () => {
|
|
|
123
126
|
fontWeight: "500",
|
|
124
127
|
fontSize: "1.5rem"
|
|
125
128
|
},
|
|
126
|
-
children: "
|
|
129
|
+
children: t("templates.title")
|
|
127
130
|
}
|
|
128
131
|
),
|
|
129
132
|
content,
|
|
130
|
-
templates?.items && templates?.items.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { pt: 2 }, children: /* @__PURE__ */
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
templates?.items && templates?.items.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { pt: 2 }, children: /* @__PURE__ */ jsx(ViewMoreLink, { to: catalogTemplatesLink, underline: "always", children: /* @__PURE__ */ jsx(
|
|
134
|
+
Trans,
|
|
135
|
+
{
|
|
136
|
+
message: "templates.viewAll",
|
|
137
|
+
params: { count: templates?.totalItems?.toString() || "" }
|
|
138
|
+
}
|
|
139
|
+
) }) })
|
|
136
140
|
]
|
|
137
141
|
}
|
|
138
142
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateSection.esm.js","sources":["../../../src/components/TemplateSection/TemplateSection.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 { Fragment } from 'react';\n\nimport {\n CodeSnippet,\n WarningPanel,\n Link as BackstageLink,\n} from '@backstage/core-components';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport CardContent from '@mui/material/CardContent';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport TemplateCard from './TemplateCard';\nimport { useEntities } from '../../hooks/useEntities';\nimport { ViewMoreLink } from './ViewMoreLink';\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 TemplateSection = () => {\n const {\n data: templates,\n error,\n isLoading,\n } = useEntities({ kind: 'Template' });\n\n const params = new URLSearchParams({\n 'filters[kind]': 'template',\n limit: '20',\n });\n const catalogTemplatesLink = `/catalog?${params.toString()}`;\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 (!templates) {\n content = (\n <WarningPanel severity=\"error\" title
|
|
1
|
+
{"version":3,"file":"TemplateSection.esm.js","sources":["../../../src/components/TemplateSection/TemplateSection.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 { Fragment } from 'react';\n\nimport {\n CodeSnippet,\n WarningPanel,\n Link as BackstageLink,\n} from '@backstage/core-components';\n\nimport Grid from '@mui/material/Grid';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\nimport CircularProgress from '@mui/material/CircularProgress';\nimport CardContent from '@mui/material/CardContent';\nimport { styled } from '@mui/material/styles';\nimport Typography from '@mui/material/Typography';\n\nimport TemplateCard from './TemplateCard';\nimport { useEntities } from '../../hooks/useEntities';\nimport { ViewMoreLink } from './ViewMoreLink';\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 TemplateSection = () => {\n const { t } = useTranslation();\n const {\n data: templates,\n error,\n isLoading,\n } = useEntities({ kind: 'Template' });\n\n const params = new URLSearchParams({\n 'filters[kind]': 'template',\n limit: '20',\n });\n const catalogTemplatesLink = `/catalog?${params.toString()}`;\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 (!templates) {\n content = (\n <WarningPanel severity=\"error\" title={t('templates.fetchError')}>\n <CodeSnippet\n language=\"text\"\n text={error?.toString() ?? t('templates.error')}\n />\n </WarningPanel>\n );\n } else {\n content = (\n <Box sx={{ padding: '8px 8px 8px 0' }}>\n <Fragment>\n <Grid container spacing={1} alignItems=\"stretch\">\n {templates?.items.map((item: any) => (\n <Grid item xs={12} md={6} lg={3} key={item.title}>\n <TemplateCard\n link={`/create/templates/${item.metadata.namespace}/${item.metadata.name}`}\n title={item.metadata.title}\n description={item.metadata.description}\n kind=\"Template\"\n />\n </Grid>\n ))}\n {templates?.items.length === 0 && (\n <Grid item xs={12} md={12}>\n <Box\n sx={{\n display: 'flex',\n alignItems: 'center',\n justifyContent: 'center',\n border: muiTheme =>\n `1px solid ${muiTheme.palette.grey[400]}`,\n borderRadius: 3,\n overflow: 'hidden',\n }}\n >\n <CardContent\n sx={{\n margin: '1rem',\n }}\n >\n <Typography sx={{ fontSize: '1.125rem', fontWeight: 500 }}>\n {t('templates.empty')}\n </Typography>\n <Typography\n sx={{\n fontSize: '0.875rem',\n fontWeight: 400,\n mt: '20px',\n mb: '16px',\n }}\n >\n {t('templates.emptyDescription')}\n </Typography>\n <StyledLink to=\"/catalog-import\" underline=\"none\">\n {t('templates.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('templates.title')}\n </Typography>\n {content}\n {templates?.items && templates?.items.length > 0 && (\n <Box sx={{ pt: 2 }}>\n <ViewMoreLink to={catalogTemplatesLink} underline=\"always\">\n <Trans\n message=\"templates.viewAll\"\n params={{ count: templates?.totalItems?.toString() || '' }}\n />\n </ViewMoreLink>\n </Box>\n )}\n </Card>\n );\n};\n"],"names":["BackstageLink"],"mappings":";;;;;;;;;;;;;;;;AAuCA,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,kBAAkB,MAAM;AACnC,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EAAM,MAAA;AAAA,IACJ,IAAM,EAAA,SAAA;AAAA,IACN,KAAA;AAAA,IACA;AAAA,GACE,GAAA,WAAA,CAAY,EAAE,IAAA,EAAM,YAAY,CAAA;AAEpC,EAAM,MAAA,MAAA,GAAS,IAAI,eAAgB,CAAA;AAAA,IACjC,eAAiB,EAAA,UAAA;AAAA,IACjB,KAAO,EAAA;AAAA,GACR,CAAA;AACD,EAAA,MAAM,oBAAuB,GAAA,CAAA,SAAA,EAAY,MAAO,CAAA,QAAA,EAAU,CAAA,CAAA;AAE1D,EAAI,IAAA,OAAA;A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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Trans.esm.js","sources":["../../src/components/Trans.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 { useTranslation } from '../hooks/useTranslation';\nimport { homepageTranslationRef } from '../translations';\n\ntype Messages = typeof homepageTranslationRef.T;\n\ninterface TransProps<TMessages extends { [key in string]: string }> {\n message: keyof TMessages;\n params?: any;\n}\n\nexport const Trans = ({ message, params }: TransProps<Messages>) => {\n const { t } = useTranslation();\n return t(message, params);\n};\n"],"names":[],"mappings":";;AA0BO,MAAM,KAAQ,GAAA,CAAC,EAAE,OAAA,EAAS,QAAmC,KAAA;AAClE,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EAAO,OAAA,CAAA,CAAE,SAAS,MAAM,CAAA;AAC1B;;;;"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const defaultLayouts = {
|
|
2
|
+
onboarding: {
|
|
3
|
+
xl: { w: 12, h: 6 },
|
|
4
|
+
lg: { w: 12, h: 6 },
|
|
5
|
+
md: { w: 12, h: 7 },
|
|
6
|
+
sm: { w: 12, h: 8 },
|
|
7
|
+
xs: { w: 12, h: 9 },
|
|
8
|
+
xxs: { w: 12, h: 14 }
|
|
9
|
+
},
|
|
10
|
+
entity: {
|
|
11
|
+
xl: { w: 12, h: 7 },
|
|
12
|
+
lg: { w: 12, h: 7 },
|
|
13
|
+
md: { w: 12, h: 8 },
|
|
14
|
+
sm: { w: 12, h: 9 },
|
|
15
|
+
xs: { w: 12, h: 11 },
|
|
16
|
+
xxs: { w: 12, h: 15 }
|
|
17
|
+
},
|
|
18
|
+
template: {
|
|
19
|
+
xl: { w: 12, h: 5 },
|
|
20
|
+
lg: { w: 12, h: 5 },
|
|
21
|
+
md: { w: 12, h: 5 },
|
|
22
|
+
sm: { w: 12, h: 5 },
|
|
23
|
+
xs: { w: 12, h: 7.5 },
|
|
24
|
+
xxs: { w: 12, h: 13.5 }
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export { defaultLayouts };
|
|
29
|
+
//# sourceMappingURL=defaults.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.esm.js","sources":["../src/defaults.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nexport type Breakpoints = 'xl' | 'lg' | 'md' | 'sm' | 'xs' | 'xxs';\n\n// prettier-ignore\nexport const commonWidths: Record<string, Record<Breakpoints, number>> = {\n small: { xl: 2, lg: 2, md: 2, sm: 3, xs: 4, xxs: 2 },\n half: { xl: 2, lg: 2, md: 2, sm: 3, xs: 4, xxs: 2 },\n '1/2': { xl: 2, lg: 2, md: 2, sm: 3, xs: 4, xxs: 2 },\n '1/3': { xl: 2, lg: 2, md: 2, sm: 3, xs: 4, xxs: 2 },\n '2/2': { xl: 2, lg: 2, md: 2, sm: 3, xs: 4, xxs: 2 },\n full: { xl: 2, lg: 2, md: 2, sm: 3, xs: 4, xxs: 2 },\n};\n\n// prettier-ignore\nexport const commonHeights: Record<string, Record<Breakpoints, number>> = {\n tiny: { xl: 1, lg: 1, md: 1, sm: 1, xs: 1, xxs: 1 },\n small: { xl: 2, lg: 2, md: 2, sm: 2, xs: 2, xxs: 2 },\n medium: { xl: 4, lg: 4, md: 4, sm: 4, xs: 4, xxs: 4 },\n large: { xl: 6, lg: 6, md: 6, sm: 6, xs: 6, xxs: 6 },\n xlarge: { xl: 10, lg: 6, md: 6, sm: 6, xs: 6, xxs: 6 },\n xxlarge: { xl: 14, lg: 6, md: 6, sm: 6, xs: 6, xxs: 6 },\n};\n\n/**\n * Default layout configurations for homepage cards\n * @public\n */\nexport const defaultLayouts = {\n onboarding: {\n xl: { w: 12, h: 6 },\n lg: { w: 12, h: 6 },\n md: { w: 12, h: 7 },\n sm: { w: 12, h: 8 },\n xs: { w: 12, h: 9 },\n xxs: { w: 12, h: 14 },\n },\n entity: {\n xl: { w: 12, h: 7 },\n lg: { w: 12, h: 7 },\n md: { w: 12, h: 8 },\n sm: { w: 12, h: 9 },\n xs: { w: 12, h: 11 },\n xxs: { w: 12, h: 15 },\n },\n template: {\n xl: { w: 12, h: 5 },\n lg: { w: 12, h: 5 },\n md: { w: 12, h: 5 },\n sm: { w: 12, h: 5 },\n xs: { w: 12, h: 7.5 },\n xxs: { w: 12, h: 13.5 },\n },\n};\n"],"names":[],"mappings":"AA0CO,MAAM,cAAiB,GAAA;AAAA,EAC5B,UAAY,EAAA;AAAA,IACV,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,GAAK,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,EAAG;AAAA,GACtB;AAAA,EACA,MAAQ,EAAA;AAAA,IACN,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,EAAG,EAAA;AAAA,IACnB,GAAK,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,EAAG;AAAA,GACtB;AAAA,EACA,QAAU,EAAA;AAAA,IACR,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,CAAE,EAAA;AAAA,IAClB,EAAI,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,GAAI,EAAA;AAAA,IACpB,GAAK,EAAA,EAAE,CAAG,EAAA,EAAA,EAAI,GAAG,IAAK;AAAA;AAE1B;;;;"}
|
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import { useState, useEffect } from 'react';
|
|
2
|
+
import { useTranslation } from './useTranslation.esm.js';
|
|
3
|
+
import { useLanguage } from './useLanguage.esm.js';
|
|
2
4
|
|
|
3
|
-
const getGreetingByTimeZone = (timeZone) => {
|
|
4
|
-
const hours = (/* @__PURE__ */ new Date()).toLocaleString(
|
|
5
|
+
const getGreetingByTimeZone = (timeZone, t, language) => {
|
|
6
|
+
const hours = (/* @__PURE__ */ new Date()).toLocaleString(language, {
|
|
5
7
|
timeZone,
|
|
6
8
|
hour: "numeric",
|
|
7
9
|
hour12: false
|
|
8
10
|
});
|
|
9
11
|
const hour = parseInt(hours, 10);
|
|
10
12
|
if (hour < 12) {
|
|
11
|
-
return "
|
|
13
|
+
return t("onboarding.greeting.goodMorning");
|
|
12
14
|
}
|
|
13
15
|
if (hour < 18) {
|
|
14
|
-
return "
|
|
16
|
+
return t("onboarding.greeting.goodAfternoon");
|
|
15
17
|
}
|
|
16
|
-
return "
|
|
18
|
+
return t("onboarding.greeting.goodEvening");
|
|
17
19
|
};
|
|
18
20
|
const useGreeting = (timeZone) => {
|
|
21
|
+
const { t } = useTranslation();
|
|
22
|
+
const language = useLanguage();
|
|
19
23
|
const [greeting, setGreeting] = useState(
|
|
20
|
-
getGreetingByTimeZone(timeZone)
|
|
24
|
+
getGreetingByTimeZone(timeZone, t, language)
|
|
21
25
|
);
|
|
22
26
|
useEffect(() => {
|
|
23
27
|
const interval = setInterval(() => {
|
|
24
|
-
setGreeting(getGreetingByTimeZone(timeZone));
|
|
28
|
+
setGreeting(getGreetingByTimeZone(timeZone, t, language));
|
|
25
29
|
}, 6e4);
|
|
26
30
|
return () => clearInterval(interval);
|
|
27
|
-
}, [timeZone]);
|
|
31
|
+
}, [timeZone, t, language]);
|
|
28
32
|
return greeting;
|
|
29
33
|
};
|
|
30
34
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGreeting.esm.js","sources":["../../src/hooks/useGreeting.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\nconst getGreetingByTimeZone = (timeZone
|
|
1
|
+
{"version":3,"file":"useGreeting.esm.js","sources":["../../src/hooks/useGreeting.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 { useTranslation } from './useTranslation';\nimport { useLanguage } from './useLanguage';\n\nconst getGreetingByTimeZone = (\n timeZone: string | undefined,\n t: any,\n language: string,\n) => {\n // Use user's language for consistent time parsing\n const hours = new Date().toLocaleString(language, {\n timeZone,\n hour: 'numeric',\n hour12: false,\n });\n const hour = parseInt(hours, 10);\n\n // Note: Time boundaries could be culturally specific in the future\n // For now, using universal 12/18 hour boundaries\n if (hour < 12) {\n return t('onboarding.greeting.goodMorning');\n }\n if (hour < 18) {\n return t('onboarding.greeting.goodAfternoon');\n }\n return t('onboarding.greeting.goodEvening');\n};\n\nconst useGreeting = (timeZone?: string) => {\n const { t } = useTranslation();\n const language = useLanguage();\n const [greeting, setGreeting] = useState<string>(\n getGreetingByTimeZone(timeZone, t, language),\n );\n\n useEffect(() => {\n const interval = setInterval(() => {\n setGreeting(getGreetingByTimeZone(timeZone, t, language));\n }, 60000); // Update every minute\n\n return () => clearInterval(interval);\n }, [timeZone, t, language]);\n\n return greeting;\n};\n\nexport default useGreeting;\n"],"names":[],"mappings":";;;;AAoBA,MAAM,qBAAwB,GAAA,CAC5B,QACA,EAAA,CAAA,EACA,QACG,KAAA;AAEH,EAAA,MAAM,KAAQ,GAAA,iBAAA,IAAI,IAAK,EAAA,EAAE,eAAe,QAAU,EAAA;AAAA,IAChD,QAAA;AAAA,IACA,IAAM,EAAA,SAAA;AAAA,IACN,MAAQ,EAAA;AAAA,GACT,CAAA;AACD,EAAM,MAAA,IAAA,GAAO,QAAS,CAAA,KAAA,EAAO,EAAE,CAAA;AAI/B,EAAA,IAAI,OAAO,EAAI,EAAA;AACb,IAAA,OAAO,EAAE,iCAAiC,CAAA;AAAA;AAE5C,EAAA,IAAI,OAAO,EAAI,EAAA;AACb,IAAA,OAAO,EAAE,mCAAmC,CAAA;AAAA;AAE9C,EAAA,OAAO,EAAE,iCAAiC,CAAA;AAC5C,CAAA;AAEM,MAAA,WAAA,GAAc,CAAC,QAAsB,KAAA;AACzC,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EAAA,MAAM,WAAW,WAAY,EAAA;AAC7B,EAAM,MAAA,CAAC,QAAU,EAAA,WAAW,CAAI,GAAA,QAAA;AAAA,IAC9B,qBAAA,CAAsB,QAAU,EAAA,CAAA,EAAG,QAAQ;AAAA,GAC7C;AAEA,EAAA,SAAA,CAAU,MAAM;AACd,IAAM,MAAA,QAAA,GAAW,YAAY,MAAM;AACjC,MAAA,WAAA,CAAY,qBAAsB,CAAA,QAAA,EAAU,CAAG,EAAA,QAAQ,CAAC,CAAA;AAAA,OACvD,GAAK,CAAA;AAER,IAAO,OAAA,MAAM,cAAc,QAAQ,CAAA;AAAA,GAClC,EAAA,CAAC,QAAU,EAAA,CAAA,EAAG,QAAQ,CAAC,CAAA;AAE1B,EAAO,OAAA,QAAA;AACT;;;;"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useApi } from '@backstage/core-plugin-api';
|
|
2
|
+
import { appLanguageApiRef } from '@backstage/core-plugin-api/alpha';
|
|
3
|
+
|
|
4
|
+
const useLanguage = () => useApi(appLanguageApiRef).getLanguage().language;
|
|
5
|
+
|
|
6
|
+
export { useLanguage };
|
|
7
|
+
//# sourceMappingURL=useLanguage.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useLanguage.esm.js","sources":["../../src/hooks/useLanguage.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { useApi } from '@backstage/core-plugin-api';\nimport { appLanguageApiRef } from '@backstage/core-plugin-api/alpha';\n\nexport const useLanguage = (): string =>\n useApi(appLanguageApiRef).getLanguage().language;\n"],"names":[],"mappings":";;;AAmBO,MAAM,cAAc,MACzB,MAAA,CAAO,iBAAiB,CAAA,CAAE,aAAc,CAAA;;;;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { useTranslationRef } from '@backstage/core-plugin-api/alpha';
|
|
2
|
+
import '../translations/index.esm.js';
|
|
3
|
+
import { homepageTranslationRef } from '../translations/ref.esm.js';
|
|
4
|
+
|
|
5
|
+
const useTranslation = () => useTranslationRef(homepageTranslationRef);
|
|
6
|
+
|
|
7
|
+
export { useTranslation };
|
|
8
|
+
//# sourceMappingURL=useTranslation.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTranslation.esm.js","sources":["../../src/hooks/useTranslation.ts"],"sourcesContent":["/*\n * Copyright Red Hat, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport {\n useTranslationRef,\n TranslationFunction,\n} from '@backstage/core-plugin-api/alpha';\n\nimport { homepageTranslationRef } from '../translations';\n\nexport const useTranslation = (): {\n t: TranslationFunction<typeof homepageTranslationRef.T>;\n} => useTranslationRef(homepageTranslationRef);\n"],"names":[],"mappings":";;;;AAuBa,MAAA,cAAA,GAAiB,MAEzB,iBAAA,CAAkB,sBAAsB;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { ClockConfig, StarredEntitiesProps, VisitedByTypeProps, FeaturedDocsCard
|
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import * as _backstage_core_plugin_api from '@backstage/core-plugin-api';
|
|
4
4
|
import { ComponentType } from 'react';
|
|
5
|
+
import * as _backstage_core_plugin_api_alpha from '@backstage/core-plugin-api/alpha';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @public
|
|
@@ -219,4 +220,144 @@ declare const EntitySection: () => react_jsx_runtime.JSX.Element;
|
|
|
219
220
|
*/
|
|
220
221
|
declare const TemplateSection: () => react_jsx_runtime.JSX.Element;
|
|
221
222
|
|
|
222
|
-
|
|
223
|
+
/**
|
|
224
|
+
* Reference translation for Homepage.
|
|
225
|
+
* Defines all the translation keys used in the plugin.
|
|
226
|
+
* @public
|
|
227
|
+
*/
|
|
228
|
+
declare const homepageTranslationRef: _backstage_core_plugin_api_alpha.TranslationRef<"plugin.homepage", {
|
|
229
|
+
readonly "search.placeholder": string;
|
|
230
|
+
readonly "header.local": string;
|
|
231
|
+
readonly "header.welcome": string;
|
|
232
|
+
readonly "header.welcomePersonalized": string;
|
|
233
|
+
readonly "templates.error": string;
|
|
234
|
+
readonly "templates.title": string;
|
|
235
|
+
readonly "templates.empty": string;
|
|
236
|
+
readonly "templates.register": string;
|
|
237
|
+
readonly "templates.fetchError": string;
|
|
238
|
+
readonly "templates.emptyDescription": string;
|
|
239
|
+
readonly "templates.viewAll": string;
|
|
240
|
+
readonly "entities.error": string;
|
|
241
|
+
readonly "entities.title": string;
|
|
242
|
+
readonly "entities.close": string;
|
|
243
|
+
readonly "entities.description": string;
|
|
244
|
+
readonly "entities.empty": string;
|
|
245
|
+
readonly "entities.register": string;
|
|
246
|
+
readonly "entities.fetchError": string;
|
|
247
|
+
readonly "entities.emptyDescription": string;
|
|
248
|
+
readonly "entities.viewAll": string;
|
|
249
|
+
readonly "homePage.empty": string;
|
|
250
|
+
readonly "quickAccess.error": string;
|
|
251
|
+
readonly "quickAccess.title": string;
|
|
252
|
+
readonly "quickAccess.fetchError": string;
|
|
253
|
+
readonly "featuredDocs.learnMore": string;
|
|
254
|
+
readonly "onboarding.guest": string;
|
|
255
|
+
readonly "onboarding.greeting.goodMorning": string;
|
|
256
|
+
readonly "onboarding.greeting.goodAfternoon": string;
|
|
257
|
+
readonly "onboarding.greeting.goodEvening": string;
|
|
258
|
+
readonly "onboarding.getStarted.title": string;
|
|
259
|
+
readonly "onboarding.getStarted.ariaLabel": string;
|
|
260
|
+
readonly "onboarding.getStarted.description": string;
|
|
261
|
+
readonly "onboarding.getStarted.buttonText": string;
|
|
262
|
+
readonly "onboarding.explore.title": string;
|
|
263
|
+
readonly "onboarding.explore.ariaLabel": string;
|
|
264
|
+
readonly "onboarding.explore.description": string;
|
|
265
|
+
readonly "onboarding.explore.buttonText": string;
|
|
266
|
+
readonly "onboarding.learn.title": string;
|
|
267
|
+
readonly "onboarding.learn.ariaLabel": string;
|
|
268
|
+
readonly "onboarding.learn.description": string;
|
|
269
|
+
readonly "onboarding.learn.buttonText": string;
|
|
270
|
+
}>;
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* The translation resource for the Homepage plugin.
|
|
274
|
+
* @public
|
|
275
|
+
*/
|
|
276
|
+
declare const homepageTranslations: _backstage_core_plugin_api_alpha.TranslationResource<"plugin.homepage">;
|
|
277
|
+
|
|
278
|
+
/**
|
|
279
|
+
* Default layout configurations for homepage cards
|
|
280
|
+
* @public
|
|
281
|
+
*/
|
|
282
|
+
declare const defaultLayouts: {
|
|
283
|
+
onboarding: {
|
|
284
|
+
xl: {
|
|
285
|
+
w: number;
|
|
286
|
+
h: number;
|
|
287
|
+
};
|
|
288
|
+
lg: {
|
|
289
|
+
w: number;
|
|
290
|
+
h: number;
|
|
291
|
+
};
|
|
292
|
+
md: {
|
|
293
|
+
w: number;
|
|
294
|
+
h: number;
|
|
295
|
+
};
|
|
296
|
+
sm: {
|
|
297
|
+
w: number;
|
|
298
|
+
h: number;
|
|
299
|
+
};
|
|
300
|
+
xs: {
|
|
301
|
+
w: number;
|
|
302
|
+
h: number;
|
|
303
|
+
};
|
|
304
|
+
xxs: {
|
|
305
|
+
w: number;
|
|
306
|
+
h: number;
|
|
307
|
+
};
|
|
308
|
+
};
|
|
309
|
+
entity: {
|
|
310
|
+
xl: {
|
|
311
|
+
w: number;
|
|
312
|
+
h: number;
|
|
313
|
+
};
|
|
314
|
+
lg: {
|
|
315
|
+
w: number;
|
|
316
|
+
h: number;
|
|
317
|
+
};
|
|
318
|
+
md: {
|
|
319
|
+
w: number;
|
|
320
|
+
h: number;
|
|
321
|
+
};
|
|
322
|
+
sm: {
|
|
323
|
+
w: number;
|
|
324
|
+
h: number;
|
|
325
|
+
};
|
|
326
|
+
xs: {
|
|
327
|
+
w: number;
|
|
328
|
+
h: number;
|
|
329
|
+
};
|
|
330
|
+
xxs: {
|
|
331
|
+
w: number;
|
|
332
|
+
h: number;
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
template: {
|
|
336
|
+
xl: {
|
|
337
|
+
w: number;
|
|
338
|
+
h: number;
|
|
339
|
+
};
|
|
340
|
+
lg: {
|
|
341
|
+
w: number;
|
|
342
|
+
h: number;
|
|
343
|
+
};
|
|
344
|
+
md: {
|
|
345
|
+
w: number;
|
|
346
|
+
h: number;
|
|
347
|
+
};
|
|
348
|
+
sm: {
|
|
349
|
+
w: number;
|
|
350
|
+
h: number;
|
|
351
|
+
};
|
|
352
|
+
xs: {
|
|
353
|
+
w: number;
|
|
354
|
+
h: number;
|
|
355
|
+
};
|
|
356
|
+
xxs: {
|
|
357
|
+
w: number;
|
|
358
|
+
h: number;
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
export { Breakpoint, CatalogStarredEntitiesCard, DynamicCustomizableHomePage, type DynamicCustomizableHomePageProps, DynamicHomePage, type DynamicHomePageProps, EntitySection, FeaturedDocsCard, Headline, type HeadlineProps, type HomePageCardMountPoint, type HomePageCardMountPointConfig, JokeCard, type Layout, type LocalClockProps, Markdown, MarkdownCard, type MarkdownCardProps, type MarkdownProps, OnboardingSection, Placeholder, type PlaceholderProps, QuickAccessCard, type QuickAccessCardProps, RecentlyVisitedCard, SearchBar, type SearchBarProps, TemplateSection, TopVisitedCard, VisitListener, WorldClock, type WorldClockProps, defaultLayouts, dynamicHomePagePlugin, homepageTranslationRef, homepageTranslations };
|