From ce829a9370c37e346c78754d987eb59a54107667 Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Mon, 9 Sep 2024 10:27:24 +0530 Subject: [PATCH 1/3] [MM-794]: Fixed the prefilled fields wehn creating issue with custom fields --- server/client.go | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/server/client.go b/server/client.go index 8ec947cd3..fbb6e1a62 100644 --- a/server/client.go +++ b/server/client.go @@ -334,14 +334,31 @@ 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 { + switch vTyped := v.(type) { + case string: + q.Add(k, vTyped) + case map[string]interface{}: + if id, ok := vTyped["id"].(string); ok { q.Add(k, id) } + case []interface{}: + for _, item1 := range vTyped { + switch vTyped2 := item1.(type) { + case string: + + q.Add(k, vTyped2) + case map[string]interface{}: + if id, ok := vTyped2["id"].(string); ok { + q.Add(k, id) + } + case []map[string]interface{}: + for _, item := range vTyped2 { + if id, ok := item["id"].(string); ok { + q.Add(k, id) + } + } + } + } } } From 035c9799145013417460d3494463a4b564f022ce Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Mon, 23 Sep 2024 13:26:10 +0530 Subject: [PATCH 2/3] [MM-794]: review fixes --- server/client.go | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/server/client.go b/server/client.go index fbb6e1a62..5a7ce56bc 100644 --- a/server/client.go +++ b/server/client.go @@ -333,28 +333,27 @@ func MakeCreateIssueURL(instance Instance, project *jira.Project, issue *jira.Is } // add custom fields - for k, v := range issue.Fields.Unknowns { - switch vTyped := v.(type) { + for key, field := range issue.Fields.Unknowns { + switch fieldTyped := field.(type) { case string: - q.Add(k, vTyped) + q.Add(key, fieldTyped) case map[string]interface{}: - if id, ok := vTyped["id"].(string); ok { - q.Add(k, id) + if id, ok := fieldTyped["id"].(string); ok { + q.Add(key, id) } case []interface{}: - for _, item1 := range vTyped { - switch vTyped2 := item1.(type) { + for _, element := range fieldTyped { + switch elementTyped := element.(type) { case string: - - q.Add(k, vTyped2) + q.Add(key, elementTyped) case map[string]interface{}: - if id, ok := vTyped2["id"].(string); ok { - q.Add(k, id) + if id, ok := elementTyped["id"].(string); ok { + q.Add(key, id) } case []map[string]interface{}: - for _, item := range vTyped2 { - if id, ok := item["id"].(string); ok { - q.Add(k, id) + for _, mapWithID := range elementTyped { + if id, ok := mapWithID["id"].(string); ok { + q.Add(key, id) } } } From df38c8e8b54a6b7ac853885349978fb07b8fc03c Mon Sep 17 00:00:00 2001 From: kshitij katiyar Date: Wed, 23 Oct 2024 17:30:04 +0530 Subject: [PATCH 3/3] [MM-794]: Added comment for jira custom field handling --- server/client.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/server/client.go b/server/client.go index 5a7ce56bc..9abb5a55d 100644 --- a/server/client.go +++ b/server/client.go @@ -335,13 +335,13 @@ func MakeCreateIssueURL(instance Instance, project *jira.Project, issue *jira.Is // add custom fields for key, field := range issue.Fields.Unknowns { switch fieldTyped := field.(type) { - case string: + case string: // handles fields like url, short text, paragraph q.Add(key, fieldTyped) - case map[string]interface{}: + case map[string]interface{}: // handles fields like dropdown if id, ok := fieldTyped["id"].(string); ok { q.Add(key, id) } - case []interface{}: + case []interface{}: // handles fields like labels, checkbox, flags for _, element := range fieldTyped { switch elementTyped := element.(type) { case string: