Skip to content

Commit

Permalink
Adding new project-level setting to enable/disable self join (#4675)
Browse files Browse the repository at this point in the history
* Adding new project level attribute

* adding attribute to project

* Modified UI to show self-join checkbox

* Fixed prettier errors

* removed config file updates

* Updating database revision

* Updating database to support self_join

* Adding new revision file

---------

Co-authored-by: Mike Laventure <[email protected]>
Co-authored-by: David Whittaker <[email protected]>
  • Loading branch information
3 people authored May 29, 2024
1 parent 0d58859 commit 45364ab
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/dispatch/case/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ def case_status_transition_flow_dispatcher(
)

case (_, CaseStatus.triage):
# Any -> Triage
# Any -> Triage/
pass

case (CaseStatus.new, CaseStatus.escalated):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
"""Adding in "allow_self_join" column to enable self join in dispatch UI
Revision ID: a836d4850a75
Revises: b07bb852fd67
Create Date: 2024-04-29 10:28:37.777618
"""
from alembic import op
import sqlalchemy as sa

# revision identifiers, used by Alembic.
revision = 'a836d4850a75'
down_revision = 'b07bb852fd67'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column('project', sa.Column('allow_self_join', sa.Boolean(), server_default='t', nullable=True))
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column('project', 'allow_self_join')
# ### end Alembic commands ###
1 change: 1 addition & 0 deletions src/dispatch/incident/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ class ProjectRead(DispatchBase):
name: NameStr
color: Optional[str]
stable_priority: Optional[IncidentPriorityRead] = None
allow_self_join: Optional[bool] = Field(True, nullable=True)


class CaseRead(DispatchBase):
Expand Down
2 changes: 2 additions & 0 deletions src/dispatch/project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class Project(Base):
)

enabled = Column(Boolean, default=True, server_default="t")
allow_self_join = Column(Boolean, default=True, server_default="t")

send_daily_reports = Column(Boolean)

Expand Down Expand Up @@ -71,6 +72,7 @@ class ProjectBase(DispatchBase):
color: Optional[str] = Field(None, nullable=True)
send_daily_reports: Optional[bool] = Field(True, nullable=True)
enabled: Optional[bool] = Field(True, nullable=True)
allow_self_join: Optional[bool] = Field(True, nullable=True)


class ProjectCreate(ProjectBase):
Expand Down
6 changes: 5 additions & 1 deletion src/dispatch/static/dispatch/src/incident/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@
<incident-priority :priority="value" />
</template>
<template #item.status="{ item, value }">
<incident-status :status="value" :id="item.id" />
<incident-status
:status="value"
:id="item.id"
:allowSelfJoin="item.project.allow_self_join"
/>
</template>
<template #item.incident_costs="{ value }">
<incident-cost-card :incident-costs="value" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{ status }}
</v-badge>
<template v-if="status === 'Active' || status === 'Stable'">
<v-tooltip location="bottom" text="Join">
<v-tooltip location="bottom" text="Join" v-if="allowSelfJoin">
<template #activator="{ props }">
<v-btn
v-bind="props"
Expand Down Expand Up @@ -46,6 +46,10 @@ export default {
type: Number,
required: true,
},
allowSelfJoin: {
type: Boolean,
required: true,
},
},
computed: {
Expand Down
8 changes: 8 additions & 0 deletions src/dispatch/static/dispatch/src/project/NewEditSheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@
hint="Whether this project is enabled for new cases and incidents."
/>
</v-col>
<v-col cols="12">
<v-checkbox
v-model="allow_self_join"
label="Allow Self Join"
hint="Allow users to self-join an incident from the UI"
/>
</v-col>
<v-col cols="12">
<color-picker-input v-model="color" />
</v-col>
Expand Down Expand Up @@ -152,6 +159,7 @@ export default {
"selected.owner_conversation",
"selected.owner_email",
"selected.enabled",
"selected.allow_self_join",
"dialogs.showCreateEdit",
]),
},
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/static/dispatch/src/project/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const getDefaultSelectedState = () => {
owner_email: null,
owner_conversation: null,
enabled: null,
allow_self_join: null,
}
}

Expand Down

0 comments on commit 45364ab

Please sign in to comment.