Skip to content

Commit d20f048

Browse files
committed
allow deleting of trigger
1 parent 9a8b40e commit d20f048

File tree

2 files changed

+31
-20
lines changed

2 files changed

+31
-20
lines changed

packages/backend/src/graphql/mutations/delete-step.ts

Lines changed: 29 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -31,28 +31,38 @@ const deleteStep: MutationResolvers['deleteStep'] = async (
3131
// ** IMPORTANT NOTE **
3232
// We only support contiguous steps for now.
3333
//
34-
if (
35-
!steps.every(
36-
(step, index) =>
37-
index === 0 || step.position === steps[index - 1].position + 1,
38-
)
39-
) {
40-
throw new Error('Must delete contiguous steps!')
41-
}
34+
if (steps.length === 1 && steps[0].type === 'trigger') {
35+
await steps[0].$query().patchAndFetch({
36+
key: null,
37+
appKey: null,
38+
connectionId: null,
39+
parameters: {},
40+
status: 'incomplete',
41+
})
42+
} else {
43+
if (
44+
!steps.every(
45+
(step, index) =>
46+
index === 0 || step.position === steps[index - 1].position + 1,
47+
)
48+
) {
49+
throw new Error('Must delete contiguous steps!')
50+
}
4251

43-
const stepIds = steps.map((step) => step.id)
52+
const stepIds = steps.map((step) => step.id)
4453

45-
/**
46-
* NOTE: do not delete execution steps
47-
* The deletion causes RDS CPU Utilisation to spike for high volume pipes.
48-
*/
49-
// await Step.relatedQuery('executionSteps', trx).for(stepIds).delete()
50-
await Step.query(trx).findByIds(stepIds).delete()
54+
/**
55+
* NOTE: do not delete execution steps
56+
* The deletion causes RDS CPU Utilisation to spike for high volume pipes.
57+
*/
58+
// await Step.relatedQuery('executionSteps', trx).for(stepIds).delete()
59+
await Step.query(trx).findByIds(stepIds).delete()
5160

52-
await steps[0].flow
53-
.$relatedQuery('steps', trx)
54-
.where('position', '>', steps[steps.length - 1].position)
55-
.patch({ position: raw(`position - ${steps.length}`) })
61+
await steps[0].flow
62+
.$relatedQuery('steps', trx)
63+
.where('position', '>', steps[steps.length - 1].position)
64+
.patch({ position: raw(`position - ${steps.length}`) })
65+
}
5666

5767
return await steps[0].flow
5868
.$query(trx)

packages/frontend/src/components/FlowStep/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,15 @@ export default function FlowStep(
182182
)
183183

184184
const isDeletable =
185-
displayOverrides?.disableDelete === true ? false : !isTrigger && !readOnly
185+
displayOverrides?.disableDelete === true ? false : !readOnly
186186
const [deleteStep, { loading: isDeletingStep }] = useMutation(DELETE_STEP, {
187187
refetchQueries: [GET_FLOW],
188188
})
189189
const onDelete = useCallback<MouseEventHandler>(
190190
async (e) => {
191191
e.stopPropagation()
192192
await deleteStep({ variables: { input: { ids: [step.id] } } })
193+
setCurrentSubstep(0)
193194
},
194195
[deleteStep, step.id],
195196
)

0 commit comments

Comments
 (0)