Skip to content

Commit

Permalink
Fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
marshallmain committed Dec 14, 2021
1 parent 5cfd00f commit ca2d093
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 114 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,63 +31,64 @@ const reason =
* accepts `EuiDataGridCellValueElementProps`, plus `data`
* from the TGrid
*/
export const RenderCellValue: React.FC<EuiDataGridCellValueElementProps & CellValueElementProps> =
({
columnId,
data,
eventId,
header,
isDetails,
isDraggable,
isExpandable,
isExpanded,
linkValues,
rowIndex,
setCellProps,
timelineId,
}) => {
const value =
getMappedNonEcsValue({
data,
fieldName: columnId,
})?.reduce((x) => x[0]) ?? '';
export const RenderCellValue: React.FC<
EuiDataGridCellValueElementProps & CellValueElementProps
> = ({
columnId,
data,
eventId,
header,
isDetails,
isDraggable,
isExpandable,
isExpanded,
linkValues,
rowIndex,
setCellProps,
timelineId,
}) => {
const value =
getMappedNonEcsValue({
data,
fieldName: columnId,
})?.reduce((x) => x[0]) ?? '';

switch (columnId) {
case ALERT_STATUS:
return (
<Status data-test-subj="alert-status" status={random(0, 1) ? 'recovered' : 'active'} />
);
case ALERT_DURATION:
case 'signal.duration.us':
return <span data-test-subj="alert-duration">{moment().fromNow(true)}</span>;
case ALERT_SEVERITY:
case 'signal.rule.severity':
return <Severity data-test-subj="rule-severity" severity={value} />;
case ALERT_REASON:
case 'signal.reason':
return (
<EuiLink data-test-subj="reason">
<TruncatableText>{reason}</TruncatableText>
</EuiLink>
);
default:
// NOTE: we're using `DefaultCellRenderer` in this example configuration as a fallback, but
// using `DefaultCellRenderer` here is entirely optional
return (
<DefaultCellRenderer
columnId={columnId}
data={data}
eventId={eventId}
header={header}
isDetails={isDetails}
isDraggable={isDraggable}
isExpandable={isExpandable}
isExpanded={isExpanded}
linkValues={linkValues}
rowIndex={rowIndex}
setCellProps={setCellProps}
timelineId={timelineId}
/>
);
}
};
switch (columnId) {
case ALERT_STATUS:
return (
<Status data-test-subj="alert-status" status={random(0, 1) ? 'recovered' : 'active'} />
);
case ALERT_DURATION:
case 'signal.duration.us':
return <span data-test-subj="alert-duration">{moment().fromNow(true)}</span>;
case ALERT_SEVERITY:
case 'signal.rule.severity':
return <Severity data-test-subj="rule-severity" severity={value} />;
case ALERT_REASON:
case 'signal.reason':
return (
<EuiLink data-test-subj="reason">
<TruncatableText>{reason}</TruncatableText>
</EuiLink>
);
default:
// NOTE: we're using `DefaultCellRenderer` in this example configuration as a fallback, but
// using `DefaultCellRenderer` here is entirely optional
return (
<DefaultCellRenderer
columnId={columnId}
data={data}
eventId={eventId}
header={header}
isDetails={isDetails}
isDraggable={isDraggable}
isExpandable={isExpandable}
isExpanded={isExpanded}
linkValues={linkValues}
rowIndex={rowIndex}
setCellProps={setCellProps}
timelineId={timelineId}
/>
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,59 +24,60 @@ const reason =
* accepts `EuiDataGridCellValueElementProps`, plus `data`
* from the TGrid
*/
export const RenderCellValue: React.FC<EuiDataGridCellValueElementProps & CellValueElementProps> =
({
columnId,
data,
eventId,
header,
isDetails,
isExpandable,
isExpanded,
linkValues,
rowIndex,
setCellProps,
timelineId,
}) => {
const value =
getMappedNonEcsValue({
data,
fieldName: columnId,
})?.reduce((x) => x[0]) ?? '';
const draggableId = `${timelineId}-${eventId}-${columnId}-${value}`;
export const RenderCellValue: React.FC<
EuiDataGridCellValueElementProps & CellValueElementProps
> = ({
columnId,
data,
eventId,
header,
isDetails,
isExpandable,
isExpanded,
linkValues,
rowIndex,
setCellProps,
timelineId,
}) => {
const value =
getMappedNonEcsValue({
data,
fieldName: columnId,
})?.reduce((x) => x[0]) ?? '';
const draggableId = `${timelineId}-${eventId}-${columnId}-${value}`;

switch (columnId) {
case 'signal.rule.severity':
case ALERT_SEVERITY:
return (
<DefaultDraggable
data-test-subj="custom-severity"
field={columnId}
id={draggableId}
value={value}
>
<Severity severity={value} />
</DefaultDraggable>
);
case 'signal.reason':
case ALERT_REASON:
return <TruncatableText data-test-subj="custom-reason">{reason}</TruncatableText>;
default:
return (
<DefaultCellRenderer
columnId={columnId}
data={data}
eventId={eventId}
header={header}
isDetails={isDetails}
isDraggable={false}
isExpandable={isExpandable}
isExpanded={isExpanded}
linkValues={linkValues}
rowIndex={rowIndex}
setCellProps={setCellProps}
timelineId={timelineId}
/>
);
}
};
switch (columnId) {
case 'signal.rule.severity':
case ALERT_SEVERITY:
return (
<DefaultDraggable
data-test-subj="custom-severity"
field={columnId}
id={draggableId}
value={value}
>
<Severity severity={value} />
</DefaultDraggable>
);
case 'signal.reason':
case ALERT_REASON:
return <TruncatableText data-test-subj="custom-reason">{reason}</TruncatableText>;
default:
return (
<DefaultCellRenderer
columnId={columnId}
data={data}
eventId={eventId}
header={header}
isDetails={isDetails}
isDraggable={false}
isExpandable={isExpandable}
isExpanded={isExpanded}
linkValues={linkValues}
rowIndex={rowIndex}
setCellProps={setCellProps}
timelineId={timelineId}
/>
);
}
};

0 comments on commit ca2d093

Please sign in to comment.