Skip to content

Commit 9511e90

Browse files
talissoncostaclaude
andcommitted
Add alpha export with Backstage new frontend system
Implements #6421 - adds `/alpha` export path that uses Backstage's new declarative frontend system while maintaining backward compatibility with the existing legacy export. Changes: - Add `@backstage/frontend-plugin-api` dependency - Create `src/alpha.ts` with new frontend system plugin using: - EntityContentBlueprint for FlagsTab - EntityCardBlueprint for FlagsmithOverviewCard and FlagsmithUsageCard - Add exports and typesVersions configuration to package.json Usage: - Legacy: `import { flagsmithPlugin } from '@internal/plugin-flagsmith'` - Alpha: `import flagsmithPlugin from '@internal/plugin-flagsmith/alpha'` 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <[email protected]>
1 parent 83e9c32 commit 9511e90

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

package.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,20 @@
3333
"backstage-cli package lint --fix"
3434
]
3535
},
36+
"exports": {
37+
".": "./src/index.ts",
38+
"./alpha": "./src/alpha.ts",
39+
"./package.json": "./package.json"
40+
},
41+
"typesVersions": {
42+
"*": {
43+
"alpha": ["src/alpha.ts"]
44+
}
45+
},
3646
"dependencies": {
3747
"@backstage/core-components": "^0.18.2",
3848
"@backstage/core-plugin-api": "^1.11.1",
49+
"@backstage/frontend-plugin-api": "^0.13.2",
3950
"@backstage/plugin-catalog-react": "^1.13.3",
4051
"@material-ui/core": "^4.9.13",
4152
"@material-ui/icons": "^4.9.1",

src/alpha.ts

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
import { createElement } from 'react';
2+
import { createFrontendPlugin } from '@backstage/frontend-plugin-api';
3+
import {
4+
EntityContentBlueprint,
5+
EntityCardBlueprint,
6+
} from '@backstage/plugin-catalog-react/alpha';
7+
8+
/**
9+
* Entity content (tab) for FlagsTab - displays feature flags for an entity
10+
* Requires annotation: flagsmith.com/project-id
11+
*/
12+
const flagsTabContent = EntityContentBlueprint.make({
13+
name: 'flags',
14+
params: {
15+
path: '/flagsmith',
16+
title: 'Feature Flags',
17+
filter: 'has:annotation:flagsmith.com/project-id',
18+
loader: () =>
19+
import('./components/FlagsTab').then(m => createElement(m.FlagsTab)),
20+
},
21+
});
22+
23+
/**
24+
* Entity card for FlagsmithOverviewCard - shows flag overview in entity page
25+
* Requires annotation: flagsmith.com/project-id
26+
*/
27+
const overviewCard = EntityCardBlueprint.make({
28+
name: 'overview',
29+
params: {
30+
filter: 'has:annotation:flagsmith.com/project-id',
31+
loader: () =>
32+
import('./components/FlagsmithOverviewCard').then(m =>
33+
createElement(m.FlagsmithOverviewCard),
34+
),
35+
},
36+
});
37+
38+
/**
39+
* Entity card for FlagsmithUsageCard - shows 30-day usage analytics
40+
* Requires annotations: flagsmith.com/project-id, flagsmith.com/org-id
41+
*/
42+
const usageCard = EntityCardBlueprint.make({
43+
name: 'usage',
44+
params: {
45+
filter: 'has:annotation:flagsmith.com/project-id,flagsmith.com/org-id',
46+
loader: () =>
47+
import('./components/FlagsmithUsageCard').then(m =>
48+
createElement(m.FlagsmithUsageCard),
49+
),
50+
},
51+
});
52+
53+
/**
54+
* Flagsmith plugin for Backstage's new frontend system.
55+
*
56+
* This is the alpha export of the Flagsmith plugin, implementing
57+
* the new declarative frontend system. It provides:
58+
*
59+
* - Entity content tab showing feature flags
60+
* - Overview card for entity pages
61+
* - Usage analytics card
62+
*
63+
* @alpha
64+
*/
65+
export default createFrontendPlugin({
66+
pluginId: 'flagsmith',
67+
extensions: [flagsTabContent, overviewCard, usageCard],
68+
});

0 commit comments

Comments
 (0)