Skip to content

Commit

Permalink
Revert data links code for sorted vector case (grafana#57175)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdvictor authored Oct 18, 2022
1 parent 4cee910 commit 9c51474
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 31 deletions.
4 changes: 0 additions & 4 deletions packages/grafana-data/src/vector/SortedVector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ export class SortedVector<T = any> implements Vector<T> {
return this.source.get(this.order[index]);
}

getOrderIndex(index: number): number {
return this.order[index];
}

toArray(): T[] {
return vectorToArray(this);
}
Expand Down
42 changes: 15 additions & 27 deletions public/app/plugins/panel/timeseries/plugins/ContextMenuPlugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,7 @@ import { css as cssCore, Global } from '@emotion/react';
import React, { useCallback, useLayoutEffect, useMemo, useRef, useState } from 'react';
import { useClickAway } from 'react-use';

import {
CartesianCoords2D,
DataFrame,
getFieldDisplayName,
InterpolateFunction,
SortedVector,
TimeZone,
ValueLinkConfig,
} from '@grafana/data';
import { CartesianCoords2D, DataFrame, getFieldDisplayName, InterpolateFunction, TimeZone } from '@grafana/data';
import {
ContextMenu,
GraphContextMenuHeader,
Expand Down Expand Up @@ -257,27 +249,23 @@ export const ContextMenuView: React.FC<ContextMenuViewProps> = ({

const hasLinks = field.config.links && field.config.links.length > 0;

const valueLinkConfig: ValueLinkConfig = {};

if (field.values instanceof SortedVector) {
valueLinkConfig.valueRowIndex = field.values.getOrderIndex(dataIdx);
} else {
valueLinkConfig.valueRowIndex = dataIdx;
}

if (hasLinks) {
if (field.getLinks) {
items.push({
items: field.getLinks(valueLinkConfig).map<MenuItemProps>((link) => {
return {
label: link.title,
ariaLabel: link.title,
url: link.href,
target: link.target,
icon: link.target === '_self' ? 'link' : 'external-link-alt',
onClick: link.onClick,
};
}),
items: field
.getLinks({
valueRowIndex: dataIdx,
})
.map<MenuItemProps>((link) => {
return {
label: link.title,
ariaLabel: link.title,
url: link.href,
target: link.target,
icon: link.target === '_self' ? 'link' : 'external-link-alt',
onClick: link.onClick,
};
}),
});
}
}
Expand Down

0 comments on commit 9c51474

Please sign in to comment.