Skip to content

Commit

Permalink
fix constraint invocation deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
duranb committed Nov 11, 2024
1 parent b4bb1ee commit bd3d47e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions src/components/modals/ManagePlanConstraintsModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,12 @@
const isSelected = selectedConstraints[constraintId];
// if we find at least one constraint invocation with the selected constraint_id, we don't want to insert this constraint_id into the plan spec
// i.e. this constraint was already selected when we entered the modal, so we don't want to kick off an update, which would cause a duplicate invocation to appear
const constraintAlreadyExistsInPlanSpec =
$allowedConstraintPlanSpecs.find(e => e.constraint_id === constraintId) !== undefined;
const constraintsInPlanSpecification = $allowedConstraintPlanSpecs.filter(
constraintPlanSpecification => constraintPlanSpecification.constraint_id === constraintId,
);
if (isSelected) {
if (!constraintAlreadyExistsInPlanSpec) {
if (!constraintsInPlanSpecification.length) {
return {
...prevConstraintPlanSpecUpdates,
constraintPlanSpecsToAdd: [
Expand All @@ -235,7 +236,7 @@
...prevConstraintPlanSpecUpdates,
constraintPlanSpecIdsToDelete: [
...prevConstraintPlanSpecUpdates.constraintPlanSpecIdsToDelete,
constraintId,
...constraintsInPlanSpecification.map(({ invocation_id }) => invocation_id),
],
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/utilities/gql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3588,7 +3588,7 @@ const gql = {
}
deleteConstraintPlanSpecifications: ${Queries.DELETE_CONSTRAINT_SPECIFICATIONS}(
where: {
constraint_id: { _in: $constraintSpecIdsToDelete },
invocation_id: { _in: $constraintSpecIdsToDelete },
}
) {
affected_rows
Expand Down

0 comments on commit bd3d47e

Please sign in to comment.