mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Query Library: Vertical space between rows; change "Run query" button color (#94177)
This commit is contained in:
@@ -3,7 +3,7 @@ import { ConnectedProps, connect } from 'react-redux';
|
|||||||
|
|
||||||
import { config, reportInteraction } from '@grafana/runtime';
|
import { config, reportInteraction } from '@grafana/runtime';
|
||||||
import { DataQuery } from '@grafana/schema';
|
import { DataQuery } from '@grafana/schema';
|
||||||
import { Button, Dropdown, Menu, ToolbarButton } from '@grafana/ui';
|
import { Button, ButtonVariant, Dropdown, Menu, ToolbarButton } from '@grafana/ui';
|
||||||
import { t } from '@grafana/ui/src/utils/i18n';
|
import { t } from '@grafana/ui/src/utils/i18n';
|
||||||
import { useSelector } from 'app/types';
|
import { useSelector } from 'app/types';
|
||||||
|
|
||||||
@@ -22,6 +22,7 @@ interface ExploreRunQueryButtonProps {
|
|||||||
queries: DataQuery[];
|
queries: DataQuery[];
|
||||||
rootDatasourceUid?: string;
|
rootDatasourceUid?: string;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
variant?: ButtonVariant;
|
||||||
onClick?: () => void;
|
onClick?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -36,6 +37,7 @@ export function ExploreRunQueryButton({
|
|||||||
rootDatasourceUid,
|
rootDatasourceUid,
|
||||||
queries,
|
queries,
|
||||||
disabled = false,
|
disabled = false,
|
||||||
|
variant = 'secondary',
|
||||||
onClick,
|
onClick,
|
||||||
changeDatasource,
|
changeDatasource,
|
||||||
setQueries,
|
setQueries,
|
||||||
@@ -82,7 +84,7 @@ export function ExploreRunQueryButton({
|
|||||||
const buttonText = runQueryText(exploreId, rootDatasourceUid);
|
const buttonText = runQueryText(exploreId, rootDatasourceUid);
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
variant="secondary"
|
variant={variant}
|
||||||
aria-label={buttonText.translation}
|
aria-label={buttonText.translation}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
runQuery(exploreId);
|
runQuery(exploreId);
|
||||||
|
|||||||
@@ -82,6 +82,7 @@ function ActionsCell({ queryTemplate, rootDatasourceUid, queryUid }: ActionsCell
|
|||||||
<ExploreRunQueryButton
|
<ExploreRunQueryButton
|
||||||
queries={queryTemplate.query ? [queryTemplate.query] : []}
|
queries={queryTemplate.query ? [queryTemplate.query] : []}
|
||||||
rootDatasourceUid={rootDatasourceUid}
|
rootDatasourceUid={rootDatasourceUid}
|
||||||
|
variant="primary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setDrawerOpened(false);
|
setDrawerOpened(false);
|
||||||
queryLibraryTrackRunQuery(queryTemplate.datasourceType || '');
|
queryLibraryTrackRunQuery(queryTemplate.datasourceType || '');
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
import { css } from '@emotion/css';
|
||||||
import { SortByFn } from 'react-table';
|
import { SortByFn } from 'react-table';
|
||||||
|
|
||||||
import { Column, InteractiveTable } from '@grafana/ui';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
|
import { Column, InteractiveTable, useStyles2 } from '@grafana/ui';
|
||||||
|
|
||||||
import ActionsCell from './ActionsCell';
|
import ActionsCell from './ActionsCell';
|
||||||
import { AddedByCell } from './AddedByCell';
|
import { AddedByCell } from './AddedByCell';
|
||||||
@@ -34,12 +36,34 @@ type Props = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export default function QueryTemplatesTable({ queryTemplateRows }: Props) {
|
export default function QueryTemplatesTable({ queryTemplateRows }: Props) {
|
||||||
|
const styles = useStyles2(getStyles);
|
||||||
return (
|
return (
|
||||||
<InteractiveTable
|
<InteractiveTable
|
||||||
columns={columns}
|
columns={columns}
|
||||||
data={queryTemplateRows}
|
data={queryTemplateRows}
|
||||||
getRowId={(row: { index: string }) => row.index}
|
getRowId={(row: { index: string }) => row.index}
|
||||||
pageSize={20}
|
pageSize={20}
|
||||||
|
className={styles.table}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getStyles = (theme: GrafanaTheme2) => ({
|
||||||
|
table: css({
|
||||||
|
'tbody tr': {
|
||||||
|
position: 'relative',
|
||||||
|
backgroundColor: theme.colors.background.secondary,
|
||||||
|
borderCollapse: 'collapse',
|
||||||
|
borderBottom: 'unset',
|
||||||
|
overflow: 'hidden', // Ensure the row doesn't overflow and cause additonal scrollbars
|
||||||
|
},
|
||||||
|
/* Adds the pseudo-element for the lines between table rows */
|
||||||
|
'tbody tr::after': {
|
||||||
|
content: '""',
|
||||||
|
position: 'absolute',
|
||||||
|
inset: 'auto 0 0 0',
|
||||||
|
height: theme.spacing(0.5),
|
||||||
|
backgroundColor: theme.colors.background.primary,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user