mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 21:28:11 +09:00 
			
		
		
		
	Fixed Issue of Review Menu Shown Behind (#32631)
Fixed #31144 --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		| @@ -164,12 +164,11 @@ | |||||||
| 										<input type="checkbox" name="{{$file.GetDiffFileName}}" autocomplete="off"{{if $file.IsViewed}} checked{{end}}> {{ctx.Locale.Tr "repo.pulls.has_viewed_file"}} | 										<input type="checkbox" name="{{$file.GetDiffFileName}}" autocomplete="off"{{if $file.IsViewed}} checked{{end}}> {{ctx.Locale.Tr "repo.pulls.has_viewed_file"}} | ||||||
| 									</label> | 									</label> | ||||||
| 								{{end}} | 								{{end}} | ||||||
| 								<div class="ui dropdown basic"> | 								<button class="btn diff-header-popup-btn tw-p-1">{{svg "octicon-kebab-horizontal" 18}}</button> | ||||||
| 									{{svg "octicon-kebab-horizontal" 18 "icon tw-mx-2"}} | 								<div class="tippy-target"> | ||||||
| 									<div class="ui menu"> |  | ||||||
| 									{{if not (or $file.IsIncomplete $file.IsBin $file.IsSubmodule)}} | 									{{if not (or $file.IsIncomplete $file.IsBin $file.IsSubmodule)}} | ||||||
| 											<button class="unescape-button item">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button> | 										<button class="unescape-button item" data-file-content-elem-id="diff-{{$file.NameHash}}">{{ctx.Locale.Tr "repo.unescape_control_characters"}}</button> | ||||||
| 											<button class="escape-button tw-hidden item">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button> | 										<button class="escape-button tw-hidden item" data-file-content-elem-id="diff-{{$file.NameHash}}">{{ctx.Locale.Tr "repo.escape_control_characters"}}</button> | ||||||
| 									{{end}} | 									{{end}} | ||||||
| 									{{if and (not $file.IsSubmodule) (not $.PageIsWiki)}} | 									{{if and (not $file.IsSubmodule) (not $.PageIsWiki)}} | ||||||
| 										{{if $file.IsDeleted}} | 										{{if $file.IsDeleted}} | ||||||
| @@ -183,7 +182,6 @@ | |||||||
| 									{{end}} | 									{{end}} | ||||||
| 								</div> | 								</div> | ||||||
| 							</div> | 							</div> | ||||||
| 							</div> |  | ||||||
| 						</h4> | 						</h4> | ||||||
| 						<div class="diff-file-body ui attached unstackable table segment" {{if and $file.IsViewed $.IsShowingAllCommits}}data-folded="true"{{end}}> | 						<div class="diff-file-body ui attached unstackable table segment" {{if and $file.IsViewed $.IsShowingAllCommits}}data-folded="true"{{end}}> | ||||||
| 							<div id="diff-source-{{$file.NameHash}}" class="file-body file-code unicode-escaped code-diff{{if $.IsSplitStyle}} code-diff-split{{else}} code-diff-unified{{end}}{{if $showFileViewToggle}} tw-hidden{{end}}"> | 							<div id="diff-source-{{$file.NameHash}}" class="file-body file-code unicode-escaped code-diff{{if $.IsSplitStyle}} code-diff-split{{else}} code-diff-unified{{end}}{{if $showFileViewToggle}} tw-hidden{{end}}"> | ||||||
|   | |||||||
| @@ -97,7 +97,7 @@ func TestPullCompare_EnableAllowEditsFromMaintainer(t *testing.T) { | |||||||
| 		user2Session := loginUser(t, "user2") | 		user2Session := loginUser(t, "user2") | ||||||
| 		resp = user2Session.MakeRequest(t, NewRequest(t, "GET", fmt.Sprintf("%s/files", prURL)), http.StatusOK) | 		resp = user2Session.MakeRequest(t, NewRequest(t, "GET", fmt.Sprintf("%s/files", prURL)), http.StatusOK) | ||||||
| 		htmlDoc := NewHTMLParser(t, resp.Body) | 		htmlDoc := NewHTMLParser(t, resp.Body) | ||||||
| 		nodes := htmlDoc.doc.Find(".diff-file-box[data-new-filename=\"README.md\"] .diff-file-header-actions .dropdown .menu a") | 		nodes := htmlDoc.doc.Find(".diff-file-box[data-new-filename=\"README.md\"] .diff-file-header-actions .tippy-target a") | ||||||
| 		if assert.Equal(t, 1, nodes.Length()) { | 		if assert.Equal(t, 1, nodes.Length()) { | ||||||
| 			// there is only "View File" button, no "Edit File" button | 			// there is only "View File" button, no "Edit File" button | ||||||
| 			assert.Equal(t, "View File", nodes.First().Text()) | 			assert.Equal(t, "View File", nodes.First().Text()) | ||||||
| @@ -121,7 +121,7 @@ func TestPullCompare_EnableAllowEditsFromMaintainer(t *testing.T) { | |||||||
| 		// user2 (admin of repo3) goes to the PR files page again | 		// user2 (admin of repo3) goes to the PR files page again | ||||||
| 		resp = user2Session.MakeRequest(t, NewRequest(t, "GET", fmt.Sprintf("%s/files", prURL)), http.StatusOK) | 		resp = user2Session.MakeRequest(t, NewRequest(t, "GET", fmt.Sprintf("%s/files", prURL)), http.StatusOK) | ||||||
| 		htmlDoc = NewHTMLParser(t, resp.Body) | 		htmlDoc = NewHTMLParser(t, resp.Body) | ||||||
| 		nodes = htmlDoc.doc.Find(".diff-file-box[data-new-filename=\"README.md\"] .diff-file-header-actions .dropdown .menu a") | 		nodes = htmlDoc.doc.Find(".diff-file-box[data-new-filename=\"README.md\"] .diff-file-header-actions .tippy-target a") | ||||||
| 		if assert.Equal(t, 2, nodes.Length()) { | 		if assert.Equal(t, 2, nodes.Length()) { | ||||||
| 			// there are "View File" button and "Edit File" button | 			// there are "View File" button and "Edit File" button | ||||||
| 			assert.Equal(t, "View File", nodes.First().Text()) | 			assert.Equal(t, "View File", nodes.First().Text()) | ||||||
|   | |||||||
| @@ -77,8 +77,10 @@ | |||||||
|   align-items: center; |   align-items: center; | ||||||
|   padding: 9px 18px; |   padding: 9px 18px; | ||||||
|   color: inherit; |   color: inherit; | ||||||
|  |   background: inherit; | ||||||
|   text-decoration: none; |   text-decoration: none; | ||||||
|   gap: 10px; |   gap: 10px; | ||||||
|  |   width: 100%; | ||||||
| } | } | ||||||
|  |  | ||||||
| .tippy-box[data-theme="menu"] .item:hover { | .tippy-box[data-theme="menu"] .item:hover { | ||||||
|   | |||||||
| @@ -18,6 +18,7 @@ import { | |||||||
| } from '../utils/dom.ts'; | } from '../utils/dom.ts'; | ||||||
| import {POST, GET} from '../modules/fetch.ts'; | import {POST, GET} from '../modules/fetch.ts'; | ||||||
| import {fomanticQuery} from '../modules/fomantic/base.ts'; | import {fomanticQuery} from '../modules/fomantic/base.ts'; | ||||||
|  | import {createTippy} from '../modules/tippy.ts'; | ||||||
|  |  | ||||||
| const {pageData, i18n} = window.config; | const {pageData, i18n} = window.config; | ||||||
|  |  | ||||||
| @@ -140,12 +141,22 @@ export function initRepoDiffConversationNav() { | |||||||
|   }); |   }); | ||||||
| } | } | ||||||
|  |  | ||||||
|  | function initDiffHeaderPopup() { | ||||||
|  |   for (const btn of document.querySelectorAll('.diff-header-popup-btn:not([data-header-popup-initialized])')) { | ||||||
|  |     btn.setAttribute('data-header-popup-initialized', ''); | ||||||
|  |     const popup = btn.nextElementSibling; | ||||||
|  |     if (!popup?.matches('.tippy-target')) throw new Error('Popup element not found'); | ||||||
|  |     createTippy(btn, {content: popup, theme: 'menu', placement: 'bottom', trigger: 'click', interactive: true, hideOnClick: true}); | ||||||
|  |   } | ||||||
|  | } | ||||||
|  |  | ||||||
| // Will be called when the show more (files) button has been pressed | // Will be called when the show more (files) button has been pressed | ||||||
| function onShowMoreFiles() { | function onShowMoreFiles() { | ||||||
|   initRepoIssueContentHistory(); |   initRepoIssueContentHistory(); | ||||||
|   initViewedCheckboxListenerFor(); |   initViewedCheckboxListenerFor(); | ||||||
|   countAndUpdateViewedFiles(); |   countAndUpdateViewedFiles(); | ||||||
|   initImageDiff(); |   initImageDiff(); | ||||||
|  |   initDiffHeaderPopup(); | ||||||
| } | } | ||||||
|  |  | ||||||
| export async function loadMoreFiles(url) { | export async function loadMoreFiles(url) { | ||||||
| @@ -221,6 +232,7 @@ export function initRepoDiffView() { | |||||||
|   initDiffFileList(); |   initDiffFileList(); | ||||||
|   initDiffCommitSelect(); |   initDiffCommitSelect(); | ||||||
|   initRepoDiffShowMore(); |   initRepoDiffShowMore(); | ||||||
|  |   initDiffHeaderPopup(); | ||||||
|   initRepoDiffFileViewToggle(); |   initRepoDiffFileViewToggle(); | ||||||
|   initViewedCheckboxListenerFor(); |   initViewedCheckboxListenerFor(); | ||||||
|   initExpandAndCollapseFilesButton(); |   initExpandAndCollapseFilesButton(); | ||||||
|   | |||||||
| @@ -1,13 +1,13 @@ | |||||||
| import {hideElem, queryElemSiblings, showElem, toggleElem} from '../utils/dom.ts'; | import {addDelegatedEventListener, hideElem, queryElemSiblings, showElem, toggleElem} from '../utils/dom.ts'; | ||||||
|  |  | ||||||
| export function initUnicodeEscapeButton() { | export function initUnicodeEscapeButton() { | ||||||
|   document.addEventListener('click', (e) => { |   addDelegatedEventListener(document, 'click', '.escape-button, .unescape-button, .toggle-escape-button', (btn, e) => { | ||||||
|     const btn = e.target.closest('.escape-button, .unescape-button, .toggle-escape-button'); |  | ||||||
|     if (!btn) return; |  | ||||||
|  |  | ||||||
|     e.preventDefault(); |     e.preventDefault(); | ||||||
|  |  | ||||||
|     const fileContent = btn.closest('.file-content, .non-diff-file-content'); |     const fileContentElemId = btn.getAttribute('data-file-content-elem-id'); | ||||||
|  |     const fileContent = fileContentElemId ? | ||||||
|  |       document.querySelector(`#${fileContentElemId}`) : | ||||||
|  |       btn.closest('.file-content, .non-diff-file-content'); | ||||||
|     const fileView = fileContent?.querySelectorAll('.file-code, .file-view'); |     const fileView = fileContent?.querySelectorAll('.file-code, .file-view'); | ||||||
|     if (btn.matches('.escape-button')) { |     if (btn.matches('.escape-button')) { | ||||||
|       for (const el of fileView) el.classList.add('unicode-escaped'); |       for (const el of fileView) el.classList.add('unicode-escaped'); | ||||||
|   | |||||||
| @@ -2,10 +2,10 @@ import {debounce} from 'throttle-debounce'; | |||||||
| import type {Promisable} from 'type-fest'; | import type {Promisable} from 'type-fest'; | ||||||
| import type $ from 'jquery'; | import type $ from 'jquery'; | ||||||
|  |  | ||||||
| type ElementArg = Element | string | NodeListOf<Element> | Array<Element> | ReturnType<typeof $>; | type ArrayLikeIterable<T> = ArrayLike<T> & Iterable<T>; // for NodeListOf and Array | ||||||
|  | type ElementArg = Element | string | ArrayLikeIterable<Element> | ReturnType<typeof $>; | ||||||
| type ElementsCallback<T extends Element> = (el: T) => Promisable<any>; | type ElementsCallback<T extends Element> = (el: T) => Promisable<any>; | ||||||
| type ElementsCallbackWithArgs = (el: Element, ...args: any[]) => Promisable<any>; | type ElementsCallbackWithArgs = (el: Element, ...args: any[]) => Promisable<any>; | ||||||
| type ArrayLikeIterable<T> = ArrayLike<T> & Iterable<T>; // for NodeListOf and Array |  | ||||||
|  |  | ||||||
| function elementsCall(el: ElementArg, func: ElementsCallbackWithArgs, ...args: any[]) { | function elementsCall(el: ElementArg, func: ElementsCallbackWithArgs, ...args: any[]) { | ||||||
|   if (typeof el === 'string' || el instanceof String) { |   if (typeof el === 'string' || el instanceof String) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user