Skip to content

Commit

Permalink
[Logs UI] Fix display of dataset values in anomaly and category examp…
Browse files Browse the repository at this point in the history
…le rows (#71693)

This removes an unnecessary JSON encoding step of values before they are passed to the field column component used in the log entry example rows in both the Anomalies and Categories tabs.
  • Loading branch information
weltenwort authored Jul 17, 2020
1 parent 93be1cf commit 44888d3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* you may not use this file except in compliance with the Elastic License.
*/

import React, { useMemo, useState, useCallback, useContext } from 'react';
import React, { useState, useCallback, useContext } from 'react';
import { i18n } from '@kbn/i18n';
import { encode } from 'rison-node';
import moment from 'moment';
Expand Down Expand Up @@ -40,12 +40,8 @@ export const CategoryExampleMessage: React.FunctionComponent<{
context: LogEntryContext;
}> = ({ id, dataset, message, timestamp, timeRange, tiebreaker, context }) => {
const [, { setContextEntry }] = useContext(ViewLogInContext.Context);
// the dataset must be encoded for the field column and the empty value must
// be turned into a user-friendly value
const encodedDatasetFieldValue = useMemo(
() => JSON.stringify(getFriendlyNameForPartitionId(dataset)),
[dataset]
);
// handle special cases for the dataset value
const humanFriendlyDataset = getFriendlyNameForPartitionId(dataset);

const [isHovered, setIsHovered] = useState<boolean>(false);
const setHovered = useCallback(() => setIsHovered(true), []);
Expand Down Expand Up @@ -100,7 +96,7 @@ export const CategoryExampleMessage: React.FunctionComponent<{
columnValue={{
columnId: datasetColumnId,
field: 'event.dataset',
value: encodedDatasetFieldValue,
value: humanFriendlyDataset,
highlights: [],
}}
highlights={noHighlights}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,8 @@ export const LogEntryExampleMessage: React.FunctionComponent<Props> = ({
const setItemIsHovered = useCallback(() => setIsHovered(true), []);
const setItemIsNotHovered = useCallback(() => setIsHovered(false), []);

// the dataset must be encoded for the field column and the empty value must
// be turned into a user-friendly value
const encodedDatasetFieldValue = useMemo(
() => JSON.stringify(getFriendlyNameForPartitionId(dataset)),
[dataset]
);
// handle special cases for the dataset value
const humanFriendlyDataset = getFriendlyNameForPartitionId(dataset);

const viewInStreamLinkProps = useLinkProps({
app: 'logs',
Expand Down Expand Up @@ -158,7 +154,7 @@ export const LogEntryExampleMessage: React.FunctionComponent<Props> = ({
columnValue={{
columnId: datasetColumnId,
field: 'event.dataset',
value: encodedDatasetFieldValue,
value: humanFriendlyDataset,
highlights: [],
}}
highlights={noHighlights}
Expand Down

0 comments on commit 44888d3

Please sign in to comment.