@red-hat-developer-hub/backstage-plugin-dynamic-home-page 1.10.6 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/README.md +93 -1
  3. package/dist/alpha/components/CustomizableGridLayout.esm.js +70 -0
  4. package/dist/alpha/components/CustomizableGridLayout.esm.js.map +1 -0
  5. package/dist/alpha/components/HomePageLayout.esm.js +25 -0
  6. package/dist/alpha/components/HomePageLayout.esm.js.map +1 -0
  7. package/dist/alpha/components/ReadOnlyGirdLayout.esm.js +137 -0
  8. package/dist/alpha/components/ReadOnlyGirdLayout.esm.js.map +1 -0
  9. package/dist/alpha/extensions/apis.esm.js +19 -0
  10. package/dist/alpha/extensions/apis.esm.js.map +1 -0
  11. package/dist/alpha/extensions/homePageCards.esm.js +117 -0
  12. package/dist/alpha/extensions/homePageCards.esm.js.map +1 -0
  13. package/dist/alpha/extensions/homePageLayoutExtension.esm.js +57 -0
  14. package/dist/alpha/extensions/homePageLayoutExtension.esm.js.map +1 -0
  15. package/dist/alpha/utils.esm.js +6 -0
  16. package/dist/alpha/utils.esm.js.map +1 -0
  17. package/dist/alpha.d.ts +77 -0
  18. package/dist/alpha.esm.js +39 -0
  19. package/dist/alpha.esm.js.map +1 -0
  20. package/dist/components/CustomizableGrid.esm.js +17 -7
  21. package/dist/components/CustomizableGrid.esm.js.map +1 -1
  22. package/dist/components/EntitySection/EntityCard.esm.js +6 -1
  23. package/dist/components/EntitySection/EntityCard.esm.js.map +1 -1
  24. package/dist/components/EntitySection/EntitySection.esm.js +143 -100
  25. package/dist/components/EntitySection/EntitySection.esm.js.map +1 -1
  26. package/dist/components/OnboardingSection/OnboardingCard.esm.js +3 -0
  27. package/dist/components/OnboardingSection/OnboardingCard.esm.js.map +1 -1
  28. package/dist/components/OnboardingSection/OnboardingSection.esm.js +33 -17
  29. package/dist/components/OnboardingSection/OnboardingSection.esm.js.map +1 -1
  30. package/dist/components/TemplateSection/TemplateSection.esm.js +87 -47
  31. package/dist/components/TemplateSection/TemplateSection.esm.js.map +1 -1
  32. package/dist/hooks/useContainerQuery.esm.js +78 -0
  33. package/dist/hooks/useContainerQuery.esm.js.map +1 -0
  34. package/dist/index.d.ts +11 -67
  35. package/dist/index.esm.js +0 -2
  36. package/dist/index.esm.js.map +1 -1
  37. package/dist/translations/de.esm.js +1 -1
  38. package/dist/translations/de.esm.js.map +1 -1
  39. package/dist/translations/es.esm.js +1 -1
  40. package/dist/translations/es.esm.js.map +1 -1
  41. package/dist/translations/fr.esm.js +1 -1
  42. package/dist/translations/fr.esm.js.map +1 -1
  43. package/dist/translations/index.esm.js.map +1 -1
  44. package/dist/translations/it.esm.js +1 -1
  45. package/dist/translations/it.esm.js.map +1 -1
  46. package/dist/translations/ja.esm.js +1 -1
  47. package/dist/translations/ja.esm.js.map +1 -1
  48. package/dist/translations/ref.esm.js +1 -1
  49. package/dist/translations/ref.esm.js.map +1 -1
  50. package/dist/utils/GridItem.esm.js +31 -0
  51. package/dist/utils/GridItem.esm.js.map +1 -0
  52. package/package.json +48 -29
