Skip to content

Commit

Permalink
Merge branch 'master' into component/status-select-refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wssheldon authored Dec 6, 2023
2 parents 5d6e3d0 + 11a2fec commit abb74c8
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 37 deletions.
4 changes: 2 additions & 2 deletions src/dispatch/case/messaging.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def send_case_close_reminder(case: Case, db_session: SessionLocal):
items = [
{
"name": case.name,
"dispatch_ui_case_url": f"{DISPATCH_UI_URL}/{case.project.organization.name}/cases/{case.id}", # noqa
"dispatch_ui_case_url": f"{DISPATCH_UI_URL}/{case.project.organization.name}/cases/{case.name}", # noqa
"title": case.title,
"status": case.status,
}
Expand Down Expand Up @@ -77,7 +77,7 @@ def send_case_triage_reminder(case: Case, db_session: SessionLocal):
"name": case.name,
"title": case.title,
"status": case.status,
"dispatch_ui_case_url": f"{DISPATCH_UI_URL}/{case.project.organization.name}/cases/{case.id}", # noqa
"dispatch_ui_case_url": f"{DISPATCH_UI_URL}/{case.project.organization.name}/cases/{case.name}", # noqa
}
]

Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/plugins/dispatch_slack/case/messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def create_case_message(case: Case, channel_id: str) -> list[Block]:
accessory=Button(
text="View",
action_id="button-link",
url=f"{DISPATCH_UI_URL}/{case.project.organization.slug}/cases/{case.id}",
url=f"{DISPATCH_UI_URL}/{case.project.organization.slug}/cases/{case.name}",
),
),
Section(text=f"*Description* \n {case.description}"),
Expand Down
42 changes: 29 additions & 13 deletions src/dispatch/static/dispatch/src/case/Page.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<template>
<div>
<PageHeader
:case-id="caseDetails.id"
:case-name="caseDetails.name"
:case-visibility="caseDetails.visibility"
:case-status="caseDetails.status"
Expand Down Expand Up @@ -92,21 +93,36 @@ const toggleDrawer = () => {
}
const fetchDetails = async () => {
const caseId = parseInt(route.params.id, 10)
const caseName = route.params.name
loading.value = true
try {
// get the full data set
CaseApi.get(caseId).then((response) => {
caseDetails.value = response.data
// Save the fetched case details to the Vuex store
store.commit("case_management/SET_SELECTED", response.data)
})
} catch (e) {
console.error("Failed to fetch case details", e)
caseDetails.value = caseDefaults
CaseApi.getAll({
filter: JSON.stringify([
{ and: [{ model: "Case", field: "name", op: "==", value: caseName }] },
]),
}).then((response) => {
if (response.data.items.length) {
// get the full data set
return CaseApi.get(response.data.items[0].id).then((response) => {
caseDetails.value = response.data
// Save the fetched case details to the Vuex store
store.commit("case_management/SET_SELECTED", response.data)
loading.value = false
})
} else {
caseDetails.value = caseDefaults
store.commit(
"notification_backend/addBeNotification",
{
text: `Case '${caseName}' could not be found.`,
type: "exception",
},
{ root: true }
)
}
loading.value = false
}
})
}
const saveCaseDetails = async () => {
Expand All @@ -132,7 +148,7 @@ const handleDescriptionUpdate = (newDescription) => {
}
watch(
() => route.params.id,
() => route.params.name,
(newName, oldName) => {
if (newName !== oldName) {
fetchDetails()
Expand Down
46 changes: 27 additions & 19 deletions src/dispatch/static/dispatch/src/case/PageHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,22 @@

<script setup lang="ts">
import { useRoute } from "vue-router"
import { computed, ref } from "vue"
import { computed, ref, watch } from "vue"
import LockButton from "@/components/LockButton.vue"
import EscalateButton from "@/case/EscalateButton.vue"
import DTooltip from "@/components/DTooltip.vue"
import ParticipantAvatarGroup from "@/participant/ParticipantAvatarGroup.vue"
import SavingState from "@/components/SavingState.vue"
import CaseApi from "@/case/api"
import type { Ref } from "vue"
const route = useRoute()
const props = defineProps({
caseId: {
type: Number,
required: true,
},
caseName: {
type: String,
required: true,
Expand All @@ -68,22 +73,28 @@ const props = defineProps({
const caseParticipants = ref([])
const loading = ref(false)
const caseIdRef: Ref<any> = ref(props.caseId)
const fetchParticipants = async () => {
const caseId = route.params.id
loading.value = true
try {
// get case participants
CaseApi.getParticipants(caseId, true).then((response) => {
// Pass true to fetch minimal data
caseParticipants.value = response.data
})
loading.value = false
} catch (e) {
console.error("Failed to fetch case participants", e)
loading.value = false
}
}
watch(
() => props.caseId,
async (caseId) => {
caseIdRef.value = caseId
if (caseId) {
try {
// get case participants
CaseApi.getParticipants(caseIdRef.value, true).then((response) => {
// Pass true to fetch minimal data
caseParticipants.value = response.data
})
loading.value = false
} catch (e) {
console.error("Failed to fetch case participants", e)
loading.value = false
}
}
},
{ immediate: true }
)
const emit = defineEmits(["toggle-drawer"])
Expand All @@ -105,9 +116,6 @@ const breadcrumbItems = computed(() => {
]
return items
})
// Fetch participants immediately when the component is created
fetchParticipants()
</script>

<style scoped>
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/static/dispatch/src/case/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
<v-list-item
:to="{
name: 'CasePage',
params: { id: item.id },
params: { name: item.name },
}"
>
<v-list-item-title>View</v-list-item-title>
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/static/dispatch/src/router/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const protectedRoute = [
],
},
{
path: "/:organization/cases/:id",
path: "/:organization/cases/:name",
name: "CasePage",
meta: { title: "Page" },
component: () => import("@/case/Page.vue"),
Expand Down

0 comments on commit abb74c8

Please sign in to comment.