[Uptime]: removed formatAndSet, added displayInterval, moved UI logic out of component view
This commit is contained in:
1 parent
89f5be2cc9
commit
47021fa55c
1 file changed
+5
-8
@@ -35,7 +35,7 @@ import { useMonitorUtils } from "../../../Hooks/useMonitorUtils";
|
|||||||
import { useGetNotificationsByTeamId } from "../../../Hooks/useNotifications";
|
import { useGetNotificationsByTeamId } from "../../../Hooks/useNotifications";
|
||||||
import { useParams } from "react-router-dom";
|
import { useParams } from "react-router-dom";
|
||||||
import {
|
import {
|
||||||
useCreateMonitor,
|
useCreateMonitor,
|
||||||
useDeleteMonitor,
|
useDeleteMonitor,
|
||||||
useUpdateMonitor,
|
useUpdateMonitor,
|
||||||
usePauseMonitor,
|
usePauseMonitor,
|
||||||
@@ -83,10 +83,6 @@ const UptimeCreate = () => {
|
|||||||
const triggerUpdate = () => {
|
const triggerUpdate = () => {
|
||||||
setUpdateTrigger(!updateTrigger);
|
setUpdateTrigger(!updateTrigger);
|
||||||
};
|
};
|
||||||
// const formatAndSet = (monitor) => {
|
|
||||||
// monitor.interval = monitor.interval / MS_PER_MINUTE;
|
|
||||||
// setMonitor(monitor);
|
|
||||||
// };
|
|
||||||
|
|
||||||
// Hooks
|
// Hooks
|
||||||
const [notifications, notificationsAreLoading, notificationsError] =
|
const [notifications, notificationsAreLoading, notificationsError] =
|
||||||
@@ -95,7 +91,7 @@ const UptimeCreate = () => {
|
|||||||
// Network
|
// Network
|
||||||
const [isLoading] = useFetchMonitorById({
|
const [isLoading] = useFetchMonitorById({
|
||||||
monitorId,
|
monitorId,
|
||||||
setMonitor, // : formatAndSet,
|
setMonitor,
|
||||||
updateTrigger: true,
|
updateTrigger: true,
|
||||||
});
|
});
|
||||||
const [createMonitor, isCreating] = useCreateMonitor();
|
const [createMonitor, isCreating] = useCreateMonitor();
|
||||||
@@ -264,6 +260,7 @@ const UptimeCreate = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const isBusy = isLoading || isCreating || isDeleting || isUpdating || isPausing;
|
const isBusy = isLoading || isCreating || isDeleting || isUpdating || isPausing;
|
||||||
|
const displayInterval = monitor?.interval / MS_PER_MINUTE || 1;
|
||||||
const parsedUrl = parseUrl(monitor?.url);
|
const parsedUrl = parseUrl(monitor?.url);
|
||||||
const protocol = parsedUrl?.protocol?.replace(":", "") || "";
|
const protocol = parsedUrl?.protocol?.replace(":", "") || "";
|
||||||
|
|
||||||
@@ -526,7 +523,7 @@ const UptimeCreate = () => {
|
|||||||
: monitorTypeMaps[monitor.type].label || t("urlMonitor")
|
: monitorTypeMaps[monitor.type].label || t("urlMonitor")
|
||||||
}
|
}
|
||||||
placeholder={monitorTypeMaps[monitor.type].placeholder || ""}
|
placeholder={monitorTypeMaps[monitor.type].placeholder || ""}
|
||||||
value={parsedUrl?.host || monitor?.url || ""}
|
value={parsedUrl?.host + parsedUrl?.pathname || monitor?.url || ""}
|
||||||
https={isCreate ? https : protocol === "https"}
|
https={isCreate ? https : protocol === "https"}
|
||||||
startAdornment={
|
startAdornment={
|
||||||
monitor?.type === "http" && (
|
monitor?.type === "http" && (
|
||||||
@@ -610,7 +607,7 @@ const UptimeCreate = () => {
|
|||||||
<Select
|
<Select
|
||||||
name="interval"
|
name="interval"
|
||||||
label={t("checkFrequency")}
|
label={t("checkFrequency")}
|
||||||
value={monitor?.interval / MS_PER_MINUTE || 1}
|
value={displayInterval}
|
||||||
onChange={onChange}
|
onChange={onChange}
|
||||||
items={FREQUENCIES}
|
items={FREQUENCIES}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user