Skip to content

Commit 5285a3e

Browse files
Add possibility to make branch in branch page (#15960)
* Add possibility to make branch in branch page (#15911) Add possibility to make branch in branch page in the area next to Download and Delete buttons. It is a more intuitive place in the interface compared to what is already there. Signed-off-by: Viktor Yakovchuk <[email protected]> * Update templates/repo/branch/list.tmpl Co-authored-by: zeripath <[email protected]>
1 parent 3aaf648 commit 5285a3e

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

options/locale/locale_en-US.ini

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1977,6 +1977,10 @@ branch.restore = Restore Branch '%s'
19771977
branch.download = Download Branch '%s'
19781978
branch.included_desc = This branch is part of the default branch
19791979
branch.included = Included
1980+
branch.create_new_branch = Create branch from branch:
1981+
branch.confirm_create_branch = Create branch
1982+
branch.new_branch = Create new branch
1983+
branch.new_branch_from = Create new branch from '%s'
19801984

19811985
tag.create_tag = Create tag <strong>%s</strong>
19821986
tag.create_success = Tag '%s' has been created.

templates/repo/branch/list.tmpl

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
{{end}}
2525
</td>
2626
<td class="right aligned overflow-visible">
27+
{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
28+
<div class="ui basic jump button icon poping up show-create-branch-modal" data-content="{{$.i18n.Tr "repo.branch.new_branch_from" ($.DefaultBranch)}}" data-variation="tiny inverted" data-branch-from="{{EscapePound $.DefaultBranch}}" data-modal="#create-branch-modal" data-position="top right">
29+
{{svg "octicon-git-branch"}}
30+
</div>
31+
{{end}}
2732
<div class="ui basic jump dropdown icon button poping up" data-content="{{$.i18n.Tr "repo.branch.download" ($.DefaultBranch)}}" data-variation="tiny inverted" data-position="top right">
2833
{{svg "octicon-download"}}
2934
<div class="menu">
@@ -102,6 +107,11 @@
102107
{{end}}
103108
</td>
104109
<td class="two wide right aligned overflow-visible">
110+
{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
111+
<div class="ui basic jump button icon poping up show-create-branch-modal" data-branch-from="{{EscapePound .Name}}" data-content="{{$.i18n.Tr "repo.branch.new_branch_from" .Name}}" data-variation="tiny inverted" data-position="top right" data-modal="#create-branch-modal" data-name="{{.Name}}">
112+
{{svg "octicon-git-branch"}}
113+
</div>
114+
{{end}}
105115
{{if (not .IsDeleted)}}
106116
<div class="ui basic jump dropdown icon button poping up" data-content="{{$.i18n.Tr "repo.branch.download" (.Name)}}" data-variation="tiny inverted" data-position="top right">
107117
{{svg "octicon-download"}}
@@ -142,4 +152,30 @@
142152
</div>
143153
{{template "base/delete_modal_actions" .}}
144154
</div>
155+
156+
<div class="ui small modal" id="create-branch-modal">
157+
<div class="header">
158+
{{.i18n.Tr "repo.branch.new_branch"}}
159+
</div>
160+
<div class="content">
161+
<form class="ui form" id="create-branch-form" action="" data-base-action="{{.Link}}/_new/branch/" method="post">
162+
{{.CsrfTokenHtml}}
163+
<div class="field">
164+
<label>
165+
{{.i18n.Tr "repo.branch.create_new_branch"}}
166+
<span class="text" id="modal-create-branch-from-span"></span>
167+
</label>
168+
</div>
169+
<div class="required field">
170+
<label for="new_branch_name">{{.i18n.Tr "repo.branch.name"}}</label>
171+
<input id="new_branch_name" name="new_branch_name" required>
172+
</div>
173+
174+
<div class="text right actions">
175+
<div class="ui cancel button">{{.i18n.Tr "settings.cancel"}}</div>
176+
<button class="ui green button">{{.i18n.Tr "repo.branch.confirm_create_branch"}}</button>
177+
</div>
178+
</form>
179+
</div>
180+
</div>
145181
{{template "base/footer" .}}

web_src/js/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,6 +2658,11 @@ $(document).ready(async () => {
26582658
$('.show-panel.button').on('click', function () {
26592659
$($(this).data('panel')).show();
26602660
});
2661+
$('.show-create-branch-modal.button').on('click', function () {
2662+
$('#create-branch-form')[0].action = $('#create-branch-form').data('base-action') + $(this).data('branch-from');
2663+
$('#modal-create-branch-from-span').text($(this).data('branch-from'));
2664+
$($(this).data('modal')).modal('show');
2665+
});
26612666
$('.show-modal.button').on('click', function () {
26622667
$($(this).data('modal')).modal('show');
26632668
});

0 commit comments

Comments
 (0)