summaryrefslogtreecommitdiffstats
path: root/web_src
diff options
context:
space:
mode:
authorsillyguodong <33891828+sillyguodong@users.noreply.github.com>2023-05-05 06:54:38 +0800
committerGitHub <noreply@github.com>2023-05-04 22:54:38 +0000
commit0c657112a3ca513f0907e74cbccb72165b3f6286 (patch)
tree5dfc3b9bc7c469700499041de351abeba14bef0c /web_src
parent0ca1958e1ab8198c40ad952dac27ef0b9825385a (diff)
downloadgitea-0c657112a3ca513f0907e74cbccb72165b3f6286.tar.gz
gitea-0c657112a3ca513f0907e74cbccb72165b3f6286.zip
Display warning when user try to rename default branch (#24512)
Follow #24380 It's better to warn users when they try to rename the default branch. ![image](https://user-images.githubusercontent.com/33891828/236107929-c8ac2854-dd0f-4500-a0a7-800c8fe48861.png) --------- Co-authored-by: techknowlogick <matti@mdranta.net> Co-authored-by: Jason Song <i@wolfogre.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Giteabot <teabot@gitea.io>
Diffstat (limited to 'web_src')
-rw-r--r--web_src/js/features/repo-branch.js5
1 files changed, 5 insertions, 0 deletions
diff --git a/web_src/js/features/repo-branch.js b/web_src/js/features/repo-branch.js
index e7c2645dcd..e6da9661b6 100644
--- a/web_src/js/features/repo-branch.js
+++ b/web_src/js/features/repo-branch.js
@@ -1,4 +1,5 @@
import $ from 'jquery';
+import {toggleElem} from '../utils/dom.js';
export function initRepoBranchButton() {
initRepoCreateBranchButton();
@@ -31,6 +32,10 @@ function initRepoRenameBranchButton() {
const oldBranchName = $(this).attr('data-old-branch-name');
$modal.find('input[name=from]').val(oldBranchName);
+ // display the warning that the branch which is chosen is the default branch
+ const $warn = $modal.find('.default-branch-warning');
+ toggleElem($warn, $(this).attr('data-is-default-branch') === 'true');
+
const $text = $modal.find('[data-rename-branch-to]');
$text.text($text.attr('data-rename-branch-to').replace('%s', oldBranchName));
});