From cbf05c3f795c1eed999dafe8d0757495e07f1ee2 Mon Sep 17 00:00:00 2001 From: a1012112796 <1012112796@qq.com> Date: Tue, 31 Aug 2021 22:03:45 +0800 Subject: Add option to update pull request by `rebase` (#16125) * add option to update pull request by `rebase` Signed-off-by: a1012112796 <1012112796@qq.com> --- web_src/js/index.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'web_src') diff --git a/web_src/js/index.js b/web_src/js/index.js index 7e4970c3a0..ba025cfade 100644 --- a/web_src/js/index.js +++ b/web_src/js/index.js @@ -1267,6 +1267,36 @@ async function initRepository() { $('.instruct-toggle').show(); }); + // Pull Request update button + const $pullUpdateButton = $('.update-button > button'); + $pullUpdateButton.on('click', function (e) { + e.preventDefault(); + const $this = $(this); + const redirect = $this.data('redirect'); + $this.addClass('loading'); + $.post($this.data('do'), { + _csrf: csrf + }).done((data) => { + if (data.redirect) { + window.location.href = data.redirect; + } else if (redirect) { + window.location.href = redirect; + } else { + window.location.reload(); + } + }); + }); + + $('.update-button > .dropdown').dropdown({ + onChange(_text, _value, $choice) { + const $url = $choice.data('do'); + if ($url) { + $pullUpdateButton.find('.button-text').text($choice.text()); + $pullUpdateButton.data('do', $url); + } + } + }); + initReactionSelector(); } -- cgit v1.2.3