From d49c7e9a76379d12b96b3ceee0bd59896ba697cd Mon Sep 17 00:00:00 2001 From: Gordon Smith Date: Wed, 30 Oct 2024 10:50:08 +0000 Subject: [PATCH] HPCC-32834 Refactor WU Details fullscreen Move fullscreen logic to WU Details to allow switching tabs in fullscreen mode Signed-off-by: Gordon Smith --- esp/src/src-react/components/Helpers.tsx | 7 +- esp/src/src-react/components/Metrics.tsx | 45 ++--- esp/src/src-react/components/Resources.tsx | 8 +- esp/src/src-react/components/Results.tsx | 9 +- .../src-react/components/WorkunitDetails.tsx | 159 +++++++++++------- .../src-react/components/WorkunitSummary.tsx | 15 +- esp/src/src-react/routes.tsx | 8 +- esp/src/src-react/util/hashUrl.ts | 141 ++++++++++++++++ esp/src/src-react/util/history.ts | 32 ++-- 9 files changed, 293 insertions(+), 131 deletions(-) create mode 100644 esp/src/src-react/util/hashUrl.ts diff --git a/esp/src/src-react/components/Helpers.tsx b/esp/src/src-react/components/Helpers.tsx index 73fed185eca..972a7453a4c 100644 --- a/esp/src/src-react/components/Helpers.tsx +++ b/esp/src/src-react/components/Helpers.tsx @@ -6,6 +6,8 @@ import { HelperRow, useWorkunitHelpers } from "../hooks/workunit"; import { HolyGrail } from "../layouts/HolyGrail"; import { FluentGrid, useCopyButtons, useFluentStoreState, FluentColumns } from "./controls/Grid"; import { ShortVerticalDivider } from "./Common"; +import { SearchParams } from "../util/hashUrl"; +import { hashHistory } from "../util/history"; function canShowContent(type: string) { switch (type) { @@ -135,8 +137,11 @@ export const Helpers: React.FunctionComponent = ({ formatter: (Type, row) => { const target = getTarget(row.id, row); if (target) { + const searchParams = new SearchParams(hashHistory.location.search); + searchParams.param("mode", encodeURIComponent(target.sourceMode)); + searchParams.param("src", encodeURIComponent(target.url)); const linkText = Type.replace("Slave", "Worker") + (row?.Description ? " (" + row.Description + ")" : ""); - return {linkText}; + return {linkText}; } return Type; } diff --git a/esp/src/src-react/components/Metrics.tsx b/esp/src/src-react/components/Metrics.tsx index 3d1f91cc2bd..d16a0d00fc1 100644 --- a/esp/src/src-react/components/Metrics.tsx +++ b/esp/src/src-react/components/Metrics.tsx @@ -15,7 +15,7 @@ import { HolyGrail } from "../layouts/HolyGrail"; import { AutosizeComponent, AutosizeHpccJSComponent } from "../layouts/HpccJSAdapter"; import { DockPanel, DockPanelItem, ResetableDockPanel } from "../layouts/DockPanel"; import { LayoutStatus, MetricGraph, MetricGraphWidget, isGraphvizWorkerResponse, layoutCache } from "../util/metricGraph"; -import { pushUrl as _pushUrl } from "../util/history"; +import { pushUrl } from "../util/history"; import { debounce } from "../util/throttle"; import { ErrorBoundary } from "../util/errorBoundary"; import { ShortVerticalDivider } from "./Common"; @@ -45,7 +45,6 @@ interface MetricsProps { queryId?: string; parentUrl?: string; selection?: string; - fullscreen?: boolean; } export const Metrics: React.FunctionComponent = ({ @@ -53,8 +52,7 @@ export const Metrics: React.FunctionComponent = ({ querySet = "", queryId = "", parentUrl = `/workunits/${wuid}/metrics`, - selection, - fullscreen = false + selection }) => { const [_uiState, _setUIState] = React.useState({ ...defaultUIState }); const [selectedMetricsSource, setSelectedMetricsSource] = React.useState(""); @@ -97,24 +95,10 @@ export const Metrics: React.FunctionComponent = ({ }).catch(err => logger.error(err)); }, [wuid]); - const pushUrl = React.useCallback((selection?: string, fullscreen?: boolean) => { - const selectionStr = selection?.length ? `/${selection}` : ""; - const fullscreenStr = fullscreen ? "?fullscreen" : ""; - _pushUrl(`${parentUrl}${selectionStr}${fullscreenStr}`); - }, [parentUrl]); - - const pushSelectionUrl = React.useCallback((selection: string) => { - pushUrl(selection, fullscreen); - }, [fullscreen, pushUrl]); - - const pushFullscreenUrl = React.useCallback((fullscreen: boolean) => { - pushUrl(selection, fullscreen); - }, [pushUrl, selection]); - const onHotspot = React.useCallback(() => { setSelectedMetricsSource("hotspot"); - pushSelectionUrl(selection); - }, [pushSelectionUrl, selection]); + pushUrl(`${parentUrl}/${selection}`); + }, [parentUrl, selection]); // Timeline --- const timeline = useConst(() => new WUTimelineNoFetch() @@ -129,11 +113,11 @@ export const Metrics: React.FunctionComponent = ({ timeline.selection([]); setSelectedMetricsSource("scopesTable"); setScopeFilter(`name:${row[7].__hpcc_id}`); - pushSelectionUrl(row[7].id); + pushUrl(`${parentUrl}/${row[7].id}`); } }, true) ; - }, [pushSelectionUrl, timeline]); + }, [parentUrl, timeline]); React.useEffect(() => { if (view.showTimeline) { @@ -157,10 +141,10 @@ export const Metrics: React.FunctionComponent = ({ .on("selectionChanged", () => { const selection = metricGraphWidget.selection().filter(id => metricGraph.item(id)).map(id => metricGraph.item(id).id); setSelectedMetricsSource("metricGraphWidget"); - pushSelectionUrl(selection.join(",")); + pushUrl(`${parentUrl}/${selection.join(",")}`); }, true) ; - }, [metricGraph, metricGraphWidget, pushSelectionUrl]); + }, [metricGraph, metricGraphWidget, parentUrl]); React.useEffect(() => { metricGraph.load(metrics); @@ -316,8 +300,8 @@ export const Metrics: React.FunctionComponent = ({ const scopesSelectionChanged = React.useCallback((source: SelectedMetricsSource, selection: IScope[]) => { setSelectedMetricsSource(source); - pushSelectionUrl(selection.map(row => row.__lparam?.id ?? row.id).join(",")); - }, [pushSelectionUrl]); + pushUrl(selection.map(row => row.__lparam?.id ?? row.id).join(",")); + }, [pushUrl]); const scopesTable = useConst(() => new ScopesTable() .multiSelect(true) @@ -532,18 +516,13 @@ export const Metrics: React.FunctionComponent = ({ }] } }, - { key: "divider_2", itemType: ContextualMenuItemType.Divider, onRender: () => }, - { - key: "fullscreen", title: nlsHPCC.MaximizeRestore, iconProps: { iconName: fullscreen ? "ChromeRestore" : "FullScreen" }, - onClick: () => pushFullscreenUrl(!fullscreen) - } - ], [dot, formatColumns, fullscreen, metrics, pushFullscreenUrl, wuid]); + ], [dot, formatColumns, metrics, wuid]); const setShowMetricOptionsHook = React.useCallback((show: boolean) => { setShowMetricOptions(show); }, []); - return