Add example to changeset, remove instanceof Promise check
Signed-off-by: Mark Dunphy <markd@spotify.com>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user