From 8c8faf2c563be120f1eeefcf157d4d5b20bae9e6 Mon Sep 17 00:00:00 2001 From: Connor Barker Date: Wed, 11 Dec 2024 12:03:54 -0500 Subject: [PATCH] [JN-565] fix trigger editing for inactive triggers (#1287) --- .../notifications/TriggerExtService.java | 7 +++++++ .../src/study/notifications/TriggerDesigner.tsx | 17 +++++++++++++++-- .../src/study/notifications/TriggerList.tsx | 2 +- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/api-admin/src/main/java/bio/terra/pearl/api/admin/service/notifications/TriggerExtService.java b/api-admin/src/main/java/bio/terra/pearl/api/admin/service/notifications/TriggerExtService.java index baac4c677b..42022009ac 100644 --- a/api-admin/src/main/java/bio/terra/pearl/api/admin/service/notifications/TriggerExtService.java +++ b/api-admin/src/main/java/bio/terra/pearl/api/admin/service/notifications/TriggerExtService.java @@ -125,6 +125,9 @@ public Trigger replace(PortalStudyEnvAuthContext authContext, UUID configId, Tri Trigger existing = triggerService.find(configId).get(); verifyTrigger(authContext, existing); + if (!existing.isActive()) { + throw new IllegalArgumentException("Cannot edit inactive trigger"); + } Trigger newConfig = create(update, authContext.getStudyEnvironment(), portalEnvironment); // after creating the new config, deactivate the old config @@ -186,6 +189,10 @@ private void verifyTrigger(PortalStudyEnvAuthContext authContext, Trigger config private Trigger create( Trigger newConfig, StudyEnvironment studyEnvironment, PortalEnvironment portalEnvironment) { + if (!newConfig.isActive()) { + throw new IllegalArgumentException("Cannot create inactive trigger"); + } + newConfig.cleanForCopying(); newConfig.setStudyEnvironmentId(studyEnvironment.getId()); newConfig.setPortalEnvironmentId(portalEnvironment.getId()); diff --git a/ui-admin/src/study/notifications/TriggerDesigner.tsx b/ui-admin/src/study/notifications/TriggerDesigner.tsx index e09e0d9f54..0621b77313 100644 --- a/ui-admin/src/study/notifications/TriggerDesigner.tsx +++ b/ui-admin/src/study/notifications/TriggerDesigner.tsx @@ -84,6 +84,10 @@ export const TriggerDesigner = ( } return
+ {!workingTrigger.active && +
+ This trigger is no longer active. Inactive triggers cannot be edited. +
}
- - + +
{showDeleteModal && ( diff --git a/ui-admin/src/study/notifications/TriggerList.tsx b/ui-admin/src/study/notifications/TriggerList.tsx index 460b7445e5..112a042c72 100644 --- a/ui-admin/src/study/notifications/TriggerList.tsx +++ b/ui-admin/src/study/notifications/TriggerList.tsx @@ -104,7 +104,7 @@ export default function TriggerList({ studyEnvContext, portalContext }: }
} -
+