Chore: fix last type errors
This commit is contained in:
@@ -2,7 +2,7 @@ import { isFunction } from 'lodash';
|
||||
import { ComponentType, FC } from 'react';
|
||||
import * as React from 'react';
|
||||
|
||||
import { GrafanaPlugin, PluginExtensionConfig, PluginType } from '@grafana/data';
|
||||
import { GrafanaPlugin, PluginType } from '@grafana/data';
|
||||
|
||||
import { SandboxPluginMeta, SandboxedPluginObject } from './types';
|
||||
import { isSandboxedPluginObject } from './utils';
|
||||
@@ -58,17 +58,6 @@ export async function sandboxPluginComponents(
|
||||
Reflect.set(pluginObject, 'root', withSandboxWrapper(Reflect.get(pluginObject, 'root'), meta));
|
||||
}
|
||||
|
||||
// extension components
|
||||
if (Reflect.has(pluginObject, 'extensionConfigs')) {
|
||||
const extensions: PluginExtensionConfig[] = Reflect.get(pluginObject, 'extensionConfigs');
|
||||
for (const extension of extensions) {
|
||||
if (Reflect.has(extension, 'component')) {
|
||||
Reflect.set(extension, 'component', withSandboxWrapper(Reflect.get(extension, 'component'), meta));
|
||||
}
|
||||
}
|
||||
Reflect.set(pluginObject, 'extensionConfigs', extensions);
|
||||
}
|
||||
|
||||
// config pages
|
||||
if (Reflect.has(pluginObject, 'configPages')) {
|
||||
const configPages: NonNullable<GrafanaPlugin['configPages']> = Reflect.get(pluginObject, 'configPages') ?? [];
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NavModelItem } from '@grafana/data';
|
||||
import { getPluginExtensions, isPluginExtensionLink } from '@grafana/runtime';
|
||||
import { usePluginLinks } from '@grafana/runtime';
|
||||
import { Button, LinkButton, Stack, Text } from '@grafana/ui';
|
||||
import { Page } from 'app/core/components/Page/Page';
|
||||
import { useAppNotification } from 'app/core/copy/appNotification';
|
||||
@@ -41,21 +41,18 @@ export const TestStuffPage = () => {
|
||||
};
|
||||
|
||||
function LinkToBasicApp({ extensionPointId }: { extensionPointId: string }) {
|
||||
const { extensions } = getPluginExtensions({ extensionPointId });
|
||||
const { links } = usePluginLinks({ extensionPointId });
|
||||
|
||||
if (extensions.length === 0) {
|
||||
if (links.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
{extensions.map((extension, i) => {
|
||||
if (!isPluginExtensionLink(extension)) {
|
||||
return null;
|
||||
}
|
||||
{links.map((link, i) => {
|
||||
return (
|
||||
<LinkButton href={extension.path} title={extension.description} key={extension.id}>
|
||||
{extension.title}
|
||||
<LinkButton href={link.path} title={link.description} key={link.id}>
|
||||
{link.title}
|
||||
</LinkButton>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { DataFrame, PanelMenuItem } from '@grafana/data';
|
||||
import { getPluginLinkExtensions } from '@grafana/runtime';
|
||||
import { isPluginExtensionLink } from '@grafana/runtime';
|
||||
import {
|
||||
SceneComponentProps,
|
||||
sceneGraph,
|
||||
@@ -11,6 +11,8 @@ import {
|
||||
} from '@grafana/scenes';
|
||||
import { getExploreUrl } from 'app/core/utils/explore';
|
||||
import { getQueryRunnerFor } from 'app/features/dashboard-scene/utils/utils';
|
||||
import { GetPluginExtensions, createPluginExtensionsGetter } from 'app/features/plugins/extensions/getPluginExtensions';
|
||||
import { pluginExtensionRegistries } from 'app/features/plugins/extensions/registry/setup';
|
||||
|
||||
import { AddToExplorationButton, extensionPointId } from '../MetricSelect/AddToExplorationsButton';
|
||||
import { getDataSource, getTrailFor } from '../utils';
|
||||
@@ -28,6 +30,18 @@ interface PanelMenuState extends SceneObjectState {
|
||||
explorationsButton?: AddToExplorationButton;
|
||||
}
|
||||
|
||||
let getPluginExtensions: GetPluginExtensions;
|
||||
|
||||
function setupGetPluginExtensions() {
|
||||
if (getPluginExtensions) {
|
||||
return getPluginExtensions;
|
||||
}
|
||||
|
||||
getPluginExtensions = createPluginExtensionsGetter(pluginExtensionRegistries);
|
||||
|
||||
return getPluginExtensions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo the VizPanelMenu interface is overly restrictive, doesn't allow any member functions on this class, so everything is currently inlined
|
||||
*/
|
||||
@@ -93,6 +107,8 @@ export class PanelMenu extends SceneObjectBase<PanelMenuState> implements VizPan
|
||||
this.state.explorationsButton?.activate();
|
||||
}
|
||||
});
|
||||
|
||||
setupGetPluginExtensions();
|
||||
}
|
||||
|
||||
addItem(item: PanelMenuItem): void {
|
||||
@@ -119,12 +135,12 @@ export class PanelMenu extends SceneObjectBase<PanelMenuState> implements VizPan
|
||||
}
|
||||
|
||||
const getInvestigationLink = (addToExplorations: AddToExplorationButton) => {
|
||||
const links = getPluginLinkExtensions({
|
||||
extensionPointId: extensionPointId,
|
||||
const links = getPluginExtensions({
|
||||
extensionPointId,
|
||||
context: addToExplorations.state.context,
|
||||
});
|
||||
}).extensions.filter((ext) => isPluginExtensionLink(ext));
|
||||
|
||||
return links.extensions[0];
|
||||
return links[0];
|
||||
};
|
||||
|
||||
const onAddToInvestigationClick = (event: React.MouseEvent, addToExplorations: AddToExplorationButton) => {
|
||||
|
||||
Reference in New Issue
Block a user