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 Case Page, Signal Graph, and supporting components #3974

Merged
merged 60 commits into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
f0f0516
[WIP] - First pass at migrating case page to Vue 3
wssheldon Nov 9, 2023
4d20ae4
Merge branch 'master' into enhancement/full-width-case-page
kevgliss Nov 10, 2023
9529f8c
Merge branch 'master' into enhancement/full-width-case-page
kevgliss Nov 13, 2023
2180886
Merge branch 'master' into enhancement/full-width-case-page
kevgliss Nov 13, 2023
0eda119
Making some progress
kevgliss Nov 13, 2023
c9addd3
Merge branch 'master' into enhancement/full-width-case-page-kglisson
wssheldon Nov 20, 2023
bbe933b
Fill out sidebar, add custom popover search, style changes
wssheldon Nov 21, 2023
d63516d
Merge branch 'master' into enhancement/full-width-case-page-kglisson
wssheldon Nov 21, 2023
64b68e2
Add fancy components for Menu, Tooltip, and Button group
wssheldon Nov 27, 2023
d63c95c
Add pariticpant folder with participant AvatarGroup component
wssheldon Nov 27, 2023
708e30c
Add composables for Hotkey and EventListener
wssheldon Nov 27, 2023
10110e7
Add Atomics folder for micro components and Hotkey to start
wssheldon Nov 27, 2023
43a4973
Add TipTap, update packages
wssheldon Nov 27, 2023
eddc7d7
Remove PopoverMenu2
wssheldon Nov 27, 2023
7dc6671
Add Signal Graph components
wssheldon Nov 27, 2023
bd235d8
Add PageHeader component
wssheldon Nov 27, 2023
affe228
Add CasePriority popover
wssheldon Nov 27, 2023
5809203
Add API route for pulling case participants
wssheldon Nov 27, 2023
d3a79ea
The rest of the changes
wssheldon Nov 27, 2023
d70b8ad
Add HoverCard and LockButton components
wssheldon Nov 27, 2023
40e9c16
Remove ParticipantChips component
wssheldon Nov 28, 2023
20afe54
Address some linter findings
wssheldon Nov 28, 2023
2358aa2
Remove console logs from graph generation
wssheldon Nov 28, 2023
3483562
Remove dead/refactored components
wssheldon Nov 29, 2023
275c4ef
Add refactored popover super components
wssheldon Nov 29, 2023
f543b69
Add escalate button
wssheldon Nov 29, 2023
91c7497
Add new tiptap component
wssheldon Nov 29, 2023
7c7ffba
Add eslint changes
wssheldon Nov 29, 2023
60ae902
Merge branch 'master' into enhancement/full-width-case-page-kglisson
wssheldon Nov 29, 2023
9bdb171
Remove unused RichEditor component
wssheldon Nov 29, 2023
e466cc3
Remove unused ProjectSelectChip component
wssheldon Nov 29, 2023
41d357f
Remove unused CaseTypeSelectChip
wssheldon Nov 29, 2023
077c9b9
Remove unused CasePrioritySelectChip
wssheldon Nov 29, 2023
d7b4d35
Remove unused CaseSeveritySelectChip
wssheldon Nov 29, 2023
aa17392
Remove unused TagChips component
wssheldon Nov 29, 2023
c048f20
CaseToggleVisibility
wssheldon Nov 29, 2023
7bfda0e
Remove EntitiesTab import from CaseTabs
wssheldon Nov 29, 2023
33963e6
Remove unused imports from NewRawSignalViewer
wssheldon Nov 29, 2023
e30b9f3
More eslint issues, unused vars, defining types, and deprecated veuti…
wssheldon Nov 29, 2023
3a915c6
Remove unused FancyButtonGroup component
wssheldon Nov 29, 2023
638b2d0
Remove unused mapMutations import in Case Table
wssheldon Nov 29, 2023
c027fb4
shadowed menu ref in AvatarGroup
wssheldon Nov 29, 2023
258a3a3
Unused CaseDetailsTabs component
wssheldon Nov 29, 2023
ce23637
unused var assignment of props in HoverCard component
wssheldon Nov 29, 2023
0466415
Use deprecated timeline in Case details page
wssheldon Nov 29, 2023
277e342
Refactor components and move to respective folders
wssheldon Nov 29, 2023
709cba8
More clean up and addressing eslin errors, refactors in SearchPopover
wssheldon Nov 29, 2023
1d91ebb
Remove more unused components CustomMenuInput, EditableTextArea
wssheldon Nov 29, 2023
26ca76a
More refactor, make resolution reason popover component
wssheldon Nov 29, 2023
b2bfb3b
Make the resource buttons work, remove tooltips that are not setup, a…
wssheldon Nov 29, 2023
6f1f6d9
Remove unused component and fix eslinet on drawer
wssheldon Nov 29, 2023
3df2076
Minor typos, unused imports, etc
wssheldon Nov 29, 2023
2d263a0
Remove unused vars and ignore placeholder funcs unused
wssheldon Nov 29, 2023
84d8f52
Addressing many of the comments from kevgliss
wssheldon Nov 29, 2023
e010a26
Moving and renaming various components
wssheldon Nov 29, 2023
a2d64dd
Generalize LockButton
wssheldon Nov 29, 2023
b076902
Make the RichEditor emit instead of directly saving
wssheldon Nov 29, 2023
26dece3
use default slots so we can use styles in SearchPopover for list items
wssheldon Nov 29, 2023
abbe96f
in addition to last commit, rename Fancy to D
wssheldon Nov 29, 2023
12ce01c
Follow similar pattern for expand but use minimal, in get_case_partic…
wssheldon Nov 29, 2023
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
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(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the minimal here to denote we don't fetch sub objects for each participant? If so, we may want to follow a similar pattern to /cases and /incidents and return the minimal object by default and allow for the ?expand=True parameter if we need it.

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
Loading