Skip to content

Commit

Permalink
Allow commit status popup on /pulls page (go-gitea#19507)
Browse files Browse the repository at this point in the history
* 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 go-gitea#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
  • Loading branch information
parnic authored and AbdulrhmnGhanem committed Aug 23, 2022
1 parent dad94eb commit 4b87f67
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
13 changes: 13 additions & 0 deletions web_src/js/features/repo-commit.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,16 @@ export function initRepoCommitLastCommitLoader() {
});
});
}

export function initCommitStatuses() {
$('.commit-statuses-trigger').each(function () {
const positionRight = $('.repository.file.list').length > 0 || $('.repository.diff').length > 0;
const popupPosition = positionRight ? 'right center' : 'left center';
$(this)
.popup({
on: 'click',
lastResort: popupPosition, // prevent error message "Popup does not fit within the boundaries of the viewport"
position: popupPosition,
});
});
}
12 changes: 0 additions & 12 deletions web_src/js/features/repo-legacy.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,18 +423,6 @@ export function initRepository() {
}


// Commit statuses
$('.commit-statuses-trigger').each(function () {
const positionRight = $('.repository.file.list').length > 0 || $('.repository.diff').length > 0;
const popupPosition = positionRight ? 'right center' : 'left center';
$(this)
.popup({
on: 'click',
lastResort: popupPosition, // prevent error message "Popup does not fit within the boundaries of the viewport"
position: popupPosition,
});
});

// File list and commits
if ($('.repository.file.list').length > 0 || $('.branch-dropdown').length > 0 ||
$('.repository.commits').length > 0 || $('.repository.release').length > 0) {
Expand Down
8 changes: 7 additions & 1 deletion web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@ import {
initRepoPullRequestMergeInstruction,
initRepoPullRequestReview,
} from './features/repo-issue.js';
import {initRepoEllipsisButton, initRepoCommitLastCommitLoader} from './features/repo-commit.js';
import {
initRepoEllipsisButton,
initRepoCommitLastCommitLoader,
initCommitStatuses,
} from './features/repo-commit.js';
import {
checkAppUrl,
initFootLanguageMenu,
Expand Down Expand Up @@ -165,6 +169,8 @@ $(document).ready(() => {
initRepoWikiForm();
initRepository();

initCommitStatuses();

initUserAuthLinkAccountView();
initUserAuthOauth2();
initUserAuthWebAuthn();
Expand Down

0 comments on commit 4b87f67

Please sign in to comment.