Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds the ability for signal definitions to be disabled (#3042) #21

Merged
merged 1 commit into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Adds the ability to toggle signal definitions.

Revision ID: 5955ed5f76b4
Revises: 20d3801ad5b7
Create Date: 2023-03-02 11:12:18.168787

"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = "5955ed5f76b4"
down_revision = "20d3801ad5b7"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column("signal", sa.Column("enabled", sa.Boolean(), nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("signal", "enabled")
# ### end Alembic commands ###
3 changes: 3 additions & 0 deletions src/dispatch/signal/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ def create_signal_instance(
variant=signal_instance_data.variant,
)

if not signal.enabled:
raise Exception("Signal definition is not enabled.")

if not signal:
raise Exception("No signal definition defined.")

Expand Down
2 changes: 2 additions & 0 deletions src/dispatch/signal/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ class Signal(Base, TimeStampMixin, ProjectMixin):
source_id = Column(Integer, ForeignKey("source.id"))
variant = Column(String)
loopin_signal_identity = Column(Boolean, default=False)
enabled = Column(Boolean, default=False)
case_type_id = Column(Integer, ForeignKey(CaseType.id))
case_type = relationship("CaseType", backref="signals")
case_priority_id = Column(Integer, ForeignKey(CasePriority.id))
Expand Down Expand Up @@ -211,6 +212,7 @@ class SignalBase(DispatchBase):
case_type: Optional[CaseTypeRead]
case_priority: Optional[CasePriorityRead]
external_id: str
enabled: Optional[bool] = False
external_url: Optional[str]
source: Optional[SourceBase]
created_at: Optional[datetime] = None
Expand Down
8 changes: 8 additions & 0 deletions src/dispatch/static/dispatch/src/signal/NewEditDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,13 @@
/>
</ValidationProvider>
</v-col>
<v-col cols="12">
<v-checkbox
v-model="enabled"
label="Enabled"
hint="Determines whether this signal definition is currently active and should be used to process signals."
/>
</v-col>
<v-col cols="12">
<tag-filter-auto-complete
label="Tags"
Expand Down Expand Up @@ -235,6 +242,7 @@ export default {
"selected.id",
"selected.name",
"selected.description",
"selected.enabled",
"selected.variant",
"selected.owner",
"selected.external_id",
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/static/dispatch/src/signal/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const getDefaultSelectedState = () => {
external_url: null,
case_type: null,
case_priority: null,
enabled: false,
filters: null,
entity_types: null,
tags: null,
Expand Down