Add possibility to record branch or tag information in an issue (#780)
This commit is contained in:
parent
174255e74e
commit
da230a2872
9 changed files with 78 additions and 0 deletions
|
@ -49,6 +49,7 @@ type Issue struct {
|
||||||
IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not.
|
IsPull bool `xorm:"INDEX"` // Indicates whether is a pull request or not.
|
||||||
PullRequest *PullRequest `xorm:"-"`
|
PullRequest *PullRequest `xorm:"-"`
|
||||||
NumComments int
|
NumComments int
|
||||||
|
Ref string
|
||||||
|
|
||||||
Deadline time.Time `xorm:"-"`
|
Deadline time.Time `xorm:"-"`
|
||||||
DeadlineUnix int64 `xorm:"INDEX"`
|
DeadlineUnix int64 `xorm:"INDEX"`
|
||||||
|
|
|
@ -194,6 +194,7 @@ func (f *NewSlackHookForm) Validate(ctx *macaron.Context, errs binding.Errors) b
|
||||||
type CreateIssueForm struct {
|
type CreateIssueForm struct {
|
||||||
Title string `binding:"Required;MaxSize(255)"`
|
Title string `binding:"Required;MaxSize(255)"`
|
||||||
LabelIDs string `form:"label_ids"`
|
LabelIDs string `form:"label_ids"`
|
||||||
|
Ref string `form:"ref"`
|
||||||
MilestoneID int64
|
MilestoneID int64
|
||||||
AssigneeID int64
|
AssigneeID int64
|
||||||
Content string
|
Content string
|
||||||
|
|
|
@ -612,6 +612,7 @@ issues.new.closed_milestone = Closed Milestones
|
||||||
issues.new.assignee = Assignee
|
issues.new.assignee = Assignee
|
||||||
issues.new.clear_assignee = Clear assignee
|
issues.new.clear_assignee = Clear assignee
|
||||||
issues.new.no_assignee = No assignee
|
issues.new.no_assignee = No assignee
|
||||||
|
issues.no_ref = No Branch/Tag Specified
|
||||||
issues.create = Create Issue
|
issues.create = Create Issue
|
||||||
issues.new_label = New Label
|
issues.new_label = New Label
|
||||||
issues.new_label_placeholder = Label name...
|
issues.new_label_placeholder = Label name...
|
||||||
|
|
|
@ -86,6 +86,22 @@ function initEditForm() {
|
||||||
initEditDiffTab($('.edit.form'));
|
initEditDiffTab($('.edit.form'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function initBranchSelector() {
|
||||||
|
var $selectBranch = $('.ui.select-branch')
|
||||||
|
var $branchMenu = $selectBranch.find('.reference-list-menu');
|
||||||
|
$branchMenu.find('.item:not(.no-select)').click(function () {
|
||||||
|
var selectedValue = $(this).data('id');
|
||||||
|
$($(this).data('id-selector')).val(selectedValue);
|
||||||
|
$selectBranch.find('.ui .branch-name').text(selectedValue);
|
||||||
|
});
|
||||||
|
$selectBranch.find('.reference.column').click(function () {
|
||||||
|
$selectBranch.find('.scrolling.reference-list-menu').css('display', 'none');
|
||||||
|
$selectBranch.find('.reference .text').removeClass('black');
|
||||||
|
$($(this).data('target')).css('display', 'block');
|
||||||
|
$(this).find('.text').addClass('black');
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function updateIssuesMeta(url, action, issueIds, elementId, afterSuccess) {
|
function updateIssuesMeta(url, action, issueIds, elementId, afterSuccess) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -106,6 +122,7 @@ function initCommentForm() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
initBranchSelector();
|
||||||
initCommentPreviewTab($('.comment.form'));
|
initCommentPreviewTab($('.comment.form'));
|
||||||
|
|
||||||
// Labels
|
// Labels
|
||||||
|
|
|
@ -292,6 +292,13 @@ func RetrieveRepoMetas(ctx *context.Context, repo *models.Repository) []*models.
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
brs, err := ctx.Repo.GitRepo.GetBranches()
|
||||||
|
if err != nil {
|
||||||
|
ctx.Handle(500, "GetBranches", err)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
ctx.Data["Branches"] = brs
|
||||||
|
|
||||||
return labels
|
return labels
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -418,6 +425,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
|
||||||
ctx.Data["PageIsIssueList"] = true
|
ctx.Data["PageIsIssueList"] = true
|
||||||
ctx.Data["RequireHighlightJS"] = true
|
ctx.Data["RequireHighlightJS"] = true
|
||||||
ctx.Data["RequireSimpleMDE"] = true
|
ctx.Data["RequireSimpleMDE"] = true
|
||||||
|
ctx.Data["ReadOnly"] = false
|
||||||
renderAttachmentSettings(ctx)
|
renderAttachmentSettings(ctx)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -447,6 +455,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
|
||||||
MilestoneID: milestoneID,
|
MilestoneID: milestoneID,
|
||||||
AssigneeID: assigneeID,
|
AssigneeID: assigneeID,
|
||||||
Content: form.Content,
|
Content: form.Content,
|
||||||
|
Ref: form.Ref,
|
||||||
}
|
}
|
||||||
if err := models.NewIssue(repo, issue, labelIDs, attachments); err != nil {
|
if err := models.NewIssue(repo, issue, labelIDs, attachments); err != nil {
|
||||||
ctx.Handle(500, "NewIssue", err)
|
ctx.Handle(500, "NewIssue", err)
|
||||||
|
@ -668,6 +677,7 @@ func ViewIssue(ctx *context.Context) {
|
||||||
ctx.Data["Participants"] = participants
|
ctx.Data["Participants"] = participants
|
||||||
ctx.Data["NumParticipants"] = len(participants)
|
ctx.Data["NumParticipants"] = len(participants)
|
||||||
ctx.Data["Issue"] = issue
|
ctx.Data["Issue"] = issue
|
||||||
|
ctx.Data["ReadOnly"] = true
|
||||||
ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))
|
ctx.Data["IsIssueOwner"] = ctx.Repo.IsWriter() || (ctx.IsSigned && issue.IsPoster(ctx.User.ID))
|
||||||
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + ctx.Data["Link"].(string)
|
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + ctx.Data["Link"].(string)
|
||||||
ctx.HTML(200, tplIssueView)
|
ctx.HTML(200, tplIssueView)
|
||||||
|
|
41
templates/repo/issue/branch_selector_field.tmpl
Normal file
41
templates/repo/issue/branch_selector_field.tmpl
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
<input id="ref_selector" name="ref" type="hidden" value="{{.Issue.Ref}}">
|
||||||
|
<div class="ui {{if .ReadOnly}}disabled{{end}} floating filter select-branch dropdown" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
|
||||||
|
<div class="ui basic small button">
|
||||||
|
<span class="text branch-name">{{if .Issue.Ref}}{{.Issue.Ref}}{{else}}{{.i18n.Tr "repo.issues.no_ref"}}{{end}}</span>
|
||||||
|
<i class="dropdown icon"></i>
|
||||||
|
</div>
|
||||||
|
<div class="menu">
|
||||||
|
<div class="ui icon search input">
|
||||||
|
<i class="filter icon"></i>
|
||||||
|
<input name="search" placeholder="{{.i18n.Tr "repo.filter_branch_and_tag"}}...">
|
||||||
|
</div>
|
||||||
|
<div class="header">
|
||||||
|
<div class="ui grid">
|
||||||
|
<div class="two column row">
|
||||||
|
<a class="reference column" href="#" data-target="#branch-list">
|
||||||
|
<span class="text black">
|
||||||
|
<i class="octicon octicon-git-branch"></i> {{.i18n.Tr "repo.branches"}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
<a class="reference column" href="#" data-target="#tag-list">
|
||||||
|
<span class="text">
|
||||||
|
<i class="reference tags icon"></i> {{.i18n.Tr "repo.tags"}}
|
||||||
|
</span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="branch-list" class="scrolling menu reference-list-menu">
|
||||||
|
{{range .Branches}}
|
||||||
|
<div class="item" data-id="{{.}}" data-id-selector="#ref_selector">{{.}}</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
<div id="tag-list" class="scrolling menu reference-list-menu" style="display: none">
|
||||||
|
{{range .Tags}}
|
||||||
|
<div class="item" data-id="{{.}}" data-id-selector="#ref_selector">{{.}}</div>
|
||||||
|
{{end}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="ui divider"></div>
|
|
@ -171,6 +171,9 @@
|
||||||
<div class="ui {{if .IsRead}}black{{else}}green{{end}} label">#{{.Index}}</div>
|
<div class="ui {{if .IsRead}}black{{else}}green{{end}} label">#{{.Index}}</div>
|
||||||
<a class="title has-emoji" href="{{$.Link}}/{{.Index}}">{{.Title}}</a>
|
<a class="title has-emoji" href="{{$.Link}}/{{.Index}}">{{.Title}}</a>
|
||||||
|
|
||||||
|
{{if .Ref}}
|
||||||
|
<a class="ui label" href="{{$.RepoLink}}/src/{{.Ref}}">{{.Ref}}</a>
|
||||||
|
{{end}}
|
||||||
{{range .Labels}}
|
{{range .Labels}}
|
||||||
<a class="ui label" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}&milestone={{$.MilestoneID}}&assignee={{$.AssigneeID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}">{{.Name | Sanitize}}</a>
|
<a class="ui label" href="{{$.Link}}?q={{$.Keyword}}&type={{$.ViewType}}&state={{$.State}}&labels={{.ID}}&milestone={{$.MilestoneID}}&assignee={{$.AssigneeID}}" style="color: {{.ForegroundColor}}; background-color: {{.Color}}">{{.Name | Sanitize}}</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
|
|
||||||
<div class="four wide column">
|
<div class="four wide column">
|
||||||
<div class="ui segment metas">
|
<div class="ui segment metas">
|
||||||
|
{{template "repo/issue/branch_selector_field" .}}
|
||||||
|
|
||||||
<input id="label_ids" name="label_ids" type="hidden" value="{{.label_ids}}">
|
<input id="label_ids" name="label_ids" type="hidden" value="{{.label_ids}}">
|
||||||
<div class="ui {{if not .Labels}}disabled{{end}} floating jump select-label dropdown">
|
<div class="ui {{if not .Labels}}disabled{{end}} floating jump select-label dropdown">
|
||||||
<span class="text">
|
<span class="text">
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<div class="four wide column">
|
<div class="four wide column">
|
||||||
<div class="ui segment metas">
|
<div class="ui segment metas">
|
||||||
|
{{template "repo/issue/branch_selector_field" .}}
|
||||||
|
|
||||||
<div class="ui {{if not .IsRepositoryWriter}}disabled{{end}} floating jump select-label dropdown">
|
<div class="ui {{if not .IsRepositoryWriter}}disabled{{end}} floating jump select-label dropdown">
|
||||||
<span class="text">
|
<span class="text">
|
||||||
<strong>{{.i18n.Tr "repo.issues.new.labels"}}</strong>
|
<strong>{{.i18n.Tr "repo.issues.new.labels"}}</strong>
|
||||||
|
|
Reference in a new issue