2024-08-23 15:00:03 +08:00
|
|
|
import { AppPlugin } from '@grafana/data';
|
2024-08-26 22:01:32 +08:00
|
|
|
|
2024-08-30 16:09:01 +08:00
|
|
|
import { LINKS_EXTENSION_POINT_ID } from '../../pages/AddedLinks';
|
2024-08-26 22:01:32 +08:00
|
|
|
import { testIds } from '../../testIds';
|
|
|
|
|
2024-08-23 15:00:03 +08:00
|
|
|
import { App } from './components/App';
|
|
|
|
|
|
|
|
export const plugin = new AppPlugin<{}>()
|
|
|
|
.setRootPage(App)
|
|
|
|
.configureExtensionLink({
|
|
|
|
title: 'Open from B',
|
|
|
|
description: 'Open a modal from plugin B',
|
|
|
|
extensionPointId: 'plugins/grafana-extensionstest-app/actions',
|
|
|
|
onClick: (_, { openModal }) => {
|
|
|
|
openModal({
|
|
|
|
title: 'Modal from app B',
|
|
|
|
body: () => <div data-testid={testIds.appB.modal}>From plugin B</div>,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.configureExtensionComponent({
|
2024-10-04 14:41:26 +08:00
|
|
|
extensionPointId: 'plugins/grafana-extensionstest-app/configure-extension-component/v1',
|
2024-08-23 15:00:03 +08:00
|
|
|
title: 'Configure extension component from B',
|
|
|
|
description: 'A component that can be reused by other app plugins. Shared using configureExtensionComponent api',
|
|
|
|
component: ({ name }: { name: string }) => <div data-testid={testIds.appB.reusableComponent}>Hello {name}!</div>,
|
|
|
|
})
|
|
|
|
.addComponent<{ name: string }>({
|
2024-10-04 14:41:26 +08:00
|
|
|
targets: 'plugins/grafana-extensionstest-app/addComponent/v1',
|
2024-08-23 15:00:03 +08:00
|
|
|
title: 'Added component from B',
|
|
|
|
description: 'A component that can be reused by other app plugins. Shared using addComponent api',
|
|
|
|
component: ({ name }: { name: string }) => (
|
|
|
|
<div data-testid={testIds.appB.reusableAddedComponent}>Hello {name}!</div>
|
|
|
|
),
|
2024-08-30 16:09:01 +08:00
|
|
|
})
|
|
|
|
.addLink({
|
|
|
|
title: 'Open from B',
|
|
|
|
description: 'Open a modal from plugin B',
|
|
|
|
targets: [LINKS_EXTENSION_POINT_ID],
|
|
|
|
onClick: (_, { openModal }) => {
|
|
|
|
openModal({
|
|
|
|
title: 'Modal from app B',
|
|
|
|
body: () => <div data-testid={testIds.appB.modal}>From plugin B</div>,
|
|
|
|
});
|
|
|
|
},
|
2024-08-23 15:00:03 +08:00
|
|
|
});
|