Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
23563f5e
G
gitlab-foss
项目概览
李少辉-开发者
/
gitlab-foss
通知
15
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
gitlab-foss
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
23563f5e
编写于
8月 28, 2018
作者:
W
Winnie Hellmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Highlight current user in comments and system notes
上级
7c1cfd0b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
106 addition
and
4 deletion
+106
-4
app/assets/javascripts/behaviors/markdown/highlight_current_user.js
.../javascripts/behaviors/markdown/highlight_current_user.js
+17
-0
app/assets/javascripts/behaviors/markdown/render_gfm.js
app/assets/javascripts/behaviors/markdown/render_gfm.js
+2
-0
app/assets/javascripts/notes/components/notes_app.vue
app/assets/javascripts/notes/components/notes_app.vue
+4
-0
app/assets/stylesheets/framework/gfm.scss
app/assets/stylesheets/framework/gfm.scss
+4
-0
changelogs/unreleased/winh-highlight-current-user.yml
changelogs/unreleased/winh-highlight-current-user.yml
+5
-0
spec/features/issues/notes_on_issues_spec.rb
spec/features/issues/notes_on_issues_spec.rb
+19
-4
spec/javascripts/behaviors/markdown/highlight_current_user_spec.js
...scripts/behaviors/markdown/highlight_current_user_spec.js
+55
-0
未找到文件。
app/assets/javascripts/behaviors/markdown/highlight_current_user.js
0 → 100644
浏览文件 @
23563f5e
/**
* Highlights the current user in existing elements with a user ID data attribute.
*
* @param elements DOM elements that represent user mentions
*/
export
default
function
highlightCurrentUser
(
elements
)
{
const
currentUserId
=
gon
&&
gon
.
current_user_id
;
if
(
!
currentUserId
)
{
return
;
}
elements
.
forEach
(
element
=>
{
if
(
parseInt
(
element
.
dataset
.
user
,
10
)
===
currentUserId
)
{
element
.
classList
.
add
(
'
current-user
'
);
}
});
}
app/assets/javascripts/behaviors/markdown/render_gfm.js
浏览文件 @
23563f5e
...
...
@@ -2,6 +2,7 @@ import $ from 'jquery';
import
syntaxHighlight
from
'
~/syntax_highlight
'
;
import
renderMath
from
'
./render_math
'
;
import
renderMermaid
from
'
./render_mermaid
'
;
import
highlightCurrentUser
from
'
./highlight_current_user
'
;
// Render GitLab flavoured Markdown
//
...
...
@@ -11,6 +12,7 @@ $.fn.renderGFM = function renderGFM() {
syntaxHighlight
(
this
.
find
(
'
.js-syntax-highlight
'
));
renderMath
(
this
.
find
(
'
.js-render-math
'
));
renderMermaid
(
this
.
find
(
'
.js-render-mermaid
'
));
highlightCurrentUser
(
this
.
find
(
'
.gfm-project_member
'
).
get
());
return
this
;
};
...
...
app/assets/javascripts/notes/components/notes_app.vue
浏览文件 @
23563f5e
...
...
@@ -11,6 +11,7 @@ import commentForm from './comment_form.vue';
import
placeholderNote
from
'
../../vue_shared/components/notes/placeholder_note.vue
'
;
import
placeholderSystemNote
from
'
../../vue_shared/components/notes/placeholder_system_note.vue
'
;
import
skeletonLoadingContainer
from
'
../../vue_shared/components/notes/skeleton_note.vue
'
;
import
highlightCurrentUser
from
'
~/behaviors/markdown/highlight_current_user
'
;
export
default
{
name
:
'
NotesApp
'
,
...
...
@@ -96,6 +97,9 @@ export default {
});
}
},
updated
()
{
this
.
$nextTick
(()
=>
highlightCurrentUser
(
this
.
$el
.
querySelectorAll
(
'
.gfm-project_member
'
)));
},
methods
:
{
...
mapActions
({
fetchDiscussions
:
'
fetchDiscussions
'
,
...
...
app/assets/stylesheets/framework/gfm.scss
浏览文件 @
23563f5e
...
...
@@ -11,6 +11,10 @@
padding
:
0
2px
;
background-color
:
$blue-100
;
border-radius
:
$border-radius-default
;
&
.current-user
{
background-color
:
$orange-100
;
}
}
.gfm-color_chip
{
...
...
changelogs/unreleased/winh-highlight-current-user.yml
0 → 100644
浏览文件 @
23563f5e
---
title
:
Highlight current user in comments
merge_request
:
21406
author
:
type
:
changed
spec/features/issues/notes_on_issues_spec.rb
浏览文件 @
23563f5e
...
...
@@ -3,6 +3,12 @@ require 'spec_helper'
describe
'Create notes on issues'
,
:js
do
let
(
:user
)
{
create
(
:user
)
}
def
submit_comment
(
text
)
fill_in
'note[note]'
,
with:
text
click_button
'Comment'
wait_for_requests
end
shared_examples
'notes with reference'
do
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:note_text
)
{
"Check
#{
mention
.
to_reference
}
"
}
...
...
@@ -12,10 +18,7 @@ describe 'Create notes on issues', :js do
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue
)
fill_in
'note[note]'
,
with:
note_text
click_button
'Comment'
wait_for_requests
submit_comment
(
note_text
)
end
it
'creates a note with reference and cross references the issue'
do
...
...
@@ -74,4 +77,16 @@ describe 'Create notes on issues', :js do
let
(
:mention
)
{
create
(
:merge_request
,
source_project:
project
)
}
end
end
it
'highlights the current user in a comment'
do
project
=
create
(
:project
)
issue
=
create
(
:issue
,
project:
project
)
project
.
add_developer
(
user
)
sign_in
(
user
)
visit
project_issue_path
(
project
,
issue
)
submit_comment
(
"@
#{
user
.
username
}
note to self"
)
expect
(
page
).
to
have_selector
'.gfm-project_member.current-user'
,
text:
user
.
username
end
end
spec/javascripts/behaviors/markdown/highlight_current_user_spec.js
0 → 100644
浏览文件 @
23563f5e
import
highlightCurrentUser
from
'
~/behaviors/markdown/highlight_current_user
'
;
describe
(
'
highlightCurrentUser
'
,
()
=>
{
let
rootElement
;
let
elements
;
beforeEach
(()
=>
{
setFixtures
(
`
<div id="dummy-root-element">
<div data-user="1">@first</div>
<div data-user="2">@second</div>
</div>
`
);
rootElement
=
document
.
getElementById
(
'
dummy-root-element
'
);
elements
=
rootElement
.
querySelectorAll
(
'
[data-user]
'
);
});
describe
(
'
without current user
'
,
()
=>
{
beforeEach
(()
=>
{
window
.
gon
=
window
.
gon
||
{};
window
.
gon
.
current_user_id
=
null
;
});
afterEach
(()
=>
{
delete
window
.
gon
.
current_user_id
;
});
it
(
'
does not highlight the user
'
,
()
=>
{
const
initialHtml
=
rootElement
.
outerHTML
;
highlightCurrentUser
(
elements
);
expect
(
rootElement
.
outerHTML
).
toBe
(
initialHtml
);
});
});
describe
(
'
with current user
'
,
()
=>
{
beforeEach
(()
=>
{
window
.
gon
=
window
.
gon
||
{};
window
.
gon
.
current_user_id
=
2
;
});
afterEach
(()
=>
{
delete
window
.
gon
.
current_user_id
;
});
it
(
'
highlights current user
'
,
()
=>
{
highlightCurrentUser
(
elements
);
expect
(
elements
.
length
).
toBe
(
2
);
expect
(
elements
[
0
]).
not
.
toHaveClass
(
'
current-user
'
);
expect
(
elements
[
1
]).
toHaveClass
(
'
current-user
'
);
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录