Skip to content

Commit

Permalink
refresh current page after toggle/run job is used (#1026)
Browse files Browse the repository at this point in the history
  • Loading branch information
fopina committed Nov 16, 2021
1 parent 5703402 commit d92b419
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions ui/src/jobs/RunButton.tsx
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand All @@ -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')
Expand Down
6 changes: 3 additions & 3 deletions ui/src/jobs/ToggleButton.tsx
Original file line number Diff line number Diff line change
@@ -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 = () => {
Expand All @@ -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')
Expand Down

0 comments on commit d92b419

Please sign in to comment.