mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(loki): Hide empty labels column
Signed-off-by: Steven Sheehy <ssheehy@firescope.com>
This commit is contained in:
@@ -77,6 +77,7 @@ export interface LogsMetaItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export interface LogsModel {
|
export interface LogsModel {
|
||||||
|
hasUniqueLabels: boolean;
|
||||||
id: string; // Identify one logs result from another
|
id: string; // Identify one logs result from another
|
||||||
meta?: LogsMetaItem[];
|
meta?: LogsMetaItem[];
|
||||||
rows: LogRowModel[];
|
rows: LogRowModel[];
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ interface Props {
|
|||||||
highlighterExpressions?: string[];
|
highlighterExpressions?: string[];
|
||||||
row: LogRowModel;
|
row: LogRowModel;
|
||||||
showDuplicates: boolean;
|
showDuplicates: boolean;
|
||||||
showLabels: boolean | null; // Tristate: null means auto
|
showLabels: boolean;
|
||||||
showLocalTime: boolean;
|
showLocalTime: boolean;
|
||||||
showUtc: boolean;
|
showUtc: boolean;
|
||||||
getRows: () => LogRowModel[];
|
getRows: () => LogRowModel[];
|
||||||
|
|||||||
@@ -169,6 +169,7 @@ export default class Logs extends PureComponent<Props, State> {
|
|||||||
const { deferLogs, renderAll, showLabels, showLocalTime, showUtc } = this.state;
|
const { deferLogs, renderAll, showLabels, showLocalTime, showUtc } = this.state;
|
||||||
const { dedupStrategy } = this.props;
|
const { dedupStrategy } = this.props;
|
||||||
const hasData = data && data.rows && data.rows.length > 0;
|
const hasData = data && data.rows && data.rows.length > 0;
|
||||||
|
const hasLabel = hasData && dedupedData.hasUniqueLabels;
|
||||||
const dedupCount = dedupedData.rows.reduce((sum, row) => sum + row.duplicates, 0);
|
const dedupCount = dedupedData.rows.reduce((sum, row) => sum + row.duplicates, 0);
|
||||||
const showDuplicates = dedupStrategy !== LogsDedupStrategy.none && dedupCount > 0;
|
const showDuplicates = dedupStrategy !== LogsDedupStrategy.none && dedupCount > 0;
|
||||||
const meta = [...data.meta];
|
const meta = [...data.meta];
|
||||||
@@ -247,7 +248,7 @@ export default class Logs extends PureComponent<Props, State> {
|
|||||||
highlighterExpressions={highlighterExpressions}
|
highlighterExpressions={highlighterExpressions}
|
||||||
row={row}
|
row={row}
|
||||||
showDuplicates={showDuplicates}
|
showDuplicates={showDuplicates}
|
||||||
showLabels={showLabels}
|
showLabels={showLabels && hasLabel}
|
||||||
showLocalTime={showLocalTime}
|
showLocalTime={showLocalTime}
|
||||||
showUtc={showUtc}
|
showUtc={showUtc}
|
||||||
onClickLabel={onClickLabel}
|
onClickLabel={onClickLabel}
|
||||||
@@ -262,7 +263,7 @@ export default class Logs extends PureComponent<Props, State> {
|
|||||||
getRows={getRows}
|
getRows={getRows}
|
||||||
row={row}
|
row={row}
|
||||||
showDuplicates={showDuplicates}
|
showDuplicates={showDuplicates}
|
||||||
showLabels={showLabels}
|
showLabels={showLabels && hasLabel}
|
||||||
showLocalTime={showLocalTime}
|
showLocalTime={showLocalTime}
|
||||||
showUtc={showUtc}
|
showUtc={showUtc}
|
||||||
onClickLabel={onClickLabel}
|
onClickLabel={onClickLabel}
|
||||||
|
|||||||
@@ -175,6 +175,8 @@ export function mergeStreamsToLogs(streams: LogsStream[], limit = DEFAULT_MAX_LI
|
|||||||
.reverse()
|
.reverse()
|
||||||
.value();
|
.value();
|
||||||
|
|
||||||
|
const hasUniqueLabels = sortedRows && sortedRows.some(row => Object.keys(row.uniqueLabels).length > 0);
|
||||||
|
|
||||||
// Meta data to display in status
|
// Meta data to display in status
|
||||||
const meta: LogsMetaItem[] = [];
|
const meta: LogsMetaItem[] = [];
|
||||||
if (_.size(commonLabels) > 0) {
|
if (_.size(commonLabels) > 0) {
|
||||||
@@ -194,6 +196,7 @@ export function mergeStreamsToLogs(streams: LogsStream[], limit = DEFAULT_MAX_LI
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
id,
|
id,
|
||||||
|
hasUniqueLabels,
|
||||||
meta,
|
meta,
|
||||||
rows: sortedRows,
|
rows: sortedRows,
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user