Merge pull request #2322 from automatisch/AUT-1422
feat: clear connection on app change in flow step
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
import { useQueryClient } from '@tanstack/react-query';
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import Box from '@mui/material/Box';
|
import Box from '@mui/material/Box';
|
||||||
@@ -43,6 +44,7 @@ function ChooseAppAndEventSubstep(props) {
|
|||||||
} = props;
|
} = props;
|
||||||
const formatMessage = useFormatMessage();
|
const formatMessage = useFormatMessage();
|
||||||
const editorContext = React.useContext(EditorContext);
|
const editorContext = React.useContext(EditorContext);
|
||||||
|
const queryClient = useQueryClient();
|
||||||
const isTrigger = step.type === 'trigger';
|
const isTrigger = step.type === 'trigger';
|
||||||
const isAction = step.type === 'action';
|
const isAction = step.type === 'action';
|
||||||
const useAppsOptions = {};
|
const useAppsOptions = {};
|
||||||
@@ -109,7 +111,7 @@ function ChooseAppAndEventSubstep(props) {
|
|||||||
);
|
);
|
||||||
|
|
||||||
const onAppChange = React.useCallback(
|
const onAppChange = React.useCallback(
|
||||||
(event, selectedOption) => {
|
async (event, selectedOption) => {
|
||||||
if (typeof selectedOption === 'object') {
|
if (typeof selectedOption === 'object') {
|
||||||
const appKey = selectedOption?.value;
|
const appKey = selectedOption?.value;
|
||||||
|
|
||||||
@@ -120,8 +122,12 @@ function ChooseAppAndEventSubstep(props) {
|
|||||||
key: '',
|
key: '',
|
||||||
appKey,
|
appKey,
|
||||||
parameters: {},
|
parameters: {},
|
||||||
|
connection: { id: null },
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: ['steps', step.id, 'connection'],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -6,11 +6,18 @@ export default function useStepConnection(stepId) {
|
|||||||
const query = useQuery({
|
const query = useQuery({
|
||||||
queryKey: ['steps', stepId, 'connection'],
|
queryKey: ['steps', stepId, 'connection'],
|
||||||
queryFn: async ({ signal }) => {
|
queryFn: async ({ signal }) => {
|
||||||
const { data } = await api.get(`/v1/steps/${stepId}/connection`, {
|
try {
|
||||||
signal,
|
const { data } = await api.get(`/v1/steps/${stepId}/connection`, {
|
||||||
});
|
signal,
|
||||||
|
});
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
} catch (error) {
|
||||||
|
if (error.response?.status === 404) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
enabled: !!stepId,
|
enabled: !!stepId,
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user