Skip to content

Commit

Permalink
Adds Case Page, Signal Graph, and supporting components (#3974)
Browse files Browse the repository at this point in the history
* [WIP] - First pass at migrating case page to Vue 3

* Making some progress

* Fill out sidebar, add custom popover search, style changes

* Add fancy components for Menu, Tooltip, and Button group

* Add pariticpant folder with participant AvatarGroup component

* Add composables for Hotkey and EventListener

* Add Atomics folder for micro components and Hotkey to start

* Add TipTap, update packages

* Remove PopoverMenu2

* Add Signal Graph components

* Add PageHeader component

* Add CasePriority popover

* Add API route for pulling case participants

* The rest of the changes

* Add HoverCard and LockButton components

* Remove ParticipantChips component

* Address some linter findings

* Remove console logs from graph generation

* Remove dead/refactored components

* Add refactored popover super components

* Add escalate button

* Add new tiptap component

* Add eslint changes

* Remove unused RichEditor component

* Remove unused ProjectSelectChip component

* Remove unused CaseTypeSelectChip

* Remove unused CasePrioritySelectChip

* Remove unused CaseSeveritySelectChip

* Remove unused TagChips component

* CaseToggleVisibility

* Remove EntitiesTab import from CaseTabs

* Remove unused imports from NewRawSignalViewer

* More eslint issues, unused vars, defining types, and deprecated veutify props

* Remove unused FancyButtonGroup component

* Remove unused mapMutations import in Case Table

* shadowed menu ref in AvatarGroup

* Unused CaseDetailsTabs component

* unused var assignment of props in HoverCard component

* Use deprecated timeline in Case details page

* Refactor components and move to respective folders

* More clean up and addressing eslin errors, refactors in SearchPopover

* Remove more unused components CustomMenuInput, EditableTextArea

* More refactor, make resolution reason popover component

* Make the resource buttons work, remove tooltips that are not setup, and remove future state code

* Remove unused component and fix eslinet on drawer

* Minor typos, unused imports, etc

* Remove unused vars and ignore placeholder funcs unused

* Addressing many of the comments from kevgliss

* Moving and renaming various components

* Generalize LockButton

* Make the RichEditor emit instead of directly saving

* use default slots so we can use styles in SearchPopover for list items

* in addition to last commit, rename Fancy to D

* Follow similar pattern for expand but use minimal, in get_case_participants view

---------

Co-authored-by: Will Sheldon <[email protected]>
  • Loading branch information
kevgliss and wssheldon authored Nov 29, 2023
1 parent 1a99d5d commit 89d5824
Show file tree
Hide file tree
Showing 37 changed files with 4,079 additions and 145 deletions.
4 changes: 2 additions & 2 deletions src/dispatch/case/flows.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
log = logging.getLogger(__name__)


def get_case_participants(case: Case, db_session: SessionLocal):
def get_case_participants_flow(case: Case, db_session: SessionLocal):
"""Get additional case participants based on priority, type and description."""
individual_contacts = []
team_contacts = []
Expand Down Expand Up @@ -187,7 +187,7 @@ def case_new_create_flow(
ticket_flows.create_case_ticket(case=case, db_session=db_session)

# we resolve participants
individual_participants, team_participants = get_case_participants(
individual_participants, team_participants = get_case_participants_flow(
case=case, db_session=db_session
)

Expand Down
24 changes: 24 additions & 0 deletions src/dispatch/case/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import datetime, timedelta

from pydantic.error_wrappers import ErrorWrapper, ValidationError
from sqlalchemy.orm import Session, joinedload
from typing import List, Optional

from dispatch.auth.models import DispatchUser
Expand All @@ -12,6 +13,7 @@
from dispatch.event import service as event_service
from dispatch.exceptions import NotFoundError
from dispatch.incident import service as incident_service
from dispatch.participant.models import Participant
from dispatch.participant import flows as participant_flows
from dispatch.participant_role.models import ParticipantRoleType
from dispatch.project import service as project_service
Expand Down Expand Up @@ -367,3 +369,25 @@ def delete(*, db_session, case_id: int):
"""Deletes an existing case."""
db_session.query(Case).filter(Case.id == case_id).delete()
db_session.commit()


def get_participants(
*, db_session: Session, case_id: int, minimal: bool = False
) -> list[Participant] | None:
"""Returns a list of participants based on the given case id."""
if minimal:
case = (
db_session.query(Case)
.join(Case.participants) # Use join for minimal
.filter(Case.id == case_id)
.first()
)
else:
case = (
db_session.query(Case)
.options(joinedload(Case.participants)) # Use joinedload for full objects
.filter(Case.id == case_id)
.first()
)

return case.participants if case else None
41 changes: 37 additions & 4 deletions src/dispatch/case/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from dispatch.models import OrganizationSlug, PrimaryKey
from dispatch.incident.models import IncidentCreate, IncidentRead
from dispatch.incident import service as incident_service
from dispatch.participant.models import ParticipantUpdate
from dispatch.participant.models import ParticipantUpdate, ParticipantRead, ParticipantReadMinimal
from dispatch.individual.models import IndividualContactRead

from .flows import (
Expand All @@ -35,10 +35,10 @@
case_triage_create_flow,
case_update_flow,
case_create_resources_flow,
get_case_participants,
get_case_participants_flow,
)
from .models import Case, CaseCreate, CasePagination, CaseRead, CaseUpdate, CaseExpandedPagination
from .service import create, delete, get, update
from .service import create, delete, get, update, get_participants


log = logging.getLogger(__name__)
Expand Down Expand Up @@ -75,6 +75,39 @@ def get_case(
return current_case


@router.get(
"/{case_id}/participants/minimal",
response_model=List[ParticipantReadMinimal],
summary="Retrieves a minimal list of case participants.",
dependencies=[Depends(PermissionsDependency([CaseViewPermission]))],
)
def get_case_participants_minimal(
case_id: PrimaryKey,
db_session: DbSession,
):
"""Retrieves the details of a single case."""
return get_participants(case_id=case_id, db_session=db_session)


@router.get(
"/{case_id}/participants",
summary="Retrieves a list of case participants.",
dependencies=[Depends(PermissionsDependency([CaseViewPermission]))],
)
def get_case_participants(
case_id: PrimaryKey,
db_session: DbSession,
minimal: bool = Query(default=False),
):
"""Retrieves the details of a single case."""
participants = get_participants(case_id=case_id, db_session=db_session, minimal=minimal)

if minimal:
return [ParticipantReadMinimal.from_orm(p) for p in participants]
else:
return [ParticipantRead.from_orm(p) for p in participants]


@router.get("", summary="Retrieves a list of cases.")
def get_cases(
common: CommonParameters,
Expand Down Expand Up @@ -159,7 +192,7 @@ def create_case_resources(
background_tasks: BackgroundTasks,
):
"""Creates resources for an existing case."""
individual_participants, team_participants = get_case_participants(
individual_participants, team_participants = get_case_participants_flow(
case=current_case, db_session=db_session
)
background_tasks.add_task(
Expand Down
Loading

0 comments on commit 89d5824

Please sign in to comment.