mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Began work on panel menu * SceneDashboard: Basic state handling for inspect panel * Switched to using scene url sync instead * Updated * Update comment on hack * Fixed url synnc issues and more / better DashboardsLoader tests * Progress on test * Updates * Progress * Progress * Update * Update * Update * Update * Update scenes lib * Update * Update --------- Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
38 lines
1.3 KiB
TypeScript
38 lines
1.3 KiB
TypeScript
import { locationUtil, PanelMenuItem } from '@grafana/data';
|
|
import { locationService } from '@grafana/runtime';
|
|
import { VizPanel, VizPanelMenu } from '@grafana/scenes';
|
|
import { t } from 'app/core/internationalization';
|
|
|
|
/**
|
|
* Behavior is called when VizPanelMenu is activated (ie when it's opened).
|
|
*/
|
|
export function panelMenuBehavior(menu: VizPanelMenu) {
|
|
// hm.. add another generic param to SceneObject to specify parent type?
|
|
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
const panel = menu.parent as VizPanel;
|
|
|
|
const location = locationService.getLocation();
|
|
const items: PanelMenuItem[] = [];
|
|
|
|
// TODO
|
|
// Add tracking via reportInteraction (but preserve the fact that these are normal links)
|
|
|
|
items.push({
|
|
text: t('panel.header-menu.view', `View`),
|
|
iconClassName: 'eye',
|
|
shortcut: 'v',
|
|
// Hm... need the numeric id to be url compatible?
|
|
href: locationUtil.getUrlForPartial(location, { viewPanel: panel.state.key }),
|
|
});
|
|
|
|
items.push({
|
|
text: t('panel.header-menu.inspect', `Inspect`),
|
|
iconClassName: 'info-circle',
|
|
shortcut: 'i',
|
|
// Hm... need the numeric id to be url compatible?
|
|
href: locationUtil.getUrlForPartial(location, { inspect: panel.state.key }),
|
|
});
|
|
|
|
menu.setState({ items });
|
|
}
|