Update Button to show Checking endpoint during the endpoint checking process in Create Monitor as well as PageSpeed
This commit is contained in:
1 parent
aee7e02587
commit
8819b0ab78
2 files changed
+10
-2
No files matched your search
@@ -43,6 +43,7 @@ const CreateMonitor = () => {
|
|||||||
});
|
});
|
||||||
const [https, setHttps] = useState(true);
|
const [https, setHttps] = useState(true);
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
|
const [isCheckingEndpoint, setIsCheckingEndpoint] = useState(false);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const fetchMonitor = async () => {
|
const fetchMonitor = async () => {
|
||||||
@@ -125,6 +126,7 @@ const CreateMonitor = () => {
|
|||||||
|
|
||||||
const handleCreateMonitor = async (event) => {
|
const handleCreateMonitor = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
setIsCheckingEndpoint(true);
|
||||||
//obj to submit
|
//obj to submit
|
||||||
let form = {
|
let form = {
|
||||||
url:
|
url:
|
||||||
@@ -156,8 +158,10 @@ const CreateMonitor = () => {
|
|||||||
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||||
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
||||||
setErrors({ url: "The entered URL is not reachable." });
|
setErrors({ url: "The entered URL is not reachable." });
|
||||||
|
setIsCheckingEndpoint(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setIsCheckingEndpoint(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
form = {
|
form = {
|
||||||
@@ -387,7 +391,7 @@ const CreateMonitor = () => {
|
|||||||
onClick={handleCreateMonitor}
|
onClick={handleCreateMonitor}
|
||||||
disabled={Object.keys(errors).length !== 0 && true}
|
disabled={Object.keys(errors).length !== 0 && true}
|
||||||
>
|
>
|
||||||
Create monitor
|
{ isCheckingEndpoint ? "Checking endpoint" : "Create monitor" }
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ const CreatePageSpeed = () => {
|
|||||||
});
|
});
|
||||||
const [https, setHttps] = useState(true);
|
const [https, setHttps] = useState(true);
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
|
const [isCheckingEndpoint, setIsCheckingEndpoint] = useState(false);
|
||||||
|
|
||||||
const handleChange = (event, name) => {
|
const handleChange = (event, name) => {
|
||||||
const { value, id } = event.target;
|
const { value, id } = event.target;
|
||||||
@@ -92,6 +93,7 @@ const CreatePageSpeed = () => {
|
|||||||
|
|
||||||
const handleCreateMonitor = async (event) => {
|
const handleCreateMonitor = async (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
setIsCheckingEndpoint(true);
|
||||||
//obj to submit
|
//obj to submit
|
||||||
let form = {
|
let form = {
|
||||||
url: `http${https ? "s" : ""}://` + monitor.url,
|
url: `http${https ? "s" : ""}://` + monitor.url,
|
||||||
@@ -118,8 +120,10 @@ const CreatePageSpeed = () => {
|
|||||||
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
if (checkEndpointAction.meta.requestStatus === "rejected") {
|
||||||
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
createToast({ body: "The endpoint you entered doesn't resolve. Check the URL again." });
|
||||||
setErrors({ url: "The entered URL is not reachable." });
|
setErrors({ url: "The entered URL is not reachable." });
|
||||||
|
setIsCheckingEndpoint(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
setIsCheckingEndpoint(false);
|
||||||
|
|
||||||
form = {
|
form = {
|
||||||
...form,
|
...form,
|
||||||
@@ -343,7 +347,7 @@ const CreatePageSpeed = () => {
|
|||||||
onClick={handleCreateMonitor}
|
onClick={handleCreateMonitor}
|
||||||
disabled={Object.keys(errors).length !== 0 && true}
|
disabled={Object.keys(errors).length !== 0 && true}
|
||||||
>
|
>
|
||||||
Create monitor
|
{ isCheckingEndpoint ? "Checking endpoint" : "Create monitor" }
|
||||||
</Button>
|
</Button>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|||||||
Reference in new issue
Block a user