Skip to content

Commit 2347c9e

Browse files
authored
Allow commit status popup on /pulls page (#19507)
* Allow commit status popup on /pulls page The /pulls page doesn't contain a "repository" element, so the early-out here was preventing the commit status popup hook from working. However, the only thing the .repository element is being used for here is determining whether the popup should be on the right or on the left, so we don't actually need the element to exist for the hook to work. Pull request #19375 allows the statuses on /pulls pages to appear clickable, but this commit is required to make the popup actually work there. * Move commit statuses popup hook to dedicated func * Add missing import
1 parent 3c140f0 commit 2347c9e

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed

web_src/js/features/repo-commit.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,16 @@ export function initRepoCommitLastCommitLoader() {
4949
});
5050
});
5151
}
52+
53+
export function initCommitStatuses() {
54+
$('.commit-statuses-trigger').each(function () {
55+
const positionRight = $('.repository.file.list').length > 0 || $('.repository.diff').length > 0;
56+
const popupPosition = positionRight ? 'right center' : 'left center';
57+
$(this)
58+
.popup({
59+
on: 'click',
60+
lastResort: popupPosition, // prevent error message "Popup does not fit within the boundaries of the viewport"
61+
position: popupPosition,
62+
});
63+
});
64+
}

web_src/js/features/repo-legacy.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -423,18 +423,6 @@ export function initRepository() {
423423
}
424424

425425

426-
// Commit statuses
427-
$('.commit-statuses-trigger').each(function () {
428-
const positionRight = $('.repository.file.list').length > 0 || $('.repository.diff').length > 0;
429-
const popupPosition = positionRight ? 'right center' : 'left center';
430-
$(this)
431-
.popup({
432-
on: 'click',
433-
lastResort: popupPosition, // prevent error message "Popup does not fit within the boundaries of the viewport"
434-
position: popupPosition,
435-
});
436-
});
437-
438426
// File list and commits
439427
if ($('.repository.file.list').length > 0 || $('.branch-dropdown').length > 0 ||
440428
$('.repository.commits').length > 0 || $('.repository.release').length > 0) {

web_src/js/index.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,11 @@ import {
3838
initRepoPullRequestMergeInstruction,
3939
initRepoPullRequestReview,
4040
} from './features/repo-issue.js';
41-
import {initRepoEllipsisButton, initRepoCommitLastCommitLoader} from './features/repo-commit.js';
41+
import {
42+
initRepoEllipsisButton,
43+
initRepoCommitLastCommitLoader,
44+
initCommitStatuses,
45+
} from './features/repo-commit.js';
4246
import {
4347
checkAppUrl,
4448
initFootLanguageMenu,
@@ -165,6 +169,8 @@ $(document).ready(() => {
165169
initRepoWikiForm();
166170
initRepository();
167171

172+
initCommitStatuses();
173+
168174
initUserAuthLinkAccountView();
169175
initUserAuthOauth2();
170176
initUserAuthWebAuthn();

0 commit comments

Comments
 (0)