Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
一杯枸杞茶ya
csdn-workflow
提交
452586c4
C
csdn-workflow
项目概览
一杯枸杞茶ya
/
csdn-workflow
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
csdn-workflow
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
452586c4
编写于
5月 07, 2021
作者:
T
Tomas Vik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: group discussion and note types into separate files
上级
e623b271
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
127 addition
and
115 deletion
+127
-115
src/data_providers/items/mr_item_model.ts
src/data_providers/items/mr_item_model.ts
+1
-1
src/gitlab/gitlab_new_service.ts
src/gitlab/gitlab_new_service.ts
+13
-99
src/gitlab/graphql/get_discussions.ts
src/gitlab/graphql/get_discussions.ts
+35
-1
src/gitlab/graphql/shared.ts
src/gitlab/graphql/shared.ts
+70
-0
src/review/gitlab_comment.test.ts
src/review/gitlab_comment.test.ts
+1
-1
src/review/gitlab_comment.ts
src/review/gitlab_comment.ts
+1
-1
src/review/gitlab_comment_thread.test.ts
src/review/gitlab_comment_thread.test.ts
+3
-5
src/review/gitlab_comment_thread.ts
src/review/gitlab_comment_thread.ts
+3
-7
未找到文件。
src/data_providers/items/mr_item_model.ts
浏览文件 @
452586c4
...
...
@@ -3,7 +3,7 @@ import { PROGRAMMATIC_COMMANDS } from '../../command_names';
import
{
createGitLabNewService
}
from
'
../../service_factory
'
;
import
{
ChangedFileItem
}
from
'
./changed_file_item
'
;
import
{
ItemModel
}
from
'
./item_model
'
;
import
{
GqlDiscussion
,
GqlTextDiffDiscussion
}
from
'
../../gitlab/g
itlab_new_service
'
;
import
{
GqlDiscussion
,
GqlTextDiffDiscussion
}
from
'
../../gitlab/g
raphql/get_discussions
'
;
import
{
handleError
}
from
'
../../log
'
;
import
{
UserFriendlyError
}
from
'
../../errors/user_friendly_error
'
;
import
{
GitLabCommentThread
}
from
'
../../review/gitlab_comment_thread
'
;
...
...
src/gitlab/gitlab_new_service.ts
浏览文件 @
452586c4
...
...
@@ -13,26 +13,25 @@ import { GitLabProject } from './gitlab_project';
import
{
getRestIdFromGraphQLId
}
from
'
../utils/get_rest_id_from_graphql_id
'
;
import
{
UserFriendlyError
}
from
'
../errors/user_friendly_error
'
;
import
{
getMrPermissionsQuery
,
MrPermissionsQueryOptions
}
from
'
./graphql/mr_permission
'
;
import
{
fragmentProjectDetails
,
GqlProject
,
noteDetailsFragment
}
from
'
./graphql/shared
'
;
import
{
fragmentProjectDetails
,
GqlBasePosition
,
GqlGenericNote
,
GqlNote
,
GqlProject
,
GqlProjectResult
,
Node
,
noteDetailsFragment
,
}
from
'
./graphql/shared
'
;
import
{
GetProjectsOptions
,
GqlProjectsResult
,
queryGetProjects
}
from
'
./graphql/get_projects
'
;
import
{
getIssueDiscussionsQuery
,
getMrDiscussionsQuery
,
GetDiscussionsQueryOptions
,
GqlDiscussion
,
GetDiscussionsQueryResult
,
}
from
'
./graphql/get_discussions
'
;
interface
Node
<
T
>
{
pageInfo
?:
{
hasNextPage
:
boolean
;
endCursor
:
string
;
};
nodes
:
T
[];
}
interface
GqlProjectResult
<
T
>
{
project
?:
T
;
}
interface
GqlSnippetProject
{
id
:
string
;
snippets
:
Node
<
GqlSnippet
>
;
...
...
@@ -58,88 +57,6 @@ export interface GqlBlob {
path
:
string
;
}
interface
GqlUser
{
avatarUrl
:
string
|
null
;
name
:
string
;
username
:
string
;
webUrl
:
string
;
}
interface
GqlBasePosition
{
diffRefs
:
{
baseSha
:
string
;
headSha
:
string
;
};
filePath
:
string
;
newPath
:
string
;
oldPath
:
string
;
}
interface
GqlImagePosition
extends
GqlBasePosition
{
positionType
:
'
image
'
;
newLine
:
null
;
oldLine
:
null
;
}
interface
GqlNewPosition
extends
GqlBasePosition
{
positionType
:
'
text
'
;
newLine
:
number
;
oldLine
:
null
;
}
interface
GqlOldPosition
extends
GqlBasePosition
{
positionType
:
'
text
'
;
newLine
:
null
;
oldLine
:
number
;
}
export
type
GqlTextPosition
=
GqlOldPosition
|
GqlNewPosition
;
interface
GqlNotePermissions
{
resolveNote
:
boolean
;
adminNote
:
boolean
;
createNote
:
boolean
;
}
interface
GqlGenericNote
<
T
extends
GqlBasePosition
|
null
>
{
id
:
string
;
author
:
GqlUser
;
createdAt
:
string
;
system
:
boolean
;
body
:
string
;
// TODO: remove this once the SystemNote.vue doesn't require plain text body
bodyHtml
:
string
;
userPermissions
:
GqlNotePermissions
;
position
:
T
;
}
interface
GqlGenericDiscussion
<
T
extends
GqlNote
>
{
replyId
:
string
;
createdAt
:
string
;
resolved
:
boolean
;
resolvable
:
boolean
;
notes
:
Node
<
T
>
;
}
export
type
GqlTextDiffNote
=
GqlGenericNote
<
GqlTextPosition
>
;
type
GqlImageNote
=
GqlGenericNote
<
GqlImagePosition
>
;
export
type
GqlOverviewNote
=
GqlGenericNote
<
null
>
;
export
type
GqlNote
=
GqlTextDiffNote
|
GqlImageNote
|
GqlOverviewNote
;
export
type
GqlDiscussion
=
|
GqlGenericDiscussion
<
GqlTextDiffNote
>
|
GqlGenericDiscussion
<
GqlImageNote
>
|
GqlGenericDiscussion
<
GqlOverviewNote
>
;
export
type
GqlTextDiffDiscussion
=
GqlGenericDiscussion
<
GqlTextDiffNote
>
;
interface
GqlDiscussionsProject
{
mergeRequest
?:
{
discussions
:
Node
<
GqlDiscussion
>
;
};
issue
?:
{
discussions
:
Node
<
GqlDiscussion
>
;
};
}
interface
RestLabelEvent
{
label
:
unknown
;
body
:
string
;
...
...
@@ -375,10 +292,7 @@ export class GitLabNewService {
iid
:
String
(
issuable
.
iid
),
endCursor
,
};
const
result
=
await
this
.
client
.
request
<
GqlProjectResult
<
GqlDiscussionsProject
>>
(
query
,
options
,
);
const
result
=
await
this
.
client
.
request
<
GetDiscussionsQueryResult
>
(
query
,
options
);
assert
(
result
.
project
,
`Project
${
projectPath
}
was not found.`
);
const
discussions
=
result
.
project
.
issue
?.
discussions
||
result
.
project
.
mergeRequest
?.
discussions
;
...
...
src/gitlab/graphql/get_discussions.ts
浏览文件 @
452586c4
import
{
gql
}
from
'
graphql-request
'
;
import
{
noteDetailsFragment
}
from
'
./shared
'
;
import
{
noteDetailsFragment
,
Node
,
GqlProjectResult
,
GqlNote
,
GqlTextDiffNote
,
GqlOverviewNote
,
GqlImageNote
,
}
from
'
./shared
'
;
const
discussionsFragment
=
gql
`
${
noteDetailsFragment
}
...
...
@@ -59,3 +67,29 @@ export interface GetDiscussionsQueryOptions {
iid
:
string
;
endCursor
?:
string
;
}
interface
GqlGenericDiscussion
<
T
extends
GqlNote
>
{
replyId
:
string
;
createdAt
:
string
;
resolved
:
boolean
;
resolvable
:
boolean
;
notes
:
Node
<
T
>
;
}
export
type
GqlTextDiffDiscussion
=
GqlGenericDiscussion
<
GqlTextDiffNote
>
;
export
type
GqlDiscussion
=
|
GqlGenericDiscussion
<
GqlTextDiffNote
>
|
GqlGenericDiscussion
<
GqlImageNote
>
|
GqlGenericDiscussion
<
GqlOverviewNote
>
;
interface
GqlDiscussionsProject
{
mergeRequest
?:
{
discussions
:
Node
<
GqlDiscussion
>
;
};
issue
?:
{
discussions
:
Node
<
GqlDiscussion
>
;
};
}
export
type
GetDiscussionsQueryResult
=
GqlProjectResult
<
GqlDiscussionsProject
>
;
src/gitlab/graphql/shared.ts
浏览文件 @
452586c4
...
...
@@ -69,3 +69,73 @@ export interface GqlProject {
webUrl
:
string
;
group
?:
GqlGroup
;
}
export
interface
GqlProjectResult
<
T
>
{
project
?:
T
;
}
export
interface
Node
<
T
>
{
pageInfo
?:
{
hasNextPage
:
boolean
;
endCursor
:
string
;
};
nodes
:
T
[];
}
interface
GqlUser
{
avatarUrl
:
string
|
null
;
name
:
string
;
username
:
string
;
webUrl
:
string
;
}
export
interface
GqlBasePosition
{
diffRefs
:
{
baseSha
:
string
;
headSha
:
string
;
};
filePath
:
string
;
newPath
:
string
;
oldPath
:
string
;
}
interface
GqlImagePosition
extends
GqlBasePosition
{
positionType
:
'
image
'
;
newLine
:
null
;
oldLine
:
null
;
}
interface
GqlNewPosition
extends
GqlBasePosition
{
positionType
:
'
text
'
;
newLine
:
number
;
oldLine
:
null
;
}
interface
GqlOldPosition
extends
GqlBasePosition
{
positionType
:
'
text
'
;
newLine
:
null
;
oldLine
:
number
;
}
export
type
GqlTextPosition
=
GqlOldPosition
|
GqlNewPosition
;
interface
GqlNotePermissions
{
resolveNote
:
boolean
;
adminNote
:
boolean
;
createNote
:
boolean
;
}
export
interface
GqlGenericNote
<
T
extends
GqlBasePosition
|
null
>
{
id
:
string
;
author
:
GqlUser
;
createdAt
:
string
;
system
:
boolean
;
body
:
string
;
// TODO: remove this once the SystemNote.vue doesn't require plain text body
bodyHtml
:
string
;
userPermissions
:
GqlNotePermissions
;
position
:
T
;
}
export
type
GqlTextDiffNote
=
GqlGenericNote
<
GqlTextPosition
>
;
export
type
GqlImageNote
=
GqlGenericNote
<
GqlImagePosition
>
;
export
type
GqlOverviewNote
=
GqlGenericNote
<
null
>
;
export
type
GqlNote
=
GqlTextDiffNote
|
GqlImageNote
|
GqlOverviewNote
;
src/review/gitlab_comment.test.ts
浏览文件 @
452586c4
import
{
GitLabComment
}
from
'
./gitlab_comment
'
;
import
{
GitLabCommentThread
}
from
'
./gitlab_comment_thread
'
;
import
{
noteOnDiff
}
from
'
../../test/integration/fixtures/graphql/discussions.js
'
;
import
{
GqlTextDiffNote
}
from
'
../gitlab/g
itlab_new_service
'
;
import
{
GqlTextDiffNote
}
from
'
../gitlab/g
raphql/shared
'
;
describe
(
'
GitLabComment
'
,
()
=>
{
let
comment
:
GitLabComment
;
...
...
src/review/gitlab_comment.ts
浏览文件 @
452586c4
import
*
as
vscode
from
'
vscode
'
;
import
{
GqlTextDiffNote
}
from
'
../gitlab/g
itlab_new_service
'
;
import
{
GqlTextDiffNote
}
from
'
../gitlab/g
raphql/shared
'
;
import
{
GitLabCommentThread
}
from
'
./gitlab_comment_thread
'
;
interface
CommentOptions
{
...
...
src/review/gitlab_comment_thread.test.ts
浏览文件 @
452586c4
...
...
@@ -5,12 +5,10 @@ import {
noteOnDiff
,
}
from
'
../../test/integration/fixtures/graphql/discussions.js
'
;
import
{
GitLabComment
}
from
'
./gitlab_comment
'
;
import
{
GitLabNewService
,
GqlTextDiffDiscussion
,
GqlTextDiffNote
,
}
from
'
../gitlab/gitlab_new_service
'
;
import
{
GitLabNewService
}
from
'
../gitlab/gitlab_new_service
'
;
import
{
mr
}
from
'
../test_utils/entities
'
;
import
{
GqlTextDiffNote
}
from
'
../gitlab/graphql/shared
'
;
import
{
GqlTextDiffDiscussion
}
from
'
../gitlab/graphql/get_discussions
'
;
describe
(
'
GitLabCommentThread
'
,
()
=>
{
let
gitlabCommentThread
:
GitLabCommentThread
;
...
...
src/review/gitlab_comment_thread.ts
浏览文件 @
452586c4
import
*
as
vscode
from
'
vscode
'
;
import
*
as
assert
from
'
assert
'
;
import
{
GitLabNewService
,
GqlNote
,
GqlTextDiffDiscussion
,
GqlTextDiffNote
,
GqlTextPosition
,
}
from
'
../gitlab/gitlab_new_service
'
;
import
{
GitLabNewService
}
from
'
../gitlab/gitlab_new_service
'
;
import
{
GitLabComment
}
from
'
./gitlab_comment
'
;
import
{
toReviewUri
}
from
'
./review_uri
'
;
import
{
GqlTextDiffDiscussion
}
from
'
../gitlab/graphql/get_discussions
'
;
import
{
GqlNote
,
GqlTextDiffNote
,
GqlTextPosition
}
from
'
../gitlab/graphql/shared
'
;
const
firstNoteFrom
=
(
discussion
:
GqlTextDiffDiscussion
):
GqlTextDiffNote
=>
{
const
note
=
discussion
.
notes
.
nodes
[
0
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录