From 8c1cf791bbc2a5fc0ff279f9ba52d372c123f2d2 Mon Sep 17 00:00:00 2001 From: garethgeorge Date: Mon, 26 Aug 2024 19:20:38 -0700 Subject: [PATCH] fix: hide system operations in tree view --- webui/src/components/OperationList.tsx | 4 ++-- webui/src/components/OperationTree.tsx | 10 +++++++--- webui/src/views/PlanView.tsx | 1 - webui/src/views/RepoView.tsx | 4 +--- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/webui/src/components/OperationList.tsx b/webui/src/components/OperationList.tsx index b87b2482..c214f4f1 100644 --- a/webui/src/components/OperationList.tsx +++ b/webui/src/components/OperationList.tsx @@ -6,6 +6,7 @@ import { GetOperationsRequest } from "../../gen/ts/v1/service_pb"; import { useAlertApi } from "./Alerts"; import { OperationRow } from "./OperationRow"; import { OplogState, syncStateFromRequest } from "../state/logstate"; +import { shouldHideStatus } from "../state/oplog"; // OperationList displays a list of operations that are either fetched based on 'req' or passed in via 'useBackups'. // If showPlan is provided the planId will be displayed next to each operation in the operation list. @@ -25,9 +26,8 @@ export const OperationList = ({ let [operations, setOperations] = useState([]); if (req) { - // track backups for this operation tree view. useEffect(() => { - const logState = new OplogState(); + const logState = new OplogState((op) => !shouldHideStatus(op.status)); logState.subscribe((ids, flowIDs, event) => { setOperations(logState.getAll()); diff --git a/webui/src/components/OperationTree.tsx b/webui/src/components/OperationTree.tsx index 51c0722c..9e22dc9d 100644 --- a/webui/src/components/OperationTree.tsx +++ b/webui/src/components/OperationTree.tsx @@ -74,10 +74,14 @@ export const OperationTree = ({ event === OperationEventType.EVENT_UPDATED ) { for (const flowID of flowIDs) { - backupInfoByFlowID.set( - flowID, - displayInfoForFlow(logState.getByFlowID(flowID) || []) + const displayInfo = displayInfoForFlow( + logState.getByFlowID(flowID) || [] ); + if (!displayInfo.hidden) { + backupInfoByFlowID.set(flowID, displayInfo); + } else { + backupInfoByFlowID.delete(flowID); + } } } else if (event === OperationEventType.EVENT_DELETED) { for (const flowID of flowIDs) { diff --git a/webui/src/views/PlanView.tsx b/webui/src/views/PlanView.tsx index c407e7a6..df8b10c7 100644 --- a/webui/src/views/PlanView.tsx +++ b/webui/src/views/PlanView.tsx @@ -13,7 +13,6 @@ import { OpSelector, } from "../../gen/ts/v1/service_pb"; import { SpinButton } from "../components/SpinButton"; -import { shouldHideStatus } from "../state/oplog"; import { useShowModal } from "../components/ModalManager"; export const PlanView = ({ plan }: React.PropsWithChildren<{ plan: Plan }>) => { diff --git a/webui/src/views/RepoView.tsx b/webui/src/views/RepoView.tsx index db35b24f..17e3ac9f 100644 --- a/webui/src/views/RepoView.tsx +++ b/webui/src/views/RepoView.tsx @@ -10,9 +10,7 @@ import { GetOperationsRequest, OpSelector, } from "../../gen/ts/v1/service_pb"; -import { shouldHideStatus } from "../state/oplog"; import { backrestService } from "../api"; -import { StringValue } from "@bufbuild/protobuf"; import { SpinButton } from "../components/SpinButton"; import { useConfig } from "../components/ConfigProvider"; import { formatErrorAlert, useAlertApi } from "../components/Alerts"; @@ -21,7 +19,7 @@ import { useShowModal } from "../components/ModalManager"; const StatsPanel = React.lazy(() => import("../components/StatsPanel")); export const RepoView = ({ repo }: React.PropsWithChildren<{ repo: Repo }>) => { - const [config, setConfig] = useConfig(); + const [config, _] = useConfig(); const showModal = useShowModal(); const alertsApi = useAlertApi()!;