mirror of https://github.com/go-gitea/gitea
Many fixes to the branch selector
This commit is contained in:
parent
c159998087
commit
d2588fd3b1
|
@ -6,39 +6,52 @@
|
|||
<div class="content">
|
||||
<form id="runWorkflowDispatchForm" class="ui form" action="{{$.Link}}/run?workflow={{$.CurWorkflow}}&actor={{$.CurActor}}&status={{.Status}}" method="post">
|
||||
{{.CsrfTokenHtml}}
|
||||
<div class="ui inline field required">
|
||||
<div class="ui field required">
|
||||
<label>{{ctx.Locale.Tr "actions.workflow.from_ref"}}:</label>
|
||||
<div class="ui floating dropdown icon button mini">
|
||||
<div class="ui filter dropdown button select-branch">
|
||||
<input type="hidden" name="ref" value="refs/heads/{{index .Branches 0}}">
|
||||
{{svg "octicon-git-branch"}}
|
||||
<span class="text tw-text-13">{{index .Branches 0}}</span>
|
||||
<span class="text branch-name gt-ellipsis">{{index .Branches 0}}</span>
|
||||
<div class="menu">
|
||||
<div class="ui icon search input">
|
||||
<div class="ui icon search input tw-w-auto">
|
||||
<i class="search icon">{{svg "octicon-search" 16 "search icon"}}</i>
|
||||
<input type="text" placeholder="{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}">
|
||||
</div>
|
||||
<div class="scrolling menu">
|
||||
<div class="header">
|
||||
{{svg "octicon-git-branch"}}
|
||||
{{ctx.Locale.Tr "repo.branches"}}
|
||||
<div class="header">
|
||||
<div class="ui grid">
|
||||
<div class="two column row">
|
||||
<a class="reference column muted" href="#" data-target="#branch-list">
|
||||
<span class="text black">
|
||||
{{svg "octicon-git-branch" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.branches"}}
|
||||
</span>
|
||||
</a>
|
||||
<a class="reference column muted" href="#" data-target="#tag-list">
|
||||
<span class="text">
|
||||
{{svg "octicon-tag" 16 "tw-mr-1"}}{{ctx.Locale.Tr "repo.tags"}}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
{{range $key, $item := .Branches}}
|
||||
<div class="item {{if eq $key 0}}active selected{{end}}" data-value="refs/heads/{{.}}">{{.}}</div>
|
||||
</div>
|
||||
<div class="branch-tag-divider"></div>
|
||||
<div id="branch-list" class="scrolling menu reference-list-menu">
|
||||
{{range .Branches}}
|
||||
<div class="item" data-value="refs/heads/{{.}}" title="{{.}}">{{.}}</div>
|
||||
{{else}}
|
||||
<div class="item">{{ctx.Locale.Tr "no_results_found"}}</div>
|
||||
{{end}}
|
||||
<div class="divider"></div>
|
||||
<div class="header">
|
||||
{{svg "octicon-tag"}}
|
||||
{{ctx.Locale.Tr "repo.tags"}}
|
||||
</div>
|
||||
{{range $key, $item := .Tags}}
|
||||
<div class="item" data-value="refs/tags/{{.}}">{{.}}</div>
|
||||
</div>
|
||||
<div id="tag-list" class="scrolling menu reference-list-menu tw-hidden">
|
||||
{{range .Tags}}
|
||||
<div class="item" data-value="refs/tags/{{.}}" title="{{.}}">{{.}}</div>
|
||||
{{else}}
|
||||
<div class="item">{{ctx.Locale.Tr "no_results_found"}}</div>
|
||||
{{end}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="divider"></div>
|
||||
{{range $key, $item := .WorkflowDispatchConfig.Inputs}}
|
||||
<div class="ui field {{if .Required}}required{{end}}">
|
||||
{{if eq .Type "choice"}}
|
||||
|
|
|
@ -5,15 +5,15 @@
|
|||
{{$.CsrfTokenHtml}}
|
||||
</form>
|
||||
{{/* TODO: share this branch selector dropdown with the same in repo page */}}
|
||||
<div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating filter select-branch dropdown tw-max-w-full" data-no-results="{{ctx.Locale.Tr "no_results_found"}}">
|
||||
<div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating filter select-branch issue-select-branch dropdown tw-max-w-full" data-no-results="{{ctx.Locale.Tr "no_results_found"}}">
|
||||
<div class="ui basic small button">
|
||||
<span class="text branch-name gt-ellipsis">{{if .Reference}}{{$.RefEndName}}{{else}}{{ctx.Locale.Tr "repo.issues.no_ref"}}{{end}}</span>
|
||||
{{if .HasIssuesOrPullsWritePermission}}{{svg "octicon-triangle-down" 14 "dropdown icon"}}{{end}}
|
||||
</div>
|
||||
<div class="menu">
|
||||
<div class="ui icon search input">
|
||||
<i class="icon">{{svg "octicon-filter" 16}}</i>
|
||||
<input name="search" placeholder="{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}...">
|
||||
<i class="search icon">{{svg "octicon-search" 16 "search icon"}}</i>
|
||||
<input type="text" placeholder="{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}">
|
||||
</div>
|
||||
<div class="header">
|
||||
<div class="ui grid">
|
||||
|
|
|
@ -2810,14 +2810,14 @@ tbody.commit-list {
|
|||
}
|
||||
|
||||
/* Branch tag selector - TODO: Merge this into the same selector on repo page */
|
||||
.repository .issue-content .issue-content-right .ui.grid .column.row {
|
||||
.select-branch .ui.grid .column.row {
|
||||
padding: 10px;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
.repository .issue-content .issue-content-right .ui.grid .column.muted {
|
||||
.select-branch .ui.grid .column.muted {
|
||||
padding: 0;
|
||||
}
|
||||
.repository .issue-content .issue-content-right .ui.grid .column.muted .text {
|
||||
.select-branch .ui.grid .column.muted .text {
|
||||
display: inline-block;
|
||||
padding: 10px;
|
||||
width: 100%;
|
||||
|
@ -2825,16 +2825,16 @@ tbody.commit-list {
|
|||
border: 1px solid transparent;
|
||||
border-bottom: none;
|
||||
}
|
||||
.repository .issue-content .issue-content-right .ui.grid .column.muted .text.black {
|
||||
.select-branch .ui.grid .column.muted .text.black {
|
||||
border-color: var(--color-secondary);
|
||||
background: var(--color-menu);
|
||||
border-top-left-radius: var(--border-radius);
|
||||
border-top-right-radius: var(--border-radius);
|
||||
}
|
||||
.repository .issue-content .issue-content-right .ui.dropdown .scrolling.menu {
|
||||
border-top: none;
|
||||
.select-branch .scrolling.menu {
|
||||
border-top: none !important;
|
||||
}
|
||||
.repository .issue-content .issue-content-right .branch-tag-divider {
|
||||
.select-branch .branch-tag-divider {
|
||||
margin-top: -1px;
|
||||
border-top: 1px solid var(--color-secondary);
|
||||
}
|
||||
|
|
|
@ -43,6 +43,50 @@ function reloadConfirmDraftComment() {
|
|||
window.location.reload();
|
||||
}
|
||||
|
||||
// code specific to the issue branch selector
|
||||
export function initBranchSelectorIssue() {
|
||||
const $selectBranch = $('.ui.issue-select-branch');
|
||||
if (!$selectBranch.length) return;
|
||||
const $branchMenu = $selectBranch.find('.reference-list-menu');
|
||||
const $isNewIssue = $branchMenu.hasClass('new-issue');
|
||||
$branchMenu.find('.item:not(.no-select)').on('click', async function () {
|
||||
const selectedValue = $(this).data('id');
|
||||
const editMode = $('#editing_mode').val();
|
||||
$($(this).data('id-selector')).val(selectedValue);
|
||||
if ($isNewIssue) {
|
||||
$selectBranch.find('.ui .branch-name').text($(this).data('name'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (editMode === 'true') {
|
||||
const form = document.getElementById('update_issueref_form');
|
||||
const params = new URLSearchParams();
|
||||
params.append('ref', selectedValue);
|
||||
try {
|
||||
await POST(form.getAttribute('action'), {data: params});
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else if (editMode === '') {
|
||||
$selectBranch.find('.ui .branch-name').text(selectedValue);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// code for all branch selectors
|
||||
export function initBranchSelectorTabs() {
|
||||
const $selectBranch = $('.ui.select-branch');
|
||||
if (!$selectBranch.length) return;
|
||||
$selectBranch.find('.reference.column').on('click', function () {
|
||||
hideElem($selectBranch.find('.scrolling.reference-list-menu'));
|
||||
$selectBranch.find('.reference .text').removeClass('black');
|
||||
showElem($($(this).data('target')));
|
||||
$(this).find('.text').addClass('black');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
export function initRepoCommentForm() {
|
||||
const $commentForm = $('.comment.form');
|
||||
if (!$commentForm.length) return;
|
||||
|
@ -55,44 +99,6 @@ export function initRepoCommentForm() {
|
|||
initSingleCommentEditor($commentForm);
|
||||
}
|
||||
|
||||
function initBranchSelector() {
|
||||
const $selectBranch = $('.ui.select-branch');
|
||||
const $branchMenu = $selectBranch.find('.reference-list-menu');
|
||||
const $isNewIssue = $branchMenu.hasClass('new-issue');
|
||||
$branchMenu.find('.item:not(.no-select)').on('click', async function () {
|
||||
const selectedValue = $(this).data('id');
|
||||
const editMode = $('#editing_mode').val();
|
||||
$($(this).data('id-selector')).val(selectedValue);
|
||||
if ($isNewIssue) {
|
||||
$selectBranch.find('.ui .branch-name').text($(this).data('name'));
|
||||
return;
|
||||
}
|
||||
|
||||
if (editMode === 'true') {
|
||||
const form = document.getElementById('update_issueref_form');
|
||||
const params = new URLSearchParams();
|
||||
params.append('ref', selectedValue);
|
||||
try {
|
||||
await POST(form.getAttribute('action'), {data: params});
|
||||
window.location.reload();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
}
|
||||
} else if (editMode === '') {
|
||||
$selectBranch.find('.ui .branch-name').text(selectedValue);
|
||||
}
|
||||
});
|
||||
$selectBranch.find('.reference.column').on('click', function () {
|
||||
hideElem($selectBranch.find('.scrolling.reference-list-menu'));
|
||||
$selectBranch.find('.reference .text').removeClass('black');
|
||||
showElem($($(this).data('target')));
|
||||
$(this).find('.text').addClass('black');
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
initBranchSelector();
|
||||
|
||||
// List submits
|
||||
function initListSubmits(selector, outerSelector) {
|
||||
const $list = $(`.ui.${outerSelector}.list`);
|
||||
|
|
|
@ -71,7 +71,12 @@ import {initCompWebHookEditor} from './features/comp/WebHookEditor.js';
|
|||
import {initRepoBranchButton} from './features/repo-branch.js';
|
||||
import {initCommonOrganization} from './features/common-organization.js';
|
||||
import {initRepoWikiForm} from './features/repo-wiki.js';
|
||||
import {initRepoCommentForm, initRepository} from './features/repo-legacy.js';
|
||||
import {
|
||||
initRepoCommentForm,
|
||||
initRepository,
|
||||
initBranchSelectorIssue,
|
||||
initBranchSelectorTabs,
|
||||
} from './features/repo-legacy.js';
|
||||
import {initCopyContent} from './features/copycontent.js';
|
||||
import {initCaptcha} from './features/captcha.js';
|
||||
import {initRepositoryActionView} from './components/RepoActionView.vue';
|
||||
|
@ -146,6 +151,8 @@ onDomReady(() => {
|
|||
initRepoBranchButton();
|
||||
initRepoCodeView();
|
||||
initRepoCommentForm();
|
||||
initBranchSelectorIssue();
|
||||
initBranchSelectorTabs();
|
||||
initRepoEllipsisButton();
|
||||
initRepoDiffCommitBranchesAndTags();
|
||||
initRepoEditor();
|
||||
|
|
Loading…
Reference in New Issue