mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataLinks: Enable multiple data links per panel (#18434)
In response to #18282 DataLinksEditor does not limit amount of links by default now (it was 1 link before, unless maxLinks prop was specified). Also, links that do not have label specified, are not rendered anymore.
This commit is contained in:
parent
151b40ee2f
commit
c38804216c
@ -66,7 +66,7 @@ export const DataLinksEditor: FC<DataLinksEditorProps> = React.memo(({ value, on
|
||||
</div>
|
||||
)}
|
||||
|
||||
{(!value || (value && value.length < (maxLinks || 1))) && (
|
||||
{(!value || (value && value.length < (maxLinks || Infinity))) && (
|
||||
<Button variant="inverse" icon="fa fa-plus" onClick={() => onAdd()}>
|
||||
Create link
|
||||
</Button>
|
||||
|
@ -8,10 +8,18 @@ type GraphContextMenuProps = ContextMenuProps & {
|
||||
getContextMenuSource: () => FlotDataPoint | null;
|
||||
};
|
||||
|
||||
export const GraphContextMenu: React.FC<GraphContextMenuProps> = ({ getContextMenuSource, ...otherProps }) => {
|
||||
export const GraphContextMenu: React.FC<GraphContextMenuProps> = ({ getContextMenuSource, items, ...otherProps }) => {
|
||||
const theme = useContext(ThemeContext);
|
||||
const source = getContextMenuSource();
|
||||
|
||||
// Do not render items that do not have label specified
|
||||
const itemsToRender = items
|
||||
? items.map(group => ({
|
||||
...group,
|
||||
items: group.items.filter(item => item.label),
|
||||
}))
|
||||
: [];
|
||||
|
||||
const renderHeader = source
|
||||
? () => {
|
||||
if (!source) {
|
||||
@ -44,5 +52,5 @@ export const GraphContextMenu: React.FC<GraphContextMenuProps> = ({ getContextMe
|
||||
}
|
||||
: null;
|
||||
|
||||
return <ContextMenu {...otherProps} renderHeader={renderHeader} />;
|
||||
return <ContextMenu {...otherProps} items={itemsToRender} renderHeader={renderHeader} />;
|
||||
};
|
||||
|
@ -162,7 +162,7 @@ class GraphCtrl extends MetricsPanelCtrl {
|
||||
this.addEditorTab('Axes', axesEditorComponent);
|
||||
this.addEditorTab('Legend', 'public/app/plugins/panel/graph/tab_legend.html');
|
||||
this.addEditorTab('Thresholds & Time Regions', 'public/app/plugins/panel/graph/tab_thresholds_time_regions.html');
|
||||
this.addEditorTab('Data link', 'public/app/plugins/panel/graph/tab_drilldown_links.html');
|
||||
this.addEditorTab('Data links', 'public/app/plugins/panel/graph/tab_drilldown_links.html');
|
||||
this.subTabIndex = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user