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

feat(ui): allow project to have a display name separate from its key #5616

Merged
merged 5 commits into from
Dec 14, 2024
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
1 change: 1 addition & 0 deletions src/dispatch/case/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

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


# Pydantic models...
Expand Down
10 changes: 5 additions & 5 deletions src/dispatch/plugins/dispatch_slack/case/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")]),
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand Down Expand Up @@ -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,
),
Expand Down
2 changes: 1 addition & 1 deletion src/dispatch/plugins/dispatch_slack/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
]
Expand Down
18 changes: 3 additions & 15 deletions src/dispatch/plugins/dispatch_slack/incident/interactive.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down Expand Up @@ -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={
Expand Down
3 changes: 3 additions & 0 deletions src/dispatch/project/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions src/dispatch/static/dispatch/src/case/CaseSummaryTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 3 additions & 3 deletions src/dispatch/static/dispatch/src/case/Table.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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">
Expand Down Expand Up @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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" },
],
}
Expand Down
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>
Expand Down Expand Up @@ -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 },
{
Expand Down
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
Expand Up @@ -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 }">
Expand Down Expand Up @@ -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 },
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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 },
Expand Down
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
Expand Up @@ -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 }">
Expand Down Expand Up @@ -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 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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" },
],
}
Expand Down
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
Expand Up @@ -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 }">
Expand Down Expand Up @@ -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" },
],
Expand Down
Loading
Loading