[Security Solution][RAC] Fixes updatedAt loading bug (#111010)

This commit is contained in:
Davis Plumlee 2021-09-07 13:59:33 -04:00 committed by GitHub
parent daf860c701
commit 733b17f80c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 8 deletions

View file

@ -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(),
[]
@ -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) {
@ -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" />

View file

@ -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(),
[]
@ -285,6 +288,8 @@ const RuleDetailsPageComponent: React.FC<DetectionEngineComponentProps> = ({
}
}, [hasIndexRead]);
const showUpdating = useMemo(() => isAlertsLoading || loading, [isAlertsLoading, loading]);
const title = useMemo(
() => (
<>
@ -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" />