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

Mention completion for issue editor. #3136

Merged
merged 7 commits into from
Dec 11, 2017
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
1 change: 1 addition & 0 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,7 @@ function initRepository() {
if ($editContentZone.html().length == 0) {
$editContentZone.html($('#edit-content-form').html());
$textarea = $segment.find('textarea');
issuesTribute.attach($textarea.get());

// Give new write/preview data-tab name to distinguish from others
var $editContentForm = $editContentZone.find('.ui.comment.form');
Expand Down
40 changes: 40 additions & 0 deletions public/vendor/plugins/tribute/tribute.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
.tribute-container {
position: absolute;
top: 0;
left: 0;
height: auto;
max-height: 300px;
max-width: 500px;
overflow: auto;
display: block;
box-shadow: 0px 1px 3px 1px #c7c7c7;
z-index: 999999; }
.tribute-container ul {
margin: 0;
margin-top: 2px;
padding: 0;
list-style: none;
background: #ffffff; }
.tribute-container li {
padding: 8px 12px;
border-bottom: 1px solid #dcdcdc;
cursor: pointer; }
.tribute-container li.highlight, .tribute-container li:hover {
background: #2185D0;
color: #ffffff;}
.tribute-container li img {
display: inline-block;
vertical-align: middle;
width: 28px;
margin-right: 5px;
}
.tribute-container li span {
font-weight: bold; }
.tribute-container li span.fullname {
font-weight: normal;
font-size: 0.8rem;
margin-left: 3px;}
.tribute-container li.no-match {
cursor: default; }
.tribute-container .menu-highlighted {
font-weight: bold; }
2 changes: 2 additions & 0 deletions public/vendor/plugins/tribute/tribute.min.js

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ func NewIssue(ctx *context.Context) {
ctx.Data["PageIsIssueList"] = true
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireSimpleMDE"] = true
ctx.Data["RequireTribute"] = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we also should require tribute in CompareAndPullRequest

setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
renderAttachmentSettings(ctx)

Expand Down Expand Up @@ -478,6 +479,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
func ViewIssue(ctx *context.Context) {
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireDropzone"] = true
ctx.Data["RequireTribute"] = true
renderAttachmentSettings(ctx)

issue, err := models.GetIssueByIndex(ctx.Repo.Repository.ID, ctx.ParamsInt64(":index"))
Expand Down
1 change: 1 addition & 0 deletions routers/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,7 @@ func CompareAndPullRequest(ctx *context.Context) {
ctx.Data["PageIsComparePull"] = true
ctx.Data["IsDiffCompare"] = true
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireTribute"] = true
setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates)
renderAttachmentSettings(ctx)

Expand Down
26 changes: 26 additions & 0 deletions templates/base/footer.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,32 @@
{{end}}
{{if .RequireDropzone}}
<script src="{{AppSubUrl}}/vendor/plugins/dropzone/dropzone.js"></script>
{{end}}
{{if .RequireTribute}}
<script src="{{AppSubUrl}}/vendor/plugins/tribute/tribute.min.js"></script>

{{if .Assignees}}
<script>
var issuesTribute = new Tribute({
values: [
{{ range .Assignees }}
{key: '{{.Name}} {{.FullName}}', value: '{{.Name}}',
name: '{{.Name}}', fullname: '{{.FullName}}', avatar: '{{.RelAvatarLink}}'},
{{ end }}
],
noMatchTemplate: function () { return null },
menuItemTemplate: function (item) {
var user = item.original;
var itemStr = '<img src="' + user.avatar + '"/><span class="name">' + user.name + '</span>';
if (user.fullname && user.fullname != '') {
itemStr += '<span class="fullname">' + user.fullname + '</span>';
}
return itemStr;
}
})
issuesTribute.attach(document.getElementById('content'))
</script>
{{end}}
{{end}}
<script src="{{AppSubUrl}}/vendor/plugins/autolink/autolink.js"></script>
<script src="{{AppSubUrl}}/vendor/plugins/emojify/emojify.min.js"></script>
Expand Down
4 changes: 4 additions & 0 deletions templates/base/head.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@
<link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/gitgraph/gitgraph.css">
{{end}}

{{if .RequireTribute}}
<link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/tribute/tribute.css">
{{end}}

<!-- Stylesheet -->
<link rel="stylesheet" href="{{AppSubUrl}}/vendor/plugins/semantic/semantic.min.css">
<link rel="stylesheet" href="{{AppSubUrl}}/css/index.css?v={{MD5 AppVer}}">
Expand Down