Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
3fdc6560
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,发现更多精彩内容 >>
提交
3fdc6560
编写于
12月 18, 2017
作者:
F
Filipa Lacerda
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'ph-es-notes-module' into 'master'
Export and use Notes ES module See merge request gitlab-org/gitlab-ce!15953
上级
ceac0ae6
0a05d874
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
25 addition
and
24 deletion
+25
-24
app/assets/javascripts/diff_notes/components/diff_note_avatars.js
...ts/javascripts/diff_notes/components/diff_note_avatars.js
+2
-2
app/assets/javascripts/init_notes.js
app/assets/javascripts/init_notes.js
+4
-2
app/assets/javascripts/main.js
app/assets/javascripts/main.js
+0
-2
app/assets/javascripts/merge_request_tabs.js
app/assets/javascripts/merge_request_tabs.js
+2
-2
app/assets/javascripts/notes.js
app/assets/javascripts/notes.js
+6
-0
spec/javascripts/merge_request_notes_spec.js
spec/javascripts/merge_request_notes_spec.js
+1
-3
spec/javascripts/merge_request_tabs_spec.js
spec/javascripts/merge_request_tabs_spec.js
+9
-10
spec/javascripts/notes_spec.js
spec/javascripts/notes_spec.js
+1
-3
未找到文件。
app/assets/javascripts/diff_notes/components/diff_note_avatars.js
浏览文件 @
3fdc6560
/* global CommentsStore */
/* global notes */
import
Vue
from
'
vue
'
;
import
collapseIcon
from
'
../icons/collapse_icon.svg
'
;
import
Notes
from
'
../../notes
'
;
import
userAvatarImage
from
'
../../vue_shared/components/user_avatar/user_avatar_image.vue
'
;
const
DiffNoteAvatars
=
Vue
.
extend
({
...
...
@@ -129,7 +129,7 @@ const DiffNoteAvatars = Vue.extend({
},
methods
:
{
clickedAvatar
(
e
)
{
notes
.
onAddDiffNote
(
e
);
Notes
.
instance
.
onAddDiffNote
(
e
);
// Toggle the active state of the toggle all button
this
.
toggleDiscussionsToggleState
();
...
...
app/assets/javascripts/init_notes.js
浏览文件 @
3fdc6560
/* global Notes */
import
Notes
from
'
./notes
'
;
export
default
()
=>
{
const
dataEl
=
document
.
querySelector
(
'
.js-notes-data
'
);
...
...
@@ -10,5 +10,7 @@ export default () => {
autocomplete
,
}
=
JSON
.
parse
(
dataEl
.
innerHTML
);
window
.
notes
=
new
Notes
(
notesUrl
,
notesIds
,
now
,
diffView
,
autocomplete
);
// Create a singleton so that we don't need to assign
// into the window object, we can just access the current isntance with Notes.instance
Notes
.
initialize
(
notesUrl
,
notesIds
,
now
,
diffView
,
autocomplete
);
};
app/assets/javascripts/main.js
浏览文件 @
3fdc6560
...
...
@@ -45,9 +45,7 @@ import './layout_nav';
import
LazyLoader
from
'
./lazy_loader
'
;
import
'
./line_highlighter
'
;
import
initLogoAnimation
from
'
./logo
'
;
import
'
./merge_request_tabs
'
;
import
'
./milestone_select
'
;
import
'
./notes
'
;
import
'
./preview_markdown
'
;
import
'
./projects_dropdown
'
;
import
'
./render_gfm
'
;
...
...
app/assets/javascripts/merge_request_tabs.js
浏览文件 @
3fdc6560
/* eslint-disable no-new, class-methods-use-this */
/* global notes */
import
Cookies
from
'
js-cookie
'
;
import
Flash
from
'
./flash
'
;
...
...
@@ -16,6 +15,7 @@ import initDiscussionTab from './image_diff/init_discussion_tab';
import
Diff
from
'
./diff
'
;
import
{
localTimeAgo
}
from
'
./lib/utils/datetime_utility
'
;
import
syntaxHighlight
from
'
./syntax_highlight
'
;
import
Notes
from
'
./notes
'
;
/* eslint-disable max-len */
// MergeRequestTabs
...
...
@@ -324,7 +324,7 @@ export default class MergeRequestTabs {
if
(
anchor
&&
anchor
.
length
>
0
)
{
const
notesContent
=
anchor
.
closest
(
'
.notes_content
'
);
const
lineType
=
notesContent
.
hasClass
(
'
new
'
)
?
'
new
'
:
'
old
'
;
notes
.
toggleDiffNote
({
Notes
.
instance
.
toggleDiffNote
({
target
:
anchor
,
lineType
,
forceShow
:
true
,
...
...
app/assets/javascripts/notes.js
浏览文件 @
3fdc6560
...
...
@@ -37,6 +37,12 @@ const MAX_VISIBLE_COMMIT_LIST_COUNT = 3;
const
REGEX_QUICK_ACTIONS
=
/^
\/\w
+.*$/gm
;
export
default
class
Notes
{
static
initialize
(
notes_url
,
note_ids
,
last_fetched_at
,
view
,
enableGFM
=
true
)
{
if
(
!
this
.
instance
)
{
this
.
instance
=
new
Notes
(
notes_url
,
note_ids
,
last_fetched_at
,
view
,
enableGFM
);
}
}
constructor
(
notes_url
,
note_ids
,
last_fetched_at
,
view
,
enableGFM
=
true
)
{
this
.
updateTargetButtons
=
this
.
updateTargetButtons
.
bind
(
this
);
this
.
updateComment
=
this
.
updateComment
.
bind
(
this
);
...
...
spec/javascripts/merge_request_notes_spec.js
浏览文件 @
3fdc6560
/* global Notes */
import
'
autosize
'
;
import
'
~/gl_form
'
;
import
'
~/lib/utils/text_utility
'
;
import
'
~/render_gfm
'
;
import
'
~/render_math
'
;
import
'
~/notes
'
;
import
Notes
from
'
~/notes
'
;
const
upArrowKeyCode
=
38
;
...
...
spec/javascripts/merge_request_tabs_spec.js
浏览文件 @
3fdc6560
/* eslint-disable no-var, comma-dangle, object-shorthand */
/* global Notes */
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
MergeRequestTabs
from
'
~/merge_request_tabs
'
;
...
...
@@ -7,7 +6,7 @@ import '~/commit/pipelines/pipelines_bundle';
import
'
~/breakpoints
'
;
import
'
~/lib/utils/common_utils
'
;
import
Diff
from
'
~/diff
'
;
import
'
~/notes
'
;
import
Notes
from
'
~/notes
'
;
import
'
vendor/jquery.scrollTo
'
;
(
function
()
{
...
...
@@ -279,8 +278,8 @@ import 'vendor/jquery.scrollTo';
loadFixtures
(
'
merge_requests/diff_comment.html.raw
'
);
$
(
'
body
'
).
attr
(
'
data-page
'
,
'
projects:merge_requests:show
'
);
window
.
gl
.
ImageFile
=
()
=>
{};
window
.
notes
=
new
Notes
(
''
,
[]);
spyOn
(
window
.
notes
,
'
toggleDiffNote
'
).
and
.
callThrough
();
Notes
.
initialize
(
''
,
[]);
spyOn
(
Notes
.
instance
,
'
toggleDiffNote
'
).
and
.
callThrough
();
});
afterEach
(()
=>
{
...
...
@@ -338,7 +337,7 @@ import 'vendor/jquery.scrollTo';
this
.
class
.
loadDiff
(
'
/foo/bar/merge_requests/1/diffs
'
);
expect
(
noteId
.
length
).
toBeGreaterThan
(
0
);
expect
(
window
.
notes
.
toggleDiffNote
).
toHaveBeenCalledWith
({
expect
(
Notes
.
instance
.
toggleDiffNote
).
toHaveBeenCalledWith
({
target
:
jasmine
.
any
(
Object
),
lineType
:
'
old
'
,
forceShow
:
true
,
...
...
@@ -349,7 +348,7 @@ import 'vendor/jquery.scrollTo';
spyOn
(
urlUtils
,
'
getLocationHash
'
).
and
.
returnValue
(
'
note_something-that-does-not-exist
'
);
this
.
class
.
loadDiff
(
'
/foo/bar/merge_requests/1/diffs
'
);
expect
(
window
.
notes
.
toggleDiffNote
).
not
.
toHaveBeenCalled
();
expect
(
Notes
.
instance
.
toggleDiffNote
).
not
.
toHaveBeenCalled
();
});
});
...
...
@@ -359,7 +358,7 @@ import 'vendor/jquery.scrollTo';
this
.
class
.
loadDiff
(
'
/foo/bar/merge_requests/1/diffs
'
);
expect
(
noteLineNumId
.
length
).
toBeGreaterThan
(
0
);
expect
(
window
.
notes
.
toggleDiffNote
).
not
.
toHaveBeenCalled
();
expect
(
Notes
.
instance
.
toggleDiffNote
).
not
.
toHaveBeenCalled
();
});
});
});
...
...
@@ -393,7 +392,7 @@ import 'vendor/jquery.scrollTo';
this
.
class
.
loadDiff
(
'
/foo/bar/merge_requests/1/diffs
'
);
expect
(
noteId
.
length
).
toBeGreaterThan
(
0
);
expect
(
window
.
notes
.
toggleDiffNote
).
toHaveBeenCalledWith
({
expect
(
Notes
.
instance
.
toggleDiffNote
).
toHaveBeenCalledWith
({
target
:
jasmine
.
any
(
Object
),
lineType
:
'
new
'
,
forceShow
:
true
,
...
...
@@ -404,7 +403,7 @@ import 'vendor/jquery.scrollTo';
spyOn
(
urlUtils
,
'
getLocationHash
'
).
and
.
returnValue
(
'
note_something-that-does-not-exist
'
);
this
.
class
.
loadDiff
(
'
/foo/bar/merge_requests/1/diffs
'
);
expect
(
window
.
notes
.
toggleDiffNote
).
not
.
toHaveBeenCalled
();
expect
(
Notes
.
instance
.
toggleDiffNote
).
not
.
toHaveBeenCalled
();
});
});
...
...
@@ -414,7 +413,7 @@ import 'vendor/jquery.scrollTo';
this
.
class
.
loadDiff
(
'
/foo/bar/merge_requests/1/diffs
'
);
expect
(
noteLineNumId
.
length
).
toBeGreaterThan
(
0
);
expect
(
window
.
notes
.
toggleDiffNote
).
not
.
toHaveBeenCalled
();
expect
(
Notes
.
instance
.
toggleDiffNote
).
not
.
toHaveBeenCalled
();
});
});
});
...
...
spec/javascripts/notes_spec.js
浏览文件 @
3fdc6560
/* eslint-disable space-before-function-paren, no-unused-expressions, no-var, object-shorthand, comma-dangle, max-len */
/* global Notes */
import
*
as
urlUtils
from
'
~/lib/utils/url_utility
'
;
import
'
autosize
'
;
import
'
~/gl_form
'
;
import
'
~/lib/utils/text_utility
'
;
import
'
~/render_gfm
'
;
import
'
~/notes
'
;
import
Notes
from
'
~/notes
'
;
(
function
()
{
window
.
gon
||
(
window
.
gon
=
{});
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录