Преглед изворни кода

Merge remote-tracking branch 'grafana/master' into table-reducer

* grafana/master:
  generic repeater
  generic repeater
  explore/logs: Hide empty duplicates column
  fix for firefox checkboxes not appearing properly, added appearance as none
  used regex instead of string replacing
ryan пре 6 година
родитељ
комит
ff2e238662

+ 9 - 9
packages/grafana-ui/src/components/VizRepeater/VizRepeater.tsx

@@ -1,23 +1,23 @@
 import React, { PureComponent } from 'react';
-import { SingleStatValueInfo, VizOrientation } from '../../types';
+import { VizOrientation } from '../../types';
 
-interface RenderProps {
+interface RenderProps<T> {
   vizWidth: number;
   vizHeight: number;
-  valueInfo: SingleStatValueInfo;
+  value: T;
 }
 
-interface Props {
-  children: (renderProps: RenderProps) => JSX.Element | JSX.Element[];
+interface Props<T> {
+  children: (renderProps: RenderProps<T>) => JSX.Element | JSX.Element[];
   height: number;
   width: number;
-  values: SingleStatValueInfo[];
+  values: T[];
   orientation: VizOrientation;
 }
 
 const SPACE_BETWEEN = 10;
 
-export class VizRepeater extends PureComponent<Props> {
+export class VizRepeater<T> extends PureComponent<Props<T>> {
   getOrientation(): VizOrientation {
     const { orientation, width, height } = this.props;
 
@@ -64,10 +64,10 @@ export class VizRepeater extends PureComponent<Props> {
 
     return (
       <div style={repeaterStyle}>
-        {values.map((valueInfo, index) => {
+        {values.map((value, index) => {
           return (
             <div key={index} style={itemStyles}>
-              {children({ vizHeight, vizWidth, valueInfo })}
+              {children({ vizHeight, vizWidth, value })}
             </div>
           );
         })}

+ 4 - 15
public/app/features/explore/Logs.tsx

@@ -64,7 +64,7 @@ interface Props {
 interface State {
   deferLogs: boolean;
   renderAll: boolean;
-  showLabels: boolean | null; // Tristate: null means auto
+  showLabels: boolean;
   showLocalTime: boolean;
   showUtc: boolean;
 }
@@ -76,7 +76,7 @@ export default class Logs extends PureComponent<Props, State> {
   state = {
     deferLogs: true,
     renderAll: false,
-    showLabels: null,
+    showLabels: false,
     showLocalTime: true,
     showUtc: false,
   };
@@ -166,12 +166,11 @@ export default class Logs extends PureComponent<Props, State> {
       return null;
     }
 
-    const { deferLogs, renderAll, showLocalTime, showUtc } = this.state;
-    let { showLabels } = this.state;
+    const { deferLogs, renderAll, showLabels, showLocalTime, showUtc } = this.state;
     const { dedupStrategy } = this.props;
     const hasData = data && data.rows && data.rows.length > 0;
-    const showDuplicates = dedupStrategy !== LogsDedupStrategy.none;
     const dedupCount = dedupedData.rows.reduce((sum, row) => sum + row.duplicates, 0);
+    const showDuplicates = dedupStrategy !== LogsDedupStrategy.none && dedupCount > 0;
     const meta = [...data.meta];
 
     if (dedupStrategy !== LogsDedupStrategy.none) {
@@ -186,16 +185,6 @@ export default class Logs extends PureComponent<Props, State> {
     const processedRows = dedupedData.rows;
     const firstRows = processedRows.slice(0, PREVIEW_LIMIT);
     const lastRows = processedRows.slice(PREVIEW_LIMIT);
-
-    // Check for labels
-    if (showLabels === null) {
-      if (hasData) {
-        showLabels = data.rows.some(row => _.size(row.uniqueLabels) > 0);
-      } else {
-        showLabels = true;
-      }
-    }
-
     const scanText = scanRange ? `Scanning ${rangeUtil.describeTimeRange(scanRange)}` : 'Scanning...';
 
     // React profiler becomes unusable if we pass all rows to all rows and their labels, using getter instead

+ 1 - 1
public/app/features/templating/custom_variable.ts

@@ -40,7 +40,7 @@ export class CustomVariable implements Variable {
   updateOptions() {
     // extract options in comma separated string (use backslash to escape wanted commas)
     this.options = _.map(this.query.match(/(?:\\,|[^,])+/g), text => {
-      text = text.replace('\\,', ',');
+      text = text.replace(/\\,/g, ',');
       return { text: text.trim(), value: text.trim() };
     });
 

+ 4 - 4
public/app/plugins/panel/bargauge/BarGaugePanel.tsx

@@ -10,12 +10,12 @@ import { BarGauge, VizRepeater } from '@grafana/ui';
 
 // Types
 import { BarGaugeOptions } from './types';
-import { PanelProps } from '@grafana/ui/src/types';
+import { PanelProps, SingleStatValueInfo } from '@grafana/ui/src/types';
 
 interface Props extends PanelProps<BarGaugeOptions> {}
 
 export class BarGaugePanel extends PureComponent<Props> {
-  renderBarGauge(value, width, height) {
+  renderBarGauge(value: SingleStatValueInfo, width, height) {
     const { replaceVariables, options } = this.props;
     const { valueOptions } = options;
 
@@ -24,7 +24,7 @@ export class BarGaugePanel extends PureComponent<Props> {
 
     return (
       <BarGauge
-        value={value}
+        value={value.value as number | null}
         width={width}
         height={height}
         prefix={prefix}
@@ -49,7 +49,7 @@ export class BarGaugePanel extends PureComponent<Props> {
 
     return (
       <VizRepeater height={height} width={width} values={values} orientation={options.orientation}>
-        {({ vizHeight, vizWidth, valueInfo }) => this.renderBarGauge(valueInfo.value, vizWidth, vizHeight)}
+        {({ vizHeight, vizWidth, value }) => this.renderBarGauge(value, vizWidth, vizHeight)}
       </VizRepeater>
     );
   }

+ 4 - 4
public/app/plugins/panel/gauge/GaugePanel.tsx

@@ -10,12 +10,12 @@ import { Gauge, VizRepeater } from '@grafana/ui';
 
 // Types
 import { GaugeOptions } from './types';
-import { PanelProps, VizOrientation } from '@grafana/ui/src/types';
+import { PanelProps, VizOrientation, SingleStatValueInfo } from '@grafana/ui/src/types';
 
 interface Props extends PanelProps<GaugeOptions> {}
 
 export class GaugePanel extends PureComponent<Props> {
-  renderGauge(value, width, height) {
+  renderGauge(value: SingleStatValueInfo, width, height) {
     const { replaceVariables, options } = this.props;
     const { valueOptions } = options;
 
@@ -24,7 +24,7 @@ export class GaugePanel extends PureComponent<Props> {
 
     return (
       <Gauge
-        value={value}
+        value={value.value as number | null}
         width={width}
         height={height}
         prefix={prefix}
@@ -52,7 +52,7 @@ export class GaugePanel extends PureComponent<Props> {
 
     return (
       <VizRepeater height={height} width={width} values={values} orientation={VizOrientation.Auto}>
-        {({ vizHeight, vizWidth, valueInfo }) => this.renderGauge(valueInfo.value, vizWidth, vizHeight)}
+        {({ vizHeight, vizWidth, value }) => this.renderGauge(value, vizWidth, vizHeight)}
       </VizRepeater>
     );
   }

+ 1 - 1
public/sass/components/_panel_logs.scss

@@ -173,7 +173,7 @@ $column-horizontal-spacing: 10px;
 
 .logs-row__duplicates {
   text-align: right;
-  width: 4.5em;
+  width: 4em;
 }
 
 .logs-row__field-highlight {

+ 1 - 0
public/sass/components/_switch.scss

@@ -94,6 +94,7 @@ input:checked + .gf-form-switch__slider::before {
     opacity: 0;
     width: 0;
     height: 0;
+    appearance: none;
   }
 
   &--transparent {