From c46de3e3a33e17f56d83964d31d681f78e6cfae8 Mon Sep 17 00:00:00 2001 From: "Terence D. Honles" Date: Wed, 2 Oct 2024 11:15:45 +0200 Subject: [PATCH] www: fix /builders/:builderid/force/:scheduler route not implemented This fixes a regression where the force scheduler link no longer works, and updates opening the modal to update the URL, so this link is more easily discovered and users are aware they can share links to the force scheduler modal. --- newsfragments/www-builder-force-modal.bugfix | 1 + .../src/views/BuilderView/BuilderView.tsx | 30 ++++++++++++++----- 2 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 newsfragments/www-builder-force-modal.bugfix diff --git a/newsfragments/www-builder-force-modal.bugfix b/newsfragments/www-builder-force-modal.bugfix new file mode 100644 index 00000000000..1132d8349fa --- /dev/null +++ b/newsfragments/www-builder-force-modal.bugfix @@ -0,0 +1 @@ +Fix missing builder force scheduler route ``/builders/:builderid/force/:scheduler``. diff --git a/www/base/src/views/BuilderView/BuilderView.tsx b/www/base/src/views/BuilderView/BuilderView.tsx index 4a787de8ebb..22cb8b2bc13 100644 --- a/www/base/src/views/BuilderView/BuilderView.tsx +++ b/www/base/src/views/BuilderView/BuilderView.tsx @@ -102,6 +102,7 @@ const buildTopbarActions = (builds: DataCollection, export const BuilderView = observer(() => { const builderid = useParams<"builderid">().builderid + const activeSchedulerName = useParams<"scheduler">().scheduler; const navigate = useNavigate(); const accessor = useDataAccessor([builderid]); @@ -183,16 +184,23 @@ export const BuilderView = observer(() => { const [shownForceScheduler, setShownForceScheduler] = useState(null); const actions = buildTopbarActions(builds, buildrequests, forceschedulers, isCancelling, - cancelWholeQueue, (sch) => setShownForceScheduler(sch)); + cancelWholeQueue, (sch) => navigate(`/builders/${builderid}/force/${sch.name}`)); useTopbarActions(actions); + const activeScheduler = forceschedulers.array.find((sch) => sch.name === activeSchedulerName); + if (activeScheduler && shownForceScheduler?.name !== activeScheduler.name) { + setShownForceScheduler(activeScheduler); + } else if (activeSchedulerName == null && shownForceScheduler) { + setShownForceScheduler(null); + } + const onForceBuildModalClose = (buildRequestNumber: string | null) => { - if (buildRequestNumber === null) { - setShownForceScheduler(null); - } else { - navigate(`/buildrequests/${buildRequestNumber}?redirect_to_build=true`); - } + navigate( + buildRequestNumber === null + ? `/builders/${builderid}` + : `/buildrequests/${buildRequestNumber}?redirect_to_build=true` + ); }; const renderDescription = (builder: Builder) => { @@ -263,7 +271,13 @@ export const BuilderView = observer(() => { buildbotSetupPlugin((reg) => { reg.registerRoute({ route: "builders/:builderid", - group: null, - element: () => , + group: null, + element: () => , + }); + + reg.registerRoute({ + route: "builders/:builderid/force/:scheduler", + group: null, + element: () => , }); });