2021-04-01 07:15:23 -05:00
|
|
|
import { css } from '@emotion/css';
|
2022-04-22 08:33:13 -05:00
|
|
|
import React, { ReactElement } from 'react';
|
|
|
|
|
2020-12-15 03:08:02 -06:00
|
|
|
import { GrafanaTheme } from '@grafana/data';
|
2022-04-22 08:33:13 -05:00
|
|
|
import { Icon, useStyles } from '@grafana/ui';
|
2020-12-15 03:08:02 -06:00
|
|
|
|
|
|
|
import { ResultInfo } from './types';
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
editURL: string;
|
|
|
|
target: ResultInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function DashboardQueryRow({ editURL, target }: Props): ReactElement {
|
|
|
|
const style = useStyles(getStyles);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={style.queryEditorRowHeader}>
|
|
|
|
<div>
|
|
|
|
<img src={target.img} width={16} className={style.logo} />
|
|
|
|
<span>{`${target.refId}:`}</span>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<a href={editURL}>
|
|
|
|
{target.query}
|
|
|
|
|
|
|
|
<Icon name="external-link-alt" />
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getStyles(theme: GrafanaTheme) {
|
|
|
|
return {
|
|
|
|
logo: css`
|
|
|
|
label: logo;
|
|
|
|
margin-right: ${theme.spacing.sm};
|
|
|
|
`,
|
|
|
|
queryEditorRowHeader: css`
|
|
|
|
label: queryEditorRowHeader;
|
|
|
|
display: flex;
|
|
|
|
padding: 4px 8px;
|
|
|
|
flex-flow: row wrap;
|
|
|
|
background: ${theme.colors.bg2};
|
|
|
|
align-items: center;
|
|
|
|
`,
|
|
|
|
};
|
|
|
|
}
|