Skip to content

Commit ad25225

Browse files
authored
Adds enabled to project to hide disabled projects from new incidents and cases (Netflix#4572)
1 parent ff09d31 commit ad25225

File tree

8 files changed

+68
-3
lines changed

8 files changed

+68
-3
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
"""Adds enabled to project
2+
3+
Revision ID: 71cb25c06fa0
4+
Revises: 91bd05855ad1
5+
Create Date: 2024-04-02 12:31:20.012288
6+
7+
"""
8+
from alembic import op
9+
import sqlalchemy as sa
10+
11+
# revision identifiers, used by Alembic.
12+
revision = "71cb25c06fa0"
13+
down_revision = "91bd05855ad1"
14+
branch_labels = None
15+
depends_on = None
16+
17+
18+
def upgrade():
19+
# ### commands auto generated by Alembic - please adjust! ###
20+
op.add_column("project", sa.Column("enabled", sa.Boolean(), server_default="t", nullable=True, default=True))
21+
# ### end Alembic commands ###
22+
23+
24+
def downgrade():
25+
# ### commands auto generated by Alembic - please adjust! ###
26+
op.drop_column("project", "enabled")
27+
# ### end Alembic commands ###

src/dispatch/project/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Project(Base):
3939
cascade="all, delete-orphan",
4040
)
4141

42+
enabled = Column(Boolean, default=True, server_default="t")
43+
4244
send_daily_reports = Column(Boolean)
4345

4446
stable_priority_id = Column(Integer, nullable=True)
@@ -68,6 +70,7 @@ class ProjectBase(DispatchBase):
6870
default: bool = False
6971
color: Optional[str] = Field(None, nullable=True)
7072
send_daily_reports: Optional[bool] = Field(True, nullable=True)
73+
enabled: Optional[bool] = Field(True, nullable=True)
7174

7275

7376
class ProjectCreate(ProjectBase):

src/dispatch/static/dispatch/src/case/ReportSubmissionCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
/>
6161
</v-col>
6262
<v-col cols="12">
63-
<project-select v-model="project" />
63+
<project-select v-model="project" excludeDisabled />
6464
</v-col>
6565
<v-col cols="12">
6666
<case-type-select :project="project" v-model="case_type" />

src/dispatch/static/dispatch/src/incident/ReportSubmissionCard.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
/>
5858
</v-col>
5959
<v-col cols="12">
60-
<project-select v-model="project" />
60+
<project-select v-model="project" excludeDisabled />
6161
</v-col>
6262
<v-col cols="12">
6363
<incident-type-select :project="project" v-model="incident_type" />

src/dispatch/static/dispatch/src/project/NewEditSheet.vue

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@
5252
name="Description"
5353
/>
5454
</v-col>
55+
<v-col cols="12">
56+
<v-checkbox
57+
v-model="enabled"
58+
label="Enabled"
59+
hint="Whether this project is enabled for new cases and incidents."
60+
/>
61+
</v-col>
5562
<v-col cols="12">
5663
<color-picker-input v-model="color" />
5764
</v-col>
@@ -144,6 +151,7 @@ export default {
144151
"selected.organization",
145152
"selected.owner_conversation",
146153
"selected.owner_email",
154+
"selected.enabled",
147155
"dialogs.showCreateEdit",
148156
]),
149157
},

src/dispatch/static/dispatch/src/project/ProjectSelect.vue

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<script>
3737
import { cloneDeep, debounce } from "lodash"
3838
import ProjectApi from "@/project/api"
39+
import SearchUtils from "@/search/utils"
3940
4041
export default {
4142
name: "ProjectSelect",
@@ -47,6 +48,10 @@ export default {
4748
return {}
4849
},
4950
},
51+
excludeDisabled: {
52+
type: Boolean,
53+
default: false,
54+
},
5055
label: {
5156
type: String,
5257
default: "Project",
@@ -66,7 +71,13 @@ export default {
6671
computed: {
6772
project: {
6873
get() {
69-
return cloneDeep(this.modelValue)
74+
let projects = cloneDeep(this.modelValue)
75+
if (this.excludeDisabled && projects && Array.isArray(projects) && projects.length > 0) {
76+
projects = projects.filter((project) => {
77+
return project.enabled
78+
})
79+
}
80+
return projects
7081
},
7182
set(value) {
7283
this.$emit("update:modelValue", value)
@@ -89,6 +100,17 @@ export default {
89100
descending: [false],
90101
}
91102
103+
if (this.excludeDisabled) {
104+
filterOptions = {
105+
filters: {
106+
enabled: [true],
107+
},
108+
...filterOptions,
109+
}
110+
}
111+
112+
filterOptions = SearchUtils.createParametersFromTableOptions({ ...filterOptions })
113+
92114
ProjectApi.getAll(filterOptions).then((response) => {
93115
this.items = response.data.items
94116

src/dispatch/static/dispatch/src/project/Table.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
{{ item.name }}
4040
</router-link>
4141
</template>
42+
<template #item.enabled="{ value }">
43+
<v-checkbox-btn :model-value="value" disabled />
44+
</template>
4245
<template #item.data-table-actions="{ item }">
4346
<v-menu location="right" origin="overlap">
4447
<template #activator="{ props }">
@@ -85,6 +88,7 @@ export default {
8588
{ title: "Description", value: "description", sortable: false },
8689
{ title: "Annual Employee Cost", value: "annual_employee_cost", sortable: false },
8790
{ title: "Business Year Hours", value: "business_year_hours", sortable: false },
91+
{ title: "Enabled", value: "enabled", sortable: false },
8892
{ title: "", key: "data-table-actions", sortable: false, align: "end" },
8993
],
9094
}

src/dispatch/static/dispatch/src/project/store.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const getDefaultSelectedState = () => {
1515
business_year_hours: 2080,
1616
owner_email: null,
1717
owner_conversation: null,
18+
enabled: null,
1819
}
1920
}
2021

0 commit comments

Comments
 (0)