diff --git a/modules/upload/upload.go b/modules/upload/upload.go index e020faca7e..97f0df0542 100644 --- a/modules/upload/upload.go +++ b/modules/upload/upload.go @@ -75,18 +75,25 @@ func AddUploadContext(ctx *context.Context, uploadType string) { if uploadType == "release" { ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/releases/attachments" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/releases/attachments/remove" + ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/releases/attachments" ctx.Data["UploadAccepts"] = strings.Replace(setting.Repository.Release.AllowedTypes, "|", ",", -1) ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize } else if uploadType == "comment" { ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove" + if len(ctx.Params(":index")) > 0 { + ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/" + ctx.Params(":index") + "/attachments" + } else { + ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/issues/attachments" + } ctx.Data["UploadAccepts"] = strings.Replace(setting.Attachment.AllowedTypes, "|", ",", -1) ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize } else if uploadType == "repo" { ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/upload-file" ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/upload-remove" + ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/upload-file" ctx.Data["UploadAccepts"] = strings.Replace(setting.Repository.Upload.AllowedTypes, "|", ",", -1) ctx.Data["UploadMaxFiles"] = setting.Repository.Upload.MaxFiles ctx.Data["UploadMaxSize"] = setting.Repository.Upload.FileMaxSize diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index a4ce0a7106..190f5117b8 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -65,9 +65,11 @@
{{.Issue.Content}}
{{if .Issue.Attachments}} -
-
- {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}} +
+
+
+ {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Issue.Attachments}} +
{{end}}
diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl index 1144b9a77a..d76c0bbfa2 100644 --- a/templates/repo/issue/view_content/attachments.tmpl +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -2,7 +2,7 @@
{{if FilenameIsImage .Name}} - {{svg "octicon-file-media"}} + {{svg "octicon-file"}} {{else}} {{svg "octicon-desktop-download"}} {{end}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index a730bd5e8b..3b70a10715 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -57,9 +57,11 @@
{{.Content}}
{{if .Attachments}} -
-
- {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments}} +
+
+
+ {{template "repo/issue/view_content/attachments" Dict "ctx" $ "Attachments" .Attachments}} +
{{end}}
diff --git a/templates/repo/upload.tmpl b/templates/repo/upload.tmpl index 93bc098dae..9215da2b19 100644 --- a/templates/repo/upload.tmpl +++ b/templates/repo/upload.tmpl @@ -1,6 +1,7 @@
{ $renderContent.show(); $editContentZone.hide(); - dz.emit('reload'); + if (dz) { + dz.emit('reload'); + } }); $editContentZone.find('.save.button').on('click', () => { $renderContent.show(); @@ -990,26 +992,32 @@ async function initRepository() { context: $editContentZone.data('context'), files: $attachments }, (data) => { - if (data.length === 0) { + if (data.length === 0 || data.content.length === 0) { $renderContent.html($('#no-content').html()); } else { $renderContent.html(data.content); } - const $content = $segment.parent(); - if (!$content.find('.ui.small.images').length) { + const $content = $segment; + if (!$content.find('.dropzone-attachments').length) { if (data.attachments !== '') { - $content.append( - '
' - ); - $content.find('.ui.small.images').html(data.attachments); + $content.append(` +
+
+
+
+
+ `); + $content.find('.dropzone-attachments .grid').html(data.attachments); } } else if (data.attachments === '') { - $content.find('.ui.small.images').parent().remove(); + $content.find('.dropzone-attachments').remove(); } else { - $content.find('.ui.small.images').html(data.attachments); + $content.find('.dropzone-attachments .grid').html(data.attachments); + } + if (dz) { + dz.emit('submit'); + dz.emit('reload'); } - dz.emit('submit'); - dz.emit('reload'); renderMarkdownContent(); }); });