Merge branch 'main' into fix-review-form

This commit is contained in:
Gusted
2022-04-29 01:05:55 +02:00
31 changed files with 370 additions and 64 deletions

View File

@@ -288,6 +288,39 @@ export function initRepoPullRequestMergeInstruction() {
});
}
export function initRepoPullRequestAllowMaintainerEdit() {
const $checkbox = $('#allow-edits-from-maintainers');
if (!$checkbox.length) return;
const promptTip = $checkbox.attr('data-prompt-tip');
const promptError = $checkbox.attr('data-prompt-error');
$checkbox.popup({content: promptTip});
$checkbox.checkbox({
'onChange': () => {
const checked = $checkbox.checkbox('is checked');
let url = $checkbox.attr('data-url');
url += '/set_allow_maintainer_edit';
$checkbox.checkbox('set disabled');
$.ajax({url, type: 'POST',
data: {_csrf: csrfToken, allow_maintainer_edit: checked},
error: () => {
$checkbox.popup({
content: promptError,
onHidden: () => {
// the error popup should be shown only once, then we restore the popup to the default message
$checkbox.popup({content: promptTip});
},
});
$checkbox.popup('show');
},
complete: () => {
$checkbox.checkbox('set enabled');
},
});
},
});
}
export function initRepoIssueReferenceRepositorySearch() {
$('.issue_reference_repository_search')
.dropdown({

View File

@@ -36,6 +36,7 @@ import {
initRepoIssueTimeTracking,
initRepoIssueWipTitle,
initRepoPullRequestMergeInstruction,
initRepoPullRequestAllowMaintainerEdit,
initRepoPullRequestReview,
} from './features/repo-issue.js';
import {
@@ -158,6 +159,7 @@ $(document).ready(() => {
initRepoMigrationStatusChecker();
initRepoProject();
initRepoPullRequestMergeInstruction();
initRepoPullRequestAllowMaintainerEdit();
initRepoPullRequestReview();
initRepoRelease();
initRepoReleaseEditor();