feat: add no data alert in test substep and execution
This commit is contained in:
@@ -8,7 +8,7 @@ class Execution extends Base {
|
|||||||
id!: string;
|
id!: string;
|
||||||
flowId!: string;
|
flowId!: string;
|
||||||
testRun = false;
|
testRun = false;
|
||||||
internalId!: string;
|
internalId: string;
|
||||||
executionSteps: ExecutionStep[] = [];
|
executionSteps: ExecutionStep[] = [];
|
||||||
|
|
||||||
static tableName = 'executions';
|
static tableName = 'executions';
|
||||||
|
@@ -38,11 +38,16 @@ class Processor {
|
|||||||
if (initialTriggerData.length === 0) {
|
if (initialTriggerData.length === 0) {
|
||||||
const lastInternalId = await this.flow.lastInternalId();
|
const lastInternalId = await this.flow.lastInternalId();
|
||||||
|
|
||||||
await Execution.query().insert({
|
const executionData: Partial<Execution> = {
|
||||||
flowId: this.flow.id,
|
flowId: this.flow.id,
|
||||||
testRun: this.testRun,
|
testRun: this.testRun,
|
||||||
internalId: lastInternalId,
|
};
|
||||||
});
|
|
||||||
|
if (lastInternalId) {
|
||||||
|
executionData.internalId = lastInternalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
await Execution.query().insert(executionData);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -109,7 +109,7 @@ export default function EditorLayout(): React.ReactElement {
|
|||||||
|
|
||||||
<Snackbar
|
<Snackbar
|
||||||
open={!!flow?.active}
|
open={!!flow?.active}
|
||||||
message={formatMessage('flowEditor.publishFlowCannotBeUpdated')}
|
message={formatMessage('flowEditor.publishedFlowCannotBeUpdated')}
|
||||||
anchorOrigin={{ horizontal: 'center', vertical: 'bottom' }}
|
anchorOrigin={{ horizontal: 'center', vertical: 'bottom' }}
|
||||||
ContentProps={{ sx: { fontWeight: 300 }}}
|
ContentProps={{ sx: { fontWeight: 300 }}}
|
||||||
action={(
|
action={(
|
||||||
|
@@ -4,9 +4,11 @@ import Box from '@mui/material/Box';
|
|||||||
import Collapse from '@mui/material/Collapse';
|
import Collapse from '@mui/material/Collapse';
|
||||||
import ListItem from '@mui/material/ListItem';
|
import ListItem from '@mui/material/ListItem';
|
||||||
import Alert from '@mui/material/Alert';
|
import Alert from '@mui/material/Alert';
|
||||||
|
import AlertTitle from '@mui/material/AlertTitle';
|
||||||
import LoadingButton from '@mui/lab/LoadingButton';
|
import LoadingButton from '@mui/lab/LoadingButton';
|
||||||
|
|
||||||
import { EditorContext } from 'contexts/Editor';
|
import { EditorContext } from 'contexts/Editor';
|
||||||
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
import JSONViewer from 'components/JSONViewer';
|
import JSONViewer from 'components/JSONViewer';
|
||||||
import { EXECUTE_FLOW } from 'graphql/mutations/execute-flow';
|
import { EXECUTE_FLOW } from 'graphql/mutations/execute-flow';
|
||||||
import FlowSubstepTitle from 'components/FlowSubstepTitle';
|
import FlowSubstepTitle from 'components/FlowSubstepTitle';
|
||||||
@@ -32,14 +34,21 @@ function TestSubstep(props: TestSubstepProps): React.ReactElement {
|
|||||||
step,
|
step,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
|
const formatMessage = useFormatMessage();
|
||||||
const editorContext = React.useContext(EditorContext);
|
const editorContext = React.useContext(EditorContext);
|
||||||
const [executeFlow, { data, error, loading }] = useMutation(EXECUTE_FLOW, { context: { autoSnackbar: false }});
|
const [executeFlow, { data, error, loading, called, reset }] = useMutation(EXECUTE_FLOW, { context: { autoSnackbar: false }});
|
||||||
const response = data?.executeFlow?.data;
|
const response = data?.executeFlow?.data;
|
||||||
|
|
||||||
const {
|
const {
|
||||||
name,
|
name,
|
||||||
} = substep;
|
} = substep;
|
||||||
|
|
||||||
|
React.useEffect(function resetTestDataOnSubstepToggle() {
|
||||||
|
if (!expanded) {
|
||||||
|
reset();
|
||||||
|
}
|
||||||
|
}, [expanded, reset])
|
||||||
|
|
||||||
const handleSubmit = React.useCallback(() => {
|
const handleSubmit = React.useCallback(() => {
|
||||||
executeFlow({
|
executeFlow({
|
||||||
variables: {
|
variables: {
|
||||||
@@ -64,6 +73,14 @@ function TestSubstep(props: TestSubstepProps): React.ReactElement {
|
|||||||
{error?.graphQLErrors.map((error) => (<>{error.message}<br /></>))}
|
{error?.graphQLErrors.map((error) => (<>{error.message}<br /></>))}
|
||||||
</Alert>}
|
</Alert>}
|
||||||
|
|
||||||
|
{called && !response && (
|
||||||
|
<Alert severity="warning" sx={{ mb: 1, width: '100%' }}>
|
||||||
|
<AlertTitle sx={{ fontWeight: 700 }}>{formatMessage('flowEditor.noTestDataTitle')}</AlertTitle>
|
||||||
|
|
||||||
|
<Box sx={{ fontWeight: 400 }}>{formatMessage('flowEditor.noTestDataMessage')}</Box>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
{response && (
|
{response && (
|
||||||
<Box sx={{ maxHeight: 400, overflowY: 'auto', width: '100%' }}>
|
<Box sx={{ maxHeight: 400, overflowY: 'auto', width: '100%' }}>
|
||||||
<JSONViewer data={response} />
|
<JSONViewer data={response} />
|
||||||
|
@@ -44,7 +44,9 @@
|
|||||||
"flow.draft": "Draft",
|
"flow.draft": "Draft",
|
||||||
"flowEditor.publish": "PUBLISH",
|
"flowEditor.publish": "PUBLISH",
|
||||||
"flowEditor.unpublish": "UNPUBLISH",
|
"flowEditor.unpublish": "UNPUBLISH",
|
||||||
"flowEditor.publishFlowCannotBeUpdated": "To edit this flow, you must first unpublish it.",
|
"flowEditor.publishedFlowCannotBeUpdated": "To edit this flow, you must first unpublish it.",
|
||||||
|
"flowEditor.noTestDataTitle": "We couldn't find matching data",
|
||||||
|
"flowEditor.noTestDataMessage": "Create a sample in the associated service and test the step again.",
|
||||||
"flow.createdAt": "created {datetime}",
|
"flow.createdAt": "created {datetime}",
|
||||||
"flow.updatedAt": "updated {datetime}",
|
"flow.updatedAt": "updated {datetime}",
|
||||||
"flow.view": "View",
|
"flow.view": "View",
|
||||||
@@ -59,6 +61,8 @@
|
|||||||
"executions.noExecutions": "There is no execution data point to show.",
|
"executions.noExecutions": "There is no execution data point to show.",
|
||||||
"execution.executedAt": "executed {datetime}",
|
"execution.executedAt": "executed {datetime}",
|
||||||
"execution.test": "Test run",
|
"execution.test": "Test run",
|
||||||
|
"execution.noDataTitle": "No data",
|
||||||
|
"execution.noDataMessage": "We successfully ran the execution, but there was no new data to process.",
|
||||||
"profileSettings.title": "My Profile",
|
"profileSettings.title": "My Profile",
|
||||||
"profileSettings.email": "Email",
|
"profileSettings.email": "Email",
|
||||||
"profileSettings.updateEmail": "Update email",
|
"profileSettings.updateEmail": "Update email",
|
||||||
|
@@ -2,8 +2,12 @@ import * as React from 'react';
|
|||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
import { useQuery } from '@apollo/client';
|
import { useQuery } from '@apollo/client';
|
||||||
import Grid from '@mui/material/Grid';
|
import Grid from '@mui/material/Grid';
|
||||||
|
import Box from '@mui/material/Box';
|
||||||
|
import AlertTitle from '@mui/material/AlertTitle';
|
||||||
|
import Alert from '@mui/material/Alert';
|
||||||
import type { IExecutionStep } from '@automatisch/types';
|
import type { IExecutionStep } from '@automatisch/types';
|
||||||
|
|
||||||
|
import useFormatMessage from 'hooks/useFormatMessage';
|
||||||
import ExecutionHeader from 'components/ExecutionHeader';
|
import ExecutionHeader from 'components/ExecutionHeader';
|
||||||
import ExecutionStep from 'components/ExecutionStep';
|
import ExecutionStep from 'components/ExecutionStep';
|
||||||
import Container from 'components/Container';
|
import Container from 'components/Container';
|
||||||
@@ -23,8 +27,9 @@ const getLimitAndOffset = (page: number) => ({
|
|||||||
|
|
||||||
export default function Execution(): React.ReactElement {
|
export default function Execution(): React.ReactElement {
|
||||||
const { executionId } = useParams() as ExecutionParams;
|
const { executionId } = useParams() as ExecutionParams;
|
||||||
|
const formatMessage = useFormatMessage();
|
||||||
const { data: execution } = useQuery(GET_EXECUTION, { variables: { executionId } });
|
const { data: execution } = useQuery(GET_EXECUTION, { variables: { executionId } });
|
||||||
const { data } = useQuery(GET_EXECUTION_STEPS, { variables: { executionId, ...getLimitAndOffset(1) } });
|
const { data, loading } = useQuery(GET_EXECUTION_STEPS, { variables: { executionId, ...getLimitAndOffset(1) } });
|
||||||
|
|
||||||
const { edges } = data?.getExecutionSteps || {};
|
const { edges } = data?.getExecutionSteps || {};
|
||||||
const executionSteps: IExecutionStep[] = edges?.map((edge: { node: IExecutionStep }) => edge.node);
|
const executionSteps: IExecutionStep[] = edges?.map((edge: { node: IExecutionStep }) => edge.node);
|
||||||
@@ -36,6 +41,14 @@ export default function Execution(): React.ReactElement {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Grid container item sx={{ mt: 2, mb: [2, 5] }} rowGap={3}>
|
<Grid container item sx={{ mt: 2, mb: [2, 5] }} rowGap={3}>
|
||||||
|
{!loading && !executionSteps?.length && (
|
||||||
|
<Alert severity="warning" sx={{ flex: 1 }}>
|
||||||
|
<AlertTitle sx={{ fontWeight: 700 }}>{formatMessage('execution.noDataTitle')}</AlertTitle>
|
||||||
|
|
||||||
|
<Box sx={{ fontWeight: 400 }}>{formatMessage('execution.noDataMessage')}</Box>
|
||||||
|
</Alert>
|
||||||
|
)}
|
||||||
|
|
||||||
{executionSteps?.map((executionStep) => (
|
{executionSteps?.map((executionStep) => (
|
||||||
<ExecutionStep key={executionStep.id} executionStep={executionStep} step={executionStep.step} />
|
<ExecutionStep key={executionStep.id} executionStep={executionStep} step={executionStep.step} />
|
||||||
))}
|
))}
|
||||||
|
Reference in New Issue
Block a user