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

[MM-794]: Fixed the issue of fields not prefilled when creating issue with custom fields #1127

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 24 additions & 8 deletions server/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,30 @@ func MakeCreateIssueURL(instance Instance, project *jira.Project, issue *jira.Is
}

// add custom fields
for k, v := range issue.Fields.Unknowns {
strV, ok := v.(string)
if ok {
q.Add(k, strV)
}
if mapV, ok := v.(map[string]interface{}); ok {
if id, ok := mapV["id"].(string); ok {
q.Add(k, id)
for key, field := range issue.Fields.Unknowns {
switch fieldTyped := field.(type) {
case string: // handles fields like url, short text, paragraph
q.Add(key, fieldTyped)
case map[string]interface{}: // handles fields like dropdown
if id, ok := fieldTyped["id"].(string); ok {
q.Add(key, id)
}
case []interface{}: // handles fields like labels, checkbox, flags
for _, element := range fieldTyped {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kshitij-Katiyar can you add some comments indicating what field type(s) each case represents.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wiggin77 Added the comment for what fields are handled in each case.
please have a look

switch elementTyped := element.(type) {
case string:
q.Add(key, elementTyped)
case map[string]interface{}:
if id, ok := elementTyped["id"].(string); ok {
q.Add(key, id)
}
case []map[string]interface{}:
for _, mapWithID := range elementTyped {
if id, ok := mapWithID["id"].(string); ok {
q.Add(key, id)
}
}
}
}
}
}
Expand Down
Loading