@@ -0,0 +1,77 @@
1
+ import * as _backstage_frontend_plugin_api from '@backstage/frontend-plugin-api';
2
+
3
+ /**
4
+ * Translation ref for the Dynamic Home Page plugin.
5
+ * Defines all translation keys used in the plugin.
6
+ *
7
+ * @public
8
+ */
9
+ declare const homepageTranslationRef: _backstage_frontend_plugin_api.TranslationRef<"plugin.homepage", {
10
+ readonly "header.local": string;
11
+ readonly "header.welcome": string;
12
+ readonly "header.welcomePersonalized": string;
13
+ readonly "search.placeholder": string;
14
+ readonly "homePage.empty": string;
15
+ readonly "quickAccess.title": string;
16
+ readonly "quickAccess.error": string;
17
+ readonly "quickAccess.fetchError": string;
18
+ readonly "featuredDocs.learnMore": string;
19
+ readonly "templates.title": string;
20
+ readonly "templates.error": string;
21
+ readonly "templates.empty": string;
22
+ readonly "templates.fetchError": string;
23
+ readonly "templates.emptyDescription": string;
24
+ readonly "templates.register": string;
25
+ readonly "templates.viewAll": string;
26
+ readonly "onboarding.guest": string;
27
+ readonly "onboarding.greeting.goodMorning": string;
28
+ readonly "onboarding.greeting.goodAfternoon": string;
29
+ readonly "onboarding.greeting.goodEvening": string;
30
+ readonly "onboarding.getStarted.title": string;
31
+ readonly "onboarding.getStarted.description": string;
32
+ readonly "onboarding.getStarted.buttonText": string;
33
+ readonly "onboarding.getStarted.ariaLabel": string;
34
+ readonly "onboarding.explore.title": string;
35
+ readonly "onboarding.explore.description": string;
36
+ readonly "onboarding.explore.buttonText": string;
37
+ readonly "onboarding.explore.ariaLabel": string;
38
+ readonly "onboarding.learn.title": string;
39
+ readonly "onboarding.learn.description": string;
40
+ readonly "onboarding.learn.buttonText": string;
41
+ readonly "onboarding.learn.ariaLabel": string;
42
+ readonly "entities.title": string;
43
+ readonly "entities.error": string;
44
+ readonly "entities.description": string;
45
+ readonly "entities.close": string;
46
+ readonly "entities.empty": string;
47
+ readonly "entities.fetchError": string;
48
+ readonly "entities.emptyDescription": string;
49
+ readonly "entities.register": string;
50
+ readonly "entities.browseTheCatalog": string;
51
+ }>;
52
+
53
+ /**
54
+ * Translation resource for the Dynamic Home Page plugin (en, de, es, fr, it, ja).
55
+ *
56
+ * @public
57
+ */
58
+ declare const homepageTranslations: _backstage_frontend_plugin_api.TranslationResource<"plugin.homepage">;
59
+
60
+ /**
61
+ * Frontend module for the Dynamic Home Page plugin (New Frontend System).
62
+ *
63
+ * Extends the `home` plugin with a custom layout and RHDH widgets: Onboarding,
64
+ * Entity Catalog, Templates, Quick Access, Search, Recently Visited, Top Visited, etc.
65
+ * Add to your app's `createApp({ features: [..., homePageDevModule] })`.
66
+ *
67
+ * @alpha
68
+ */
69
+ declare const homePageModule: _backstage_frontend_plugin_api.FrontendModule;
70
+ /**
71
+ * Translation module for the Dynamic Home Page plugin.
72
+ *
73
+ * @alpha
74
+ */
75
+ declare const homepageTranslationsModule: _backstage_frontend_plugin_api.FrontendModule;
76
+
77
+ export { homePageModule, homepageTranslationRef, homepageTranslations, homepageTranslationsModule };
@@ -0,0 +1,39 @@
1
+ import { TranslationBlueprint } from '@backstage/plugin-app-react';
2
+ import { createFrontendModule } from '@backstage/frontend-plugin-api';
3
+ import { onboardingSectionWidget, entitySectionWidget, templateSectionWidget, quickAccessCardWidget, featuredDocsCardWidget, searchBarWidget, TopVisitedWidget, RecentlyVisitedWidget, catalogStarredWidget, disableToolkit } from './alpha/extensions/homePageCards.esm.js';
4
+ import { homepageTranslations } from './translations/index.esm.js';
5
+ import { homePageLayoutExtension } from './alpha/extensions/homePageLayoutExtension.esm.js';
6
+ import { quickAccessApi } from './alpha/extensions/apis.esm.js';
7
+ export { homepageTranslationRef } from './translations/ref.esm.js';
8
+
9
+ const homePageModule = createFrontendModule({
10
+ pluginId: "home",
11
+ extensions: [
12
+ homePageLayoutExtension,
13
+ onboardingSectionWidget,
14
+ entitySectionWidget,
15
+ templateSectionWidget,
16
+ quickAccessApi,
17
+ quickAccessCardWidget,
18
+ featuredDocsCardWidget,
19
+ searchBarWidget,
20
+ TopVisitedWidget,
21
+ RecentlyVisitedWidget,
22
+ catalogStarredWidget,
23
+ disableToolkit
24
+ ]
25
+ });
26
+ const homepageTranslationsModule = createFrontendModule({
27
+ pluginId: "app",
28
+ extensions: [
29
+ TranslationBlueprint.make({
30
+ name: "homepage-translations",
31
+ params: {
32
+ resource: homepageTranslations
33
+ }
34
+ })
35
+ ]
36
+ });
37
+
38
+ export { homePageModule, homepageTranslations, homepageTranslationsModule };
39
+ //# sourceMappingURL=alpha.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"alpha.esm.js","sources":["../src/alpha/index.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 { TranslationBlueprint } from '@backstage/plugin-app-react';\nimport { createFrontendModule } from '@backstage/frontend-plugin-api';\nimport {\n catalogStarredWidget,\n disableToolkit,\n entitySectionWidget,\n featuredDocsCardWidget,\n onboardingSectionWidget,\n quickAccessCardWidget,\n RecentlyVisitedWidget,\n searchBarWidget,\n templateSectionWidget,\n TopVisitedWidget,\n} from './extensions/homePageCards';\nimport { homepageTranslations } from '../translations';\n\nimport { homePageLayoutExtension } from './extensions/homePageLayoutExtension';\nimport { quickAccessApi } from './extensions/apis';\n\n/**\n * Frontend module for the Dynamic Home Page plugin (New Frontend System).\n *\n * Extends the `home` plugin with a custom layout and RHDH widgets: Onboarding,\n * Entity Catalog, Templates, Quick Access, Search, Recently Visited, Top Visited, etc.\n * Add to your app's `createApp({ features: [..., homePageDevModule] })`.\n *\n * @alpha\n */\nexport const homePageModule = createFrontendModule({\n pluginId: 'home',\n extensions: [\n homePageLayoutExtension,\n onboardingSectionWidget,\n entitySectionWidget,\n templateSectionWidget,\n quickAccessApi,\n quickAccessCardWidget,\n featuredDocsCardWidget,\n searchBarWidget,\n TopVisitedWidget,\n RecentlyVisitedWidget,\n catalogStarredWidget,\n disableToolkit,\n ],\n});\n\n/**\n * Translation module for the Dynamic Home Page plugin.\n *\n * @alpha\n */\nexport const homepageTranslationsModule = createFrontendModule({\n pluginId: 'app',\n extensions: [\n TranslationBlueprint.make({\n name: 'homepage-translations',\n params: {\n resource: homepageTranslations,\n },\n }),\n ],\n});\n\n/**\n *\n * @alpha\n */\nexport { homepageTranslationRef, homepageTranslations } from '../translations';\n"],"names":[],"mappings":";;;;;;;;AA4CO,MAAM,iBAAiB,oBAAqB,CAAA;AAAA,EACjD,QAAU,EAAA,MAAA;AAAA,EACV,UAAY,EAAA;AAAA,IACV,uBAAA;AAAA,IACA,uBAAA;AAAA,IACA,mBAAA;AAAA,IACA,qBAAA;AAAA,IACA,cAAA;AAAA,IACA,qBAAA;AAAA,IACA,sBAAA;AAAA,IACA,eAAA;AAAA,IACA,gBAAA;AAAA,IACA,qBAAA;AAAA,IACA,oBAAA;AAAA,IACA;AAAA;AAEJ,CAAC;AAOM,MAAM,6BAA6B,oBAAqB,CAAA;AAAA,EAC7D,QAAU,EAAA,KAAA;AAAA,EACV,UAAY,EAAA;AAAA,IACV,qBAAqB,IAAK,CAAA;AAAA,MACxB,IAAM,EAAA,uBAAA;AAAA,MACN,MAAQ,EAAA;AAAA,QACN,QAAU,EAAA;AAAA;AACZ,KACD;AAAA;AAEL,CAAC;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
- import { useMemo } from 'react';
2
+ import { useRef, useMemo } from 'react';
3
3
  import { CustomHomepageGrid } from '@backstage/plugin-home';
