From d92b41985a84b550baf00d18a64da2397551f869 Mon Sep 17 00:00:00 2001 From: Filipe Pina <636320+fopina@users.noreply.github.com> Date: Tue, 16 Nov 2021 17:25:15 +0000 Subject: [PATCH] refresh current page after toggle/run job is used (#1026) --- ui/src/jobs/RunButton.tsx | 6 +++--- ui/src/jobs/ToggleButton.tsx | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ui/src/jobs/RunButton.tsx b/ui/src/jobs/RunButton.tsx index 5d36053e5..ec1eb7ee8 100644 --- a/ui/src/jobs/RunButton.tsx +++ b/ui/src/jobs/RunButton.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; import { useState } from 'react'; import { useDispatch } from 'react-redux'; -import { useNotify, useRedirect, fetchStart, fetchEnd, Button } from 'react-admin'; +import { useNotify, useRefresh, fetchStart, fetchEnd, Button } from 'react-admin'; import { apiUrl } from '../dataProvider'; import RunIcon from '@material-ui/icons/PlayArrow'; const RunButton = ({record}: any) => { const dispatch = useDispatch(); - const redirect = useRedirect(); + const refresh = useRefresh(); const notify = useNotify(); const [loading, setLoading] = useState(false); const handleClick = () => { @@ -16,7 +16,7 @@ const RunButton = ({record}: any) => { fetch(`${apiUrl}/jobs/${record.id}`, { method: 'POST' }) .then(() => { notify('Success running job'); - redirect('/jobs'); + refresh(); }) .catch((e) => { notify('Error on running job', 'warning') diff --git a/ui/src/jobs/ToggleButton.tsx b/ui/src/jobs/ToggleButton.tsx index 5bc1d46c2..40cbc3625 100644 --- a/ui/src/jobs/ToggleButton.tsx +++ b/ui/src/jobs/ToggleButton.tsx @@ -1,13 +1,13 @@ import * as React from 'react'; import { useState } from 'react'; import { useDispatch } from 'react-redux'; -import { useNotify, useRedirect, fetchStart, fetchEnd, Button } from 'react-admin'; +import { useNotify, useRefresh, fetchStart, fetchEnd, Button } from 'react-admin'; import { apiUrl } from '../dataProvider'; import ToggleIcon from '@material-ui/icons/Pause'; const ToggleButton = ({record}: any) => { const dispatch = useDispatch(); - const redirect = useRedirect(); + const refresh = useRefresh(); const notify = useNotify(); const [loading, setLoading] = useState(false); const handleClick = () => { @@ -16,7 +16,7 @@ const ToggleButton = ({record}: any) => { fetch(`${apiUrl}/jobs/${record.id}/toggle`, { method: 'POST' }) .then(() => { notify('Job toggled'); - redirect('/jobs'); + refresh(); }) .catch((e) => { notify('Error on toggle job', 'warning')