Revert data links code for sorted vector case (#57175) (#57183)

(cherry picked from commit 9c514748f7)

Co-authored-by: Victor Marin <36818606+mdvictor@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-10-18 09:13:31 -04:00
committed by GitHub
co-authored by Victor Marin
parent 02b1030662
commit 0905058657
2 changed files with 15 additions and 31 deletions
@@ -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);
}
@@ -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,
@@ -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,
};
}),
});
}
}