4
4
  import { createCardExtension } from '@backstage/plugin-home-react';
5
5
  import GlobalStyles from '@mui/material/GlobalStyles';
@@ -7,11 +7,14 @@ import { useTheme } from '@mui/material/styles';
7
7
  import 'react-grid-layout/css/styles.css';
8
8
  import { dynamicHomePagePlugin } from '../plugin.esm.js';
9
9
  import { useTranslation } from '../hooks/useTranslation.esm.js';
10
+ import { useContainerQuery } from '../hooks/useContainerQuery.esm.js';
10
11
  import { getCardTitle, getCardDescription, isCardADefaultConfiguration } from '../utils/customizable-cards.esm.js';
11
12
 
12
13
  const CustomizableGrid = ({ mountPoints }) => {
13
14
  const theme = useTheme();
14
15
  const { t } = useTranslation();
16
+ const gridContainerRef = useRef(null);
17
+ useContainerQuery(gridContainerRef, { notifyWindowResize: true });
15
18
  const { children, config } = useMemo(() => {
16
19
  const childDictionary = {};
17
20
  const defaultConfig = [];
@@ -77,13 +80,20 @@ const CustomizableGrid = ({ mountPoints }) => {
77
80
  }
78
81
  ),
79
82
  /* @__PURE__ */ jsx(
80
- CustomHomepageGrid,
83
+ "div",
81
84
  {
82
- config,
83
- preventCollision: false,
84
- compactType: "vertical",
85
- style: { margin: "-10px" },
86
- children
85
+ ref: gridContainerRef,
86
+ style: { width: "100%", minWidth: 0, boxSizing: "border-box" },
87
+ children: /* @__PURE__ */ jsx(
88
+ CustomHomepageGrid,
89
+ {
90
+ config,
91
+ preventCollision: false,
92
+ compactType: "vertical",
93
+ style: { margin: "-10px" },
94
+ children
95
+ }
96
+ )
87
97
  }
88
98
  )
89
99
  ] });
