From 4a39f89b67ac4034ef49736b523799b0c6a385d3 Mon Sep 17 00:00:00 2001 From: bduran Date: Fri, 6 Dec 2024 09:15:32 -0800 Subject: [PATCH] add force constraint re-check button --- .../constraints/ConstraintsPanel.svelte | 25 +++++++++++++++++-- src/routes/plans/[id]/+page.svelte | 2 +- src/utilities/effects.test.ts | 1 + src/utilities/effects.ts | 3 ++- src/utilities/gql.ts | 5 ++-- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/src/components/constraints/ConstraintsPanel.svelte b/src/components/constraints/ConstraintsPanel.svelte index aff5721114..9b663da4b3 100644 --- a/src/components/constraints/ConstraintsPanel.svelte +++ b/src/components/constraints/ConstraintsPanel.svelte @@ -5,6 +5,7 @@ import FilterIcon from '@nasa-jpl/stellar/icons/filter.svg?component'; import PlanLeftArrow from '@nasa-jpl/stellar/icons/plan_with_left_arrow.svg?component'; import PlanRightArrow from '@nasa-jpl/stellar/icons/plan_with_right_arrow.svg?component'; + import RefreshIcon from '@nasa-jpl/stellar/icons/refresh.svg?component'; import VisibleHideIcon from '@nasa-jpl/stellar/icons/visible_hide.svg?component'; import VisibleShowIcon from '@nasa-jpl/stellar/icons/visible_show.svg?component'; import { PlanStatusMessages } from '../../enums/planStatusMessages'; @@ -261,10 +262,30 @@ $plan && effects.checkConstraints($plan, true, user)}> + $plan && effects.checkConstraints($plan, user)} + on:click={() => $plan && effects.checkConstraints($plan, false, user)} use={[ [ permissionHandler, diff --git a/src/routes/plans/[id]/+page.svelte b/src/routes/plans/[id]/+page.svelte index 89c9221bf0..600ff13ea0 100644 --- a/src/routes/plans/[id]/+page.svelte +++ b/src/routes/plans/[id]/+page.svelte @@ -705,7 +705,7 @@ : 'You do not have permission to run a constraint check'} status={$constraintsStatus} showStatusInMenu={false} - on:click={() => $plan && effects.checkConstraints($plan, data.user)} + on:click={() => $plan && effects.checkConstraints($plan, false, data.user)} indeterminate > diff --git a/src/utilities/effects.test.ts b/src/utilities/effects.test.ts index 558b3cfc46..1a92cc068d 100644 --- a/src/utilities/effects.test.ts +++ b/src/utilities/effects.test.ts @@ -128,6 +128,7 @@ describe('Handle modal and requests in effects', () => { id: 1, owner: 'test', } as Plan, + false, mockUser, ); diff --git a/src/utilities/effects.ts b/src/utilities/effects.ts index bdd7428a41..1b1366e3f0 100644 --- a/src/utilities/effects.ts +++ b/src/utilities/effects.ts @@ -422,7 +422,7 @@ const effects = { } }, - async checkConstraints(plan: Plan, user: User | null): Promise { + async checkConstraints(plan: Plan, force: boolean = false, user: User | null): Promise { try { rawCheckConstraintsStatus.set(Status.Incomplete); if (plan !== null) { @@ -430,6 +430,7 @@ const effects = { const data = await reqHasura( gql.CHECK_CONSTRAINTS, { + force, planId, }, user, diff --git a/src/utilities/gql.ts b/src/utilities/gql.ts index a244b4d66b..9e02e1504c 100644 --- a/src/utilities/gql.ts +++ b/src/utilities/gql.ts @@ -276,8 +276,8 @@ const gql = { `, CHECK_CONSTRAINTS: `#graphql - query CheckConstraints($planId: Int!) { - constraintResponses: ${Queries.CONSTRAINT_VIOLATIONS}(planId: $planId) { + query CheckConstraints($planId: Int!, $force: Boolean!) { + constraintResponses: ${Queries.CONSTRAINT_VIOLATIONS}(planId: $planId, force: $force) { success constraintId constraintInvocationId @@ -2398,6 +2398,7 @@ const gql = { SUB_CONSTRAINT_RUNS: `#graphql subscription SubConstraintRuns($simulationDatasetId: Int!) { constraintRuns: ${Queries.CONSTRAINT_RUN}(where: { simulation_dataset_id: { _eq: $simulationDatasetId }}) { + arguments constraint_id constraint_invocation_id constraint_revision