diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2023-04-20 14:39:44 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-20 02:39:44 -0400 |
commit | de2268ffab922de67f51e98541d0f9078795ac5d (patch) | |
tree | a9f79d0bcb2914d64ce1399a025fb01e887cc7eb /templates | |
parent | 92e07f270aa925d518b13686f78befb63da0a747 (diff) | |
download | gitea-de2268ffab922de67f51e98541d0f9078795ac5d.tar.gz gitea-de2268ffab922de67f51e98541d0f9078795ac5d.zip |
Fix issue attachment handling (#24202)
Close #24195
Some of the changes are taken from my another fix
https://github.com/go-gitea/gitea/pull/20147/commits/f07b0de997125c9b79cc5af27966a7cdd1803a4d
in #20147 (although that PR was discarded ....)
The bug is:
1. The old code doesn't handle `removedfile` event correctly
2. The old code doesn't provide attachments for type=CommentTypeReview
This PR doesn't intend to refactor the "upload" code to a perfect state
(to avoid making the review difficult), so some legacy styles are kept.
---------
Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'templates')
-rw-r--r-- | templates/repo/diff/comments.tmpl | 2 | ||||
-rw-r--r-- | templates/repo/issue/view_content.tmpl | 20 | ||||
-rw-r--r-- | templates/repo/issue/view_content/attachments.tmpl | 20 | ||||
-rw-r--r-- | templates/repo/issue/view_content/comments.tmpl | 6 |
4 files changed, 25 insertions, 23 deletions
diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl index 5bcaeeb463..f301261533 100644 --- a/templates/repo/diff/comments.tmpl +++ b/templates/repo/diff/comments.tmpl @@ -55,7 +55,7 @@ {{end}} </div> <div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div> - <div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.root.RepoLink}}/comments/{{.ID}}" data-context="{{$.root.RepoLink}}"></div> + <div class="edit-content-zone gt-hidden" data-update-url="{{$.root.RepoLink}}/comments/{{.ID}}" data-context="{{$.root.RepoLink}}"></div> </div> {{$reactions := .Reactions.GroupByType}} {{if $reactions}} diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl index a5d9b0bde0..081b7d08c6 100644 --- a/templates/repo/issue/view_content.tmpl +++ b/templates/repo/issue/view_content.tmpl @@ -78,7 +78,7 @@ {{end}} </div> <div id="issue-{{.Issue.ID}}-raw" class="raw-content gt-hidden">{{.Issue.Content}}</div> - <div class="edit-content-zone gt-hidden" data-write="issue-{{.Issue.ID}}-write" data-preview="issue-{{.Issue.ID}}-preview" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-context="{{.RepoLink}}" data-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/attachments" data-view-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/view-attachments"></div> + <div class="edit-content-zone gt-hidden" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/content" data-context="{{.RepoLink}}" data-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/attachments" data-view-attachment-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/view-attachments"></div> {{if .Issue.Attachments}} {{template "repo/issue/view_content/attachments" dict "ctxData" $ "Attachments" .Issue.Attachments "Content" .Issue.RenderedContent}} {{end}} @@ -166,13 +166,15 @@ <template id="issue-comment-editor-template"> <div class="ui comment form"> - {{template "shared/combomarkdowneditor" (dict - "locale" $.locale - "MarkdownPreviewUrl" (print .Repository.Link "/markup") - "MarkdownPreviewContext" .RepoLink - "TextareaName" "content" - "DropzoneParentContainer" ".ui.form" - )}} + <div class="field"> + {{template "shared/combomarkdowneditor" (dict + "locale" $.locale + "MarkdownPreviewUrl" (print .Repository.Link "/markup") + "MarkdownPreviewContext" .RepoLink + "TextareaName" "content" + "DropzoneParentContainer" ".ui.form" + )}} + </div> {{if .IsAttachmentEnabled}} <div class="field"> @@ -180,7 +182,7 @@ </div> {{end}} - <div class="field footer"> + <div class="field"> <div class="text right edit"> <button class="ui basic secondary cancel button" tabindex="3">{{.locale.Tr "repo.issues.cancel"}}</button> <button class="ui primary save button" tabindex="2">{{.locale.Tr "repo.issues.save"}}</button> diff --git a/templates/repo/issue/view_content/attachments.tmpl b/templates/repo/issue/view_content/attachments.tmpl index 3c0190b7d8..7a429c31ec 100644 --- a/templates/repo/issue/view_content/attachments.tmpl +++ b/templates/repo/issue/view_content/attachments.tmpl @@ -1,11 +1,11 @@ <div class="dropzone-attachments"> {{if .Attachments}} - <div class="ui clearing divider"></div> + <div class="ui divider"></div> {{end}} - <div class="ui middle aligned padded grid"> - {{$hasThumbnails := false}} - {{- range .Attachments -}} - <div class="twelve wide column" style="padding: 6px;"> + {{$hasThumbnails := false}} + {{- range .Attachments -}} + <div class="gt-df"> + <div class="gt-f1 gt-p-3"> <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'> {{if FilenameIsImage .Name}} {{if not (containGeneric $.Content .UUID)}} @@ -18,20 +18,20 @@ <span><strong>{{.Name}}</strong></span> </a> </div> - <div class="four wide column" style="padding: 0px;"> + <div class="gt-p-3 gt-df gt-ac"> <span class="ui text grey right">{{.Size | FileSize}}</span> </div> - {{end -}} - </div> + </div> + {{end -}} {{if $hasThumbnails}} - <div class="ui clearing divider"></div> + <div class="ui divider"></div> <div class="ui small thumbnails"> {{- range .Attachments -}} {{if FilenameIsImage .Name}} {{if not (containGeneric $.Content .UUID)}} <a target="_blank" rel="noopener noreferrer" href="{{.DownloadURL}}"> - <img src="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'> + <img alt="{{.Name}}" src="{{.DownloadURL}}" title='{{$.ctxData.locale.Tr "repo.issues.attachment.open_tab" .Name}}'> </a> {{end}} {{end}} diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl index 39a6722e84..116c02b8b5 100644 --- a/templates/repo/issue/view_content/comments.tmpl +++ b/templates/repo/issue/view_content/comments.tmpl @@ -78,7 +78,7 @@ {{end}} </div> <div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div> - <div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> + <div class="edit-content-zone gt-hidden" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> {{if .Attachments}} {{template "repo/issue/view_content/attachments" dict "ctxData" $ "Attachments" .Attachments "Content" .RenderedContent}} {{end}} @@ -450,7 +450,7 @@ {{end}} </div> <div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div> - <div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> + <div class="edit-content-zone gt-hidden" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> {{if .Attachments}} {{template "repo/issue/view_content/attachments" dict "ctxData" $ "Attachments" .Attachments "Content" .RenderedContent}} {{end}} @@ -577,7 +577,7 @@ {{end}} </div> <div id="issuecomment-{{.ID}}-raw" class="raw-content gt-hidden">{{.Content}}</div> - <div class="edit-content-zone gt-hidden" data-write="issuecomment-{{.ID}}-write" data-preview="issuecomment-{{.ID}}-preview" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> + <div class="edit-content-zone gt-hidden" data-update-url="{{$.RepoLink}}/comments/{{.ID}}" data-context="{{$.RepoLink}}" data-attachment-url="{{$.RepoLink}}/comments/{{.ID}}/attachments"></div> </div> {{$reactions := .Reactions.GroupByType}} {{if $reactions}} |