Skip to content

Commit 1ecf752

Browse files
Revert "feat(homepage): add dual mount point system for extensible homepage f…" (#1752)
This reverts commit 8f47cd6.
1 parent e8b5090 commit 1ecf752

15 files changed

Lines changed: 32 additions & 392 deletions

workspaces/homepage/.changeset/add-dual-mount-point-system.md

Lines changed: 0 additions & 8 deletions
This file was deleted.

workspaces/homepage/docs/create-a-new-card.md

Lines changed: 1 addition & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -38,48 +38,16 @@ Cards commonly uses the [InfoCard](https://backstage.io/storybook/?path=/story/l
3838
);
3939
```
4040

41-
3. And finally, users can add them to their `app-config` to expose the component as mount point `home.page/cards` (for default cards) or `home.page/widgets` (for additional plugin cards):
41+
3. And finally, users can add them to their `app-config` to expose the component as mount point `home.page/cards`:
4242

4343
```yaml
4444
dynamicPlugins:
4545
frontend:
4646
your-plugin-id:
4747
mountPoints:
48-
# For default cards that appear by default
4948
- mountPoint: home.page/cards
5049
importName: YourHomePageCard
5150
config:
52-
title: 'My Custom Card' # Title for "Add widget" dialog
53-
description: 'Description of what it does' # Description for dialog
54-
layout: ...
55-
props: ...
56-
# For additional cards contributed by plugins
57-
- mountPoint: home.page/widgets
58-
importName: YourAdditionalCard
59-
config:
60-
title: 'Plugin Card' # Title for "Add widget" dialog
61-
description: 'Card from external plugin' # Description for dialog
62-
priority: 10 # Optional: higher priority appears first
6351
layout: ...
6452
props: ...
6553
```
66-
67-
## Configuration Options
68-
69-
### Metadata (for "Add widget" dialog)
70-
71-
- **`title`** (optional): Display name shown in the "Add widget" dialog
72-
- **`description`** (optional): Description text shown in the "Add widget" dialog
73-
74-
If `title` and `description` are not provided in config, the component will appear in the "Add widget" dialog with its component name or without description.
75-
76-
### Layout and Behavior
77-
78-
- **`priority`** (optional): Number to control display order (higher priority appears first)
79-
- **`layouts`**: Responsive layout configuration for different screen sizes
80-
- **`props`**: Properties passed to the component
81-
82-
## Mount Points
83-
84-
- **`home.page/cards`** - Default homepage cards that appear by default
85-
- **`home.page/widgets`** - Additional cards contributed by other plugins that appear alongside default cards

workspaces/homepage/docs/defaults.md

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,6 @@ The plugin provides two main components:
1111
- **`DynamicHomePage`** - A read-only homepage that displays configured cards without user customization
1212
- **`DynamicCustomizableHomePage`** - An interactive homepage that allows users to add, remove, move, and resize cards
1313

14-
## Mount Points
15-
16-
The plugin supports two mount points for extensibility:
17-
18-
- **`home.page/cards`** - Default homepage cards that appear by default and are used for "restore defaults" functionality
19-
- **`home.page/widgets`** - Additional cards contributed by other plugins that appear alongside default cards
20-
21-
Cards from both mount points are displayed together, with optional priority-based ordering.
22-
2314
## Default home page
2415

2516
The default home page shows a "Onboarding Section" card, a "Entity Section" card, and a "Template Section" card by default.

workspaces/homepage/docs/index.md

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,8 @@
1-
# RHDH Home Page plugin
1+
# RHDH Home Page pluginpage
22

33
The RHDH home page plugin is based on the upstream [home plugin](https://github.com/backstage/backstage/blob/master/plugins/home/README.md).
44

5-
It allows primarily **admins** to customize the homepage in the `app-config`, and plugin authors to extend the home page with additional cards or content.
6-
7-
## Key Features
8-
9-
- **Dual Mount Point System**: Separate default cards from plugin-contributed cards
10-
- **Config-Based Metadata**: Add titles and descriptions directly in YAML configuration
11-
- **Customizable Grid**: Drag-and-drop, resizable cards with "Add widget" functionality
12-
- **Plugin Integration**: Easy integration for external plugins via configuration
13-
14-
## Mount Points
15-
16-
The plugin supports two mount points:
17-
18-
- **`home.page/cards`** - Default homepage cards that appear by default
19-
- **`home.page/widgets`** - Additional cards contributed by other plugins that appear in the "Add widget" dialog
20-
21-
## Configuration-Based Metadata
22-
23-
Cards can have titles and descriptions defined directly in the configuration:
24-
25-
```yaml
26-
dynamicPlugins:
27-
frontend:
28-
your-plugin:
29-
mountPoints:
30-
- mountPoint: home.page/widgets
31-
importName: YourCard
32-
config:
33-
title: 'Your Card Title'
34-
description: 'Description shown in Add widget dialog'
35-
```
5+
It allows primarly **admins** to customize the homepage in the `app-config`, and plugin authors to extend the home page with additional cards or content.
366

377
The default home page shows a Search input field, a "Quick Access" card, and a "Your Starred Entities" card by default.
388

workspaces/homepage/packages/app/src/App.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,15 @@ const mountPoints: HomePageCardMountPoint[] = [
138138

139139
const scalprumState: ScalprumState = {
140140
initialized: true,
141-
api: {
142-
dynamicRootConfig: {
143-
mountPoints: {
144-
'home.page/cards': mountPoints,
145-
// Additional cards from other plugins will be loaded at runtime
146-
'home.page/widgets': [],
147-
},
148-
},
149-
},
141+
api: mountPoints
142+
? {
143+
dynamicRootConfig: {
144+
mountPoints: {
145+
'home.page/cards': mountPoints,
146+
},
147+
},
148+
}
149+
: undefined,
150150
config: {},
151151
pluginStore: new PluginStore(),
152152
};

workspaces/homepage/plugins/dynamic-home-page/app-config.dynamic.yaml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ dynamicPlugins:
66
- path: /
77
importName: DynamicHomePage
88
mountPoints:
9-
# Default homepage cards - appear by default
109
- mountPoint: home.page/cards
1110
importName: OnboardingSection
1211
config:
@@ -37,31 +36,3 @@ dynamicPlugins:
3736
sm: { w: 12, h: 5 }
3837
xs: { w: 12, h: 7.5 }
3938
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 }

workspaces/homepage/plugins/dynamic-home-page/report.api.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,14 +222,10 @@ export interface HomePageCardMountPoint {
222222

223223
// @public (undocumented)
224224
export interface HomePageCardMountPointConfig {
225-
// (undocumented)
226-
description?: string;
227225
// (undocumented)
228226
layouts?: Record<Breakpoint, Layout>;
229227
// (undocumented)
230228
priority?: number;
231-
// (undocumented)
232-
title?: string;
233229
}
234230

235231
// @public

workspaces/homepage/plugins/dynamic-home-page/src/components/CustomizableGrid.tsx

Lines changed: 4 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import { useTheme } from '@mui/material/styles';
2929

3030
import { ErrorBoundary } from '@backstage/core-components';
3131
import { CustomHomepageGrid } from '@backstage/plugin-home';
32-
import { attachComponentData } from '@backstage/core-plugin-api';
3332

3433
import { makeStyles } from 'tss-react/mui';
3534

@@ -63,7 +62,6 @@ const useStyles = makeStyles()({
6362
*/
6463
export interface CustomizableGridProps {
6564
mountPoints: HomePageCardMountPoint[];
66-
defaultMountPoints?: HomePageCardMountPoint[]; // For config prop - only default cards
6765
breakpoints?: Record<string, number>;
6866
cols?: Record<string, number>;
6967
}
@@ -76,38 +74,10 @@ export const CustomizableGrid = (props: CustomizableGridProps) => {
7674
const theme = useTheme();
7775

7876
const cards = useMemo<Card[]>(() => {
79-
if (!props.mountPoints || !Array.isArray(props.mountPoints)) {
80-
return [];
81-
}
82-
8377
return props.mountPoints.map<Card>((mountPoint, index) => {
8478
const id = (index + 1).toString();
8579
const layouts: Record<string, Layout> = {};
8680

87-
// Apply config-based metadata to component if provided (skip if already exists)
88-
if (mountPoint.config?.title) {
89-
try {
90-
attachComponentData(
91-
mountPoint.Component,
92-
'title',
93-
mountPoint.config.title,
94-
);
95-
} catch (error) {
96-
// Ignore duplicate metadata errors - component already has title
97-
}
98-
}
99-
if (mountPoint.config?.description) {
100-
try {
101-
attachComponentData(
102-
mountPoint.Component,
103-
'description',
104-
mountPoint.config.description,
105-
);
106-
} catch (error) {
107-
// Ignore duplicate metadata errors - component already has description
108-
}
109-
}
110-
11181
if (mountPoint.config?.layouts) {
11282
for (const [breakpoint, layout] of Object.entries(
11383
mountPoint.config.layouts,
@@ -162,16 +132,13 @@ export const CustomizableGrid = (props: CustomizableGridProps) => {
162132
));
163133
}, [cards, classes.cardWrapper]);
164134

165-
// Create default layout configuration for "restore defaults" functionality
166-
// Use only default mount points for restore defaults, but all mount points for "Add widget" dialog
135+
// Create default layout configuration for initial display AND restore defaults functionality
167136
const defaultConfig = useMemo(() => {
168-
const configMountPoints = props.defaultMountPoints || []; // Use only default cards for restore
169-
170-
if (!configMountPoints || configMountPoints.length === 0) {
137+
if (!props.mountPoints || props.mountPoints.length === 0) {
171138
return [];
172139
}
173140

174-
return configMountPoints.map((mountPoint, index) => {
141+
return props.mountPoints.map((mountPoint, index) => {
175142
const layout = mountPoint.config?.layouts?.xl || {};
176143

177144
return {
@@ -188,7 +155,7 @@ export const CustomizableGrid = (props: CustomizableGridProps) => {
188155
deletable: true,
189156
};
190157
});
191-
}, [props.defaultMountPoints]);
158+
}, [props.mountPoints]);
192159

193160
return (
194161
<>

workspaces/homepage/plugins/dynamic-home-page/src/components/CustomizableHomePage.tsx

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { CustomizableGrid } from './CustomizableGrid';
2626

2727
export interface HomePageProps extends HeaderProps {
2828
cards?: HomePageCardMountPoint[];
29-
defaultCards?: HomePageCardMountPoint[];
3029
}
3130

3231
export const CustomizableHomePage = (props: HomePageProps) => {
@@ -56,10 +55,7 @@ export const CustomizableHomePage = (props: HomePageProps) => {
5655
{filteredAndSortedHomePageCards.length === 0 ? (
5756
<EmptyState title={t('homePage.empty')} missing="content" />
5857
) : (
59-
<CustomizableGrid
60-
mountPoints={filteredAndSortedHomePageCards}
61-
defaultMountPoints={props.defaultCards}
62-
/>
58+
<CustomizableGrid mountPoints={filteredAndSortedHomePageCards} />
6359
)}
6460
</Content>
6561
</Page>

workspaces/homepage/plugins/dynamic-home-page/src/components/DynamicCustomizableHomePage.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,7 @@ export interface DynamicCustomizableHomePageProps {
4040
export const DynamicCustomizableHomePage = (
4141
props: DynamicCustomizableHomePageProps,
4242
) => {
43-
const { allCards, defaultCards } = useDynamicHomePageCards();
43+
const cards = useDynamicHomePageCards();
4444

45-
return (
46-
<CustomizableHomePage
47-
{...props}
48-
cards={allCards}
49-
defaultCards={defaultCards}
50-
/>
51-
);
45+
return <CustomizableHomePage {...props} cards={cards} />;
5246
};

0 commit comments

Comments
 (0)