File tree Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Expand file tree Collapse file tree 3 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -2412,6 +2412,7 @@ branch.included_desc = This branch is part of the default branch
24122412branch.included = Included
24132413branch.create_new_branch = Create branch from branch:
24142414branch.confirm_create_branch = Create branch
2415+ branch.warning_rename_default_branch = You are renaming the default branch.
24152416branch.rename_branch_to = Rename " %s" to:
24162417branch.confirm_rename_branch = Rename branch
24172418branch.create_branch_operation = Create branch
Original file line number Diff line number Diff line change 5252 {{end}}
5353 {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted) (not $.IsMirror)}}
5454 <button class="ui tertiary button show-modal show-rename-branch-modal gt-mx-3"
55+ data-is-default-branch="true"
5556 data-modal="#rename-branch-modal"
5657 data-old-branch-name="{{$.DefaultBranch}}"
5758 data-tooltip-content="{{$.locale.Tr "repo.branch.rename" ($.DefaultBranch)}}"
158159 {{end}}
159160 {{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted) (not $.IsMirror)}}
160161 <button class="ui tertiary button show-modal show-rename-branch-modal gt-mx-3"
162+ data-is-default-branch="false"
161163 data-old-branch-name="{{.Name}}"
162164 data-modal="#rename-branch-modal"
163165 data-tooltip-content="{{$.locale.Tr "repo.branch.rename" (.Name)}}"
229231 <form class="ui form" action="{{$.Repository.Link}}/settings/rename_branch" method="post">
230232 <div class="content">
231233 {{.CsrfTokenHtml}}
234+ <div class="field default-branch-warning">
235+ <span class="text red">{{.locale.Tr "repo.branch.warning_raname_default_branch"}}</span>
236+ </div>
232237 <div class="field">
233238 <span class="text" data-rename-branch-to="{{.locale.Tr "repo.branch.rename_branch_to"}}"></span>
234239 </div>
Original file line number Diff line number Diff line change 11import $ from 'jquery' ;
2+ import { toggleElem } from '../utils/dom.js' ;
23
34export function initRepoBranchButton ( ) {
45 initRepoCreateBranchButton ( ) ;
@@ -31,6 +32,10 @@ function initRepoRenameBranchButton() {
3132 const oldBranchName = $ ( this ) . attr ( 'data-old-branch-name' ) ;
3233 $modal . find ( 'input[name=from]' ) . val ( oldBranchName ) ;
3334
35+ // display the warning that the branch which is chosen is the default branch
36+ const $warn = $modal . find ( '.default-branch-warning' ) ;
37+ toggleElem ( $warn , $ ( this ) . attr ( 'data-is-default-branch' ) === 'true' ) ;
38+
3439 const $text = $modal . find ( '[data-rename-branch-to]' ) ;
3540 $text . text ( $text . attr ( 'data-rename-branch-to' ) . replace ( '%s' , oldBranchName ) ) ;
3641 } ) ;
You can’t perform that action at this time.
0 commit comments