diff options
author | techknowlogick <techknowlogick@gitea.io> | 2020-09-30 21:25:57 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 09:25:57 +0800 |
commit | c1c5e00d207634acfa73aea2c3bdc43508fa7181 (patch) | |
tree | a98468f17093b6af92e0349b68e32a80fed7d1a4 | |
parent | 3e279dfb0bc08fe74ed394d0ea26b7c6a8b23b86 (diff) | |
download | gitea-c1c5e00d207634acfa73aea2c3bdc43508fa7181.tar.gz gitea-c1c5e00d207634acfa73aea2c3bdc43508fa7181.zip |
Prevent empty div when editing comment (#12404) (#12991)
* Prevent empty div when editing comment
The template for attachments needs to remove whitespace and return empty when there are no attachments.
Fix #10220
Co-authored-by: zeripath <art27@cantab.net>
-rw-r--r-- | routers/repo/issue.go | 6 | ||||
-rw-r--r-- | templates/repo/issue/view_content/attachments.tmpl | 4 |
2 files changed, 5 insertions, 5 deletions
diff --git a/routers/repo/issue.go b/routers/repo/issue.go index 6000d12b4f..8c773576b6 100644 --- a/routers/repo/issue.go +++ b/routers/repo/issue.go @@ -1956,7 +1956,7 @@ func updateAttachments(item interface{}, files []string) error { case *models.Comment: attachments = content.Attachments default: - return fmt.Errorf("Unknow Type") + return fmt.Errorf("Unknown Type: %T", content) } for i := 0; i < len(attachments); i++ { if util.IsStringInSlice(attachments[i].UUID, files) { @@ -1974,7 +1974,7 @@ func updateAttachments(item interface{}, files []string) error { case *models.Comment: err = content.UpdateAttachments(files) default: - return fmt.Errorf("Unknow Type") + return fmt.Errorf("Unknown Type: %T", content) } if err != nil { return err @@ -1986,7 +1986,7 @@ func updateAttachments(item interface{}, files []string) error { case *models.Comment: content.Attachments, err = models.GetAttachmentsByCommentID(content.ID) default: - return fmt.Errorf("Unknow Type") + return fmt.Errorf("Unknown Type: %T", content) } return err } diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl index 2d3c638179..3c69dbc2ba 100644 --- a/templates/repo/issue/view_content/attachments.tmpl +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -1,4 +1,4 @@ -{{range .Attachments}} +{{- range .Attachments -}} <div class="twelve wide column" style="padding: 6px;"> <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctx.i18n.Tr "repo.issues.attachment.open_tab" .Name}}'> {{if FilenameIsImage .Name}} @@ -12,4 +12,4 @@ <div class="four wide column" style="padding: 0px;"> <span class="ui text grey right">{{.Size | FileSize}}</span> </div> -{{end}} +{{end -}} |