The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/features/variables/inspect/VariablesDependenciesButton...

50 lines
1.4 KiB

import React, { FC, useMemo } from 'react';
import { Provider } from 'react-redux';
// @ts-ignore
import { Button } from '@grafana/ui';
import { createDependencyEdges, createDependencyNodes, filterNodesWithDependencies } from './utils';
import { store } from '../../../store/store';
import { VariableModel } from '../types';
import { NetworkGraphModal } from './NetworkGraphModal';
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={() => showModal()} icon="channel-add" variant="secondary">
Show dependencies
</Button>
);
}}
</NetworkGraphModal>
);
};
export const VariablesDependenciesButton: FC<Props> = (props) => (
<Provider store={store}>
<UnProvidedVariablesDependenciesButton {...props} />
</Provider>
);