From 6bac901fc1ed5cc3d97cb1a54817cbcda0c49f1c Mon Sep 17 00:00:00 2001 From: jonandernovella Date: Wed, 13 Sep 2023 11:25:52 +0200 Subject: [PATCH] fix: Make search also return Project info This solves the existing bug when you search based on normal text instead of issue ids. --- backend/api/issueSearchHandler.go | 8 +++++--- backend/api/models.go | 9 +++++++-- frontend/src/components/QuickAdd.tsx | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/backend/api/issueSearchHandler.go b/backend/api/issueSearchHandler.go index fe42c0ac..3acc5d3c 100644 --- a/backend/api/issueSearchHandler.go +++ b/backend/api/issueSearchHandler.go @@ -36,9 +36,10 @@ func issueSearchHandler(c *fiber.Ctx) error { searchResponse := struct { Results []struct { - Id int `json:"id"` - Type string `json:"type"` - Title string `json:"title"` + Id int `json:"id"` + Type string `json:"type"` + Title string `json:"title"` + Project Project `json:"project"` } `json:"results"` }{} @@ -73,6 +74,7 @@ func issueSearchHandler(c *fiber.Ctx) error { issue := Issue{ Id: issue.Id, Subject: issuesResponse.Issues[0].Subject, + Project: issuesResponse.Issues[0].Project, } foundIssues = append(foundIssues, issue) } diff --git a/backend/api/models.go b/backend/api/models.go index 65d8b28d..102e4aa4 100644 --- a/backend/api/models.go +++ b/backend/api/models.go @@ -4,9 +4,14 @@ type user struct { Login string `json:"login"` } +type Project struct { + Id int `json:"id"` +} + type Issue struct { - Id int `json:"id"` - Subject string `json:"subject"` + Id int `json:"id"` + Subject string `json:"subject"` + Project Project `json:"project"` } type IssueWithTitle struct { diff --git a/frontend/src/components/QuickAdd.tsx b/frontend/src/components/QuickAdd.tsx index 975c1381..0b78dd3d 100644 --- a/frontend/src/components/QuickAdd.tsx +++ b/frontend/src/components/QuickAdd.tsx @@ -126,6 +126,7 @@ export const QuickAdd = ({ messages: "0", // projects: "0" produces weird results. open_issues: "1", + projects: "1", }; const foundIssues: { issues: Issue[] } = await fetch(