Add example to changeset, remove instanceof Promise check

Signed-off-by: Mark Dunphy <markd@spotify.com>
This commit is contained in:
Mark Dunphy
2025-04-08 08:06:57 -04:00
parent 3626bcf2e3
commit 5ed70bf42e
2 changed files with 34 additions and 3 deletions
+32 -1
View File
@@ -3,4 +3,35 @@
'@backstage/plugin-catalog': minor
---
Adds `EntityContextMenuItemBlueprint` to enable extending the entity page's context menu
Adds `EntityContextMenuItemBlueprint` to enable extending the entity page's context menu with user defined items.
For example:
```ts
import { EntityContextMenuItemBlueprint } from '@backstage/plugin-catalog-react/alpha';
const myCustomHref = EntityContextMenuItemBlueprint.make({
name: 'test-href',
params: {
icon: <span>Example Icon</span>,
useProps: () => ({
title: 'Example Href',
href: '/example-path',
disabled: false,
component: 'a',
}),
},
});
const myCustomOnClick = EntityContextMenuItemBlueprint.make({
name: 'test-click',
params: {
icon: <span>Test Icon</span>,
useProps: () => ({
title: 'Example onClick',
onClick: () => window.alert('Hello world!'),
disabled: false,
}),
},
});
```
@@ -73,8 +73,8 @@ export const EntityContextMenuItemBlueprint = createExtensionBlueprint({
if ('onClick' in menuItemProps) {
handleClick = () => {
const result = menuItemProps.onClick();
if (result instanceof Promise) {
result.then(onClose);
if (result && 'finally' in result) {
result.finally(onClose);
} else {
onClose();
}