From e4c3f62935ff5fd2dad38656def2a6e2409d4e60 Mon Sep 17 00:00:00 2001 From: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> Date: Wed, 6 Sep 2023 13:34:38 -0400 Subject: [PATCH] HPCC-30222 ECL Watch cut back multiple calls to WsLogaccess.GetLogs Signed-off-by: Jeremy Clements <79224539+jeclrsg@users.noreply.github.com> --- esp/src/src-react/components/WorkunitDetails.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/esp/src/src-react/components/WorkunitDetails.tsx b/esp/src/src-react/components/WorkunitDetails.tsx index f8f66be72b8..f1fe4d7ee13 100644 --- a/esp/src/src-react/components/WorkunitDetails.tsx +++ b/esp/src/src-react/components/WorkunitDetails.tsx @@ -1,10 +1,12 @@ import * as React from "react"; import { IPivotItemProps, Pivot, PivotItem } from "@fluentui/react"; +import { scopedLogger } from "@hpcc-js/util"; import { SizeMe } from "react-sizeme"; import nlsHPCC from "src/nlsHPCC"; import { service, hasLogAccess } from "src/ESPLog"; import { useWorkunit } from "../hooks/workunit"; import { useUserTheme } from "../hooks/theme"; +import { useDeepEffect } from "../hooks/deepHooks"; import { DojoAdapter } from "../layouts/DojoAdapter"; import { pivotItemStyle } from "../layouts/pivot"; import { pushUrl } from "../util/history"; @@ -22,6 +24,8 @@ import { WorkunitSummary } from "./WorkunitSummary"; import { Result } from "./Result"; import { Logs } from "./Logs"; +const logger = scopedLogger("src-react/components/WorkunitDetails.tsx"); + interface WorkunitDetailsProps { wuid: string; tab?: string; @@ -54,7 +58,8 @@ export const WorkunitDetails: React.FunctionComponent = ({ const [logCount, setLogCount] = React.useState("*"); const [logsDisabled, setLogsDisabled] = React.useState(true); - React.useEffect(() => { + + useDeepEffect(() => { hasLogAccess().then(response => { setLogsDisabled(!response); return response; @@ -62,12 +67,12 @@ export const WorkunitDetails: React.FunctionComponent = ({ if (hasLogAccess) { service.GetLogsEx({ ...queryParams, jobId: wuid, LogLineStartFrom: 0, LogLineLimit: 10 }).then(response => { // HPCC-27711 - Requesting LogLineLimit=1 causes issues setLogCount(response.total); - }); + }).catch((err) => logger.error(err)); } }).catch(() => { setLogsDisabled(true); }); - }, [queryParams, wuid]); + }, [wuid], [queryParams]); return {({ size }) => pushUrl(`/workunits/${wuid}/${evt.props.itemKey}`)}>