2021-03-09 05:49:05 -06:00
|
|
|
import React, { FC } from 'react';
|
2020-11-05 02:53:27 -06:00
|
|
|
import { css } from 'emotion';
|
|
|
|
import { Icon, Tooltip, useStyles } from '@grafana/ui';
|
|
|
|
import { GrafanaTheme } from '@grafana/data';
|
2021-03-09 05:49:05 -06:00
|
|
|
import { UsagesToNetwork } from './utils';
|
2020-11-05 02:53:27 -06:00
|
|
|
import { VariablesUnknownButton } from './VariablesUnknownButton';
|
|
|
|
|
2021-03-09 05:49:05 -06:00
|
|
|
interface Props {
|
|
|
|
usages: UsagesToNetwork[];
|
2020-11-05 02:53:27 -06:00
|
|
|
}
|
|
|
|
|
2021-03-09 05:49:05 -06:00
|
|
|
export const VariablesUnknownTable: FC<Props> = ({ usages }) => {
|
2020-11-05 02:53:27 -06:00
|
|
|
const style = useStyles(getStyles);
|
|
|
|
return (
|
|
|
|
<div className={style.container}>
|
|
|
|
<h5>
|
|
|
|
Unknown Variables
|
|
|
|
<Tooltip content="This table lists all variable references that no longer exist in this dashboard.">
|
|
|
|
<Icon name="info-circle" className={style.infoIcon} />
|
|
|
|
</Tooltip>
|
|
|
|
</h5>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<table className="filter-table filter-table--hover">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<th>Variable</th>
|
|
|
|
<th colSpan={5} />
|
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2021-03-09 05:49:05 -06:00
|
|
|
{usages.map((usage) => {
|
|
|
|
const { variable } = usage;
|
2020-11-05 02:53:27 -06:00
|
|
|
const { id, name } = variable;
|
|
|
|
return (
|
|
|
|
<tr key={id}>
|
|
|
|
<td className={style.firstColumn}>
|
|
|
|
<span>{name}</span>
|
|
|
|
</td>
|
|
|
|
<td className={style.defaultColumn} />
|
|
|
|
<td className={style.defaultColumn} />
|
|
|
|
<td className={style.defaultColumn} />
|
|
|
|
<td className={style.lastColumn}>
|
2021-03-09 05:49:05 -06:00
|
|
|
<VariablesUnknownButton id={variable.id} usages={usages} />
|
2020-11-05 02:53:27 -06:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
);
|
|
|
|
})}
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
const getStyles = (theme: GrafanaTheme) => ({
|
|
|
|
container: css`
|
|
|
|
margin-top: ${theme.spacing.xl};
|
|
|
|
padding-top: ${theme.spacing.xl};
|
|
|
|
border-top: 1px solid ${theme.colors.panelBorder};
|
|
|
|
`,
|
|
|
|
infoIcon: css`
|
|
|
|
margin-left: ${theme.spacing.sm};
|
|
|
|
`,
|
|
|
|
defaultColumn: css`
|
|
|
|
width: 1%;
|
|
|
|
`,
|
|
|
|
firstColumn: css`
|
|
|
|
width: 1%;
|
|
|
|
vertical-align: top;
|
|
|
|
color: ${theme.colors.textStrong};
|
|
|
|
`,
|
|
|
|
lastColumn: css`
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
width: 100%;
|
|
|
|
text-align: right;
|
|
|
|
`,
|
|
|
|
});
|