From 6cfa77a335aebc6482930be35e81c1d7baf7b0f9 Mon Sep 17 00:00:00 2001 From: Jesulayomy Date: Fri, 25 Jul 2025 11:11:39 -0400 Subject: [PATCH] [Uptime]: Add clone Route and restore cloning logic --- client/src/Pages/Uptime/Create/index.jsx | 16 ++++++++++------ client/src/Routes/index.jsx | 4 ++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/client/src/Pages/Uptime/Create/index.jsx b/client/src/Pages/Uptime/Create/index.jsx index fa8519b1f..9a847b251 100644 --- a/client/src/Pages/Uptime/Create/index.jsx +++ b/client/src/Pages/Uptime/Create/index.jsx @@ -60,9 +60,10 @@ const parseUrl = (url) => { * Create page renders monitor creation or configuration views. * @component */ -const UptimeCreate = () => { +const UptimeCreate = ({ clone }) => { const { monitorId } = useParams(); - const isCreate = typeof monitorId === "undefined"; + const isCreate = typeof monitorId === "undefined" || clone === true; + const isClone = clone === true; // States const [monitor, setMonitor] = useState({ @@ -162,15 +163,18 @@ const UptimeCreate = () => { let form = {}; if (isCreate) { form = { - ...rest, url: - monitor.type === "http" + monitor.type === "http" && !isClone ? `http${https ? "s" : ""}://` + monitor.url : monitor.url, - port: monitor.type === "port" ? monitor.port : undefined, name: monitor.name || monitor.url.substring(0, 50), type: monitor.type, + port: monitor.type === "port" ? monitor.port : undefined, interval: monitor.interval, + matchMethod: monitor.matchMethod, + expectedValue: monitor.expectedValue, + jsonPath: monitor.jsonPath, + ignoreTlsErrors: monitor.ignoreTlsErrors, }; } else { form = { @@ -265,7 +269,7 @@ const UptimeCreate = () => { const protocol = parsedUrl?.protocol?.replace(":", "") || ""; useEffect(() => { - if (!isCreate) { + if (!isCreate || isClone) { if (monitor.matchMethod) { setUseAdvancedMatching(true); } else { diff --git a/client/src/Routes/index.jsx b/client/src/Routes/index.jsx index 5bb89db58..04d6f9b0b 100644 --- a/client/src/Routes/index.jsx +++ b/client/src/Routes/index.jsx @@ -83,6 +83,10 @@ const Routes = () => { path="/uptime/create" element={} /> + } + /> }