mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* Chore: initial commit * Refactor: adds usages * Refactor: adds FeatureInfoBox * Refactor: uses graphs instead * Refactor: adds id, name, title to prop instead of key * Refactor: adds usages to VariablesList * Refactor: Moves unknowns to first page * Refactor: minor stylings and icons * Refactor: styling * Refactor: changed to button with modal * Refactor: adds VariablesDependenciesButton * Refactor: changes after UX feedback * Refactor: renames heading * Refactor: changes after PR comments * Refactor: small changes after PR comments
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
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]);
|
|
|
|
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>
|
|
);
|