Added workflow rerun functionality in frontend (#2474)

Signed-off-by: Amit Kumar Das <amitkumar.das@mayadata.io>
This commit is contained in:
Amit Kumar Das 2021-02-25 19:53:45 +05:30 committed by GitHub
parent de0418fb2c
commit aa475a1002
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 8 deletions

View File

@ -341,7 +341,7 @@ settings:
disconnect: Are you sure you want to disconnect? disconnect: Are you sure you want to disconnect?
save: Save Locally save: Save Locally
repo: Git Repository repo: Git Repository
desc: If there are any active workflows, then the configuration of such workflows will be moved to this repository desc: '* Any existing or active workflows saved locally will not be synced into the git repository'
connect: Connect connect: Connect
branch: Branch branch: Branch
URL: Git URL URL: Git URL

View File

@ -162,3 +162,9 @@ export const DISABLE_GITOPS = gql`
disableGitOps(project_id: $data) disableGitOps(project_id: $data)
} }
`; `;
export const RERUN_CHAOS_WORKFLOW = gql`
mutation rerunChaosWorkflow($data: String!) {
reRunChaosWorkFlow(workflowID: $data)
}
`;

View File

@ -18,7 +18,11 @@ import React from 'react';
import { useTranslation } from 'react-i18next'; import { useTranslation } from 'react-i18next';
import { useSelector } from 'react-redux'; import { useSelector } from 'react-redux';
import YAML from 'yaml'; import YAML from 'yaml';
import ReplayIcon from '@material-ui/icons/Replay';
import { useMutation } from '@apollo/client';
import ButtonOutline from '../../../components/Button/ButtonOutline'; import ButtonOutline from '../../../components/Button/ButtonOutline';
import { RERUN_CHAOS_WORKFLOW } from '../../../graphql/mutations';
import * as TabActions from '../../../redux/actions/tabs';
import { ScheduleWorkflow } from '../../../models/graphql/scheduleData'; import { ScheduleWorkflow } from '../../../models/graphql/scheduleData';
import useActions from '../../../redux/actions'; import useActions from '../../../redux/actions';
import * as WorkflowActions from '../../../redux/actions/workflow'; import * as WorkflowActions from '../../../redux/actions/workflow';
@ -33,11 +37,6 @@ interface TableDataProps {
deleteRow: (wfid: string) => void; deleteRow: (wfid: string) => void;
} }
interface Weights {
experimentName: string;
weight: number;
}
const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => { const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
const classes = useStyles(); const classes = useStyles();
const { t } = useTranslation(); const { t } = useTranslation();
@ -47,7 +46,7 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
null null
); );
const [isModalOpen, setIsModalOpen] = React.useState<boolean>(false); const [isModalOpen, setIsModalOpen] = React.useState<boolean>(false);
const tabs = useActions(TabActions);
const open = Boolean(anchorEl); const open = Boolean(anchorEl);
const isOpen = Boolean(popAnchorEl); const isOpen = Boolean(popAnchorEl);
const id = isOpen ? 'simple-popover' : undefined; const id = isOpen ? 'simple-popover' : undefined;
@ -107,6 +106,20 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
}); });
} }
const [reRunChaosWorkFlow] = useMutation(RERUN_CHAOS_WORKFLOW, {
onCompleted: () => {
tabs.changeWorkflowsTabs(0);
},
});
const reRunSchedule = () => {
reRunChaosWorkFlow({
variables: {
data: data.workflow_id,
},
});
};
return ( return (
<> <>
<TableCell className={classes.workflowNameData}> <TableCell className={classes.workflowNameData}>
@ -242,6 +255,7 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
> >
<MoreVertIcon /> <MoreVertIcon />
</IconButton> </IconButton>
<Menu <Menu
id="long-menu" id="long-menu"
anchorEl={anchorEl} anchorEl={anchorEl}
@ -265,6 +279,18 @@ const TableData: React.FC<TableDataProps> = ({ data, deleteRow }) => {
) : ( ) : (
<></> <></>
)} )}
{data.cronSyntax === '' ? (
<MenuItem value="Rerun_Schedule" onClick={() => reRunSchedule()}>
<div className={classes.expDiv}>
<ReplayIcon className={classes.rerunBtn} />
<Typography data-cy="reRunSchedule" className={classes.btnText}>
Re-Run Schedule
</Typography>
</div>
</MenuItem>
) : (
<></>
)}
<MenuItem <MenuItem
value="Download" value="Download"
onClick={() => onClick={() =>

View File

@ -160,6 +160,12 @@ const useStyles = makeStyles((theme) => ({
width: '1.2rem', width: '1.2rem',
height: '1.2rem', height: '1.2rem',
}, },
rerunBtn: {
marginTop: theme.spacing(0.1),
marginLeft: theme.spacing(-0.375),
width: '1.2rem',
height: '1.2rem',
},
// Experiment Weights PopOver Property // Experiment Weights PopOver Property
weightDiv: { weightDiv: {
width: '15.1875rem', width: '15.1875rem',

View File

@ -43,8 +43,9 @@ const useStyles = makeStyles((theme: Theme) => ({
}, },
infoText: { infoText: {
maxWidth: '25rem', maxWidth: '25rem',
color: theme.palette.warning.main, color: theme.palette.error.main,
fontSize: '0.75rem', fontSize: '0.75rem',
marginLeft: theme.spacing(2),
}, },
gitInfo: { gitInfo: {
marginTop: theme.spacing(1.5), marginTop: theme.spacing(1.5),