Skip to content

armgit / fider

Public Imported from GitHub
0

Open platform to collect and prioritize feedback

enhancement: make comment optional when responding to an idea (#419)

Guilherme Oenning5f5d289ab638
diff --git a/app/actions/idea.go b/app/actions/idea.go
index 4162bc599..a17cb96fa 100644
--- a/app/actions/idea.go
+++ b/app/actions/idea.go
@@ -167,8 +167,6 @@ func (input *SetResponse) Validate(user *models.User, services *app.Services) *v
if original != nil {
input.Original = original
}
- } else if input.Model.Status != models.IdeaOpen && input.Model.Text == "" {
- result.AddFieldFailure("text", "Description is required.")
}
return result
diff --git a/app/handlers/idea.go b/app/handlers/idea.go
index 1971b6cb9..f2d4116ba 100644
--- a/app/handlers/idea.go
+++ b/app/handlers/idea.go
@@ -220,6 +220,7 @@ func SetResponse() web.HandlerFunc {
return c.Failure(err)
}
+ prevStatus := idea.Status
if input.Model.Status == models.IdeaDuplicate {
err = c.Services().Ideas.MarkAsDuplicate(idea, input.Original)
} else {
@@ -229,7 +230,7 @@ func SetResponse() web.HandlerFunc {
return c.Failure(err)
}
- c.Enqueue(tasks.NotifyAboutStatusChange(idea, input.Model))
+ c.Enqueue(tasks.NotifyAboutStatusChange(idea, prevStatus))
return c.Ok(web.Map{})
}
diff --git a/app/tasks/tasks.go b/app/tasks/tasks.go
index e73689672..8ad51b1a2 100644
--- a/app/tasks/tasks.go
+++ b/app/tasks/tasks.go
@@ -148,10 +148,11 @@ func NotifyAboutNewComment(idea *models.Idea, comment *models.NewComment) worker
}
//NotifyAboutStatusChange sends a notification (web and email) to subscribers
-func NotifyAboutStatusChange(idea *models.Idea, response *models.SetResponse) worker.Task {
+func NotifyAboutStatusChange(idea *models.Idea, prevStatus int) worker.Task {
return describe("Notify about idea status change", func(c *worker.Context) error {
- //Don't notify if status is the same
- if idea.Status == response.Status {
+ //Don't notify if previous status is the same
+ c.Logger().Infof("%d, %d", prevStatus, idea.Status)
+ if prevStatus == idea.Status {
return nil
}
@@ -161,7 +162,7 @@ func NotifyAboutStatusChange(idea *models.Idea, response *models.SetResponse) wo
return c.Failure(err)
}
- title := fmt.Sprintf("**%s** changed status of **%s** to **%s**", c.User().Name, idea.Title, models.GetIdeaStatusName(response.Status))
+ title := fmt.Sprintf("**%s** changed status of **%s** to **%s**", c.User().Name, idea.Title, models.GetIdeaStatusName(idea.Status))
link := fmt.Sprintf("/ideas/%d/%s", idea.Number, idea.Slug)
for _, user := range users {
if _, err = c.Services().Notifications.Insert(user, title, link, idea.ID); err != nil {
@@ -176,8 +177,8 @@ func NotifyAboutStatusChange(idea *models.Idea, response *models.SetResponse) wo
}
var duplicate template.HTML
- if response.Status == models.IdeaDuplicate {
- originalIdea, err := c.Services().Ideas.GetByNumber(response.OriginalNumber)
+ if idea.Status == models.IdeaDuplicate {
+ originalIdea, err := c.Services().Ideas.GetByNumber(idea.Response.Original.Number)
if err != nil {
return c.Failure(err)
}
@@ -193,8 +194,8 @@ func NotifyAboutStatusChange(idea *models.Idea, response *models.SetResponse) wo
params := email.Params{
"title": fmt.Sprintf("[%s] %s", c.Tenant().Name, idea.Title),
- "content": markdown.Parse(response.Text),
- "status": models.GetIdeaStatusName(response.Status),
+ "content": markdown.Parse(idea.Response.Text),
+ "status": models.GetIdeaStatusName(idea.Status),
"duplicate": duplicate,
"view": linkWithText("View it on your browser", c.BaseURL(), "/ideas/%d/%s", idea.Number, idea.Slug),
"unsubscribe": linkWithText("unsubscribe from it", c.BaseURL(), "/ideas/%d/%s", idea.Number, idea.Slug),
diff --git a/public/components/ShowIdeaResponse.tsx b/public/components/ShowIdeaResponse.tsx
index 8ce7007a8..1a59e84d6 100644
--- a/public/components/ShowIdeaResponse.tsx
+++ b/public/components/ShowIdeaResponse.tsx
@@ -31,7 +31,11 @@ interface IdeaResponseProps {
response: IdeaResponse;
}
-const StatusDetails = (props: IdeaResponseProps): JSX.Element => {
+const StatusDetails = (props: IdeaResponseProps): JSX.Element | null => {
+ if (!props.response.text) {
+ return null;
+ }
+
return (
<div className="content">
<MultiLineText text={props.response.text} style="full" />
diff --git a/public/components/common/Segment.scss b/public/components/common/Segment.scss
index b46ac0be3..52c727f72 100644
--- a/public/components/common/Segment.scss
+++ b/public/components/common/Segment.scss
@@ -4,7 +4,7 @@
margin: 10px 0;
box-shadow: 0 1px 2px 0 rgba(34, 36, 38, 0.15);
border-radius: 5px;
- border: 1px solid rgba(34, 36, 38, 0.15);
+ border: 0.1px solid rgba(34, 36, 38, 0.15);
&:first-child {
margin-top: 0em;
@@ -16,7 +16,7 @@
box-shadow: 0 1px 2px 0 rgba(34, 36, 38, 0.15);
border-radius: 5px;
margin: 10px 0;
- border: 1px solid rgba(34, 36, 38, 0.15);
+ border: 0.1px solid rgba(34, 36, 38, 0.15);
&:first-child {
margin-top: 0em;
@@ -27,7 +27,7 @@
box-shadow: none;
border-radius: 0px;
border: none;
- border-bottom: 1px solid rgba(34, 36, 38, 0.15);
+ border-bottom: 0.1px solid rgba(34, 36, 38, 0.15);
&:last-child {
border-bottom: none;
}
diff --git a/views/templates/change_status.tpl b/views/templates/change_status.tpl
index 656a654e7..150009e1d 100644
--- a/views/templates/change_status.tpl
+++ b/views/templates/change_status.tpl
@@ -2,9 +2,9 @@ subject: {{ .title }}
body:
{{ if .duplicate }}
- <p>This idea has been closed as a <strong>{{ .status }}</strong> of {{ .duplicate }}. </p>
+ <i>This idea has been closed as a <strong>{{ .status }}</strong> of {{ .duplicate }}.</i>
{{ else }}
- Status has changed to <strong>{{ .status }}</strong>. <br />
+ <i>Status has changed to <strong>{{ .status }}</strong>.</i> <br />
{{ .content }}
{{ end }}