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

Enabled assignee updating via case modal #3625

Merged
merged 1 commit into from
Jul 26, 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
24 changes: 18 additions & 6 deletions src/dispatch/plugins/dispatch_slack/case/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
from dispatch.case import flows as case_flows
from dispatch.case import service as case_service
from dispatch.case.enums import CaseStatus
from dispatch.case.models import Case, CaseCreate, CaseUpdate
from dispatch.enums import UserRoles
from dispatch.case.models import Case, CaseCreate, CaseRead, CaseUpdate
from dispatch.entity import service as entity_service
from dispatch.enums import UserRoles
from dispatch.exceptions import ExistsError
from dispatch.incident import flows as incident_flows
from dispatch.individual.models import IndividualContactRead
Expand Down Expand Up @@ -749,7 +749,7 @@ def assignee_select(
placeholder: str = "Select Assignee",
initial_user: str = None,
action_id: str = None,
block_id: str = None,
block_id: str = DefaultBlockIds.case_assignee_select,
label: str = "Assignee",
**kwargs,
):
Expand Down Expand Up @@ -1145,6 +1145,7 @@ def handle_edit_submission_event(
):
ack()
case = case_service.get(db_session=db_session, case_id=context["subject"].id)
previous_case = CaseRead.from_orm(case)

case_priority = None
if form_data.get(DefaultBlockIds.case_priority_select):
Expand All @@ -1154,6 +1155,11 @@ def handle_edit_submission_event(
if form_data.get(DefaultBlockIds.case_type_select):
case_type = {"name": form_data[DefaultBlockIds.case_type_select]["name"]}

if form_data.get(DefaultBlockIds.case_assignee_select):
assignee_email = client.users_info(
user=form_data[DefaultBlockIds.case_assignee_select]["value"]
)["user"]["profile"]["email"]

case_in = CaseUpdate(
title=form_data[DefaultBlockIds.title_input],
description=form_data[DefaultBlockIds.description_input],
Expand All @@ -1166,11 +1172,17 @@ def handle_edit_submission_event(
)

case = case_service.update(db_session=db_session, case=case, case_in=case_in, current_user=user)
blocks = create_case_message(case=case, channel_id=context["subject"].channel_id)
client.chat_update(
blocks=blocks, ts=case.conversation.thread_id, channel=case.conversation.channel_id
case_flows.case_update_flow(
case_id=case.id,
previous_case=previous_case,
db_session=db_session,
assignee_email=assignee_email,
user_email=user.email,
organization_slug=context["subject"].organization_slug,
)

return case


@app.action(CaseNotificationActions.resolve, middleware=[button_context_middleware, db_middleware])
def resolve_button_click(
Expand Down
1 change: 1 addition & 0 deletions src/dispatch/plugins/dispatch_slack/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class DefaultBlockIds(DispatchEnum):
case_status_select = "case-status-select"
case_severity_select = "case-severity-select"
case_type_select = "case-type-select"
case_assignee_select = "case-assignee-select"

# entities
entity_select = "entity-select"
Expand Down
Loading