Skip to content

Commit

Permalink
[Security Solution][RAC] Fixes updatedAt loading bug (#111010) (#111440)
Browse files Browse the repository at this point in the history
Co-authored-by: Davis Plumlee <[email protected]>
  • Loading branch information
kibanamachine and dplumlee authored Sep 7, 2021
1 parent 2fa1822 commit 673bcfd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ const DetectionEnginePageComponent: React.FC<DetectionEngineComponentProps> = ({
const updatedAt = useShallowEqualSelector(
(state) => (getTimeline(state, TimelineId.detectionsPage) ?? timelineDefaults).updated
);
const isAlertsLoading = useShallowEqualSelector(
(state) => (getTimeline(state, TimelineId.detectionsPage) ?? timelineDefaults).isLoading
);
const getGlobalFiltersQuerySelector = useMemo(
() => inputsSelectors.globalFiltersQuerySelector(),
[]
Expand Down Expand Up @@ -144,6 +147,8 @@ const DetectionEnginePageComponent: React.FC<DetectionEngineComponentProps> = ({
} = useKibana().services;
const [filterGroup, setFilterGroup] = useState<Status>(FILTER_OPEN);

const showUpdating = useMemo(() => isAlertsLoading || loading, [isAlertsLoading, loading]);

const updateDateRangeCallback = useCallback<UpdateDateRange>(
({ x }) => {
if (!x) {
Expand Down Expand Up @@ -342,10 +347,11 @@ const DetectionEnginePageComponent: React.FC<DetectionEngineComponentProps> = ({
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
{timelinesUi.getLastUpdated({
updatedAt: updatedAt || 0,
showUpdating: loading,
})}
{updatedAt &&
timelinesUi.getLastUpdated({
updatedAt: updatedAt || Date.now(),
showUpdating,
})}
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,9 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
const updatedAt = useShallowEqualSelector(
(state) => (getTimeline(state, TimelineId.detectionsPage) ?? timelineDefaults).updated
);
const isAlertsLoading = useShallowEqualSelector(
(state) => (getTimeline(state, TimelineId.detectionsPage) ?? timelineDefaults).isLoading
);
const getGlobalFiltersQuerySelector = useMemo(
() => inputsSelectors.globalFiltersQuerySelector(),
[]
Expand Down Expand Up @@ -285,6 +288,8 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
}
}, [hasIndexRead]);

const showUpdating = useMemo(() => isAlertsLoading || loading, [isAlertsLoading, loading]);

const title = useMemo(
() => (
<>
Expand Down Expand Up @@ -772,10 +777,11 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
{timelinesUi.getLastUpdated({
updatedAt: updatedAt || 0,
showUpdating: loading,
})}
{updatedAt &&
timelinesUi.getLastUpdated({
updatedAt: updatedAt || Date.now(),
showUpdating,
})}
</EuiFlexItem>
</EuiFlexGroup>
<EuiSpacer size="l" />
Expand Down

0 comments on commit 673bcfd

Please sign in to comment.