diff --git a/packages/grafana-ui/src/components/Forms/InlineField.tsx b/packages/grafana-ui/src/components/Forms/InlineField.tsx index e6d9542f07a..540d03015c6 100644 --- a/packages/grafana-ui/src/components/Forms/InlineField.tsx +++ b/packages/grafana-ui/src/components/Forms/InlineField.tsx @@ -13,6 +13,8 @@ export interface Props extends Omit = ({ @@ -25,6 +27,7 @@ export const InlineField: FC = ({ disabled, className, grow, + transparent, ...htmlProps }) => { const theme = useTheme(); @@ -37,7 +40,7 @@ export const InlineField: FC = ({ } const labelElement = typeof label === 'string' ? ( - + {label} ) : ( diff --git a/packages/grafana-ui/src/components/Forms/InlineLabel.tsx b/packages/grafana-ui/src/components/Forms/InlineLabel.tsx index 9c7b3c9972f..714b4161737 100644 --- a/packages/grafana-ui/src/components/Forms/InlineLabel.tsx +++ b/packages/grafana-ui/src/components/Forms/InlineLabel.tsx @@ -12,6 +12,8 @@ export interface Props extends Omit = ({ className, tooltip, width, + transparent, as: Component = 'label', ...rest }) => { const theme = useTheme(); - const styles = getInlineLabelStyles(theme, width); - + const styles = getInlineLabelStyles(theme, transparent, width); return ( {children} @@ -46,7 +48,7 @@ export const InlineLabel: FunctionComponent = ({ ); }; -export const getInlineLabelStyles = (theme: GrafanaTheme, width?: number | 'auto') => { +export const getInlineLabelStyles = (theme: GrafanaTheme, transparent = false, width?: number | 'auto') => { return { label: css` display: flex; @@ -56,7 +58,7 @@ export const getInlineLabelStyles = (theme: GrafanaTheme, width?: number | 'auto padding: 0 ${theme.spacing.sm}; font-weight: ${theme.typography.weight.semibold}; font-size: ${theme.typography.size.sm}; - background-color: ${theme.colors.bg2}; + background-color: ${transparent ? 'transparent' : theme.colors.bg2}; height: ${theme.height.md}px; line-height: ${theme.height.md}px; margin-right: ${theme.spacing.xs}; diff --git a/packages/grafana-ui/src/components/Switch/Switch.tsx b/packages/grafana-ui/src/components/Switch/Switch.tsx index c26369d713b..555fcc8b493 100644 --- a/packages/grafana-ui/src/components/Switch/Switch.tsx +++ b/packages/grafana-ui/src/components/Switch/Switch.tsx @@ -7,6 +7,8 @@ import { focusCss } from '../../themes/mixins'; export interface Props extends Omit, 'value'> { value?: boolean; + /** Make switch's background and border transparent */ + transparent?: boolean; } export const Switch = React.forwardRef( @@ -40,9 +42,9 @@ export const Switch = React.forwardRef( Switch.displayName = 'Switch'; -export const InlineSwitch = React.forwardRef((props, ref) => { +export const InlineSwitch = React.forwardRef(({ transparent, ...props }, ref) => { const theme = useTheme(); - const styles = getSwitchStyles(theme); + const styles = getSwitchStyles(theme, transparent); return (
@@ -53,7 +55,7 @@ export const InlineSwitch = React.forwardRef((props, re InlineSwitch.displayName = 'Switch'; -const getSwitchStyles = stylesFactory((theme: GrafanaTheme) => { +const getSwitchStyles = stylesFactory((theme: GrafanaTheme, transparent?: boolean) => { return { switch: css` width: 32px; @@ -120,8 +122,8 @@ const getSwitchStyles = stylesFactory((theme: GrafanaTheme) => { height: ${theme.spacing.formInputHeight}px; display: flex; align-items: center; - background: ${theme.colors.formInputBg}; - border: 1px solid ${theme.colors.formInputBorder}; + background: ${transparent ? 'transparent' : theme.colors.formInputBg}; + border: 1px solid ${transparent ? 'transparent' : theme.colors.formInputBorder}; border-radius: ${theme.border.radius.md}; `, }; diff --git a/public/app/features/explore/Logs.tsx b/public/app/features/explore/Logs.tsx index 60028d57557..bcddbccbb28 100644 --- a/public/app/features/explore/Logs.tsx +++ b/public/app/features/explore/Logs.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { css, cx } from 'emotion'; +import { css } from 'emotion'; import { capitalize } from 'lodash'; import { @@ -17,11 +17,20 @@ import { GraphSeriesXY, LinkModel, Field, + GrafanaTheme, } from '@grafana/data'; -import { LegacyForms, LogLabels, ToggleButtonGroup, ToggleButton, LogRows, Button } from '@grafana/ui'; -const { Switch } = LegacyForms; +import { + LogLabels, + RadioButtonGroup, + LogRows, + Button, + InlineField, + InlineFieldRow, + InlineSwitch, + withTheme, + stylesFactory, +} from '@grafana/ui'; import store from 'app/core/store'; - import { ExploreGraphPanel } from './ExploreGraphPanel'; import { MetaInfoText } from './MetaInfoText'; import { RowContextOptions } from '@grafana/ui/src/components/Logs/LogRowContextProvider'; @@ -52,8 +61,8 @@ interface Props { logsSeries?: GraphSeriesXY[]; dedupedRows?: LogRowModel[]; visibleRange?: AbsoluteTimeRange; - width: number; + theme: GrafanaTheme; highlighterExpressions?: string[]; loading: boolean; absoluteRange: AbsoluteTimeRange; @@ -82,7 +91,7 @@ interface State { showDetectedFields: string[]; } -export class Logs extends PureComponent { +export class UnthemedLogs extends PureComponent { flipOrderTimer: NodeJS.Timeout; cancelFlippingTimer: NodeJS.Timeout; @@ -224,14 +233,16 @@ export class Logs extends PureComponent { absoluteRange, onChangeTime, getFieldLinks, + dedupStrategy, + theme, } = this.props; + const { showLabels, showTime, wrapLogMessage, logsSortOrder, isFlipping, showDetectedFields } = this.state; + if (!logRows) { return null; } - const { showLabels, showTime, wrapLogMessage, logsSortOrder, isFlipping, showDetectedFields } = this.state; - const { dedupStrategy } = this.props; const hasData = logRows && logRows.length > 0; const dedupCount = dedupedRows ? dedupedRows.reduce((sum, row) => (row.duplicates ? sum + row.duplicates : sum), 0) @@ -256,60 +267,57 @@ export class Logs extends PureComponent { const scanText = scanRange ? `Scanning ${rangeUtil.describeTimeRange(scanRange)}` : 'Scanning...'; const series = logsSeries ? logsSeries : []; + const styles = getStyles(theme); return ( -
-
- -
-
-
-
- - - - - {Object.keys(LogsDedupStrategy).map((dedupType: string, i) => ( - - {capitalize(dedupType)} - - ))} - -
- -
+ <> + +
+ + + + + + + + + + + + ({ + label: capitalize(dedupType), + value: dedupType, + description: LogsDedupDescription[dedupType], + }))} + value={dedupStrategy} + onChange={this.onChangeDedup} + className={styles.radioButtons} + /> + + +
{meta && ( @@ -323,7 +331,7 @@ export class Logs extends PureComponent { /> )} - {showDetectedFields && showDetectedFields.length > 0 && ( + {showDetectedFields?.length > 0 && ( { /> {!loading && !hasData && !scanning && ( -
+
No logs found.
)} -
+ ); } } + +export const Logs = withTheme(UnthemedLogs); + +const getStyles = stylesFactory((theme: GrafanaTheme) => { + return { + noData: css` + > * { + margin-left: 0.5em; + } + `, + logOptions: css` + display: flex; + justify-content: space-between; + align-items: baseline; + flex-wrap: wrap; + background-color: ${theme.colors.bg1}; + padding: ${theme.spacing.sm} ${theme.spacing.md}; + border-radius: ${theme.border.radius.md}; + margin: ${theme.spacing.md} 0 ${theme.spacing.sm}; + border: 1px solid ${theme.colors.panelBorder}; + `, + flipButton: css` + margin: ${theme.spacing.xs} 0 0 ${theme.spacing.sm}; + `, + radioButtons: css` + margin: 0 ${theme.spacing.sm}; + `, + }; +}); diff --git a/public/app/features/explore/SecondaryActions.tsx b/public/app/features/explore/SecondaryActions.tsx index 273c516ea79..8b27b12c269 100644 --- a/public/app/features/explore/SecondaryActions.tsx +++ b/public/app/features/explore/SecondaryActions.tsx @@ -1,6 +1,7 @@ import React from 'react'; import { css, cx } from 'emotion'; -import { stylesFactory, Icon } from '@grafana/ui'; +import { GrafanaTheme } from '@grafana/data'; +import { stylesFactory, Button, HorizontalGroup, useTheme } from '@grafana/ui'; type Props = { addQueryRowButtonDisabled?: boolean; @@ -13,48 +14,49 @@ type Props = { onClickQueryInspectorButton: () => void; }; -const getStyles = stylesFactory(() => { +const getStyles = stylesFactory((theme: GrafanaTheme) => { return { - button: css` - margin: 1em 4px 0 0; + containerMargin: css` + margin-top: ${theme.spacing.md}; `, }; }); export function SecondaryActions(props: Props) { - const styles = getStyles(); + const theme = useTheme(); + const styles = getStyles(theme); return ( -
- {!props.addQueryRowButtonHidden && ( - + )} + - )} - - + Query history + + +
); } diff --git a/public/app/plugins/datasource/testdata/QueryEditor.tsx b/public/app/plugins/datasource/testdata/QueryEditor.tsx index cc71bff1f73..f0ef67aa79e 100644 --- a/public/app/plugins/datasource/testdata/QueryEditor.tsx +++ b/public/app/plugins/datasource/testdata/QueryEditor.tsx @@ -4,7 +4,7 @@ import { useAsync } from 'react-use'; // Components import { selectors as editorSelectors } from '@grafana/e2e-selectors'; -import { Input, InlineFieldRow, InlineField, Select, TextArea, Switch } from '@grafana/ui'; +import { Input, InlineFieldRow, InlineField, Select, TextArea, InlineSwitch } from '@grafana/ui'; import { QueryEditorProps, SelectableValue } from '@grafana/data'; import { StreamingClientEditor, ManualEntryEditor, RandomWalkEditor } from './components'; @@ -205,7 +205,7 @@ export const QueryEditor = ({ query, datasource, onChange, onRunQuery }: Props) /> - + )} diff --git a/public/sass/_grafana.scss b/public/sass/_grafana.scss index 0076b2d1498..392310d631c 100644 --- a/public/sass/_grafana.scss +++ b/public/sass/_grafana.scss @@ -53,7 +53,6 @@ @import 'components/panel_table'; @import 'components/panel_text'; @import 'components/panel_heatmap'; -@import 'components/panel_logs'; @import 'components/tagsinput'; @import 'components/tables_lists'; @import 'components/search'; diff --git a/public/sass/components/_panel_logs.scss b/public/sass/components/_panel_logs.scss deleted file mode 100644 index ca1696180d2..00000000000 --- a/public/sass/components/_panel_logs.scss +++ /dev/null @@ -1,34 +0,0 @@ -$column-horizontal-spacing: 10px; - -.logs-panel-options { - display: flex; - background-color: $page-bg; - padding: $space-sm $space-md $space-sm $space-md; - border-radius: $border-radius; - margin: $space-md 0 $space-sm; - border: $panel-border; - flex-direction: column; -} - -.logs-panel-controls { - display: flex; - justify-content: space-between; - align-items: baseline; - flex-wrap: wrap; - .logs-panel-controls-main { - display: flex; - justify-items: flex-start; - align-items: center; - flex-wrap: wrap; - - > * { - margin-right: $spacer * 2; - } - } -} - -.logs-panel-nodata { - > * { - margin-left: 0.5em; - } -} diff --git a/public/sass/pages/_explore.scss b/public/sass/pages/_explore.scss index 887bdc4ed10..6d3f474c6cb 100644 --- a/public/sass/pages/_explore.scss +++ b/public/sass/pages/_explore.scss @@ -20,22 +20,8 @@ .explore-active-button { box-shadow: $btn-active-box-shadow; - border: 1px solid $orange-dark; - background-image: none; - background-color: transparent; + border: 1px solid $orange-dark !important; color: $orange-dark !important; - - &:focus { - background-color: transparent; - } - - i { - text-shadow: none; - background: linear-gradient(180deg, #f05a28 30%, #fbca0a 100%); - background-clip: text; - -webkit-text-fill-color: transparent; - -moz-text-fill-color: transparent; - } } .explore-ds-picker {