mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
* Add and configure eslint-plugin-import * Fix the lint:ts npm command * Autofix + prettier all the files * Manually fix remaining files * Move jquery code in jest-setup to external file to safely reorder imports * Resolve issue caused by circular dependencies within Prometheus * Update .betterer.results * Fix missing // @ts-ignore * ignore iconBundle.ts * Fix missing // @ts-ignore
42 lines
1009 B
TypeScript
42 lines
1009 B
TypeScript
import React, { FC, useMemo } from 'react';
|
|
|
|
import { IconButton } from '@grafana/ui';
|
|
|
|
import { NetworkGraphModal } from './NetworkGraphModal';
|
|
import { UsagesToNetwork } from './utils';
|
|
|
|
interface Props {
|
|
id: string;
|
|
usages: UsagesToNetwork[];
|
|
}
|
|
|
|
export const VariablesUnknownButton: FC<Props> = ({ id, usages }) => {
|
|
const network = useMemo(() => usages.find((n) => n.variable.id === id), [id, usages]);
|
|
|
|
if (!network) {
|
|
return null;
|
|
}
|
|
|
|
const nodes = network.nodes.map((n) => {
|
|
if (n.label.includes(`$${id}`)) {
|
|
return { ...n, color: '#FB7E81' };
|
|
}
|
|
return n;
|
|
});
|
|
|
|
return (
|
|
<NetworkGraphModal show={false} title={`Showing usages for: $${id}`} nodes={nodes} edges={network.edges}>
|
|
{({ showModal }) => {
|
|
return (
|
|
<IconButton
|
|
onClick={() => showModal()}
|
|
name="code-branch"
|
|
title="Show usages"
|
|
data-testid="VariablesUnknownButton"
|
|
/>
|
|
);
|
|
}}
|
|
</NetworkGraphModal>
|
|
);
|
|
};
|