Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
15f3362d
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,发现更多精彩内容 >>
提交
15f3362d
编写于
6月 29, 2017
作者:
F
Fatih Acet
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
IssueDiscussionsRefactor: Implement polling mechanism.
上级
17d67a98
变更
5
显示空白变更内容
内联
并排
Showing
5 changed file
with
71 addition
and
8 deletion
+71
-8
app/assets/javascripts/notes/components/issue_comment_form.vue
...ssets/javascripts/notes/components/issue_comment_form.vue
+2
-2
app/assets/javascripts/notes/components/issue_notes.vue
app/assets/javascripts/notes/components/issue_notes.vue
+15
-2
app/assets/javascripts/notes/services/issue_notes_service.js
app/assets/javascripts/notes/services/issue_notes_service.js
+9
-0
app/assets/javascripts/notes/stores/issue_notes_store.js
app/assets/javascripts/notes/stores/issue_notes_store.js
+44
-3
app/views/projects/issues/_discussion.html.haml
app/views/projects/issues/_discussion.html.haml
+1
-1
未找到文件。
app/assets/javascripts/notes/components/issue_comment_form.vue
浏览文件 @
15f3362d
...
...
@@ -133,13 +133,13 @@ export default {
ref=
"textarea"
slot=
"textarea"
placeholder=
"Write a comment or drag your files here..."
@
keydown.meta.enter=
"handleSave"
>
@
keydown.meta.enter=
"handleSave
()
"
>
</textarea>
</markdown-field>
<div
class=
"note-form-actions clearfix"
>
<div
class=
"pull-left btn-group append-right-10 comment-type-dropdown js-comment-type-dropdown"
>
<input
@
click=
"handleSave"
@
click=
"handleSave
()
"
:disabled=
"!note.length"
:value=
"commentButtonTitle"
class=
"btn btn-nr btn-create comment-btn js-comment-button js-comment-submit-button"
...
...
app/assets/javascripts/notes/components/issue_notes.vue
浏览文件 @
15f3362d
...
...
@@ -39,14 +39,27 @@ export default {
},
},
mounted
()
{
const
path
=
this
.
$el
.
parentNode
.
dataset
.
discussionsPath
;
this
.
$store
.
dispatch
(
'
fetchNotes
'
,
p
ath
)
const
{
discussionsPath
,
notesPath
,
lastFetchedAt
}
=
this
.
$el
.
parentNode
.
dataset
;
this
.
$store
.
dispatch
(
'
fetchNotes
'
,
discussionsP
ath
)
.
then
(()
=>
{
this
.
isLoading
=
false
;
})
.
catch
(()
=>
{
new
Flash
(
'
Something went wrong while fetching issue comments. Please try again.
'
);
// eslint-disable-line
});
const
options
=
{
endpoint
:
`
${
notesPath
}
?full_data=1`
,
lastFetchedAt
,
};
// FIXME: @fatihacet Implement real polling mechanism
setInterval
(()
=>
{
this
.
$store
.
dispatch
(
'
poll
'
,
options
)
.
then
((
res
)
=>
{
options
.
lastFetchedAt
=
res
.
last_fetched_at
;
});
},
6000
);
},
};
</
script
>
...
...
app/assets/javascripts/notes/services/issue_notes_service.js
浏览文件 @
15f3362d
...
...
@@ -19,4 +19,13 @@ export default {
createNewNote
(
endpoint
,
data
)
{
return
Vue
.
http
.
post
(
endpoint
,
data
,
{
emulateJSON
:
true
});
},
poll
(
endpoint
,
lastFetchedAt
)
{
const
options
=
{
headers
:
{
'
X-Last-Fetched-At
'
:
lastFetchedAt
,
}
};
return
Vue
.
http
.
get
(
endpoint
,
options
);
},
};
app/assets/javascripts/notes/stores/issue_notes_store.js
浏览文件 @
15f3362d
...
...
@@ -15,7 +15,7 @@ const getters = {
};
const
mutations
=
{
setNotes
(
storeState
,
notes
)
{
set
Initial
Notes
(
storeState
,
notes
)
{
storeState
.
notes
=
notes
;
},
toggleDiscussion
(
storeState
,
{
discussionId
})
{
...
...
@@ -40,7 +40,9 @@ const mutations = {
addNewReplyToDiscussion
(
storeState
,
note
)
{
const
noteObj
=
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
if
(
noteObj
)
{
noteObj
.
notes
.
push
(
note
);
}
},
updateNote
(
storeState
,
note
)
{
const
noteObj
=
findNoteObjectById
(
storeState
.
notes
,
note
.
discussion_id
);
...
...
@@ -72,7 +74,7 @@ const actions = {
.
fetchNotes
(
path
)
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
context
.
commit
(
'
setNotes
'
,
res
);
context
.
commit
(
'
set
Initial
Notes
'
,
res
);
});
},
deleteNote
(
context
,
note
)
{
...
...
@@ -114,6 +116,45 @@ const actions = {
return
res
;
});
},
poll
(
context
,
data
)
{
const
{
endpoint
,
lastFetchedAt
}
=
data
;
return
service
.
poll
(
endpoint
,
lastFetchedAt
)
.
then
(
res
=>
res
.
json
())
.
then
((
res
)
=>
{
if
(
res
.
notes
.
length
)
{
const
notesById
=
{};
// Simple lookup object to check whether we have a discussion id already in our store
context
.
state
.
notes
.
forEach
((
note
)
=>
{
note
.
notes
.
forEach
((
n
)
=>
{
notesById
[
n
.
id
]
=
true
;
});
});
res
.
notes
.
forEach
((
note
)
=>
{
if
(
notesById
[
note
.
id
])
{
context
.
commit
(
'
updateNote
'
,
note
);
}
else
{
if
(
note
.
type
===
'
DiscussionNote
'
)
{
const
discussion
=
findNoteObjectById
(
context
.
state
.
notes
,
note
.
discussion_id
);
if
(
discussion
)
{
context
.
commit
(
'
addNewReplyToDiscussion
'
,
note
);
}
else
{
context
.
commit
(
'
addNewNote
'
,
note
);
}
}
else
{
context
.
commit
(
'
addNewNote
'
,
note
);
}
}
});
}
return
res
;
});
},
};
export
default
{
...
...
app/views/projects/issues/_discussion.html.haml
浏览文件 @
15f3362d
...
...
@@ -3,7 +3,7 @@
=
link_to
'Reopen issue'
,
issue_path
(
@issue
,
issue:
{
state_event: :reopen
},
format:
'json'
),
data:
{
original_text:
"Reopen issue"
,
alternative_text:
"Comment & reopen issue"
},
class:
"btn btn-nr btn-reopen btn-comment js-note-target-reopen
#{
issue_button_visibility
(
@issue
,
false
)
}
"
,
title:
'Reopen issue'
=
link_to
'Close issue'
,
issue_path
(
@issue
,
issue:
{
state_event: :close
},
format:
'json'
),
data:
{
original_text:
"Close issue"
,
alternative_text:
"Comment & close issue"
},
class:
"btn btn-nr btn-close btn-comment js-note-target-close
#{
issue_button_visibility
(
@issue
,
true
)
}
"
,
title:
'Close issue'
%section
{
data:
{
discussions_path:
discussions_namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
,
format: :json
),
new_session_path:
new_session_path
(
:user
,
redirect_to_referer:
'yes'
)
}
}
%section
{
data:
{
discussions_path:
discussions_namespace_project_issue_path
(
@project
.
namespace
,
@project
,
@issue
,
format: :json
),
new_session_path:
new_session_path
(
:user
,
redirect_to_referer:
'yes'
)
,
notes_path:
notes_url
,
last_fetched_at:
Time
.
now
.
to_i
}
}
#js-notes
-
content_for
:page_specific_javascripts
do
=
webpack_bundle_tag
'common_vue'
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录