{{end}}
{{end}}
{{end}}
diff --git a/templates/repo/issue/view_content/conversation.tmpl b/templates/repo/issue/view_content/conversation.tmpl
index 429350fcd77..030315d039d 100644
--- a/templates/repo/issue/view_content/conversation.tmpl
+++ b/templates/repo/issue/view_content/conversation.tmpl
@@ -4,16 +4,16 @@ At the moment, two kinds of request handler call this template:
* Other compare and diff pages -> ... -> {section_unified.tmpl|section_split.tmpl} -> this)
The variables in "ctx.Data" are different in each case, making this template fragile, hard to read and maintain. */}}
{{if len .comments}}
- {{$comment := index .comments 0}}
- {{$invalid := $comment.Invalidated}}
- {{$resolved := $comment.IsResolved}}
- {{$resolveDoer := $comment.ResolveDoer}}
- {{$hasReview := and $comment.Review}}
- {{$isReviewPending := and $hasReview (eq $comment.Review.Type 0)}}
+ {{$firstComment := index .comments 0}}
+ {{$invalid := $firstComment.Invalidated}}
+ {{$resolved := $firstComment.IsResolved}}
+ {{$resolveDoer := $firstComment.ResolveDoer}}
+ {{$hasReview := and $firstComment.Review}}
+ {{$isReviewPending := and $hasReview (eq $firstComment.Review.Type 0)}}
- {{$comment.TreePath}}
+ {{$firstComment.TreePath}}
{{if $invalid}}
{{ctx.Locale.Tr "repo.issues.review.outdated"}}
@@ -22,7 +22,7 @@ The variables in "ctx.Data" are different in each case, making this template fra
{{if or $invalid $resolved}}
-
+
{{svg "octicon-unfold" 16 "tw-mr-2"}}
{{if $resolved}}
{{ctx.Locale.Tr "repo.issues.review.show_resolved"}}
@@ -30,7 +30,7 @@ The variables in "ctx.Data" are different in each case, making this template fra
{{ctx.Locale.Tr "repo.issues.review.show_outdated"}}
{{end}}
-
+
{{svg "octicon-fold" 16 "tw-mr-2"}}
{{if $resolved}}
{{ctx.Locale.Tr "repo.issues.review.hide_resolved"}}
@@ -41,10 +41,10 @@ The variables in "ctx.Data" are different in each case, making this template fra
{{end}}
@@ -88,7 +88,7 @@ The variables in "ctx.Data" are different in each case, making this template fra
{{template "repo/issue/view_content/show_role" dict "ShowRole" .ShowRole}}
{{if not $.Repository.IsArchived}}
{{template "repo/issue/view_content/add_reaction" dict "ActionURL" (printf "%s/comments/%d/reactions" $.RepoLink .ID)}}
- {{template "repo/issue/view_content/context_menu" dict "item" . "delete" true "issue" true "diff" true "IsCommentPoster" (and $.IsSigned (eq $.SignedUserID .PosterID))}}
+ {{template "repo/issue/view_content/context_menu" dict "ConvContentType" "issue_comment" "ConvContentItem" $comment}}
{{end}}
@@ -125,7 +125,7 @@ The variables in "ctx.Data" are different in each case, making this template fra
{{if and $.CanMarkConversation $hasReview (not $isReviewPending)}}
-
+
{{if $resolved}}
{{ctx.Locale.Tr "repo.issues.review.un_resolve_conversation"}}
{{else}}
@@ -140,7 +140,7 @@ The variables in "ctx.Data" are different in each case, making this template fra
{{end}}
`));
}
showFomanticModal(modal);
}
-export function registerShortcutHandler(fullKey: string, handler: ShortcutHandler) {
- fullKey = fullKey.toLowerCase();
- shortcutHandlers[fullKey] ||= [];
- shortcutHandlers[fullKey].push(handler);
+export function registerShortcutHandler(name: string, handler: ShortcutHandler) {
+ shortcutHandlers[name] ||= [];
+ shortcutHandlers[name].push(handler);
}
export function initGlobalShortcut() {
@@ -169,20 +179,22 @@ export function initGlobalShortcut() {
shortcutPresses.push({fullKey, pressTime});
const fullKeys = shortcutPresses.map((p) => p.fullKey).join(' ');
- for (const handler of shortcutHandlers[fullKeys.toLowerCase()] || []) {
- if (handler(target)) {
- e.preventDefault();
- shortcutPresses.length = 0;
- return;
- }
- }
-
// It's said that "spaces in aria-keyshortcuts separate alternative shortcuts", but we want to support multi-key shortcuts
// So here we use our own data attribute to store the full shortcut keys, and match it case-insensitively.
const matchedElems = document.querySelectorAll(`[data-shortcut-keys="${CSS.escape(fullKeys)}" i]`);
if (!matchedElems.length) return;
// TODO: if there are multiple matches, maybe we could introduce some priority rules to determine which one to trigger
const matchedElem = matchedElems[0];
+ const handlerName = matchedElem.getAttribute('data-shortcut-handler')!;
+ if (shortcutHandlers[handlerName]) {
+ for (const handler of shortcutHandlers[handlerName]) {
+ if (handler(target)) break;
+ }
+ e.preventDefault();
+ shortcutPresses.length = 0;
+ return;
+ }
+
e.preventDefault();
shortcutPresses.length = 0;
matchedElem.click();