mirror of
https://github.com/bluewave-labs/Checkmate.git
synced 2026-01-26 11:54:11 -06:00
[Uptime]: Add clone Route and restore cloning logic
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -83,6 +83,10 @@ const Routes = () => {
|
||||
path="/uptime/create"
|
||||
element={<UptimeCreate />}
|
||||
/>
|
||||
<Route
|
||||
path="/uptime/create/:monitorId"
|
||||
element={<UptimeCreate clone={true} />}
|
||||
/>
|
||||
<Route
|
||||
path="/uptime/:monitorId/"
|
||||
element={<UptimeDetails />}
|
||||
|
||||
Reference in New Issue
Block a user