@@ -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 { 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,CA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AAA,IAAA;AAAA,QAAK,CAAC,CAAA,EAAG,CACR,KAAA,CAAA,CAAE,KAAS,IAAA,CAAA,CAAE,KAAQ,GAAA,CAAA,CAAE,KAAM,CAAA,aAAA,CAAc,CAAE,CAAA,KAAK,CAAI,GAAA;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
+ {"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, useRef } 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 { useContainerQuery } from '../hooks/useContainerQuery';\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 const gridContainerRef = useRef<HTMLDivElement>(null);\n useContainerQuery(gridContainerRef, { notifyWindowResize: true });\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 <div\n ref={gridContainerRef}\n style={{ width: '100%', minWidth: 0, boxSizing: 'border-box' }}\n >\n <CustomHomepageGrid\n config={config}\n preventCollision={false}\n compactType=\"vertical\"\n style={{ margin: '-10px' }}\n >\n {children}\n </CustomHomepageGrid>\n </div>\n </>\n );\n};\n"],"names":[],"mappings":";;;;;;;;;;;;AA4DO,MAAM,gBAAmB,GAAA,CAAC,EAAE,WAAA,EAAyC,KAAA;AAC1E,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,EAAE,CAAE,EAAA,GAAI,cAAe,EAAA;AAC7B,EAAM,MAAA,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BAAA,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,KAAA;AAAA,MAAA;AAAA,QACC,GAAK,EAAA,gBAAA;AAAA,QACL,OAAO,EAAE,KAAA,EAAO,QAAQ,QAAU,EAAA,CAAA,EAAG,WAAW,YAAa,EAAA;AAAA,QAE7D,QAAA,kBAAA,GAAA;AAAA,UAAC,kBAAA;AAAA,UAAA;AAAA,YACC,MAAA;AAAA,YACA,gBAAkB,EAAA,KAAA;AAAA,YAClB,WAAY,EAAA,UAAA;AAAA,YACZ,KAAA,EAAO,EAAE,MAAA,EAAQ,OAAQ,EAAA;AAAA,YAExB;AAAA;AAAA;AACH;AAAA;AACF,GACF,EAAA,CAAA;AAEJ;;;;"}
@@ -19,14 +19,19 @@ const EntityCard = ({
19
19
  {
20
20
  elevation: 0,
21
21
  sx: {
22
+ height: "100%",
22
23
  border: (theme) => `1px solid ${theme.palette.grey[400]}`,
23
24
  overflow: "auto",
24
- maxHeight: "100%"
25
+ display: "flex",
26
+ flexDirection: "column"
25
27
  },
26
28
  children: /* @__PURE__ */ jsxs(
27
29
  CardContent,
28
30
  {
29
31
  sx: {
32
+ flex: 1,
33
+ display: "flex",
34
+ flexDirection: "column",
30
35
  pb: 2,
31
36
  "&:last-child": {
32
37
  pb: 2
@@ -1 +1 @@
1
- {"version":3,"file":"EntityCard.esm.js","sources":["../../../src/components/EntitySection/EntityCard.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 { FC } from 'react';\n\nimport { EntityRefLink } from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { MarkdownContent } from '@backstage/core-components';\n\nimport CardContent from '@mui/material/CardContent';\nimport Typography from '@mui/material/Typography';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\n\nimport TagList from './TagList';\n\ninterface EntityCardProps {\n title: string;\n version?: string;\n description: string;\n tags: string[];\n kind: string;\n entity: Entity;\n}\n\nconst EntityCard: FC<EntityCardProps> = ({\n title,\n description,\n tags,\n kind,\n entity,\n}) => {\n return (\n <Card\n elevation={0}\n sx={{\n border: theme => `1px solid ${theme.palette.grey[400]}`,\n overflow: 'auto',\n maxHeight: '100%',\n }}\n >\n <CardContent\n sx={{\n pb: 2,\n '&:last-child': {\n pb: 2,\n },\n backgroundColor: 'transparent',\n }}\n >\n <Box sx={{ overflow: 'hidden' }}>\n <EntityRefLink\n entityRef={entity}\n style={{\n display: '-webkit-box',\n WebkitBoxOrient: 'vertical',\n WebkitLineClamp: 1,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n fontSize: '0.875rem',\n fontWeight: '500',\n textDecoration: 'underline',\n }}\n >\n {title}\n </EntityRefLink>\n </Box>\n <Box\n sx={{\n pt: 2,\n height: '175px',\n overflow: 'hidden',\n }}\n >\n <Typography\n variant=\"body2\"\n paragraph\n sx={{\n display: '-webkit-box',\n WebkitLineClamp: 8,\n WebkitBoxOrient: 'vertical',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n '& p': {\n margin: 'auto',\n },\n }}\n >\n <MarkdownContent content={description} />\n </Typography>\n </Box>\n <TagList kind={kind} tags={tags} />\n </CardContent>\n </Card>\n );\n};\n\nexport default EntityCard;\n"],"names":[],"mappings":";;;;;;;;;AAqCA,MAAM,aAAkC,CAAC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AAA,OAAA;AAAA,kBACR,QAAU,EAAA;AAAA,iBACZ;AAAA,gBAEA,QAAA,kBAAA,GAAA;AAAA,kBAAC,UAAA;AAAA,kBAAA;AAAA,oBACC,OAAQ,EAAA,OAAA;AAAA,oBACR,SAAS,EAAA,IAAA;AAAA,oBACT,EAAI,EAAA;AAAA,sBACF,OAAS,EAAA,aAAA;AAAA,sBACT,eAAiB,EAAA,CAAA;AAAA,sBACjB,eAAiB,EAAA,UAAA;AAAA,sBACjB,QAAU,EAAA,QAAA;AAAA,sBACV,YAAc,EAAA,UAAA;AAAA,sBACd,KAAO,EAAA;AAAA,wBACL,MAAQ,EAAA;AAAA;AACV,qBACF;AAAA,oBAEA,QAAA,kBAAA,GAAA,CAAC,eAAgB,EAAA,EAAA,OAAA,EAAS,WAAa,EAAA;AAAA;AAAA;AACzC;AAAA,aACF;AAAA,4BACA,GAAA,CAAC,OAAQ,EAAA,EAAA,IAAA,EAAY,IAAY,EAAA;AAAA;AAAA;AAAA;AACnC;AAAA,GACF;AAEJ;;;;"}
1
+ {"version":3,"file":"EntityCard.esm.js","sources":["../../../src/components/EntitySection/EntityCard.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 { FC } from 'react';\n\nimport { EntityRefLink } from '@backstage/plugin-catalog-react';\nimport { Entity } from '@backstage/catalog-model';\nimport { MarkdownContent } from '@backstage/core-components';\n\nimport CardContent from '@mui/material/CardContent';\nimport Typography from '@mui/material/Typography';\nimport Box from '@mui/material/Box';\nimport Card from '@mui/material/Card';\n\nimport TagList from './TagList';\n\ninterface EntityCardProps {\n title: string;\n version?: string;\n description: string;\n tags: string[];\n kind: string;\n entity: Entity;\n}\n\nconst EntityCard: FC<EntityCardProps> = ({\n title,\n description,\n tags,\n kind,\n entity,\n}) => {\n return (\n <Card\n elevation={0}\n sx={{\n height: '100%',\n border: theme => `1px solid ${theme.palette.grey[400]}`,\n overflow: 'auto',\n display: 'flex',\n flexDirection: 'column',\n }}\n >\n <CardContent\n sx={{\n flex: 1,\n display: 'flex',\n flexDirection: 'column',\n pb: 2,\n '&:last-child': {\n pb: 2,\n },\n backgroundColor: 'transparent',\n }}\n >\n <Box sx={{ overflow: 'hidden' }}>\n <EntityRefLink\n entityRef={entity}\n style={{\n display: '-webkit-box',\n WebkitBoxOrient: 'vertical',\n WebkitLineClamp: 1,\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n fontSize: '0.875rem',\n fontWeight: '500',\n textDecoration: 'underline',\n }}\n >\n {title}\n </EntityRefLink>\n </Box>\n <Box\n sx={{\n pt: 2,\n height: '175px',\n overflow: 'hidden',\n }}\n >\n <Typography\n variant=\"body2\"\n paragraph\n sx={{\n display: '-webkit-box',\n WebkitLineClamp: 8,\n WebkitBoxOrient: 'vertical',\n overflow: 'hidden',\n textOverflow: 'ellipsis',\n '& p': {\n margin: 'auto',\n },\n }}\n >\n <MarkdownContent content={description} />\n </Typography>\n </Box>\n <TagList kind={kind} tags={tags} />\n </CardContent>\n </Card>\n );\n};\n\nexport default EntityCard;\n"],"names":[],"mappings":";;;;;;;;;AAqCA,MAAM,aAAkC,CAAC;AAAA,EACvC,KAAA;AAAA,EACA,WAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAM,KAAA;AACJ,EACE,uBAAA,GAAA;AAAA,IAAC,IAAA;AAAA,IAAA;AAAA,MACC,SAAW,EAAA,CAAA;AAAA,MACX,EAAI,EAAA;AAAA,QACF,MAAQ,EAAA,MAAA;AAAA,QACR,QAAQ,CAAS,KAAA,KAAA,CAAA,UAAA,E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A,OAAA;AAAA,oBACR,SAAS,EAAA,IAAA;AAAA,oBACT,EAAI,EAAA;AAAA,sBACF,OAAS,EAAA,aAAA;AAAA,sBACT,eAAiB,EAAA,CAAA;AAAA,sBACjB,eAAiB,EAAA,UAAA;AAAA,sBACjB,QAAU,EAAA,QAAA;AAAA,sBACV,YAAc,EAAA,UAAA;AAAA,sBACd,KAAO,EAAA;AAAA,wBACL,MAAQ,EAAA;AAAA;AACV,qBACF;AAAA,oBAEA,QAAA,kBAAA,GAAA,CAAC,eAAgB,EAAA,EAAA,OAAA,EAAS,WAAa,EAAA;AAAA;AAAA;AACzC;AAAA,aACF;AAAA,4BACA,GAAA,CAAC,OAAQ,EAAA,EAAA,IAAA,EAAY,IAAY,EAAA;AAAA;AAAA;AAAA;AACnC;AAAA,GACF;AAEJ;;;;"}
@@ -1,5 +1,5 @@
1
1
  import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useState, useEffect, Fragment } from 'react';
2
+ import { useState, useRef, useEffect, useCallback, Fragment } from 'react';
3
3
  import { Link, WarningPanel, CodeSnippet } from '@backstage/core-components';
4
4
  import { useUserProfile } from '@backstage/plugin-user-settings';
5
5
  import Grid from '@mui/material/Grid';
@@ -12,14 +12,14 @@ import CloseIcon from '@mui/icons-material/Close';
12
12
  import CircularProgress from '@mui/material/CircularProgress';
13
13
  import CardContent from '@mui/material/CardContent';
14
14
  import { styled, useTheme } from '@mui/material/styles';
15
- import useMediaQuery from '@mui/material/useMediaQuery';
16
15
  import EntityCard from './EntityCard.esm.js';
17
16
  import { ViewMoreLink } from './ViewMoreLink.esm.js';
18
17
  import HomePageEntityIllustration from '../../images/homepage-entities-1.svg';
19
18
  import { useEntities } from '../../hooks/useEntities.esm.js';
20
19
  import { hasEntityIllustrationUserDismissed, addDismissedEntityIllustrationUsers } from '../../utils/utils.esm.js';
21
20
  import { useTranslation } from '../../hooks/useTranslation.esm.js';
22
- import { Trans } from '../Trans.esm.js';
21
+ import { containerGridItemSx } from '../../utils/GridItem.esm.js';
22
+ import { useContainerQuery } from '../../hooks/useContainerQuery.esm.js';
23
23
 
24
24
  const StyledLink = styled(Link)(({ theme }) => ({
25
25
  textDecoration: "none",
@@ -36,26 +36,31 @@ const EntitySection = () => {
36
36
  const [isRemoveFirstCard, setIsRemoveFirstCard] = useState(false);
37
37
  const [showDiscoveryCard, setShowDiscoveryCard] = useState(true);
38
38
  const [imgLoaded, setImgLoaded] = useState(false);
39
- const [isMediumBreakpoint, setIsMediumBreakpoint] = useState(false);
40
- const isMd = useMediaQuery(theme.breakpoints.only("md"));
41
- useEffect(() => {
42
- if (isMd) {
43
- setIsMediumBreakpoint(true);
44
- } else {
45
- setIsMediumBreakpoint(false);
46
- }
47
- }, [isMd]);
39
+ const containerRef = useRef(null);
40
+ const containerSize = useContainerQuery(containerRef);
41
+ const entityCardCount = containerSize === "xs" || containerSize === "sm" ? 2 : 4;
42
+ const illustrationWidthMap = {
43
+ md: 180,
44
+ lg: 220,
45
+ xl: 266
46
+ };
47
+ const illustrationWidth = illustrationWidthMap[containerSize] ?? 266;
48
+ const visibleEntitiesCount = (() => {
49
+ const isWide = containerSize === "xl" || containerSize === "lg" || containerSize === "md";
50
+ if (!isWide) return entityCardCount;
51
+ return isRemoveFirstCard ? entityCardCount : entityCardCount - 2;
52
+ })();
48
53
  useEffect(() => {
49
54
  const isUserDismissedEntityIllustration = hasEntityIllustrationUserDismissed(displayName);
50
55
  setIsRemoveFirstCard(isUserDismissedEntityIllustration);
51
56
  }, [displayName]);
52
- const handleClose = () => {
57
+ const handleClose = useCallback(() => {
53
58
  setShowDiscoveryCard(false);
54
59
  setTimeout(() => {
55
60
  addDismissedEntityIllustrationUsers(displayName);
56
61
  setIsRemoveFirstCard(true);
57
62
  }, 500);
58
- };
63
+ }, [displayName]);
59
64
  const { data, error, isLoading } = useEntities({
60
65
  kind: ["Component", "API", "Resource", "System"]
61
66
  });
@@ -83,14 +88,13 @@ const EntitySection = () => {
83
88
  }
84
89
  ) });
85
90
  } else {
86
- let entityCardCount = 2;
87
- if (isMediumBreakpoint) entityCardCount = 3;
88
91
  content = /* @__PURE__ */ jsx(Box, { sx: { padding: "8px 8px 8px 0" }, children: /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 1, alignItems: "stretch", children: [
89
- !isRemoveFirstCard && !profileLoading && /* @__PURE__ */ jsx(Grid, { item: true, xs: 12, md: 6, lg: 5, children: /* @__PURE__ */ jsxs(
92
+ !isRemoveFirstCard && !profileLoading && containerSize !== "xs" && containerSize !== "sm" && /* @__PURE__ */ jsx(Grid, { item: true, sx: containerGridItemSx({ md: 4 }), children: /* @__PURE__ */ jsx(
90
93
  Card,
91
94
  {
92
95
  elevation: 0,
93
96
  sx: {
97
+ height: "100%",
94
98
  border: `1px solid ${theme.palette.grey[400]}`,
95
99
  display: "flex",
96
100
  flexDirection: "row",
@@ -100,57 +104,74 @@ const EntitySection = () => {
100
104
  opacity: showDiscoveryCard ? 1 : 0,
101
105
  transform: showDiscoveryCard ? "translateX(0)" : "translateX(-50px)"
102
106
  },
103
- children: [
104
- !imgLoaded && /* @__PURE__ */ jsx(
105
- Skeleton,
106
- {
107
- variant: "rectangular",
108
- height: 300,
109
- sx: {
110
- borderRadius: 3,
111
- width: "clamp(140px, 14vw, 266px)"
112
- }
113
- }
114
- ),
115
- /* @__PURE__ */ jsx(
116
- Box,
117
- {
118
- component: "img",
119
- src: HomePageEntityIllustration,
120
- onLoad: () => setImgLoaded(true),
121
- alt: "",
122
- height: 300,
123
- sx: {
124
- width: "clamp(140px, 14vw, 266px)"
125
- }
126
- }
127
- ),
128
- /* @__PURE__ */ jsxs(Box, { sx: { p: 2 }, children: [
129
- /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(Typography, { variant: "body2", paragraph: true, children: t("entities.description") }) }),
130
- entities?.length > 0 && /* @__PURE__ */ jsx(
131
- IconButton,
132
- {
133
- onClick: handleClose,
134
- "aria-label": t("entities.close"),
135
- style: {
136
- position: "absolute",
137
- top: "8px",
138
- right: "8px"
139
- },
140
- children: /* @__PURE__ */ jsx(CloseIcon, { style: { width: "16px", height: "16px" } })
141
- }
142
- )
143
- ] })
144
- ]
107
+ children: /* @__PURE__ */ jsxs(
108
+ Box,
109
+ {
110
+ sx: {
111
+ display: "flex",
112
+ flexDirection: "row",
113
+ alignItems: "center"
114
+ },
115
+ children: [
116
+ !imgLoaded && /* @__PURE__ */ jsx(
117
+ Skeleton,
118
+ {
119
+ variant: "rectangular",
120
+ height: 300,
121
+ sx: {
122
+ borderRadius: 3,
123
+ width: illustrationWidth
124
+ }
125
+ }
126
+ ),
127
+ /* @__PURE__ */ jsx(
128
+ Box,
129
+ {
130
+ component: "img",
131
+ src: HomePageEntityIllustration,
132
+ onLoad: () => setImgLoaded(true),
133
+ alt: "",
134
+ height: 300,
135
+ sx: {
136
+ width: illustrationWidth
137
+ }
138
+ }
139
+ ),
140
+ /* @__PURE__ */ jsxs(Box, { sx: { p: 2 }, children: [
141
+ /* @__PURE__ */ jsx(Box, { sx: { p: 2 }, children: /* @__PURE__ */ jsx(Typography, { variant: "body2", paragraph: true, children: t("entities.description") }) }),
142
+ entities?.length > 0 && /* @__PURE__ */ jsx(
143
+ IconButton,
144
+ {
145
+ onClick: handleClose,
146
+ "aria-label": t("entities.close"),
147
+ style: {
148
+ position: "absolute",
149
+ top: "8px",
150
+ right: "8px"
151
+ },
152
+ children: /* @__PURE__ */ jsx(
153
+ CloseIcon,
154
+ {
155
+ style: { width: "16px", height: "16px" }
156
+ }
157
+ )
158
+ }
159
+ )
160
+ ] })
161
+ ]
162
+ }
163
+ )
145
164
  }
146
- ) }, "entities illustration"),
147
- entities?.slice(0, isRemoveFirstCard ? 4 : entityCardCount).map((item) => /* @__PURE__ */ jsx(
165
+ ) }),
166
+ entities?.slice(0, visibleEntitiesCount).map((item) => /* @__PURE__ */ jsx(
148
167
  Grid,
149
168
  {
150
169
  item: true,
151
- xs: 12,
152
- md: 6,
153
- lg: isRemoveFirstCard ? 3 : 3.5,
170
+ sx: containerGridItemSx({
171
+ xs: 12,
172
+ sm: 6,
173
+ md: isRemoveFirstCard ? 3 : 4
174
+ }),
154
175
  children: /* @__PURE__ */ jsx(
155
176
  EntityCard,
156
177
  {
@@ -165,36 +186,47 @@ const EntitySection = () => {
165
186
  },
166
187
  item.metadata.name
167
188
  )),
168
- entities?.length === 0 && /* @__PURE__ */ jsx(Grid, { item: true, md: isRemoveFirstCard ? 12 : 7, children: /* @__PURE__ */ jsx(
169
- Box,
189
+ entities?.length === 0 && /* @__PURE__ */ jsx(
190
+ Grid,
170
191
  {
171
- sx: {
172
- display: "flex",
173
- alignItems: "center",
174
- justifyContent: "center",
175
- minHeight: 300,
176
- border: (muiTheme) => `1px solid ${muiTheme.palette.grey[400]}`,
177
- borderRadius: 3,
178
- overflow: "hidden"
179
- },
180
- children: /* @__PURE__ */ jsxs(CardContent, { children: [
181
- /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "1.125rem", fontWeight: 500 }, children: t("entities.empty") }),
182
- /* @__PURE__ */ jsx(
183
- Typography,
184
- {
185
- sx: {
186
- fontSize: "0.875rem",
187
- fontWeight: 400,
188
- mt: "20px",
189
- mb: "16px"
190
- },
191
- children: t("entities.emptyDescription")
192
- }
193
- ),
194
- /* @__PURE__ */ jsx(StyledLink, { to: "/catalog-import", underline: "none", children: t("entities.register") })
195
- ] })
192
+ item: true,
193
+ sx: containerGridItemSx({
194
+ sm: 12,
195
+ md: isRemoveFirstCard ? 12 : 8
196
+ }),
197
+ children: /* @__PURE__ */ jsx(
198
+ Box,
199
+ {
200
+ sx: {
201
+ height: "100%",
202
+ minHeight: 300,
203
+ display: "flex",
204
+ alignItems: "center",
205
+ justifyContent: "center",
206
+ border: (muiTheme) => `1px solid ${muiTheme.palette.grey[400]}`,
207
+ borderRadius: 3,
208
+ overflow: "hidden"
209
+ },
210
+ children: /* @__PURE__ */ jsxs(CardContent, { children: [
211
+ /* @__PURE__ */ jsx(Typography, { sx: { fontSize: "1.125rem", fontWeight: 500 }, children: t("entities.empty") }),
212
+ /* @__PURE__ */ jsx(
213
+ Typography,
214
+ {
215
+ sx: {
216
+ fontSize: "0.875rem",
217
+ fontWeight: 400,
218
+ mt: "20px",
219
+ mb: "16px"
220
+ },
221
+ children: t("entities.emptyDescription")
222
+ }
223
+ ),
224
+ /* @__PURE__ */ jsx(StyledLink, { to: "/catalog-import", underline: "none", children: t("entities.register") })
225
+ ] })
226
+ }
227
+ )
196
228
  }
197
- ) })
229
+ )
198
230
  ] }) }) });
199
231
  }
200
232
  return /* @__PURE__ */ jsxs(
@@ -204,7 +236,9 @@ const EntitySection = () => {
204
236
  sx: {
205
237
  padding: "24px",
206
238
  border: (muitheme) => `1px solid ${muitheme.palette.grey[300]}`,
207
- overflow: "auto"
239
+ containerType: "inline-size",
240
+ display: "flex",
241
+ flexDirection: "column"
208
242
  },
209
243
  children: [
210
244
  /* @__PURE__ */ jsx(
@@ -215,19 +249,28 @@ const EntitySection = () => {
215
249
  display: "flex",
216
250
  alignItems: "center",
217
251
  fontWeight: "500",
218
- fontSize: "1.5rem"
252
+ fontSize: "1.5rem",
253
+ flexShrink: 0
219
254
  },
220
255
  children: t("entities.title")
221
256
  }
222
257
  ),
223
- content,
224
- entities?.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { pt: 2 }, children: /* @__PURE__ */ jsx(ViewMoreLink, { to: "/catalog", children: /* @__PURE__ */ jsx(
225
- Trans,
258
+ /* @__PURE__ */ jsxs(
259
+ Box,
226
260
  {
227
- message: "entities.viewAll",
228
- params: { count: data?.totalItems?.toString() || "" }
261
+ ref: containerRef,
262
+ sx: {
263
+ flex: 1,
264
+ minHeight: 0,
265
+ overflowY: "auto",
266
+ mt: 1
267
+ },
268
+ children: [
269
+ content,
270
+ entities?.length > 0 && /* @__PURE__ */ jsx(Box, { sx: { pt: 2 }, children: /* @__PURE__ */ jsx(ViewMoreLink, { to: "/catalog", children: t("entities.browseTheCatalog") }) })
271
+ ]
229
272
  }
230
- ) }) })
273
+ )
231
274
  ]
232
275
  }
233
276
  );