@red-hat-developer-hub/backstage-plugin-dynamic-home-page 1.9.2 → 1.9.3
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 +14 -0
- package/app-config.dynamic.yaml +29 -0
- package/dist/components/CustomizableGrid.esm.js +58 -85
- package/dist/components/CustomizableGrid.esm.js.map +1 -1
- package/dist/components/DynamicCustomizableHomePage.esm.js +3 -3
- package/dist/components/DynamicCustomizableHomePage.esm.js.map +1 -1
- package/dist/components/DynamicHomePage.esm.js +2 -2
- package/dist/components/DynamicHomePage.esm.js.map +1 -1
- package/dist/components/HomePage.esm.js +18 -18
- package/dist/components/HomePage.esm.js.map +1 -1
- package/dist/components/ReadOnlyGrid.esm.js +8 -7
- package/dist/components/ReadOnlyGrid.esm.js.map +1 -1
- package/dist/components/VisitListener.esm.js +2 -2
- package/dist/components/VisitListener.esm.js.map +1 -1
- package/dist/hooks/useDynamicHomePageCards.esm.js +13 -1
- package/dist/hooks/useDynamicHomePageCards.esm.js.map +1 -1
- package/dist/index.d.ts +23 -118
- package/dist/index.esm.js +0 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/plugin.esm.js +1 -1
- package/dist/plugin.esm.js.map +1 -1
- package/dist/translations/utils.esm.js +10 -0
- package/dist/translations/utils.esm.js.map +1 -0
- package/dist/utils/customizable-cards.esm.js +31 -0
- package/dist/utils/customizable-cards.esm.js.map +1 -0
- package/package.json +1 -1
- package/dist/components/CustomizableHomePage.esm.js +0 -29
- package/dist/components/CustomizableHomePage.esm.js.map +0 -1
- package/dist/defaults.esm.js +0 -37
- package/dist/defaults.esm.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @red-hat-developer-hub/backstage-plugin-dynamic-home-page
|
|
2
2
|
|
|
3
|
+
## 1.9.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- b62354f: Fixes an issue with the customizable home page that cards of the same mount point could not be displayed multiple times.
|
|
8
|
+
|
|
9
|
+
To enable this feature it is still required to change the home page mount point to `DynamicCustomizableHomePage`.
|
|
10
|
+
|
|
11
|
+
For these customizations the mount points requires also a `config.id` (unique identifier) and `config.title` to be displayed in the "Add widget" dialog. An additional `config.description` can be configured as well.
|
|
12
|
+
|
|
13
|
+
When customization is disabled mount points with an `config.layout` and these without a `config.id` for backward compatibility will be shown.
|
|
14
|
+
|
|
15
|
+
- 40b80fe: Change "lifecycle" to active in catalog.yaml
|
|
16
|
+
|
|
3
17
|
## 1.9.2
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/app-config.dynamic.yaml
CHANGED
|
@@ -6,6 +6,7 @@ dynamicPlugins:
|
|
|
6
6
|
- path: /
|
|
7
7
|
importName: DynamicHomePage
|
|
8
8
|
mountPoints:
|
|
9
|
+
# Default homepage cards - appear by default
|
|
9
10
|
- mountPoint: home.page/cards
|
|
10
11
|
importName: OnboardingSection
|
|
11
12
|
config:
|
|
@@ -36,3 +37,31 @@ dynamicPlugins:
|
|
|
36
37
|
sm: { w: 12, h: 5 }
|
|
37
38
|
xs: { w: 12, h: 7.5 }
|
|
38
39
|
xxs: { w: 12, h: 13.5 }
|
|
40
|
+
|
|
41
|
+
# Additional plugin widgets - available in "Add widget" dialog
|
|
42
|
+
- mountPoint: home.page/widgets
|
|
43
|
+
importName: RecentlyVisitedCard
|
|
44
|
+
config:
|
|
45
|
+
title: 'Recently Visited'
|
|
46
|
+
description: 'Quick access to recently viewed entities and pages'
|
|
47
|
+
priority: 2
|
|
48
|
+
layouts:
|
|
49
|
+
xl: { w: 4, h: 3 }
|
|
50
|
+
lg: { w: 4, h: 3 }
|
|
51
|
+
md: { w: 6, h: 3 }
|
|
52
|
+
sm: { w: 12, h: 3 }
|
|
53
|
+
xs: { w: 12, h: 3 }
|
|
54
|
+
xxs: { w: 12, h: 3 }
|
|
55
|
+
- mountPoint: home.page/widgets
|
|
56
|
+
importName: TopVisitedCard
|
|
57
|
+
config:
|
|
58
|
+
title: 'Most Visited'
|
|
59
|
+
description: 'Your most frequently accessed entities and services'
|
|
60
|
+
priority: 1
|
|
61
|
+
layouts:
|
|
62
|
+
xl: { w: 4, h: 3 }
|
|
63
|
+
lg: { w: 4, h: 3 }
|
|
64
|
+
md: { w: 6, h: 3 }
|
|
65
|
+
sm: { w: 12, h: 3 }
|
|
66
|
+
xs: { w: 12, h: 3 }
|
|
67
|
+
xxs: { w: 12, h: 3 }
|
|
@@ -1,98 +1,70 @@
|
|
|
1
1
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import { useMemo } from 'react';
|
|
3
|
+
import { CustomHomepageGrid } from '@backstage/plugin-home';
|
|
4
|
+
import { createCardExtension } from '@backstage/plugin-home-react';
|
|
3
5
|
import GlobalStyles from '@mui/material/GlobalStyles';
|
|
4
6
|
import { useTheme } from '@mui/material/styles';
|
|
5
|
-
import { ErrorBoundary } from '@backstage/core-components';
|
|
6
|
-
import { CustomHomepageGrid } from '@backstage/plugin-home';
|
|
7
|
-
import { makeStyles } from 'tss-react/mui';
|
|
8
7
|
import 'react-grid-layout/css/styles.css';
|
|
8
|
+
import { dynamicHomePagePlugin } from '../plugin.esm.js';
|
|
9
|
+
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
10
|
+
import { getCardTitle, getCardDescription, isCardADefaultConfiguration } from '../utils/customizable-cards.esm.js';
|
|
9
11
|
|
|
10
|
-
const
|
|
11
|
-
// Make card content scrollable (so that cards don't overlap)
|
|
12
|
-
cardWrapper: {
|
|
13
|
-
'& > div[class*="MuiCard-root"]': {
|
|
14
|
-
width: "100%",
|
|
15
|
-
height: "100%"
|
|
16
|
-
},
|
|
17
|
-
'& div[class*="MuiCardContent-root"]': {
|
|
18
|
-
overflow: "auto"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
const CustomizableGrid = (props) => {
|
|
23
|
-
const { classes } = useStyles();
|
|
12
|
+
const CustomizableGrid = ({ mountPoints }) => {
|
|
24
13
|
const theme = useTheme();
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
)) {
|
|
33
|
-
layouts[breakpoint] = {
|
|
34
|
-
i: id,
|
|
35
|
-
x: layout.x ?? 0,
|
|
36
|
-
y: layout.y ?? 0,
|
|
37
|
-
w: layout.w ?? 12,
|
|
38
|
-
h: layout.h ?? 4,
|
|
39
|
-
isDraggable: true,
|
|
40
|
-
isResizable: true
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
["xl", "lg", "md", "sm", "xs", "xxs"].forEach((breakpoint) => {
|
|
45
|
-
layouts[breakpoint] = {
|
|
46
|
-
i: id,
|
|
47
|
-
x: 0,
|
|
48
|
-
y: 0,
|
|
49
|
-
w: 12,
|
|
50
|
-
h: 4,
|
|
51
|
-
isDraggable: true,
|
|
52
|
-
isResizable: true
|
|
53
|
-
};
|
|
54
|
-
});
|
|
14
|
+
const { t } = useTranslation();
|
|
15
|
+
const { children, config } = useMemo(() => {
|
|
16
|
+
const childDictionary = {};
|
|
17
|
+
const defaultConfig = [];
|
|
18
|
+
mountPoints.forEach((mountPoint) => {
|
|
19
|
+
if (!mountPoint.config?.id) {
|
|
20
|
+
return;
|
|
55
21
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
22
|
+
const id = mountPoint.config.id;
|
|
23
|
+
const title = getCardTitle(t, mountPoint);
|
|
24
|
+
const description = getCardDescription(t, mountPoint);
|
|
25
|
+
const componentParts = {
|
|
26
|
+
Content: (props) => /* @__PURE__ */ jsx(mountPoint.Component, { ...mountPoint.config.props, ...props }),
|
|
27
|
+
// Untested and unsupported for now!
|
|
28
|
+
Actions: mountPoint.Actions,
|
|
29
|
+
// Untested and unsupported for now!
|
|
30
|
+
Settings: mountPoint.Settings,
|
|
31
|
+
// This is a workaround to NOT automatically wrap in an InfoCard
|
|
32
|
+
ContextProvider: (props) => /* @__PURE__ */ jsx(mountPoint.Component, { ...mountPoint.config.props, ...props })
|
|
61
33
|
};
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
card.id
|
|
75
|
-
));
|
|
76
|
-
}, [cards, classes.cardWrapper]);
|
|
77
|
-
const defaultConfig = useMemo(() => {
|
|
78
|
-
if (!props.mountPoints || props.mountPoints.length === 0) {
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
return props.mountPoints.map((mountPoint, index) => {
|
|
82
|
-
const layout = mountPoint.config?.layouts?.xl || {};
|
|
83
|
-
return {
|
|
84
|
-
component: /* @__PURE__ */ jsx(mountPoint.Component, { ...mountPoint.config?.props || {} }),
|
|
85
|
-
x: layout.x ?? 0,
|
|
86
|
-
y: layout.y ?? index * 5,
|
|
87
|
-
width: layout.w ?? 12,
|
|
88
|
-
height: layout.h ?? 4,
|
|
89
|
-
movable: true,
|
|
90
|
-
resizable: true,
|
|
91
|
-
draggable: true,
|
|
92
|
-
deletable: true
|
|
34
|
+
const cardExtension = createCardExtension({
|
|
35
|
+
name: id,
|
|
36
|
+
title,
|
|
37
|
+
description,
|
|
38
|
+
layout: mountPoint.config.cardLayout,
|
|
39
|
+
settings: mountPoint.config.settings,
|
|
40
|
+
components: () => Promise.resolve(componentParts)
|
|
41
|
+
});
|
|
42
|
+
const Card = dynamicHomePagePlugin.provide(cardExtension);
|
|
43
|
+
childDictionary[id] = {
|
|
44
|
+
child: /* @__PURE__ */ jsx(Card, {}),
|
|
45
|
+
title
|
|
93
46
|
};
|
|
47
|
+
if (isCardADefaultConfiguration(mountPoint)) {
|
|
48
|
+
const layout = mountPoint.config?.layouts?.xl || {};
|
|
49
|
+
defaultConfig.push({
|
|
50
|
+
component: id,
|
|
51
|
+
x: layout.x ?? 0,
|
|
52
|
+
y: layout.y ?? 0,
|
|
53
|
+
width: layout.w ?? 12,
|
|
54
|
+
height: layout.h ?? 4,
|
|
55
|
+
movable: true,
|
|
56
|
+
deletable: true,
|
|
57
|
+
resizable: true
|
|
58
|
+
});
|
|
59
|
+
}
|
|
94
60
|
});
|
|
95
|
-
|
|
61
|
+
return {
|
|
62
|
+
children: Object.values(childDictionary).sort(
|
|
63
|
+
(a, b) => a.title && b.title ? a.title.localeCompare(b.title) : 0
|
|
64
|
+
).map((e) => e.child),
|
|
65
|
+
config: defaultConfig
|
|
66
|
+
};
|
|
67
|
+
}, [mountPoints, t]);
|
|
96
68
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
97
69
|
/* @__PURE__ */ jsx(
|
|
98
70
|
GlobalStyles,
|
|
@@ -107,9 +79,10 @@ const CustomizableGrid = (props) => {
|
|
|
107
79
|
/* @__PURE__ */ jsx(
|
|
108
80
|
CustomHomepageGrid,
|
|
109
81
|
{
|
|
110
|
-
config
|
|
82
|
+
config,
|
|
111
83
|
preventCollision: false,
|
|
112
84
|
compactType: "vertical",
|
|
85
|
+
style: { margin: "-10px" },
|
|
113
86
|
children
|
|
114
87
|
}
|
|
115
88
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CustomizableGrid.esm.js","sources":["../../src/components/CustomizableGrid.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\n// This complete read-only home page grid picks up the idea and styles from\n// https://github.com/backstage/backstage/blob/master/plugins/home\n// Esp. from the CustomHomepageGrid component:\n// https://github.com/backstage/backstage/blob/master/plugins/home/src/components/CustomHomepage/CustomHomepageGrid.tsx\n// but without the drag and drop functionality.\n\nimport type {
|
|
1
|
+
{"version":3,"file":"CustomizableGrid.esm.js","sources":["../../src/components/CustomizableGrid.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\n// This complete read-only home page grid picks up the idea and styles from\n// https://github.com/backstage/backstage/blob/master/plugins/home\n// Esp. from the CustomHomepageGrid component:\n// https://github.com/backstage/backstage/blob/master/plugins/home/src/components/CustomHomepage/CustomHomepageGrid.tsx\n// but without the drag and drop functionality.\n\nimport type { ReactElement } from 'react';\nimport { useMemo } from 'react';\n\nimport {\n CustomHomepageGrid,\n LayoutConfiguration,\n} from '@backstage/plugin-home';\nimport {\n ComponentParts,\n createCardExtension,\n} from '@backstage/plugin-home-react';\n\nimport GlobalStyles from '@mui/material/GlobalStyles';\nimport { useTheme } from '@mui/material/styles';\n\n// Removes the doubled scrollbar\nimport 'react-grid-layout/css/styles.css';\n\nimport { HomePageCardMountPoint } from '../types';\nimport { dynamicHomePagePlugin } from '../plugin';\nimport { useTranslation } from '../hooks/useTranslation';\nimport {\n isCardADefaultConfiguration,\n getCardTitle,\n getCardDescription,\n} from '../utils/customizable-cards';\n\n/**\n * @public\n */\nexport interface CustomizableGridProps {\n mountPoints: HomePageCardMountPoint[];\n}\n\n/**\n * @public\n */\nexport const CustomizableGrid = ({ mountPoints }: CustomizableGridProps) => {\n const theme = useTheme();\n const { t } = useTranslation();\n\n const { children, config } = useMemo(() => {\n // Children contains the additional / available cards a user can add.\n // Maps the card name to the actual card component.\n // Contains also the title to allow sorting before rendering.\n const childDictionary: Record<\n string,\n { child: ReactElement; title: string | undefined }\n > = {};\n\n // Config contains the default layout of the homepage\n const defaultConfig: LayoutConfiguration[] = [];\n\n mountPoints.forEach(mountPoint => {\n if (!mountPoint.config?.id) {\n return;\n }\n const id = mountPoint.config.id;\n const title = getCardTitle(t, mountPoint);\n const description = getCardDescription(t, mountPoint);\n\n const automaticallyWrapInInfoCard = false;\n\n const componentParts: ComponentParts = {\n Content: props => (\n <mountPoint.Component {...mountPoint.config!.props} {...props} />\n ),\n // Untested and unsupported for now!\n Actions: mountPoint.Actions as () => JSX.Element,\n // Untested and unsupported for now!\n Settings: mountPoint.Settings as () => JSX.Element,\n // This is a workaround to NOT automatically wrap in an InfoCard\n ContextProvider: automaticallyWrapInInfoCard\n ? undefined\n : props => (\n <mountPoint.Component {...mountPoint.config!.props} {...props} />\n ),\n };\n\n const cardExtension = createCardExtension({\n name: id,\n title,\n description,\n layout: mountPoint.config.cardLayout,\n settings: mountPoint.config.settings,\n components: () => Promise.resolve(componentParts),\n });\n\n const Card = dynamicHomePagePlugin.provide(cardExtension);\n\n childDictionary[id] = {\n child: <Card />,\n title,\n };\n\n if (isCardADefaultConfiguration(mountPoint)) {\n const layout = mountPoint.config?.layouts?.xl || {};\n\n defaultConfig.push({\n component: id,\n x: layout.x ?? 0,\n y: layout.y ?? 0,\n width: layout.w ?? 12,\n height: layout.h ?? 4,\n movable: true,\n deletable: true,\n resizable: true,\n });\n }\n });\n\n return {\n children: Object.values(childDictionary)\n .sort((a, b) =>\n a.title && b.title ? a.title.localeCompare(b.title) : 0,\n )\n .map(e => e.child),\n config: defaultConfig,\n };\n }, [mountPoints, t]);\n\n return (\n <>\n <GlobalStyles\n styles={{\n '[class*=\"makeStyles-settingsOverlay\"]': {\n backgroundColor:\n theme.palette.mode === 'dark'\n ? 'rgba(20, 20, 20, 0.95) !important'\n : 'rgba(40, 40, 40, 0.93) !important',\n },\n }}\n />\n <CustomHomepageGrid\n config={config}\n preventCollision={false}\n compactType=\"vertical\"\n style={{ margin: '-10px' }}\n >\n {children}\n </CustomHomepageGrid>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;AA2DO,MAAM,gBAAmB,GAAA,CAAC,EAAE,WAAA,EAAyC,KAAA;AAC1E,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAE7B,EAAA,MAAM,EAAE,QAAA,EAAU,MAAO,EAAA,GAAI,QAAQ,MAAM;AAIzC,IAAA,MAAM,kBAGF,EAAC;AAGL,IAAA,MAAM,gBAAuC,EAAC;AAE9C,IAAA,WAAA,CAAY,QAAQ,CAAc,UAAA,KAAA;AAChC,MAAI,IAAA,CAAC,UAAW,CAAA,MAAA,EAAQ,EAAI,EAAA;AAC1B,QAAA;AAAA;AAEF,MAAM,MAAA,EAAA,GAAK,WAAW,MAAO,CAAA,EAAA;AAC7B,MAAM,MAAA,KAAA,GAAQ,YAAa,CAAA,CAAA,EAAG,UAAU,CAAA;AACxC,MAAM,MAAA,WAAA,GAAc,kBAAmB,CAAA,CAAA,EAAG,UAAU,CAAA;AAIpD,MAAA,MAAM,cAAiC,GAAA;AAAA,QACrC,OAAA,EAAS,CACP,KAAA,qBAAA,GAAA,CAAC,UAAW,CAAA,SAAA,EAAX,EAAsB,GAAG,UAAW,CAAA,MAAA,CAAQ,KAAQ,EAAA,GAAG,KAAO,EAAA,CAAA;AAAA;AAAA,QAGjE,SAAS,UAAW,CAAA,OAAA;AAAA;AAAA,QAEpB,UAAU,UAAW,CAAA,QAAA;AAAA;AAAA,QAErB,eAAiB,EAEb,CAAA,KAAA,qBACG,GAAA,CAAA,UAAA,CAAW,SAAX,EAAA,EAAsB,GAAG,UAAA,CAAW,MAAQ,CAAA,KAAA,EAAQ,GAAG,KAAO,EAAA;A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;AAAA,OAEvD,CAAA,GAAA,CAAI,CAAK,CAAA,KAAA,CAAA,CAAE,KAAK,CAAA;AAAA,MACnB,MAAQ,EAAA;AAAA,KACV;AAAA,GACC,EAAA,CAAC,WAAa,EAAA,CAAC,CAAC,CAAA;AAEnB,EAAA,uBAEI,IAAA,CAAA,QAAA,EAAA,EAAA,QAAA,EAAA;AAAA,oBAAA,GAAA;AAAA,MAAC,YAAA;AAAA,MAAA;AAAA,QACC,MAAQ,EAAA;AAAA,UACN,uCAAyC,EAAA;AAAA,YACvC,eACE,EAAA,KAAA,CAAM,OAAQ,CAAA,IAAA,KAAS,SACnB,mCACA,GAAA;AAAA;AACR;AACF;AAAA,KACF;AAAA,oBACA,GAAA;AAAA,MAAC,kBAAA;AAAA,MAAA;AAAA,QACC,MAAA;AAAA,QACA,gBAAkB,EAAA,KAAA;AAAA,QAClB,WAAY,EAAA,UAAA;AAAA,QACZ,KAAA,EAAO,EAAE,MAAA,EAAQ,OAAQ,EAAA;AAAA,QAExB;AAAA;AAAA;AACH,GACF,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards.esm.js';
|
|
3
|
-
import {
|
|
3
|
+
import { HomePage } from './HomePage.esm.js';
|
|
4
4
|
|
|
5
5
|
const DynamicCustomizableHomePage = (props) => {
|
|
6
|
-
const
|
|
7
|
-
return /* @__PURE__ */ jsx(
|
|
6
|
+
const mountPoints = useDynamicHomePageCards();
|
|
7
|
+
return /* @__PURE__ */ jsx(HomePage, { ...props, mountPoints, customizable: true });
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export { DynamicCustomizableHomePage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicCustomizableHomePage.esm.js","sources":["../../src/components/DynamicCustomizableHomePage.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 { ClockConfig } from '@backstage/plugin-home';\n\nimport { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards';\nimport {
|
|
1
|
+
{"version":3,"file":"DynamicCustomizableHomePage.esm.js","sources":["../../src/components/DynamicCustomizableHomePage.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 { ClockConfig } from '@backstage/plugin-home';\n\nimport { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards';\nimport { HomePage } from './HomePage';\nimport type { LocalClockProps } from './LocalClock';\n\n/**\n * This type is similar to Omit<HomePageProps, 'cards'>.\n * We redefine it here to avoid the need to export HomePageProps to the API export!\n * @public\n */\nexport interface DynamicCustomizableHomePageProps {\n title?: string;\n personalizedTitle?: string;\n pageTitle?: string;\n subtitle?: string;\n localClock?: LocalClockProps;\n worldClocks?: ClockConfig[];\n}\n\n/**\n * @public\n */\nexport const DynamicCustomizableHomePage = (\n props: DynamicCustomizableHomePageProps,\n) => {\n const mountPoints = useDynamicHomePageCards();\n\n return <HomePage {...props} mountPoints={mountPoints} customizable />;\n};\n"],"names":[],"mappings":";;;;AAuCa,MAAA,2BAAA,GAA8B,CACzC,KACG,KAAA;AACH,EAAA,MAAM,cAAc,uBAAwB,EAAA;AAE5C,EAAA,2BAAQ,QAAU,EAAA,EAAA,GAAG,KAAO,EAAA,WAAA,EAA0B,cAAY,IAAC,EAAA,CAAA;AACrE;;;;"}
|
|
@@ -3,8 +3,8 @@ import { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards.esm.js
|
|
|
3
3
|
import { HomePage } from './HomePage.esm.js';
|
|
4
4
|
|
|
5
5
|
const DynamicHomePage = (props) => {
|
|
6
|
-
const
|
|
7
|
-
return /* @__PURE__ */ jsx(HomePage, { ...props,
|
|
6
|
+
const mountPoints = useDynamicHomePageCards();
|
|
7
|
+
return /* @__PURE__ */ jsx(HomePage, { ...props, mountPoints, customizable: false });
|
|
8
8
|
};
|
|
9
9
|
|
|
10
10
|
export { DynamicHomePage };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicHomePage.esm.js","sources":["../../src/components/DynamicHomePage.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 { ClockConfig } from '@backstage/plugin-home';\n\nimport { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards';\nimport { HomePage } from './HomePage';\nimport type { LocalClockProps } from './LocalClock';\n\n/**\n * This type is similar to Omit<HomePageProps, 'cards'>.\n * We redefine it here to avoid the need to export HomePageProps to the API export!\n * @public\n */\nexport interface DynamicHomePageProps {\n title?: string;\n personalizedTitle?: string;\n pageTitle?: string;\n subtitle?: string;\n localClock?: LocalClockProps;\n worldClocks?: ClockConfig[];\n}\n\n/**\n * @public\n */\nexport const DynamicHomePage = (props: DynamicHomePageProps) => {\n const
|
|
1
|
+
{"version":3,"file":"DynamicHomePage.esm.js","sources":["../../src/components/DynamicHomePage.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 { ClockConfig } from '@backstage/plugin-home';\n\nimport { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards';\nimport { HomePage } from './HomePage';\nimport type { LocalClockProps } from './LocalClock';\n\n/**\n * This type is similar to Omit<HomePageProps, 'cards'>.\n * We redefine it here to avoid the need to export HomePageProps to the API export!\n * @public\n */\nexport interface DynamicHomePageProps {\n title?: string;\n personalizedTitle?: string;\n pageTitle?: string;\n subtitle?: string;\n localClock?: LocalClockProps;\n worldClocks?: ClockConfig[];\n}\n\n/**\n * @public\n */\nexport const DynamicHomePage = (props: DynamicHomePageProps) => {\n const mountPoints = useDynamicHomePageCards();\n\n return <HomePage {...props} mountPoints={mountPoints} customizable={false} />;\n};\n"],"names":[],"mappings":";;;;AAuCa,MAAA,eAAA,GAAkB,CAAC,KAAgC,KAAA;AAC9D,EAAA,MAAM,cAAc,uBAAwB,EAAA;AAE5C,EAAA,2BAAQ,QAAU,EAAA,EAAA,GAAG,KAAO,EAAA,WAAA,EAA0B,cAAc,KAAO,EAAA,CAAA;AAC7E;;;;"}
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { Page, Content, EmptyState } from '@backstage/core-components';
|
|
1
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
+
import { EmptyState, Page, Content } from '@backstage/core-components';
|
|
4
3
|
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
5
4
|
import { Header } from './Header.esm.js';
|
|
6
5
|
import { ReadOnlyGrid } from './ReadOnlyGrid.esm.js';
|
|
6
|
+
import { CustomizableGrid } from './CustomizableGrid.esm.js';
|
|
7
7
|
|
|
8
|
-
const HomePage = (
|
|
8
|
+
const HomePage = ({
|
|
9
|
+
mountPoints,
|
|
10
|
+
customizable,
|
|
11
|
+
...otherProps
|
|
12
|
+
}) => {
|
|
9
13
|
const { t } = useTranslation();
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
(a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0)
|
|
19
|
-
);
|
|
20
|
-
return filteredAndSorted;
|
|
21
|
-
}, [props.cards]);
|
|
14
|
+
let content;
|
|
15
|
+
if (mountPoints.length === 0) {
|
|
16
|
+
content = /* @__PURE__ */ jsx(EmptyState, { title: t("homePage.empty"), missing: "content" });
|
|
17
|
+
} else if (customizable) {
|
|
18
|
+
content = /* @__PURE__ */ jsx(CustomizableGrid, { mountPoints });
|
|
19
|
+
} else {
|
|
20
|
+
content = /* @__PURE__ */ jsx(ReadOnlyGrid, { mountPoints });
|
|
21
|
+
}
|
|
22
22
|
return /* @__PURE__ */ jsxs(Page, { themeId: "home", children: [
|
|
23
|
-
/* @__PURE__ */ jsx(Header, { title: t("header.welcome"), ...
|
|
24
|
-
/* @__PURE__ */ jsx(Content, { children:
|
|
23
|
+
/* @__PURE__ */ jsx(Header, { title: t("header.welcome"), ...otherProps }),
|
|
24
|
+
/* @__PURE__ */ jsx(Content, { children: content })
|
|
25
25
|
] });
|
|
26
26
|
};
|
|
27
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 {
|
|
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 { Content, EmptyState, Page } from '@backstage/core-components';\n\nimport { useTranslation } from '../hooks/useTranslation';\nimport { HomePageCardMountPoint } from '../types';\nimport { Header, HeaderProps } from './Header';\nimport { ReadOnlyGrid } from './ReadOnlyGrid';\nimport { CustomizableGrid } from './CustomizableGrid';\n\nexport interface HomePageProps extends HeaderProps {\n mountPoints: HomePageCardMountPoint[];\n customizable: boolean;\n}\n\nexport const HomePage = ({\n mountPoints,\n customizable,\n ...otherProps\n}: HomePageProps) => {\n const { t } = useTranslation();\n\n let content: React.ReactNode;\n if (mountPoints.length === 0) {\n content = <EmptyState title={t('homePage.empty')} missing=\"content\" />;\n } else if (customizable) {\n content = <CustomizableGrid mountPoints={mountPoints} />;\n } else {\n content = <ReadOnlyGrid mountPoints={mountPoints} />;\n }\n\n return (\n <Page themeId=\"home\">\n <Header title={t('header.welcome')} {...otherProps} />\n <Content>{content}</Content>\n </Page>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA6BO,MAAM,WAAW,CAAC;AAAA,EACvB,WAAA;AAAA,EACA,YAAA;AAAA,EACA,GAAG;AACL,CAAqB,KAAA;AACnB,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAE7B,EAAI,IAAA,OAAA;AACJ,EAAI,IAAA,WAAA,CAAY,WAAW,CAAG,EAAA;AAC5B,IAAA,OAAA,uBAAW,UAAW,EAAA,EAAA,KAAA,EAAO,EAAE,gBAAgB,CAAA,EAAG,SAAQ,SAAU,EAAA,CAAA;AAAA,aAC3D,YAAc,EAAA;AACvB,IAAU,OAAA,mBAAA,GAAA,CAAC,oBAAiB,WAA0B,EAAA,CAAA;AAAA,GACjD,MAAA;AACL,IAAU,OAAA,mBAAA,GAAA,CAAC,gBAAa,WAA0B,EAAA,CAAA;AAAA;AAGpD,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,UAAY,EAAA,CAAA;AAAA,oBACpD,GAAA,CAAC,WAAS,QAAQ,EAAA,OAAA,EAAA;AAAA,GACpB,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -5,6 +5,7 @@ import { ErrorBoundary } from '@backstage/core-components';
|
|
|
5
5
|
import { makeStyles } from 'tss-react/mui';
|
|
6
6
|
import 'react-grid-layout/css/styles.css';
|
|
7
7
|
import useMeasure from 'react-use/lib/useMeasure';
|
|
8
|
+
import { isCardADefaultConfiguration } from '../utils/customizable-cards.esm.js';
|
|
8
9
|
|
|
9
10
|
const gridGap = 16;
|
|
10
11
|
const defaultProps = {
|
|
@@ -46,16 +47,16 @@ const useStyles = makeStyles()({
|
|
|
46
47
|
}
|
|
47
48
|
}
|
|
48
49
|
});
|
|
49
|
-
const ReadOnlyGrid = (
|
|
50
|
+
const ReadOnlyGrid = ({ mountPoints }) => {
|
|
50
51
|
const { classes } = useStyles();
|
|
51
52
|
const [measureRef, measureRect] = useMeasure();
|
|
52
53
|
const cards = useMemo(() => {
|
|
53
|
-
return
|
|
54
|
+
return mountPoints.filter(isCardADefaultConfiguration).map((cardMountPoint, index) => {
|
|
54
55
|
const id = (index + 1).toString();
|
|
55
56
|
const layouts2 = {};
|
|
56
|
-
if (
|
|
57
|
+
if (cardMountPoint.config?.layouts) {
|
|
57
58
|
for (const [breakpoint, layout] of Object.entries(
|
|
58
|
-
|
|
59
|
+
cardMountPoint.config.layouts
|
|
59
60
|
)) {
|
|
60
61
|
layouts2[breakpoint] = {
|
|
61
62
|
i: id,
|
|
@@ -82,12 +83,12 @@ const ReadOnlyGrid = (props) => {
|
|
|
82
83
|
}
|
|
83
84
|
return {
|
|
84
85
|
id,
|
|
85
|
-
Component:
|
|
86
|
-
props:
|
|
86
|
+
Component: cardMountPoint.Component,
|
|
87
|
+
props: cardMountPoint.config?.props,
|
|
87
88
|
layouts: layouts2
|
|
88
89
|
};
|
|
89
90
|
});
|
|
90
|
-
}, [
|
|
91
|
+
}, [mountPoints]);
|
|
91
92
|
const layouts = useMemo(() => {
|
|
92
93
|
const result = {};
|
|
93
94
|
for (const card of cards) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReadOnlyGrid.esm.js","sources":["../../src/components/ReadOnlyGrid.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\n// This complete read-only home page grid picks up the idea and styles from\n// https://github.com/backstage/backstage/blob/master/plugins/home\n// Esp. from the CustomHomepageGrid component:\n// https://github.com/backstage/backstage/blob/master/plugins/home/src/components/CustomHomepage/CustomHomepageGrid.tsx\n// but without the drag and drop functionality.\n\nimport type { ComponentType } from 'react';\n\nimport { useMemo } from 'react';\nimport {\n Layout,\n Layouts,\n Responsive,\n ResponsiveProps,\n} from 'react-grid-layout';\n\nimport { ErrorBoundary } from '@backstage/core-components';\n\nimport { makeStyles } from 'tss-react/mui';\n\n// Removes the doubled scrollbar\nimport 'react-grid-layout/css/styles.css';\n\nimport useMeasure from 'react-use/lib/useMeasure';\n\nimport { HomePageCardMountPoint } from '../types';\n\ninterface Card {\n id: string;\n Component: ComponentType<any>;\n props?: Record<string, any>;\n layouts: Record<string, Layout>;\n}\n\nconst gridGap = 16;\n\nconst defaultProps: ResponsiveProps = {\n // Aligned with the 1.0-1.2 home page gap.\n margin: [gridGap, gridGap],\n // Same as in home-plugin CustomHomepageGrid\n rowHeight: 60,\n\n // We use always a 12-column grid, but each cards can define\n // their number of columns (width) and start column (x) per breakpoint.\n breakpoints: {\n xl: 1600,\n lg: 1200,\n md: 996,\n sm: 768,\n xs: 480,\n xxs: 0,\n },\n cols: {\n xl: 12,\n lg: 12,\n md: 12,\n sm: 12,\n xs: 12,\n xxs: 12,\n },\n\n isDraggable: false,\n isResizable: false,\n compactType: null,\n};\n\nconst useStyles = makeStyles()({\n // Make card content scrollable (so that cards don't overlap)\n cardWrapper: {\n '& > div[class*=\"MuiCard-root\"]': {\n width: '100%',\n height: '100%',\n },\n '& div[class*=\"MuiCardContent-root\"]': {\n overflow: 'auto',\n },\n },\n});\n\n/**\n * @public\n */\nexport interface ReadOnlyGridProps {\n mountPoints: HomePageCardMountPoint[];\n
|
|
1
|
+
{"version":3,"file":"ReadOnlyGrid.esm.js","sources":["../../src/components/ReadOnlyGrid.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\n// This complete read-only home page grid picks up the idea and styles from\n// https://github.com/backstage/backstage/blob/master/plugins/home\n// Esp. from the CustomHomepageGrid component:\n// https://github.com/backstage/backstage/blob/master/plugins/home/src/components/CustomHomepage/CustomHomepageGrid.tsx\n// but without the drag and drop functionality.\n\nimport type { ComponentType } from 'react';\n\nimport { useMemo } from 'react';\nimport {\n Layout,\n Layouts,\n Responsive,\n ResponsiveProps,\n} from 'react-grid-layout';\n\nimport { ErrorBoundary } from '@backstage/core-components';\n\nimport { makeStyles } from 'tss-react/mui';\n\n// Removes the doubled scrollbar\nimport 'react-grid-layout/css/styles.css';\n\nimport useMeasure from 'react-use/lib/useMeasure';\n\nimport { HomePageCardMountPoint } from '../types';\nimport { isCardADefaultConfiguration } from '../utils/customizable-cards';\n\ninterface Card {\n id: string;\n Component: ComponentType<any>;\n props?: Record<string, any>;\n layouts: Record<string, Layout>;\n}\n\nconst gridGap = 16;\n\nconst defaultProps: ResponsiveProps = {\n // Aligned with the 1.0-1.2 home page gap.\n margin: [gridGap, gridGap],\n // Same as in home-plugin CustomHomepageGrid\n rowHeight: 60,\n\n // We use always a 12-column grid, but each cards can define\n // their number of columns (width) and start column (x) per breakpoint.\n breakpoints: {\n xl: 1600,\n lg: 1200,\n md: 996,\n sm: 768,\n xs: 480,\n xxs: 0,\n },\n cols: {\n xl: 12,\n lg: 12,\n md: 12,\n sm: 12,\n xs: 12,\n xxs: 12,\n },\n\n isDraggable: false,\n isResizable: false,\n compactType: null,\n};\n\nconst useStyles = makeStyles()({\n // Make card content scrollable (so that cards don't overlap)\n cardWrapper: {\n '& > div[class*=\"MuiCard-root\"]': {\n width: '100%',\n height: '100%',\n },\n '& div[class*=\"MuiCardContent-root\"]': {\n overflow: 'auto',\n },\n },\n});\n\n/**\n * @public\n */\nexport interface ReadOnlyGridProps {\n mountPoints: HomePageCardMountPoint[];\n}\n\n/**\n * @public\n */\nexport const ReadOnlyGrid = ({ mountPoints }: ReadOnlyGridProps) => {\n const { classes } = useStyles();\n const [measureRef, measureRect] = useMeasure<HTMLDivElement>();\n\n const cards = useMemo<Card[]>(() => {\n return mountPoints\n .filter(isCardADefaultConfiguration)\n .map<Card>((cardMountPoint, index) => {\n const id = (index + 1).toString();\n const layouts: Record<string, Layout> = {};\n\n if (cardMountPoint.config?.layouts) {\n for (const [breakpoint, layout] of Object.entries(\n cardMountPoint.config.layouts,\n )) {\n layouts[breakpoint] = {\n i: id,\n x: layout.x ?? 0,\n y: layout.y ?? 0,\n w: layout.w ?? 12,\n h: layout.h ?? 4,\n isDraggable: false,\n isResizable: false,\n };\n }\n } else {\n // Default layout for cards without a layout configuration\n ['xl', 'lg', 'md', 'sm', 'xs', 'xxs'].forEach(breakpoint => {\n layouts[breakpoint] = {\n i: id,\n x: 0,\n y: 0,\n w: 12,\n h: 4,\n isDraggable: false,\n isResizable: false,\n };\n });\n }\n\n return {\n id,\n Component: cardMountPoint.Component,\n props: cardMountPoint.config?.props,\n layouts,\n };\n });\n }, [mountPoints]);\n\n const layouts = useMemo<Layouts>(() => {\n const result: Layouts = {};\n for (const card of cards) {\n for (const [breakpoint, layoutPerBreakpoint] of Object.entries(\n card.layouts,\n )) {\n if (!result[breakpoint]) {\n result[breakpoint] = [];\n }\n result[breakpoint].push(layoutPerBreakpoint);\n }\n }\n return result;\n }, [cards]);\n\n const children = useMemo(() => {\n return cards.map(card => (\n <div\n key={card.id}\n data-cardid={card.id}\n data-testid={`home-page card ${card.id}`}\n data-layout={JSON.stringify(card.layouts)}\n className={classes.cardWrapper}\n >\n <ErrorBoundary>\n <card.Component {...card.props} />\n </ErrorBoundary>\n </div>\n ));\n }, [cards, classes.cardWrapper]);\n\n return (\n <div style={{ margin: -gridGap }}>\n <div ref={measureRef} />\n {measureRect.width ? (\n <Responsive\n {...defaultProps}\n width={measureRect.width}\n layouts={layouts}\n >\n {children}\n </Responsive>\n ) : null}\n </div>\n );\n};\n"],"names":["layouts"],"mappings":";;;;;;;;;AAmDA,MAAM,OAAU,GAAA,EAAA;AAEhB,MAAM,YAAgC,GAAA;AAAA;AAAA,EAEpC,MAAA,EAAQ,CAAC,OAAA,EAAS,OAAO,CAAA;AAAA;AAAA,EAEzB,SAAW,EAAA,EAAA;AAAA;AAAA;AAAA,EAIX,WAAa,EAAA;AAAA,IACX,EAAI,EAAA,IAAA;AAAA,IACJ,EAAI,EAAA,IAAA;AAAA,IACJ,EAAI,EAAA,GAAA;AAAA,IACJ,EAAI,EAAA,GAAA;AAAA,IACJ,EAAI,EAAA,GAAA;AAAA,IACJ,GAAK,EAAA;AAAA,GACP;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,EAAI,EAAA,EAAA;AAAA,IACJ,EAAI,EAAA,EAAA;AAAA,IACJ,EAAI,EAAA,EAAA;AAAA,IACJ,EAAI,EAAA,EAAA;AAAA,IACJ,EAAI,EAAA,EAAA;AAAA,IACJ,GAAK,EAAA;AAAA,GACP;AAAA,EAEA,WAAa,EAAA,KAAA;AAAA,EACb,WAAa,EAAA,KAAA;AAAA,EACb,WAAa,EAAA;AACf,CAAA;AAEA,MAAM,SAAA,GAAY,YAAa,CAAA;AAAA;AAAA,EAE7B,WAAa,EAAA;AAAA,IACX,gCAAkC,EAAA;AAAA,MAChC,KAAO,EAAA,MAAA;AAAA,MACP,MAAQ,EAAA;AAAA,KACV;AAAA,IACA,qCAAuC,EAAA;AAAA,MACrC,QAAU,EAAA;AAAA;AACZ;AAEJ,CAAC,CAAA;AAYM,MAAM,YAAe,GAAA,CAAC,EAAE,WAAA,EAAqC,KAAA;AAClE,EAAM,MAAA,EAAE,OAAQ,EAAA,GAAI,SAAU,EAAA;AAC9B,EAAA,MAAM,CAAC,UAAA,EAAY,WAAW,CAAA,GAAI,UAA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,CAAC,CAAA;AAE/B,EAAA,4BACG,KAAI,EAAA,EAAA,KAAA,EAAO,EAAE,MAAQ,EAAA,KACpB,EAAA,QAAA,EAAA;AAAA,oBAAC,GAAA,CAAA,KAAA,EAAA,EAAI,KAAK,UAAY,EAAA,CAAA;AAAA,IACrB,YAAY,KACX,mBAAA,GAAA;AAAA,MAAC,UAAA;AAAA,MAAA;AAAA,QACE,GAAG,YAAA;AAAA,QACJ,OAAO,WAAY,CAAA,KAAA;AAAA,QACnB,OAAA;AAAA,QAEC;AAAA;AAAA,KAED,GAAA;AAAA,GACN,EAAA,CAAA;AAEJ;;;;"}
|
|
@@ -6,7 +6,7 @@ import { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards.esm.js
|
|
|
6
6
|
const VisitListener = () => {
|
|
7
7
|
const cards = useDynamicHomePageCards();
|
|
8
8
|
const shouldLoadVisitListener = useMemo(() => {
|
|
9
|
-
if (
|
|
9
|
+
if (cards.length === 0) {
|
|
10
10
|
return false;
|
|
11
11
|
}
|
|
12
12
|
const requiresVisitListener = [
|
|
@@ -14,7 +14,7 @@ const VisitListener = () => {
|
|
|
14
14
|
"Extension(TopVisitedCard)"
|
|
15
15
|
];
|
|
16
16
|
return cards.some(
|
|
17
|
-
(card) => requiresVisitListener.includes(card.Component.displayName)
|
|
17
|
+
(card) => card.Component?.displayName && requiresVisitListener.includes(card.Component.displayName)
|
|
18
18
|
);
|
|
19
19
|
}, [cards]);
|
|
20
20
|
return shouldLoadVisitListener ? /* @__PURE__ */ jsx(VisitListener$1, {}) : null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"VisitListener.esm.js","sources":["../../src/components/VisitListener.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 { VisitListener as VisitListenerComponent } from '@backstage/plugin-home';\nimport { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards';\n\nexport const VisitListener = () => {\n const cards = useDynamicHomePageCards();\n\n const shouldLoadVisitListener = useMemo<boolean>(() => {\n if (
|
|
1
|
+
{"version":3,"file":"VisitListener.esm.js","sources":["../../src/components/VisitListener.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 { VisitListener as VisitListenerComponent } from '@backstage/plugin-home';\nimport { useDynamicHomePageCards } from '../hooks/useDynamicHomePageCards';\n\nexport const VisitListener = () => {\n const cards = useDynamicHomePageCards();\n\n const shouldLoadVisitListener = useMemo<boolean>(() => {\n if (cards.length === 0) {\n return false;\n }\n\n const requiresVisitListener = [\n 'Extension(RecentlyVisitedCard)',\n 'Extension(TopVisitedCard)',\n ];\n\n return cards.some(\n card =>\n card.Component?.displayName &&\n requiresVisitListener.includes(card.Component.displayName),\n );\n }, [cards]);\n\n return shouldLoadVisitListener ? <VisitListenerComponent /> : null;\n};\n"],"names":["VisitListenerComponent"],"mappings":";;;;;AAqBO,MAAM,gBAAgB,MAAM;AACjC,EAAA,MAAM,QAAQ,uBAAwB,EAAA;AAEtC,EAAM,MAAA,uBAAA,GAA0B,QAAiB,MAAM;AACrD,IAAI,IAAA,KAAA,CAAM,WAAW,CAAG,EAAA;AACtB,MAAO,OAAA,KAAA;AAAA;AAGT,IAAA,MAAM,qBAAwB,GAAA;AAAA,MAC5B,gCAAA;AAAA,MACA;AAAA,KACF;AAEA,IAAA,OAAO,KAAM,CAAA,IAAA;AAAA,MACX,CAAA,IAAA,KACE,KAAK,SAAW,EAAA,WAAA,IAChB,sBAAsB,QAAS,CAAA,IAAA,CAAK,UAAU,WAAW;AAAA,KAC7D;AAAA,GACF,EAAG,CAAC,KAAK,CAAC,CAAA;AAEV,EAAO,OAAA,uBAAA,mBAA2B,GAAA,CAAAA,eAAA,EAAA,EAAuB,CAAK,GAAA,IAAA;AAChE;;;;"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
1
2
|
import { useScalprum } from '@scalprum/react-core';
|
|
2
3
|
|
|
3
4
|
const useDynamicHomePageCards = () => {
|
|
4
5
|
const scalprum = useScalprum();
|
|
5
6
|
const cards = scalprum?.api?.dynamicRootConfig?.mountPoints?.["home.page/cards"];
|
|
6
|
-
return
|
|
7
|
+
return useMemo(() => {
|
|
8
|
+
if (!cards || !Array.isArray(cards)) {
|
|
9
|
+
return [];
|
|
10
|
+
}
|
|
11
|
+
const filteredAndSorted = cards.filter(
|
|
12
|
+
(card) => card.Component && card.enabled !== false && (!card.config?.priority || card.config.priority >= 0)
|
|
13
|
+
);
|
|
14
|
+
filteredAndSorted.sort(
|
|
15
|
+
(a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0)
|
|
16
|
+
);
|
|
17
|
+
return filteredAndSorted;
|
|
18
|
+
}, [cards]);
|
|
7
19
|
};
|
|
8
20
|
|
|
9
21
|
export { useDynamicHomePageCards };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDynamicHomePageCards.esm.js","sources":["../../src/hooks/useDynamicHomePageCards.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 { useScalprum } from '@scalprum/react-core';\n\nimport { HomePageCardMountPoint } from '../types';\n\ninterface ScalprumState {\n api?: {\n dynamicRootConfig?: {\n mountPoints?: {\n 'home.page/cards': HomePageCardMountPoint[];\n };\n };\n };\n}\n\nexport const useDynamicHomePageCards = ()
|
|
1
|
+
{"version":3,"file":"useDynamicHomePageCards.esm.js","sources":["../../src/hooks/useDynamicHomePageCards.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 { useMemo } from 'react';\nimport { useScalprum } from '@scalprum/react-core';\n\nimport { HomePageCardMountPoint } from '../types';\n\ninterface ScalprumState {\n api?: {\n dynamicRootConfig?: {\n mountPoints?: {\n 'home.page/cards': HomePageCardMountPoint[];\n };\n };\n };\n}\n\nexport const useDynamicHomePageCards = (): HomePageCardMountPoint[] => {\n const scalprum = useScalprum<ScalprumState>();\n\n const cards =\n scalprum?.api?.dynamicRootConfig?.mountPoints?.['home.page/cards'];\n\n return useMemo(() => {\n if (!cards || !Array.isArray(cards)) {\n return [];\n }\n\n const filteredAndSorted = cards.filter(\n card =>\n card.Component &&\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 }, [cards]);\n};\n"],"names":[],"mappings":";;;AA+BO,MAAM,0BAA0B,MAAgC;AACrE,EAAA,MAAM,WAAW,WAA2B,EAAA;AAE5C,EAAA,MAAM,KACJ,GAAA,QAAA,EAAU,GAAK,EAAA,iBAAA,EAAmB,cAAc,iBAAiB,CAAA;AAEnE,EAAA,OAAO,QAAQ,MAAM;AACnB,IAAA,IAAI,CAAC,KAAS,IAAA,CAAC,KAAM,CAAA,OAAA,CAAQ,KAAK,CAAG,EAAA;AACnC,MAAA,OAAO,EAAC;AAAA;AAGV,IAAA,MAAM,oBAAoB,KAAM,CAAA,MAAA;AAAA,MAC9B,CACE,IAAA,KAAA,IAAA,CAAK,SACL,IAAA,IAAA,CAAK,OAAY,KAAA,KAAA,KAChB,CAAC,IAAA,CAAK,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,GACT,EAAG,CAAC,KAAK,CAAC,CAAA;AACZ;;;;"}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ 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
5
|
import * as _backstage_core_plugin_api_alpha from '@backstage/core-plugin-api/alpha';
|
|
6
|
+
import { CardLayout, CardSettings } from '@backstage/plugin-home-react';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* @public
|
|
@@ -122,7 +123,26 @@ interface Layout {
|
|
|
122
123
|
* @public
|
|
123
124
|
*/
|
|
124
125
|
interface HomePageCardMountPointConfig {
|
|
126
|
+
/**
|
|
127
|
+
* This is the internal id that solves duplication issues when using
|
|
128
|
+
* cthe same omponent with different configurations.
|
|
129
|
+
* This is used as reference identifier when calling
|
|
130
|
+
* `createCardExtension` (as name) to convert dynamic mount points
|
|
131
|
+
* to home page cards for the `CustomHomepageGrid`.
|
|
132
|
+
*
|
|
133
|
+
* **NOTE:** This field is required when enabling user customization!
|
|
134
|
+
*/
|
|
135
|
+
id?: string;
|
|
136
|
+
title?: string;
|
|
137
|
+
titleKey?: string;
|
|
138
|
+
description?: string;
|
|
139
|
+
descriptionKey?: string;
|
|
140
|
+
cardLayout?: CardLayout;
|
|
141
|
+
settings?: CardSettings;
|
|
125
142
|
priority?: number;
|
|
143
|
+
/**
|
|
144
|
+
* Setting a layout configuration enables this card by default.
|
|
145
|
+
*/
|
|
126
146
|
layouts?: Record<Breakpoint, Layout>;
|
|
127
147
|
}
|
|
128
148
|
/**
|
|
@@ -130,6 +150,8 @@ interface HomePageCardMountPointConfig {
|
|
|
130
150
|
*/
|
|
131
151
|
interface HomePageCardMountPoint {
|
|
132
152
|
Component: ComponentType;
|
|
153
|
+
Actions?: ComponentType;
|
|
154
|
+
Settings?: ComponentType;
|
|
133
155
|
config?: HomePageCardMountPointConfig & {
|
|
134
156
|
props?: Record<string, any>;
|
|
135
157
|
};
|
|
@@ -275,121 +297,4 @@ declare const homepageTranslationRef: _backstage_core_plugin_api_alpha.Translati
|
|
|
275
297
|
*/
|
|
276
298
|
declare const homepageTranslations: _backstage_core_plugin_api_alpha.TranslationResource<"plugin.homepage">;
|
|
277
299
|
|
|
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
|
-
quickAccessCard: {
|
|
362
|
-
xl: {
|
|
363
|
-
w: number;
|
|
364
|
-
h: number;
|
|
365
|
-
x: number;
|
|
366
|
-
};
|
|
367
|
-
lg: {
|
|
368
|
-
w: number;
|
|
369
|
-
h: number;
|
|
370
|
-
x: number;
|
|
371
|
-
};
|
|
372
|
-
md: {
|
|
373
|
-
w: number;
|
|
374
|
-
h: number;
|
|
375
|
-
x: number;
|
|
376
|
-
};
|
|
377
|
-
sm: {
|
|
378
|
-
w: number;
|
|
379
|
-
h: number;
|
|
380
|
-
x: number;
|
|
381
|
-
};
|
|
382
|
-
xs: {
|
|
383
|
-
w: number;
|
|
384
|
-
h: number;
|
|
385
|
-
x: number;
|
|
386
|
-
};
|
|
387
|
-
xxs: {
|
|
388
|
-
w: number;
|
|
389
|
-
h: number;
|
|
390
|
-
x: number;
|
|
391
|
-
};
|
|
392
|
-
};
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
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 };
|
|
300
|
+
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, dynamicHomePagePlugin, homepageTranslationRef, homepageTranslations };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
export { CatalogStarredEntitiesCard, DynamicCustomizableHomePage, DynamicHomePage, EntitySection, FeaturedDocsCard, Headline, JokeCard, Markdown, MarkdownCard, OnboardingSection, Placeholder, QuickAccessCard, RecentlyVisitedCard, SearchBar, TemplateSection, TopVisitedCard, VisitListener, WorldClock, dynamicHomePagePlugin } from './plugin.esm.js';
|
|
2
2
|
export { homepageTranslations } from './translations/index.esm.js';
|
|
3
|
-
export { defaultLayouts } from './defaults.esm.js';
|
|
4
3
|
export { homepageTranslationRef } from './translations/ref.esm.js';
|
|
5
4
|
//# sourceMappingURL=index.esm.js.map
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|
package/dist/plugin.esm.js
CHANGED
|
@@ -86,7 +86,7 @@ const MarkdownCard = dynamicHomePagePlugin.provide(
|
|
|
86
86
|
);
|
|
87
87
|
const Placeholder = dynamicHomePagePlugin.provide(
|
|
88
88
|
createComponentExtension({
|
|
89
|
-
name: "
|
|
89
|
+
name: "Placeholder",
|
|
90
90
|
component: {
|
|
91
91
|
lazy: () => import('./components/Placeholder.esm.js').then((m) => m.Placeholder)
|
|
92
92
|
}
|
package/dist/plugin.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.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 type { ComponentType } from 'react';\n\nimport {\n configApiRef,\n createApiFactory,\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n discoveryApiRef,\n identityApiRef,\n storageApiRef,\n} from '@backstage/core-plugin-api';\n\nimport {\n type StarredEntitiesProps,\n type VisitedByTypeProps,\n type FeaturedDocsCardProps,\n visitsApiRef,\n VisitsStorageApi,\n} from '@backstage/plugin-home';\n\nimport { rootRouteRef } from './routes';\nimport { QuickAccessApiClient, quickAccessApiRef } from './api';\n\nimport type { DynamicHomePageProps } from './components/DynamicHomePage';\nimport type { DynamicCustomizableHomePageProps } from './components/DynamicCustomizableHomePage';\nimport type { SearchBarProps } from './components/SearchBar';\nimport type { QuickAccessCardProps } from './components/QuickAccessCard';\nimport type { HeadlineProps } from './components/Headline';\nimport type { MarkdownProps } from './components/Markdown';\nimport type { MarkdownCardProps } from './components/MarkdownCard';\nimport type { PlaceholderProps } from './components/Placeholder';\n\nexport type { DynamicHomePageProps } from './components/DynamicHomePage';\nexport type { DynamicCustomizableHomePageProps } from './components/DynamicCustomizableHomePage';\nexport type { SearchBarProps } from './components/SearchBar';\nexport type { QuickAccessCardProps } from './components/QuickAccessCard';\nexport type { HeadlineProps } from './components/Headline';\nexport type { MarkdownProps } from './components/Markdown';\nexport type { MarkdownCardProps } from './components/MarkdownCard';\nexport type { PlaceholderProps } from './components/Placeholder';\nexport type { LocalClockProps } from './components/LocalClock';\nexport type { WorldClockProps } from './components/WorldClock';\nexport type {\n HomePageCardMountPoint,\n HomePageCardMountPointConfig,\n Breakpoint,\n Layout,\n} from './types';\n\n/**\n * Dynamic Home Page Plugin\n * @public\n */\nexport const dynamicHomePagePlugin = createPlugin({\n id: 'dynamic-home-page',\n routes: {\n root: rootRouteRef,\n },\n apis: [\n createApiFactory({\n api: quickAccessApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n configApi: configApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ discoveryApi, configApi, identityApi }) =>\n new QuickAccessApiClient({ discoveryApi, configApi, identityApi }),\n }),\n createApiFactory({\n api: visitsApiRef,\n deps: {\n storageApi: storageApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ storageApi, identityApi }) =>\n VisitsStorageApi.create({ storageApi, identityApi }),\n }),\n ],\n});\n\n/**\n * Dynamic Home Page\n * @public\n */\nexport const DynamicHomePage: ComponentType<DynamicHomePageProps> =\n dynamicHomePagePlugin.provide(\n createRoutableExtension({\n name: 'DynamicHomePage',\n component: () =>\n import('./components/DynamicHomePage').then(m => m.DynamicHomePage),\n mountPoint: rootRouteRef,\n }),\n );\n\n/**\n * Customizable Dynamic Home Page\n * @public\n */\nexport const DynamicCustomizableHomePage: ComponentType<DynamicCustomizableHomePageProps> =\n dynamicHomePagePlugin.provide(\n createRoutableExtension({\n name: 'DynamicCustomizableHomePage',\n component: () =>\n import('./components/DynamicCustomizableHomePage').then(\n m => m.DynamicCustomizableHomePage,\n ),\n mountPoint: rootRouteRef,\n }),\n );\n\n/**\n * @public\n */\nexport const SearchBar: ComponentType<SearchBarProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'SearchBar',\n component: {\n lazy: () => import('./components/SearchBar').then(m => m.SearchBar),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const QuickAccessCard: ComponentType<QuickAccessCardProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'QuickAccessCard',\n component: {\n lazy: () =>\n import('./components/QuickAccessCard').then(m => m.QuickAccessCard),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const Headline: ComponentType<HeadlineProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'Headline',\n component: {\n lazy: () => import('./components/Headline').then(m => m.Headline),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const Markdown: ComponentType<MarkdownProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'Markdown',\n component: {\n lazy: () => import('./components/Markdown').then(m => m.Markdown),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const MarkdownCard: ComponentType<MarkdownCardProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'MarkdownCard',\n component: {\n lazy: () =>\n import('./components/MarkdownCard').then(m => m.MarkdownCard),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const Placeholder: ComponentType<PlaceholderProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'MarkdownCard',\n component: {\n lazy: () => import('./components/Placeholder').then(m => m.Placeholder),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const CatalogStarredEntitiesCard: ComponentType<StarredEntitiesProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'CatalogStarredEntitiesCard',\n component: {\n lazy: () =>\n import('@backstage/plugin-home').then(m => m.HomePageStarredEntities),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const RecentlyVisitedCard: ComponentType<VisitedByTypeProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'RecentlyVisitedCard',\n component: {\n lazy: () =>\n import('@backstage/plugin-home').then(m => m.HomePageRecentlyVisited),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const TopVisitedCard: ComponentType<VisitedByTypeProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'TopVisitedCard',\n component: {\n lazy: () =>\n import('@backstage/plugin-home').then(m => m.HomePageTopVisited),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const FeaturedDocsCard: ComponentType<FeaturedDocsCardProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'FeaturedDocsCard',\n component: {\n lazy: () =>\n import('./components/FeaturedDocsCard').then(m => m.FeaturedDocsCard),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const JokeCard: ComponentType<{\n defaultCategory?: 'any' | 'programming';\n}> = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'JokeCard',\n component: {\n lazy: () =>\n import('@backstage/plugin-home').then(m => m.HomePageRandomJoke),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const VisitListener = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'VisitListener',\n component: {\n lazy: () =>\n import('./components/VisitListener').then(m => m.VisitListener),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const WorldClock = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'WorldClock',\n component: {\n lazy: () => import('./components/WorldClock').then(m => m.WorldClock),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const OnboardingSection = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'OnboardingSection',\n component: {\n lazy: () =>\n import('./components/OnboardingSection').then(m => m.OnboardingSection),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const EntitySection = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'EntitySection',\n component: {\n lazy: () =>\n import('./components/EntitySection').then(m => m.EntitySection),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const TemplateSection = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'TemplateSection',\n component: {\n lazy: () =>\n import('./components/TemplateSection').then(m => m.TemplateSection),\n },\n }),\n);\n"],"names":[],"mappings":";;;;;AAsEO,MAAM,wBAAwB,YAAa,CAAA;AAAA,EAChD,EAAI,EAAA,mBAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA;AAAA,GACR;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,iBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,SAAW,EAAA,YAAA;AAAA,QACX,WAAa,EAAA;AA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ClE,GACD;AACH;AAKO,MAAM,aAAa,qBAAsB,CAAA,OAAA;AAAA,EAC9C,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,YAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MAAM,OAAO,gCAAyB,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,UAAU;AAAA;AACtE,GACD;AACH;AAKO,MAAM,oBAAoB,qBAAsB,CAAA,OAAA;AAAA,EACrD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,mBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MACJ,OAAO,6CAAgC,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,iBAAiB;AAAA;AAC1E,GACD;AACH;AAKO,MAAM,gBAAgB,qBAAsB,CAAA,OAAA;AAAA,EACjD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,eAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MACJ,OAAO,yCAA4B,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,aAAa;AAAA;AAClE,GACD;AACH;AAKO,MAAM,kBAAkB,qBAAsB,CAAA,OAAA;AAAA,EACnD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,iBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MACJ,OAAO,2CAA8B,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,eAAe;AAAA;AACtE,GACD;AACH;;;;"}
|
|
1
|
+
{"version":3,"file":"plugin.esm.js","sources":["../src/plugin.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 type { ComponentType } from 'react';\n\nimport {\n configApiRef,\n createApiFactory,\n createComponentExtension,\n createPlugin,\n createRoutableExtension,\n discoveryApiRef,\n identityApiRef,\n storageApiRef,\n} from '@backstage/core-plugin-api';\n\nimport {\n type StarredEntitiesProps,\n type VisitedByTypeProps,\n type FeaturedDocsCardProps,\n visitsApiRef,\n VisitsStorageApi,\n} from '@backstage/plugin-home';\n\nimport { rootRouteRef } from './routes';\nimport { QuickAccessApiClient, quickAccessApiRef } from './api';\n\nimport type { DynamicHomePageProps } from './components/DynamicHomePage';\nimport type { DynamicCustomizableHomePageProps } from './components/DynamicCustomizableHomePage';\nimport type { SearchBarProps } from './components/SearchBar';\nimport type { QuickAccessCardProps } from './components/QuickAccessCard';\nimport type { HeadlineProps } from './components/Headline';\nimport type { MarkdownProps } from './components/Markdown';\nimport type { MarkdownCardProps } from './components/MarkdownCard';\nimport type { PlaceholderProps } from './components/Placeholder';\n\nexport type { DynamicHomePageProps } from './components/DynamicHomePage';\nexport type { DynamicCustomizableHomePageProps } from './components/DynamicCustomizableHomePage';\nexport type { SearchBarProps } from './components/SearchBar';\nexport type { QuickAccessCardProps } from './components/QuickAccessCard';\nexport type { HeadlineProps } from './components/Headline';\nexport type { MarkdownProps } from './components/Markdown';\nexport type { MarkdownCardProps } from './components/MarkdownCard';\nexport type { PlaceholderProps } from './components/Placeholder';\nexport type { LocalClockProps } from './components/LocalClock';\nexport type { WorldClockProps } from './components/WorldClock';\nexport type {\n HomePageCardMountPoint,\n HomePageCardMountPointConfig,\n Breakpoint,\n Layout,\n} from './types';\n\n/**\n * Dynamic Home Page Plugin\n * @public\n */\nexport const dynamicHomePagePlugin = createPlugin({\n id: 'dynamic-home-page',\n routes: {\n root: rootRouteRef,\n },\n apis: [\n createApiFactory({\n api: quickAccessApiRef,\n deps: {\n discoveryApi: discoveryApiRef,\n configApi: configApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ discoveryApi, configApi, identityApi }) =>\n new QuickAccessApiClient({ discoveryApi, configApi, identityApi }),\n }),\n createApiFactory({\n api: visitsApiRef,\n deps: {\n storageApi: storageApiRef,\n identityApi: identityApiRef,\n },\n factory: ({ storageApi, identityApi }) =>\n VisitsStorageApi.create({ storageApi, identityApi }),\n }),\n ],\n});\n\n/**\n * Dynamic Home Page\n * @public\n */\nexport const DynamicHomePage: ComponentType<DynamicHomePageProps> =\n dynamicHomePagePlugin.provide(\n createRoutableExtension({\n name: 'DynamicHomePage',\n component: () =>\n import('./components/DynamicHomePage').then(m => m.DynamicHomePage),\n mountPoint: rootRouteRef,\n }),\n );\n\n/**\n * Customizable Dynamic Home Page\n * @public\n */\nexport const DynamicCustomizableHomePage: ComponentType<DynamicCustomizableHomePageProps> =\n dynamicHomePagePlugin.provide(\n createRoutableExtension({\n name: 'DynamicCustomizableHomePage',\n component: () =>\n import('./components/DynamicCustomizableHomePage').then(\n m => m.DynamicCustomizableHomePage,\n ),\n mountPoint: rootRouteRef,\n }),\n );\n\n/**\n * @public\n */\nexport const SearchBar: ComponentType<SearchBarProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'SearchBar',\n component: {\n lazy: () => import('./components/SearchBar').then(m => m.SearchBar),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const QuickAccessCard: ComponentType<QuickAccessCardProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'QuickAccessCard',\n component: {\n lazy: () =>\n import('./components/QuickAccessCard').then(m => m.QuickAccessCard),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const Headline: ComponentType<HeadlineProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'Headline',\n component: {\n lazy: () => import('./components/Headline').then(m => m.Headline),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const Markdown: ComponentType<MarkdownProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'Markdown',\n component: {\n lazy: () => import('./components/Markdown').then(m => m.Markdown),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const MarkdownCard: ComponentType<MarkdownCardProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'MarkdownCard',\n component: {\n lazy: () =>\n import('./components/MarkdownCard').then(m => m.MarkdownCard),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const Placeholder: ComponentType<PlaceholderProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'Placeholder',\n component: {\n lazy: () => import('./components/Placeholder').then(m => m.Placeholder),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const CatalogStarredEntitiesCard: ComponentType<StarredEntitiesProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'CatalogStarredEntitiesCard',\n component: {\n lazy: () =>\n import('@backstage/plugin-home').then(m => m.HomePageStarredEntities),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const RecentlyVisitedCard: ComponentType<VisitedByTypeProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'RecentlyVisitedCard',\n component: {\n lazy: () =>\n import('@backstage/plugin-home').then(m => m.HomePageRecentlyVisited),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const TopVisitedCard: ComponentType<VisitedByTypeProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'TopVisitedCard',\n component: {\n lazy: () =>\n import('@backstage/plugin-home').then(m => m.HomePageTopVisited),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const FeaturedDocsCard: ComponentType<FeaturedDocsCardProps> =\n dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'FeaturedDocsCard',\n component: {\n lazy: () =>\n import('./components/FeaturedDocsCard').then(m => m.FeaturedDocsCard),\n },\n }),\n );\n\n/**\n * @public\n */\nexport const JokeCard: ComponentType<{\n defaultCategory?: 'any' | 'programming';\n}> = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'JokeCard',\n component: {\n lazy: () =>\n import('@backstage/plugin-home').then(m => m.HomePageRandomJoke),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const VisitListener = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'VisitListener',\n component: {\n lazy: () =>\n import('./components/VisitListener').then(m => m.VisitListener),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const WorldClock = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'WorldClock',\n component: {\n lazy: () => import('./components/WorldClock').then(m => m.WorldClock),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const OnboardingSection = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'OnboardingSection',\n component: {\n lazy: () =>\n import('./components/OnboardingSection').then(m => m.OnboardingSection),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const EntitySection = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'EntitySection',\n component: {\n lazy: () =>\n import('./components/EntitySection').then(m => m.EntitySection),\n },\n }),\n);\n\n/**\n * @public\n */\nexport const TemplateSection = dynamicHomePagePlugin.provide(\n createComponentExtension({\n name: 'TemplateSection',\n component: {\n lazy: () =>\n import('./components/TemplateSection').then(m => m.TemplateSection),\n },\n }),\n);\n"],"names":[],"mappings":";;;;;AAsEO,MAAM,wBAAwB,YAAa,CAAA;AAAA,EAChD,EAAI,EAAA,mBAAA;AAAA,EACJ,MAAQ,EAAA;AAAA,IACN,IAAM,EAAA;AAAA,GACR;AAAA,EACA,IAAM,EAAA;AAAA,IACJ,gBAAiB,CAAA;AAAA,MACf,GAAK,EAAA,iBAAA;AAAA,MACL,IAAM,EAAA;AAAA,QACJ,YAAc,EAAA,eAAA;AAAA,QACd,SAAW,EAAA,YAAA;AAAA,QACX,WAAa,EAAA;AAAA,OACf;AAAA,MACA,OAAS,EAAA,CAAC,EAAE,YAAA,EAAc,SAAW,EAAA,WAAA,EACnC,KAAA,IAAI,oBAAqB,CAAA,EAAE,YAAc,EAAA,SAAA,EAAW,aAAa;AAAA,KACpE,CAA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AM,OAAO,gCAAyB,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,UAAU;AAAA;AACtE,GACD;AACH;AAKO,MAAM,oBAAoB,qBAAsB,CAAA,OAAA;AAAA,EACrD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,mBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MACJ,OAAO,6CAAgC,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,iBAAiB;AAAA;AAC1E,GACD;AACH;AAKO,MAAM,gBAAgB,qBAAsB,CAAA,OAAA;AAAA,EACjD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,eAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MACJ,OAAO,yCAA4B,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,aAAa;AAAA;AAClE,GACD;AACH;AAKO,MAAM,kBAAkB,qBAAsB,CAAA,OAAA;AAAA,EACnD,wBAAyB,CAAA;AAAA,IACvB,IAAM,EAAA,iBAAA;AAAA,IACN,SAAW,EAAA;AAAA,MACT,IAAA,EAAM,MACJ,OAAO,2CAA8B,EAAE,IAAK,CAAA,CAAA,CAAA,KAAK,EAAE,eAAe;AAAA;AACtE,GACD;AACH;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
const getTranslatedTextWithFallback = (t, translationKey, fallbackText) => {
|
|
2
|
+
if (!translationKey) {
|
|
3
|
+
return fallbackText;
|
|
4
|
+
}
|
|
5
|
+
const translation = t(translationKey, {});
|
|
6
|
+
return translation !== translationKey ? translation : fallbackText;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export { getTranslatedTextWithFallback };
|
|
10
|
+
//# sourceMappingURL=utils.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.esm.js","sources":["../../src/translations/utils.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 */\nimport { TranslationFunction } from '@backstage/core-plugin-api/alpha';\n\nimport { homepageTranslationRef } from './ref';\n\n/**\n * Utility function to get translated text with fallback to original text\n *\n * @param t - Translation function\n * @param translationKey - Optional translation key to look up\n * @param fallbackText - Text to display if translation key is not provided or translation is not found\n * @returns Translated text or fallback text\n */\nexport const getTranslatedTextWithFallback = (\n t: TranslationFunction<typeof homepageTranslationRef.T>,\n translationKey: string | undefined,\n fallbackText: string | undefined,\n): string | undefined => {\n if (!translationKey) {\n return fallbackText;\n }\n\n const translation = t(translationKey as keyof typeof t, {});\n return translation !== translationKey ? translation : fallbackText;\n};\n"],"names":[],"mappings":"AA2BO,MAAM,6BAAgC,GAAA,CAC3C,CACA,EAAA,cAAA,EACA,YACuB,KAAA;AACvB,EAAA,IAAI,CAAC,cAAgB,EAAA;AACnB,IAAO,OAAA,YAAA;AAAA;AAGT,EAAA,MAAM,WAAc,GAAA,CAAA,CAAE,cAAkC,EAAA,EAAE,CAAA;AAC1D,EAAO,OAAA,WAAA,KAAgB,iBAAiB,WAAc,GAAA,YAAA;AACxD;;;;"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { getTranslatedTextWithFallback } from '../translations/utils.esm.js';
|
|
2
|
+
|
|
3
|
+
function isCardADefaultConfiguration(cardMountPoint) {
|
|
4
|
+
return !!cardMountPoint.config?.layouts || !cardMountPoint.config?.id;
|
|
5
|
+
}
|
|
6
|
+
function getComponentDisplayName(cardMountPoint) {
|
|
7
|
+
const displayName = cardMountPoint.Component.displayName;
|
|
8
|
+
if (displayName?.includes("Extension(")) {
|
|
9
|
+
return displayName.replace("Extension(", "").replace(")", "");
|
|
10
|
+
}
|
|
11
|
+
return displayName;
|
|
12
|
+
}
|
|
13
|
+
function getCardTitle(t, cardMountPoint) {
|
|
14
|
+
return getTranslatedTextWithFallback(
|
|
15
|
+
t,
|
|
16
|
+
cardMountPoint.config?.titleKey,
|
|
17
|
+
cardMountPoint.config?.title
|
|
18
|
+
) ?? getComponentDisplayName(cardMountPoint);
|
|
19
|
+
}
|
|
20
|
+
function getCardDescription(t, cardMountPoint) {
|
|
21
|
+
const title = getCardTitle(t, cardMountPoint);
|
|
22
|
+
const description = getTranslatedTextWithFallback(
|
|
23
|
+
t,
|
|
24
|
+
cardMountPoint.config?.descriptionKey,
|
|
25
|
+
cardMountPoint.config?.description
|
|
26
|
+
) ?? cardMountPoint.config?.props?.title ?? cardMountPoint.config?.props?.debugContent;
|
|
27
|
+
return title === description ? undefined : description;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export { getCardDescription, getCardTitle, isCardADefaultConfiguration };
|
|
31
|
+
//# sourceMappingURL=customizable-cards.esm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"customizable-cards.esm.js","sources":["../../src/utils/customizable-cards.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 { TranslationFunction } from '@backstage/core-plugin-api/alpha';\n\nimport { HomePageCardMountPoint } from '../types';\nimport { homepageTranslationRef } from '../translations';\nimport { getTranslatedTextWithFallback } from '../translations/utils';\n\n/**\n * Util function that decides if a `home.page/card` mount point will be rendered\n * as 'default card' or just as 'available card'.\n *\n * This is needed when customization is enabled and if customers might adopt\n * the customization in yaml feature previously.\n *\n * 1. Card mount points with a `config.layout` should be shown by default.\n * 2. Card mount points without a `config.id` should be shown by default\n * as well for backward compatibilty!\n */\nexport function isCardADefaultConfiguration(\n cardMountPoint: HomePageCardMountPoint,\n): boolean {\n return !!cardMountPoint.config?.layouts || !cardMountPoint.config?.id;\n}\n\nfunction getComponentDisplayName(\n cardMountPoint: HomePageCardMountPoint,\n): string | undefined {\n const displayName = cardMountPoint.Component.displayName;\n if (displayName?.includes('Extension(')) {\n return displayName.replace('Extension(', '').replace(')', '');\n }\n return displayName;\n}\n\nexport function getCardTitle(\n t: TranslationFunction<typeof homepageTranslationRef.T>,\n cardMountPoint: HomePageCardMountPoint,\n): string | undefined {\n return (\n getTranslatedTextWithFallback(\n t,\n cardMountPoint.config?.titleKey,\n cardMountPoint.config?.title,\n ) ?? getComponentDisplayName(cardMountPoint)\n );\n}\n\nexport function getCardDescription(\n t: TranslationFunction<typeof homepageTranslationRef.T>,\n cardMountPoint: HomePageCardMountPoint,\n): string | undefined {\n const title = getCardTitle(t, cardMountPoint);\n const description =\n getTranslatedTextWithFallback(\n t,\n cardMountPoint.config?.descriptionKey,\n cardMountPoint.config?.description,\n ) ??\n cardMountPoint.config?.props?.title ??\n cardMountPoint.config?.props?.debugContent;\n return title === description ? undefined : description;\n}\n"],"names":[],"mappings":";;AAiCO,SAAS,4BACd,cACS,EAAA;AACT,EAAA,OAAO,CAAC,CAAC,cAAA,CAAe,QAAQ,OAAW,IAAA,CAAC,eAAe,MAAQ,EAAA,EAAA;AACrE;AAEA,SAAS,wBACP,cACoB,EAAA;AACpB,EAAM,MAAA,WAAA,GAAc,eAAe,SAAU,CAAA,WAAA;AAC7C,EAAI,IAAA,WAAA,EAAa,QAAS,CAAA,YAAY,CAAG,EAAA;AACvC,IAAA,OAAO,YAAY,OAAQ,CAAA,YAAA,EAAc,EAAE,CAAE,CAAA,OAAA,CAAQ,KAAK,EAAE,CAAA;AAAA;AAE9D,EAAO,OAAA,WAAA;AACT;AAEgB,SAAA,YAAA,CACd,GACA,cACoB,EAAA;AACpB,EACE,OAAA,6BAAA;AAAA,IACE,CAAA;AAAA,IACA,eAAe,MAAQ,EAAA,QAAA;AAAA,IACvB,eAAe,MAAQ,EAAA;AAAA,GACzB,IAAK,wBAAwB,cAAc,CAAA;AAE/C;AAEgB,SAAA,kBAAA,CACd,GACA,cACoB,EAAA;AACpB,EAAM,MAAA,KAAA,GAAQ,YAAa,CAAA,CAAA,EAAG,cAAc,CAAA;AAC5C,EAAA,MAAM,WACJ,GAAA,6BAAA;AAAA,IACE,CAAA;AAAA,IACA,eAAe,MAAQ,EAAA,cAAA;AAAA,IACvB,eAAe,MAAQ,EAAA;AAAA,OAEzB,cAAe,CAAA,MAAA,EAAQ,OAAO,KAC9B,IAAA,cAAA,CAAe,QAAQ,KAAO,EAAA,YAAA;AAChC,EAAO,OAAA,KAAA,KAAU,cAAc,SAAY,GAAA,WAAA;AAC7C;;;;"}
|
package/package.json
CHANGED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import { Page, Content, EmptyState } from '@backstage/core-components';
|
|
4
|
-
import { useTranslation } from '../hooks/useTranslation.esm.js';
|
|
5
|
-
import { Header } from './Header.esm.js';
|
|
6
|
-
import { CustomizableGrid } from './CustomizableGrid.esm.js';
|
|
7
|
-
|
|
8
|
-
const CustomizableHomePage = (props) => {
|
|
9
|
-
const { t } = useTranslation();
|
|
10
|
-
const filteredAndSortedHomePageCards = useMemo(() => {
|
|
11
|
-
if (!props.cards) {
|
|
12
|
-
return [];
|
|
13
|
-
}
|
|
14
|
-
const filteredAndSorted = props.cards.filter(
|
|
15
|
-
(card) => card.enabled !== false && (!card.config?.priority || card.config.priority >= 0)
|
|
16
|
-
);
|
|
17
|
-
filteredAndSorted.sort(
|
|
18
|
-
(a, b) => (b.config?.priority ?? 0) - (a.config?.priority ?? 0)
|
|
19
|
-
);
|
|
20
|
-
return filteredAndSorted;
|
|
21
|
-
}, [props.cards]);
|
|
22
|
-
return /* @__PURE__ */ jsxs(Page, { themeId: "home", children: [
|
|
23
|
-
/* @__PURE__ */ jsx(Header, { ...props }),
|
|
24
|
-
/* @__PURE__ */ jsx(Content, { children: filteredAndSortedHomePageCards.length === 0 ? /* @__PURE__ */ jsx(EmptyState, { title: t("homePage.empty"), missing: "content" }) : /* @__PURE__ */ jsx(CustomizableGrid, { mountPoints: filteredAndSortedHomePageCards }) })
|
|
25
|
-
] });
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export { CustomizableHomePage };
|
|
29
|
-
//# sourceMappingURL=CustomizableHomePage.esm.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 </Page>\n );\n};\n"],"names":[],"mappings":";;;;;;;AA8Ba,MAAA,oBAAA,GAAuB,CAAC,KAAyB,KAAA;AAC5D,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,oBAAC,GAAA,CAAA,MAAA,EAAA,EAAQ,GAAG,KAAO,EAAA,CAAA;AAAA,wBAClB,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,gBAAiB,EAAA,EAAA,WAAA,EAAa,gCAAgC,CAEnE,EAAA;AAAA,GACF,EAAA,CAAA;AAEJ;;;;"}
|
package/dist/defaults.esm.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
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
|
-
quickAccessCard: {
|
|
27
|
-
xl: { w: 6, h: 8, x: 6 },
|
|
28
|
-
lg: { w: 6, h: 8, x: 6 },
|
|
29
|
-
md: { w: 6, h: 8, x: 6 },
|
|
30
|
-
sm: { w: 12, h: 8, x: 6 },
|
|
31
|
-
xs: { w: 12, h: 8, x: 6 },
|
|
32
|
-
xxs: { w: 12, h: 8, x: 6 }
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export { defaultLayouts };
|
|
37
|
-
//# sourceMappingURL=defaults.esm.js.map
|
package/dist/defaults.esm.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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 quickAccessCard: {\n xl: { w: 6, h: 8, x: 6 },\n lg: { w: 6, h: 8, x: 6 },\n md: { w: 6, h: 8, x: 6 },\n sm: { w: 12, h: 8, x: 6 },\n xs: { w: 12, h: 8, x: 6 },\n xxs: { w: 12, h: 8, x: 6 },\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,EA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