From d5805a9904427aa4ec57e15dba009d532e93791c Mon Sep 17 00:00:00 2001
From: Marc Vilanova <39573146+mvilanova@users.noreply.github.com>
Date: Thu, 14 Nov 2024 10:19:46 -0800
Subject: [PATCH] Revert "Removes option to delete a signal definition (#5471)"
This reverts commit a557071ea6d0b57994b2a923da775934aa43b782.
---
src/dispatch/signal/service.py | 8 +++
src/dispatch/signal/views.py | 17 ++++++
.../dispatch/src/signal/DeleteDialog.vue | 35 ++++++++++++
.../static/dispatch/src/signal/Table.vue | 8 ++-
tests/signal/test_signal_service.py | 55 ++++++++++---------
5 files changed, 95 insertions(+), 28 deletions(-)
create mode 100644 src/dispatch/static/dispatch/src/signal/DeleteDialog.vue
diff --git a/src/dispatch/signal/service.py b/src/dispatch/signal/service.py
index eff71818ccef..751201594093 100644
--- a/src/dispatch/signal/service.py
+++ b/src/dispatch/signal/service.py
@@ -536,6 +536,14 @@ def update(*, db_session: Session, signal: Signal, signal_in: SignalUpdate) -> S
return signal
+def delete(*, db_session: Session, signal_id: int):
+ """Deletes a signal definition."""
+ signal = db_session.query(Signal).filter(Signal.id == signal_id).one()
+ db_session.delete(signal)
+ db_session.commit()
+ return signal_id
+
+
def is_valid_uuid(val):
try:
uuid.UUID(str(val), version=4)
diff --git a/src/dispatch/signal/views.py b/src/dispatch/signal/views.py
index 74202f39e4a8..e8dab18aabe7 100644
--- a/src/dispatch/signal/views.py
+++ b/src/dispatch/signal/views.py
@@ -36,6 +36,7 @@
create,
create_signal_engagement,
create_signal_filter,
+ delete,
delete_signal_filter,
get,
get_by_primary_or_external_id,
@@ -329,3 +330,19 @@ def update_signal(
) from None
return signal
+
+
+@router.delete(
+ "/{signal_id}",
+ response_model=None,
+ dependencies=[Depends(PermissionsDependency([SensitiveProjectActionPermission]))],
+)
+def delete_signal(db_session: DbSession, signal_id: Union[str, PrimaryKey]):
+ """Deletes a signal."""
+ signal = get_by_primary_or_external_id(db_session=db_session, signal_id=signal_id)
+ if not signal:
+ raise HTTPException(
+ status_code=status.HTTP_404_NOT_FOUND,
+ detail=[{"msg": "A signal with this id does not exist."}],
+ )
+ delete(db_session=db_session, signal_id=signal.id)
diff --git a/src/dispatch/static/dispatch/src/signal/DeleteDialog.vue b/src/dispatch/static/dispatch/src/signal/DeleteDialog.vue
new file mode 100644
index 000000000000..7036ee81151d
--- /dev/null
+++ b/src/dispatch/static/dispatch/src/signal/DeleteDialog.vue
@@ -0,0 +1,35 @@
+
+
+
+
+ Delete Signal Definition?
+
+
+ Are you sure you would like to delete this Signal Definition?
+
+
+
+ Cancel
+ Delete
+
+
+
+
+
+
diff --git a/src/dispatch/static/dispatch/src/signal/Table.vue b/src/dispatch/static/dispatch/src/signal/Table.vue
index 0a438ba65f49..7b7a5fb1116f 100644
--- a/src/dispatch/static/dispatch/src/signal/Table.vue
+++ b/src/dispatch/static/dispatch/src/signal/Table.vue
@@ -1,6 +1,7 @@
+
@@ -87,6 +88,9 @@
View / Edit
+
+ Delete
+
@@ -100,12 +104,12 @@