diff --git a/src/components/constraints/ConstraintListItem.svelte b/src/components/constraints/ConstraintListItem.svelte index 5a2131dce4..8907e2ae8d 100644 --- a/src/components/constraints/ConstraintListItem.svelte +++ b/src/components/constraints/ConstraintListItem.svelte @@ -213,13 +213,12 @@ > View Constraint + {#if version?.type === 'JAR'} + Duplicate Invocation + Delete Invocation + {/if} - {#if version?.type === 'JAR'} - Duplicate Invocation - Delete Invocation - {/if} -
{#if constraint.description} diff --git a/src/components/constraints/ConstraintsPanel.svelte b/src/components/constraints/ConstraintsPanel.svelte index 34b9825d96..2f0c3d438e 100644 --- a/src/components/constraints/ConstraintsPanel.svelte +++ b/src/components/constraints/ConstraintsPanel.svelte @@ -162,10 +162,10 @@ async function onDeleteConstraintInvocation(event: CustomEvent) { const { - detail: { constraint_metadata, specification_id, ...constraintPlanSpec }, + detail: { constraint_metadata, ...constraintPlanSpec }, } = event; if ($plan) { - await effects.deleteConstraintInvocations($plan, specification_id, [constraintPlanSpec.invocation_id], user); + await effects.deleteConstraintInvocations($plan, [constraintPlanSpec.invocation_id], user); } } diff --git a/src/types/constraint.ts b/src/types/constraint.ts index 196870e267..d91e071c79 100644 --- a/src/types/constraint.ts +++ b/src/types/constraint.ts @@ -42,7 +42,6 @@ export type ConstraintPlanSpecification = { enabled: boolean; invocation_id?: number; plan_id: number; - specification_id: number; // constraint_definition: ConstraintDefinition; // plan: Plan; }; diff --git a/src/utilities/effects.ts b/src/utilities/effects.ts index 43d55874da..b2393f3cc7 100644 --- a/src/utilities/effects.ts +++ b/src/utilities/effects.ts @@ -718,24 +718,23 @@ const effects = { }, async createConstraintPlanSpecification( - spec_goal: ConstraintPlanSpecInsertInput, + constraintPlanSpecification: ConstraintPlanSpecInsertInput, user: User | null, ): Promise { try { if (!queryPermissions.CREATE_CONSTRAINT_PLAN_SPECIFICATION(user)) { throwPermissionError('create a scheduling spec goal'); } - const data = await reqHasura( gql.CREATE_CONSTRAINT_PLAN_SPECIFICATION, - { spec_goal }, + { constraintPlanSpecification }, user, ); const { createConstraintSpec } = data; if (createConstraintSpec != null) { - const { specification_id } = createConstraintSpec; + const { invocation_id } = createConstraintSpec; showSuccessToast('New Constraint Invocation Created Successfully'); - return specification_id; + return invocation_id ?? null; } else { throw Error('Unable to create a constraint spec invocation'); } @@ -2357,7 +2356,6 @@ const effects = { async deleteConstraintInvocations( plan: Plan, - constraintSpecificationId: number, constraintInvocationIdsToDelete: (number | undefined)[], user: User | null, ) { @@ -2368,8 +2366,7 @@ const effects = { const { deleteConstraintPlanSpecifications } = await reqHasura( gql.DELETE_CONSTRAINT_INVOCATIONS, { - constraintInvocationIdsToDelete: constraintInvocationIdsToDelete, - specificationId: constraintSpecificationId, + constraintInvocationIdsToDelete, }, user, ); @@ -5703,7 +5700,6 @@ const effects = { enabled, id: constraintId, invocation_id, - planId: plan.id, revision, }, user, @@ -5733,7 +5729,7 @@ const effects = { const { deleteConstraintPlanSpecifications, insertConstraintPlanSpecifications } = await reqHasura( gql.UPDATE_CONSTRAINT_PLAN_SPECIFICATIONS, - { constraintSpecIdsToDelete, constraintSpecsToInsert, planId: plan.id }, + { constraintSpecIdsToDelete, constraintSpecsToInsert }, user, ); diff --git a/src/utilities/gql.ts b/src/utilities/gql.ts index 4da89afb0c..aefaedc830 100644 --- a/src/utilities/gql.ts +++ b/src/utilities/gql.ts @@ -415,11 +415,11 @@ const gql = { CREATE_CONSTRAINT_PLAN_SPECIFICATION: `#graphql mutation CreateConstraintSpecification($constraintPlanSpecification: constraint_specification_insert_input!) { - createConstraintSpec: ${Queries.INSERT_CONSTRAINT_SPECIFICATION}(object: $spec_goal) { + createConstraintSpec: ${Queries.INSERT_CONSTRAINT_SPECIFICATION}(object: $constraintPlanSpecification) { + arguments + constraint_id enabled - goal_id - priority - specification_id + invocation_id } } `, @@ -913,7 +913,7 @@ const gql = { mutation DeleteConstraintInvocations($constraintInvocationIdsToDelete: [Int!]! = [], $specificationId: Int!) { deleteConstraintPlanSpecifications: ${Queries.DELETE_CONSTRAINT_SPECIFICATIONS}( where: { - constraint_invocation_id: { _in: $constraintInvocationIdsToDelete }, + invocation_id: { _in: $constraintInvocationIdsToDelete }, _and: { specification_id: { _eq: $specificationId }, } @@ -1220,21 +1220,6 @@ const gql = { } `, - // DELETE_SCHEDULING_GOAL_PLAN_SPECIFICATIONS: `#graphql - // mutation DeleteSchedulingGoalPlanSpecification($goalIds: [Int!]!, $planId: Int!) { - // ${Queries.DELETE_SCHEDULING_SPECIFICATION_GOALS}( - // where: { - // goal_id: { _in: $goalIds }, - // _and: { - // plan_id: { _eq: $planId }, - // } - // } - // ) { - // affected_rows - // } - // } - // `, - DELETE_SEQUENCE_ADAPTATION: `#graphql mutation DeleteSequenceAdaptation($id: Int!) { deleteSequenceAdaptation: ${Queries.DELETE_SEQUENCE_ADAPTATION}(id: $id) { @@ -2366,7 +2351,7 @@ const gql = { ${Queries.CONSTRAINT_SPECIFICATIONS} (where: {specification: {plan_id: {_eq: $planId}}}) { arguments constraint_id - constraint_invocation_id + invocation_id constraint_revision enabled specification_id @@ -2390,7 +2375,7 @@ const gql = { order_by: { constraint_id: desc } ) { constraint_id - constraint_invocation_id + invocation_id constraint_revision enabled constraint_metadata { @@ -3573,9 +3558,9 @@ const gql = { `, UPDATE_CONSTRAINT_PLAN_SPECIFICATION: `#graphql - mutation UpdateConstraintPlanSpecification($arguments: jsonb, $constraint_invocation_id: Int!, $revision: Int!, $enabled: Boolean!) { + mutation UpdateConstraintPlanSpecification($arguments: jsonb, $constraintInvocationId: Int!, $revision: Int!, $enabled: Boolean!) { updateConstraintPlanSpecification: ${Queries.UPDATE_CONSTRAINT_SPECIFICATION}( - pk_columns: { constraint_invocation_id: $constraint_invocation_id }, + pk_columns: { invocation_id: $constraintInvocationId }, _set: { arguments: $arguments, constraint_revision: $revision,