diff --git a/public/app/features/dashboard-scene/edit-pane/VizPanelEditableElement.tsx b/public/app/features/dashboard-scene/edit-pane/VizPanelEditableElement.tsx
index 0f88658da85..f608297ed96 100644
--- a/public/app/features/dashboard-scene/edit-pane/VizPanelEditableElement.tsx
+++ b/public/app/features/dashboard-scene/edit-pane/VizPanelEditableElement.tsx
@@ -120,7 +120,7 @@ const OpenPanelEditViz = ({ panel }: OpenPanelEditVizProps) => {
size="sm"
tooltip={t('dashboard.viz-panel.options.configure-button-tooltip', 'Edit queries and visualization options')}
>
- Configure panel
+ Configure
);
diff --git a/public/app/features/dashboard-scene/scene/AddLibraryPanelDrawer.tsx b/public/app/features/dashboard-scene/scene/AddLibraryPanelDrawer.tsx
index 1d4c4b198a5..e92b570b7be 100644
--- a/public/app/features/dashboard-scene/scene/AddLibraryPanelDrawer.tsx
+++ b/public/app/features/dashboard-scene/scene/AddLibraryPanelDrawer.tsx
@@ -10,7 +10,7 @@ import {
import { getDashboardSceneFor, getDefaultVizPanel } from '../utils/utils';
import { LibraryPanelBehavior } from './LibraryPanelBehavior';
-import { DashboardGridItem } from './layout-default/DashboardGridItem';
+import { isDashboardLayoutItem } from './types/DashboardLayoutItem';
export interface AddLibraryPanelDrawerState extends SceneObjectState {
panelToReplaceRef?: SceneObjectRef;
@@ -35,13 +35,11 @@ export class AddLibraryPanelDrawer extends SceneObjectBase {
+ setIsOpen(isOpen);
+ }, []);
+
const onConfigure = () => {
locationService.partial({ editPanel: props.id });
};
+ const onUseLibraryPanel = () => {
+ const dashboard = window.__grafanaSceneContext;
+
+ if (!(dashboard instanceof DashboardScene)) {
+ throw new Error('DashboardScene not found');
+ }
+
+ const panel = findVizPanelByKey(dashboard, getVizPanelKeyForPanelId(props.id));
+ if (!panel) {
+ throw new Error('Panel not found');
+ }
+
+ dashboard.onShowAddLibraryPanelDrawer(panel.getRef());
+ };
+
+ const MenuActions = () => (
+
+ );
+
return (
-
+
+
+
+
+
+
);
diff --git a/public/app/features/dashboard-scene/scene/layout-default/DashboardGridItem.tsx b/public/app/features/dashboard-scene/scene/layout-default/DashboardGridItem.tsx
index 6b6639efd8b..79173b5f7c2 100644
--- a/public/app/features/dashboard-scene/scene/layout-default/DashboardGridItem.tsx
+++ b/public/app/features/dashboard-scene/scene/layout-default/DashboardGridItem.tsx
@@ -86,6 +86,10 @@ export class DashboardGridItem
return getDashboardGridItemOptions(this);
}
+ public setElementBody(body: VizPanel): void {
+ this.setState({ body });
+ }
+
public editingStarted() {
if (!this.state.variableName) {
return;
diff --git a/public/app/features/dashboard-scene/scene/layout-responsive-grid/ResponsiveGridItem.tsx b/public/app/features/dashboard-scene/scene/layout-responsive-grid/ResponsiveGridItem.tsx
index e314190b244..1479d4b3ca7 100644
--- a/public/app/features/dashboard-scene/scene/layout-responsive-grid/ResponsiveGridItem.tsx
+++ b/public/app/features/dashboard-scene/scene/layout-responsive-grid/ResponsiveGridItem.tsx
@@ -71,6 +71,10 @@ export class AutoGridItem extends SceneObjectBase implements
return getOptions(this);
}
+ public setElementBody(body: VizPanel): void {
+ this.setState({ body });
+ }
+
public performRepeat() {
if (!this.state.variableName || sceneGraph.hasVariableDependencyInLoadingState(this)) {
return;
diff --git a/public/app/features/dashboard-scene/scene/types/DashboardLayoutItem.ts b/public/app/features/dashboard-scene/scene/types/DashboardLayoutItem.ts
index 21a4fc6e7eb..44391c27c33 100644
--- a/public/app/features/dashboard-scene/scene/types/DashboardLayoutItem.ts
+++ b/public/app/features/dashboard-scene/scene/types/DashboardLayoutItem.ts
@@ -1,4 +1,4 @@
-import { SceneObject } from '@grafana/scenes';
+import { SceneObject, VizPanel } from '@grafana/scenes';
import { OptionsPaneCategoryDescriptor } from 'app/features/dashboard/components/PanelEditor/OptionsPaneCategoryDescriptor';
/**
* Abstraction to handle editing of different layout elements (wrappers for VizPanels and other objects)
@@ -24,6 +24,11 @@ export interface DashboardLayoutItem extends SceneObject {
* When coming out of panel edit
*/
editingCompleted?(withChanges: boolean): void;
+
+ /**
+ * Change inner body / viz panel
+ */
+ setElementBody(body: VizPanel): void;
}
export function isDashboardLayoutItem(obj: SceneObject): obj is DashboardLayoutItem {
diff --git a/public/locales/en-US/grafana.json b/public/locales/en-US/grafana.json
index 04f8f28cf5e..eb74f4a20b1 100644
--- a/public/locales/en-US/grafana.json
+++ b/public/locales/en-US/grafana.json
@@ -1631,7 +1631,9 @@
}
},
"new-panel": {
- "configure-button": "Configure panel"
+ "configure-button": "Configure",
+ "menu-open-panel-editor": "Configure",
+ "menu-use-library-panel": "Use library panel"
},
"new-panel-title": "New panel",
"options": {