Skip to content

Commit 08e5d1a

Browse files
Revert "type a load of formfield configs"
This reverts commit 8ef4856.
1 parent 8ef4856 commit 08e5d1a

File tree

3 files changed

+40
-77
lines changed

3 files changed

+40
-77
lines changed

src/sentry/integrations/jira/endpoints/search.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
from sentry.api.api_publish_status import ApiPublishStatus
1111
from sentry.api.base import control_silo_endpoint
1212
from sentry.integrations.api.bases.integration import IntegrationEndpoint
13-
from sentry.integrations.jira.integration import JiraProjectMapping
1413
from sentry.integrations.models.integration import Integration
1514
from sentry.organizations.services.organization import RpcOrganization
1615
from sentry.shared_integrations.exceptions import ApiError, ApiUnauthorized, IntegrationError
@@ -95,7 +94,7 @@ def get(
9594
return Response({"detail": "Unable to fetch projects from Jira"}, status=400)
9695

9796
projects = [
98-
JiraProjectMapping(label=f"{p["key"]} - {p["name"]}", value=p["id"])
97+
{"label": f"{p["key"]} - {p["name"]}", "value": p["id"]}
9998
for p in response.get("values", [])
10099
]
101100

src/sentry/integrations/jira/integration.py

Lines changed: 22 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323
)
2424
from sentry.integrations.jira.models.create_issue_metadata import JiraIssueTypeMetadata
2525
from sentry.integrations.jira.tasks import migrate_issues
26-
from sentry.integrations.mixins.issues import (
27-
MAX_CHAR,
28-
BaseFormFieldConfig,
29-
IssueSyncIntegration,
30-
ResolveSyncAction,
31-
)
26+
from sentry.integrations.mixins.issues import MAX_CHAR, IssueSyncIntegration, ResolveSyncAction
3227
from sentry.integrations.models.external_issue import ExternalIssue
3328
from sentry.integrations.models.integration_external_project import IntegrationExternalProject
3429
from sentry.integrations.services.integration import integration_service
@@ -133,15 +128,6 @@ class JiraProjectMapping(TypedDict):
133128
label: str
134129

135130

136-
class SelectFormFieldConfig(BaseFormFieldConfig, total=False):
137-
choices: list[tuple[str, str]]
138-
updatesForm: bool
139-
140-
141-
class AsyncSelectFormFieldConfig(SelectFormFieldConfig):
142-
url: str
143-
144-
145131
class JiraIntegration(IssueSyncIntegration):
146132
outbound_status_key = "sync_status_forward"
147133
inbound_status_key = "sync_status_reverse"
@@ -842,41 +828,33 @@ def get_create_issue_config(self, group: Group | None, user: RpcUser, **kwargs):
842828
if not any(c for c in issue_type_choices if c[0] == issue_type):
843829
issue_type = issue_type_meta["id"]
844830

845-
projects_form_field = SelectFormFieldConfig(
846-
name="project",
847-
label="Jira Project",
848-
choices=[(p["id"], f"{p["key"]} - {p["name"]}") for p in jira_projects],
849-
default=meta["id"],
850-
type="select",
851-
updatesForm=True,
852-
required=True,
853-
)
854-
831+
projects_form_field = {
832+
"name": "project",
833+
"label": "Jira Project",
834+
"choices": [(p["id"], f"{p["key"]} - {p["name"]}") for p in jira_projects],
835+
"default": meta["id"],
836+
"type": "select",
837+
"updatesForm": True,
838+
"required": True,
839+
}
855840
if features.has("organizations:jira-paginated-projects", group.organization, actor=user):
856-
paginated_projects_url = self.search_url(group.organization.slug)
857-
projects_form_field = AsyncSelectFormFieldConfig(
858-
name="project",
859-
label="Jira Project",
860-
choices=[(p["id"], f"{p["key"]} - {p["name"]}") for p in jira_projects],
861-
default=meta["id"],
862-
type="select",
863-
updatesForm=True,
864-
required=True,
865-
url=paginated_projects_url,
841+
paginated_projects_url = reverse(
842+
"sentry-extensions-jira-search", args=[self.organization.slug, self.model.id]
866843
)
844+
projects_form_field["url"] = paginated_projects_url
867845

868846
fields = [
869847
projects_form_field,
870848
*fields,
871-
SelectFormFieldConfig(
872-
name="issuetype",
873-
label="Issue Type",
874-
choices=issue_type_choices,
875-
default=issue_type or issue_type_meta["id"],
876-
type="select",
877-
updatesForm=True,
878-
required=bool(issue_type_choices),
879-
),
849+
{
850+
"name": "issuetype",
851+
"label": "Issue Type",
852+
"default": issue_type or issue_type_meta["id"],
853+
"type": "select",
854+
"choices": issue_type_choices,
855+
"updatesForm": True,
856+
"required": bool(issue_type_choices), # required if we have any type choices
857+
},
880858
]
881859

882860
# title is renamed to summary before sending to Jira

src/sentry/integrations/mixins/issues.py

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from collections.abc import Mapping, Sequence
88
from copy import deepcopy
99
from operator import attrgetter
10-
from typing import Any, ClassVar, TypedDict
10+
from typing import Any, ClassVar
1111

1212
from sentry.eventstore.models import GroupEvent
1313
from sentry.integrations.base import IntegrationInstallation
@@ -35,19 +35,6 @@
3535
MAX_CHAR = 50
3636

3737

38-
class BaseFormFieldConfig(TypedDict):
39-
name: str
40-
label: str
41-
default: str
42-
type: str
43-
required: bool
44-
45-
46-
class TextAreaFormFieldConfig(BaseFormFieldConfig, total=False):
47-
autosize: bool
48-
maxRows: int
49-
50-
5138
class ResolveSyncAction(enum.Enum):
5239
"""
5340
When an issue's state changes, we may have to sync the state based on the
@@ -157,7 +144,7 @@ def get_group_description(self, group, event, **kwargs):
157144
@all_silo_function
158145
def get_create_issue_config(
159146
self, group: Group | None, user: User | RpcUser, **kwargs
160-
) -> list[BaseFormFieldConfig]:
147+
) -> list[dict[str, Any]]:
161148
"""
162149
These fields are used to render a form for the user,
163150
and are then passed in the format of:
@@ -173,22 +160,21 @@ def get_create_issue_config(
173160
event = group.get_latest_event()
174161

175162
return [
176-
BaseFormFieldConfig(
177-
name="title",
178-
label="Title",
179-
default=self.get_group_title(group, event, **kwargs),
180-
type="string",
181-
required=True,
182-
),
183-
TextAreaFormFieldConfig(
184-
name="description",
185-
label="Description",
186-
default=self.get_group_description(group, event, **kwargs),
187-
type="textarea",
188-
autosize=True,
189-
maxRows=10,
190-
required=False,
191-
),
163+
{
164+
"name": "title",
165+
"label": "Title",
166+
"default": self.get_group_title(group, event, **kwargs),
167+
"type": "string",
168+
"required": True,
169+
},
170+
{
171+
"name": "description",
172+
"label": "Description",
173+
"default": self.get_group_description(group, event, **kwargs),
174+
"type": "textarea",
175+
"autosize": True,
176+
"maxRows": 10,
177+
},
192178
]
193179

194180
def get_link_issue_config(self, group, **kwargs):

0 commit comments

Comments
 (0)