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 @@ + + + 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 @@ @@ -100,12 +104,12 @@