Skip to content

Commit

Permalink
[Security Solution][RAC] Fixes updatedAt loading bug (elastic#111010)
Browse files Browse the repository at this point in the history
  • Loading branch information
dplumlee authored and chrisronline committed Sep 8, 2021
1 parent ba26d0f commit 726e760
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 726e760

Please sign in to comment.