Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add possibility to make branch in branch page #15960

Merged
merged 3 commits into from
May 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,10 @@ branch.restore = Restore Branch '%s'
branch.download = Download Branch '%s'
branch.included_desc = This branch is part of the default branch
branch.included = Included
branch.create_new_branch = Create branch from branch:
branch.confirm_create_branch = Create branch
branch.new_branch = Create new branch
branch.new_branch_from = Create new branch from '%s'

tag.create_tag = Create tag <strong>%s</strong>
tag.create_success = Tag '%s' has been created.
Expand Down
36 changes: 36 additions & 0 deletions templates/repo/branch/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@
{{end}}
</td>
<td class="right aligned overflow-visible">
{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
<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">
{{svg "octicon-git-branch"}}
</div>
{{end}}
<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">
{{svg "octicon-download"}}
<div class="menu">
Expand Down Expand Up @@ -102,6 +107,11 @@
{{end}}
</td>
<td class="two wide right aligned overflow-visible">
{{if and $.IsWriter (not $.Repository.IsArchived) (not .IsDeleted)}}
<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}}">
{{svg "octicon-git-branch"}}
</div>
{{end}}
{{if (not .IsDeleted)}}
<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">
{{svg "octicon-download"}}
Expand Down Expand Up @@ -142,4 +152,30 @@
</div>
{{template "base/delete_modal_actions" .}}
</div>

<div class="ui small modal" id="create-branch-modal">
<div class="header">
{{.i18n.Tr "repo.branch.new_branch"}}
</div>
<div class="content">
<form class="ui form" id="create-branch-form" action="" data-base-action="{{.Link}}/_new/branch/" method="post">
{{.CsrfTokenHtml}}
<div class="field">
<label>
{{.i18n.Tr "repo.branch.create_new_branch"}}
<span class="text" id="modal-create-branch-from-span"></span>
</label>
</div>
<div class="required field">
<label for="new_branch_name">{{.i18n.Tr "repo.branch.name"}}</label>
<input id="new_branch_name" name="new_branch_name" required>
</div>

<div class="text right actions">
<div class="ui cancel button">{{.i18n.Tr "settings.cancel"}}</div>
<button class="ui green button">{{.i18n.Tr "repo.branch.confirm_create_branch"}}</button>
</div>
</form>
</div>
</div>
{{template "base/footer" .}}
5 changes: 5 additions & 0 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2658,6 +2658,11 @@ $(document).ready(async () => {
$('.show-panel.button').on('click', function () {
$($(this).data('panel')).show();
});
$('.show-create-branch-modal.button').on('click', function () {
$('#create-branch-form')[0].action = $('#create-branch-form').data('base-action') + $(this).data('branch-from');
$('#modal-create-branch-from-span').text($(this).data('branch-from'));
$($(this).data('modal')).modal('show');
});
$('.show-modal.button').on('click', function () {
$($(this).data('modal')).modal('show');
});
Expand Down