Skip to content

Commit

Permalink
feat(ui): allow project to have a display name separate from its key (#…
Browse files Browse the repository at this point in the history
whitdog47 authored Dec 14, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 27c40d7 commit 6fce74f
Showing 41 changed files with 137 additions and 92 deletions.
1 change: 1 addition & 0 deletions src/dispatch/case/models.py
Original file line number Diff line number Diff line change
@@ -230,6 +230,7 @@ class SignalInstanceRead(DispatchBase):
class ProjectRead(DispatchBase):
id: Optional[PrimaryKey]
name: NameStr
display_name: Optional[str]
color: Optional[str]
allow_self_join: Optional[bool] = Field(True, nullable=True)

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"""Adding display name to the projct model
Revision ID: 2d9e4d392ea4
Revises: 575ca7d954a8
Create Date: 2024-12-12 16:34:58.098426
"""

from alembic import op
import sqlalchemy as sa


# revision identifiers, used by Alembic.
revision = "2d9e4d392ea4"
down_revision = "575ca7d954a8"
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.add_column(
"project", sa.Column("display_name", sa.String(), server_default="", nullable=False)
)

# Copy data from 'name' column to 'display_name' column
op.execute("UPDATE project SET display_name = name")

# ### end Alembic commands ###


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


class CaseRead(DispatchBase):
1 change: 1 addition & 0 deletions src/dispatch/incident/priority/models.py
Original file line number Diff line number Diff line change
@@ -38,6 +38,7 @@ class IncidentPriority(Base, ProjectMixin):
class ProjectRead(DispatchBase):
id: Optional[PrimaryKey]
name: NameStr
display_name: Optional[str]


# Pydantic models...
10 changes: 5 additions & 5 deletions src/dispatch/plugins/dispatch_slack/case/interactive.py
Original file line number Diff line number Diff line change
@@ -184,7 +184,7 @@ def handle_escalate_case_command(

default_title = case.name
default_description = case.description
default_project = {"text": case.project.name, "value": case.project.id}
default_project = {"text": case.project.display_name, "value": case.project.id}

blocks = [
Context(elements=[MarkdownText(text="Accept the defaults or adjust as needed.")]),
@@ -1303,7 +1303,7 @@ def escalate_button_click(
description_input(initial_value=case.description),
project_select(
db_session=db_session,
initial_option={"text": case.project.name, "value": case.project.id},
initial_option={"text": case.project.display_name, "value": case.project.id},
action_id=CaseEscalateActions.project_select,
dispatch_action=True,
),
@@ -1358,7 +1358,7 @@ def handle_project_select_action(
description_input(),
project_select(
db_session=db_session,
initial_option={"text": project.name, "value": project.id},
initial_option={"text": project.display_name, "value": project.id},
action_id=CaseEscalateActions.project_select,
dispatch_action=True,
),
@@ -2138,7 +2138,7 @@ def handle_report_project_select_action(
description_input(),
project_select(
db_session=db_session,
initial_option={"text": project.name, "value": project.id},
initial_option={"text": project.display_name, "value": project.id},
action_id=CaseReportActions.project_select,
dispatch_action=True,
),
@@ -2243,7 +2243,7 @@ def handle_report_case_type_select_action(
description_input(),
project_select(
db_session=db_session,
initial_option={"text": project.name, "value": project.id},
initial_option={"text": project.display_name, "value": project.id},
action_id=CaseReportActions.project_select,
dispatch_action=True,
),
2 changes: 1 addition & 1 deletion src/dispatch/plugins/dispatch_slack/fields.py
Original file line number Diff line number Diff line change
@@ -301,7 +301,7 @@ def project_select(
):
"""Creates a project select."""
projects = [
{"text": p.name, "value": p.id}
{"text": p.display_name, "value": p.id}
for p in project_service.get_all(db_session=db_session)
if p.enabled
]
18 changes: 3 additions & 15 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
@@ -309,7 +309,7 @@ def handle_update_incident_project_select_action(
incident_status_select(initial_option={"text": incident.status, "value": incident.status}),
project_select(
db_session=db_session,
initial_option={"text": project.name, "value": project.id},
initial_option={"text": project.display_name, "value": project.id},
action_id=IncidentUpdateActions.project_select,
dispatch_action=True,
),
@@ -2114,20 +2114,8 @@ def handle_update_incident_command(
description_input(initial_value=incident.description),
resolution_input(initial_value=incident.resolution),
incident_status_select(initial_option={"text": incident.status, "value": incident.status}),
project_select(
db_session=db_session,
initial_option={"text": incident.project.name, "value": incident.project.id},
action_id=IncidentUpdateActions.project_select,
dispatch_action=True,
),
incident_type_select(
db_session=db_session,
initial_option={
"text": incident.incident_type.name,
"value": incident.incident_type.id,
},
project_id=incident.project.id,
),
Section(text=f"*Project*: {incident.project.display_name}"),
Context(elements=[MarkdownText(text="Project is read-only")]),
incident_severity_select(
db_session=db_session,
initial_option={
3 changes: 3 additions & 0 deletions src/dispatch/project/models.py
Original file line number Diff line number Diff line change
@@ -40,6 +40,8 @@ class Project(Base):
cascade="all, delete-orphan",
)

display_name = Column(String, nullable=False, server_default="")

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

@@ -82,6 +84,7 @@ def slug(self):
class ProjectBase(DispatchBase):
id: Optional[PrimaryKey]
name: NameStr
display_name: Optional[str] = Field("", nullable=False)
owner_email: Optional[EmailStr] = Field(None, nullable=True)
owner_conversation: Optional[str] = Field(None, nullable=True)
annual_employee_cost: Optional[int]
4 changes: 2 additions & 2 deletions src/dispatch/static/dispatch/src/case/CaseSummaryTable.vue
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
<template #item.status="{ item, value }">
<case-status :status="value" :id="item.id" />
</template>
<template #item.project.name="{ item, value }">
<template #item.project.display_name="{ item, value }">
<v-chip size="small" :color="item.project.color">
{{ value }}
</v-chip>
@@ -55,7 +55,7 @@ export default {
{ title: "Status", key: "status", sortable: false },
{ title: "Type", key: "case_type.name", sortable: false },
{ title: "Priority", key: "case_priority.name", sortable: false, width: "10%" },
{ title: "Project", key: "project.name", sortable: false },
{ title: "Project", key: "project.display_name", sortable: false },
{ title: "Reported At", key: "reported_at", sortable: false },
{ title: "Assignee", key: "assignee.email", sortable: false },
{ title: "", key: "data-table-actions", sortable: false, align: "end" },
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@
<v-divider />
<v-list-item>
<v-list-item-title>Project</v-list-item-title>
<v-list-item-subtitle>{{ project.name }}</v-list-item-subtitle>
<v-list-item-subtitle>{{ project.display_name }}</v-list-item-subtitle>
</v-list-item>
<v-divider />
<v-list-item>
6 changes: 3 additions & 3 deletions src/dispatch/static/dispatch/src/case/Table.vue
Original file line number Diff line number Diff line change
@@ -79,9 +79,9 @@
:dedicatedChannel="item.dedicated_channel"
/>
</template>
<template #item.project.name="{ item }">
<template #item.project.display_name="{ item }">
<v-chip size="small" :color="item.project.color">
{{ item.project.name }}
{{ item.project.display_name }}
</v-chip>
</template>
<template #item.case_costs="{ value }" v-if="auth.currentUser.experimental_features">
@@ -228,7 +228,7 @@ function loadHeaders() {
{ title: "Type", value: "case_type.name", sortable: true },
{ title: "Severity", value: "case_severity.name", sortable: true },
{ title: "Priority", value: "case_priority.name", sortable: true },
{ title: "Project", value: "project.name", sortable: true },
{ title: "Project", value: "project.display_name", sortable: true },
{ title: "Assignee", value: "assignee", sortable: false },
{ title: "Cost", key: "case_costs", sortable: false, experimental_features: true },
{ title: "Reported At", value: "reported_at", sortable: true },
Original file line number Diff line number Diff line change
@@ -25,13 +25,13 @@
</template>
<template #chip="{ item, props }">
<v-chip v-bind="props">
<span>{{ item.raw.project.name }}/</span>{{ item.raw.name }}
<span>{{ item.raw.project.display_name }}/</span>{{ item.raw.name }}
</v-chip>
</template>
<template #item="data">
<v-list-item v-bind="data.props" :title="null">
<v-list-item-title>
<span>{{ data.item.raw.project.name }}/</span>{{ data.item.raw.name }}
<span>{{ data.item.raw.project.display_name }}/</span>{{ data.item.raw.name }}
</v-list-item-title>
<v-list-item-subtitle :title="data.item.raw.description">
{{ data.item.raw.description }}
Original file line number Diff line number Diff line change
@@ -25,13 +25,13 @@
</template>
<template #chip="{ item, props }">
<v-chip v-bind="props">
<span>{{ item.raw.project.name }}/</span>{{ item.raw.name }}
<span>{{ item.raw.project.display_name }}/</span>{{ item.raw.name }}
</v-chip>
</template>
<template #item="data">
<v-list-item v-bind="data.props" :title="null">
<v-list-item-title>
<span>{{ data.item.raw.project.name }}/</span>{{ data.item.raw.name }}
<span>{{ data.item.raw.project.display_name }}/</span>{{ data.item.raw.name }}
</v-list-item-title>
<v-list-item-subtitle :title="data.item.raw.description">
{{ data.item.raw.description }}
Original file line number Diff line number Diff line change
@@ -25,13 +25,13 @@
</template>
<template #chip="{ item, props }">
<v-chip v-bind="props">
<span>{{ item.raw.project.name }}/</span>{{ item.raw.name }}
<span>{{ item.raw.project.display_name }}/</span>{{ item.raw.name }}
</v-chip>
</template>
<template #item="data">
<v-list-item v-bind="data.props" :title="null">
<v-list-item-title>
<span>{{ data.item.raw.project.name }}/</span>{{ data.item.raw.name }}
<span>{{ data.item.raw.project.display_name }}/</span>{{ data.item.raw.name }}
</v-list-item-title>
<v-list-item-subtitle :title="data.item.raw.description">
{{ data.item.raw.description }}
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
</v-card-title>
</v-card>
<v-data-table :headers="headers" :items="items" :loading="loading" :search="search">
<template #item.project.name="{ item, value }">
<template #item.project.display_name="{ item, value }">
<v-chip size="small" :color="item.project.color">
{{ value }}
</v-chip>
@@ -45,7 +45,7 @@ export default {
headers: [
{ title: "Name", key: "name", align: "left", width: "10%" },
{ title: "Title", key: "title", sortable: false },
{ title: "Project", key: "project.name", sortable: true },
{ title: "Project", key: "project.display_name", sortable: true },
{ title: "", key: "data-table-actions", sortable: false, align: "end" },
],
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<template>
<v-data-table :headers="headers" :items="items">
<template #item.project.name="{ item, value }">
<template #item.project.display_name="{ item, value }">
<v-chip size="small" :color="item.project.color">
{{ value }}
</v-chip>
@@ -29,7 +29,7 @@ export default {
return {
headers: [
{ title: "Name", key: "name", sortable: true },
{ title: "Project", key: "project.name", sortable: false },
{ title: "Project", key: "project.display_name", sortable: false },
{ title: "Description", key: "description", sortable: false },
{ title: "Language", key: "language", sortable: true },
{
6 changes: 3 additions & 3 deletions src/dispatch/static/dispatch/src/data/query/Table.vue
Original file line number Diff line number Diff line change
@@ -35,9 +35,9 @@
:loading="loading"
loading-text="Loading... Please wait"
>
<template #item.project.name="{ item }">
<template #item.project.display_name="{ item }">
<v-chip size="small" :color="item.project.color">
{{ item.project.name }}
{{ item.project.display_name }}
</v-chip>
</template>
<template #item.data-table-actions="{ item }">
@@ -86,7 +86,7 @@ export default {
return {
headers: [
{ title: "Name", value: "name", sortable: true },
{ title: "Project", value: "project.name", sortable: false },
{ title: "Project", value: "project.display_name", sortable: false },
{ title: "Description", value: "description", sortable: false },
{ title: "Language", value: "language", sortable: true },
{
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
<b>{{ value }}</b>
</router-link>
</template>
<template #item.project.name="{ item, value }">
<template #item.project.display_name="{ item, value }">
<v-chip size="small" :color="item.project.color">
{{ value }}
</v-chip>
@@ -67,7 +67,7 @@ export default {
return {
headers: [
{ title: "Name", key: "name", sortable: true },
{ title: "Project", key: "project.name", sortable: false },
{ title: "Project", key: "project.display_name", sortable: false },
{ title: "Environment", key: "source_environment.name", sortable: true },
{ title: "Owner", key: "owner" },
{ title: "Status", key: "source_status", sortable: true },
6 changes: 3 additions & 3 deletions src/dispatch/static/dispatch/src/data/source/Table.vue
Original file line number Diff line number Diff line change
@@ -45,9 +45,9 @@
<b>{{ item.name }}</b>
</router-link>
</template>
<template #item.project.name="{ item }">
<template #item.project.display_name="{ item }">
<v-chip size="small" :color="item.project.color">
{{ item.project.name }}
{{ item.project.display_name }}
</v-chip>
</template>
<template #item.source_status="{ item }">
@@ -120,7 +120,7 @@ export default {
return {
headers: [
{ title: "Name", value: "name", sortable: true },
{ title: "Project", value: "project.name", sortable: false },
{ title: "Project", value: "project.display_name", sortable: false },
{ title: "Environment", value: "source_environment.name", sortable: true },
{ title: "Owner", value: "owner" },
{ title: "Status", value: "source_status", sortable: true },
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@
<v-icon size="small">mdi-open-in-new</v-icon>
</a>
</template>
<template #item.project.name="{ item, value }">
<template #item.project.display_name="{ item, value }">
<v-chip size="small" :color="item.project.color">
{{ value }}
</v-chip>
@@ -39,7 +39,7 @@ export default {
headers: [
{ title: "Name", key: "name", sortable: false },
{ title: "Description", key: "description", sortable: false },
{ title: "Project", key: "project.name", sortable: true },
{ title: "Project", key: "project.display_name", sortable: true },
{ title: "", key: "data-table-actions", sortable: false, align: "end" },
],
}
6 changes: 3 additions & 3 deletions src/dispatch/static/dispatch/src/feedback/incident/Table.vue
Original file line number Diff line number Diff line change
@@ -44,9 +44,9 @@
<span>{{ formatDate(item.created_at) }}</span>
</v-tooltip>
</template>
<template #item.project.name="{ item }">
<template #item.project.display_name="{ item }">
<v-chip size="small" :color="item.project.color">
{{ item.project.name }}
{{ item.project.display_name }}
</v-chip>
</template>
<template #item.name="{ item }">
@@ -110,7 +110,7 @@ export default {
{ title: "Participant", value: "participant", sortable: true },
{ title: "Rating", value: "rating", sortable: true },
{ title: "Feedback", value: "feedback", sortable: true },
{ title: "Project", value: "project.name", sortable: false },
{ title: "Project", value: "project.display_name", sortable: false },
{ title: "Created At", value: "created_at", sortable: true },
{ title: "", key: "data-table-actions", sortable: false, align: "end" },
],
Loading

0 comments on commit 6fce74f

Please sign in to comment.