mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -06:00
3c6e0e8ef8
* 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
61 lines
1.5 KiB
TypeScript
61 lines
1.5 KiB
TypeScript
import React, { FC, useMemo } from 'react';
|
|
import { Provider } from 'react-redux';
|
|
|
|
import { reportInteraction } from '@grafana/runtime';
|
|
import { Button } from '@grafana/ui';
|
|
|
|
import { store } from '../../../store/store';
|
|
import { VariableModel } from '../types';
|
|
|
|
import { NetworkGraphModal } from './NetworkGraphModal';
|
|
import { createDependencyEdges, createDependencyNodes, filterNodesWithDependencies } from './utils';
|
|
|
|
interface OwnProps {
|
|
variables: VariableModel[];
|
|
}
|
|
|
|
interface ConnectedProps {}
|
|
|
|
interface DispatchProps {}
|
|
|
|
type Props = OwnProps & ConnectedProps & DispatchProps;
|
|
|
|
export const UnProvidedVariablesDependenciesButton: FC<Props> = ({ variables }) => {
|
|
const nodes = useMemo(() => createDependencyNodes(variables), [variables]);
|
|
const edges = useMemo(() => createDependencyEdges(variables), [variables]);
|
|
|
|
if (!edges.length) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<NetworkGraphModal
|
|
show={false}
|
|
title="Dependencies"
|
|
nodes={filterNodesWithDependencies(nodes, edges)}
|
|
edges={edges}
|
|
>
|
|
{({ showModal }) => {
|
|
return (
|
|
<Button
|
|
onClick={() => {
|
|
reportInteraction('Show variable dependencies');
|
|
showModal();
|
|
}}
|
|
icon="channel-add"
|
|
variant="secondary"
|
|
>
|
|
Show dependencies
|
|
</Button>
|
|
);
|
|
}}
|
|
</NetworkGraphModal>
|
|
);
|
|
};
|
|
|
|
export const VariablesDependenciesButton: FC<Props> = (props) => (
|
|
<Provider store={store}>
|
|
<UnProvidedVariablesDependenciesButton {...props} />
|
|
</Provider>
|
|
);
|