Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
gitlab-foss
提交
7e390dcc
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,发现更多精彩内容 >>
提交
7e390dcc
编写于
8月 13, 2018
作者:
T
Tim Zallmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added constants for Render values + Optimised for Loop
上级
53468a77
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
39 addition
and
8 deletion
+39
-8
app/assets/javascripts/diffs/constants.js
app/assets/javascripts/diffs/constants.js
+3
-0
app/assets/javascripts/diffs/store/mutations.js
app/assets/javascripts/diffs/store/mutations.js
+18
-8
spec/javascripts/diffs/store/mutations_spec.js
spec/javascripts/diffs/store/mutations_spec.js
+18
-0
未找到文件。
app/assets/javascripts/diffs/constants.js
浏览文件 @
7e390dcc
...
...
@@ -25,3 +25,6 @@ export const CONTEXT_LINE_CLASS_NAME = 'diff-expanded';
export
const
UNFOLD_COUNT
=
20
;
export
const
COUNT_OF_AVATARS_IN_GUTTER
=
3
;
export
const
LENGTH_OF_AVATAR_TOOLTIP
=
17
;
export
const
LINES_TO_BE_RENDERED_DIRECTLY
=
100
;
export
const
MAX_LINES_TO_BE_RENDERED
=
2000
;
app/assets/javascripts/diffs/store/mutations.js
浏览文件 @
7e390dcc
...
...
@@ -2,6 +2,7 @@ import Vue from 'vue';
import
_
from
'
underscore
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
findDiffFile
,
addLineReferences
,
removeMatchLine
,
addContextLines
}
from
'
./utils
'
;
import
{
LINES_TO_BE_RENDERED_DIRECTLY
,
MAX_LINES_TO_BE_RENDERED
}
from
'
../constants
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
default
{
...
...
@@ -17,31 +18,40 @@ export default {
[
types
.
SET_DIFF_DATA
](
state
,
data
)
{
const
diffData
=
convertObjectPropsToCamelCase
(
data
,
{
deep
:
true
});
let
showingLines
=
0
;
diffData
.
diffFiles
.
forEach
(
file
=>
{
const
filesLength
=
diffData
.
diffFiles
.
length
;
let
i
;
for
(
i
=
0
;
i
<
filesLength
;
i
+=
1
)
{
const
file
=
diffData
.
diffFiles
[
i
];
if
(
file
.
parallelDiffLines
)
{
file
.
parallelDiffLines
.
forEach
(
line
=>
{
const
linesLength
=
file
.
parallelDiffLines
.
length
;
let
u
=
0
;
for
(
u
=
0
;
u
<
linesLength
;
u
+=
1
)
{
const
line
=
file
.
parallelDiffLines
[
u
];
// eslint-disable-next-line no-param-reassign
if
(
line
.
left
)
delete
line
.
left
.
text
;
// eslint-disable-next-line no-param-reassign
if
(
line
.
right
)
delete
line
.
right
.
text
;
}
);
}
}
if
(
file
.
highlightedDiffLines
)
{
file
.
highlightedDiffLines
.
forEach
(
line
=>
{
const
linesLength
=
file
.
highlightedDiffLines
.
length
;
let
u
=
0
;
for
(
u
=
0
;
u
<
linesLength
;
u
+=
1
)
{
const
line
=
file
.
highlightedDiffLines
[
u
];
// eslint-disable-next-line no-param-reassign
delete
line
.
text
;
}
);
}
}
if
(
file
.
highlightedDiffLines
)
{
showingLines
+=
file
.
parallelDiffLines
.
length
;
}
Object
.
assign
(
file
,
{
renderIt
:
showingLines
<
200
,
collapsed
:
file
.
text
&&
showingLines
>
2000
,
renderIt
:
showingLines
<
LINES_TO_BE_RENDERED_DIRECTLY
,
collapsed
:
file
.
text
&&
showingLines
>
MAX_LINES_TO_BE_RENDERED
,
});
}
);
}
Object
.
assign
(
state
,
{
...
diffData
,
...
...
spec/javascripts/diffs/store/mutations_spec.js
浏览文件 @
7e390dcc
import
mutations
from
'
~/diffs/store/mutations
'
;
import
*
as
types
from
'
~/diffs/store/mutation_types
'
;
import
{
INLINE_DIFF_VIEW_TYPE
}
from
'
~/diffs/constants
'
;
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
describe
(
'
DiffsStoreMutations
'
,
()
=>
{
describe
(
'
SET_BASE_CONFIG
'
,
()
=>
{
...
...
@@ -24,6 +25,23 @@ describe('DiffsStoreMutations', () => {
});
});
describe
(
'
SET_DIFF_DATA
'
,
()
=>
{
it
(
'
should set diff data type properly
'
,
()
=>
{
const
state
=
{};
const
diffMock
=
{
diff_files
:
[
diffFileMockData
],
};
mutations
[
types
.
SET_DIFF_DATA
](
state
,
diffMock
);
const
firstLine
=
state
.
diffFiles
[
0
].
parallelDiffLines
[
0
];
expect
(
firstLine
.
right
.
text
).
toBeUndefined
();
expect
(
state
.
diffFiles
[
0
].
renderIt
).
toEqual
(
true
);
expect
(
state
.
diffFiles
[
0
].
collapsed
).
toEqual
(
false
);
});
});
describe
(
'
SET_DIFF_VIEW_TYPE
'
,
()
=>
{
it
(
'
should set diff view type properly
'
,
()
=>
{
const
state
=
{};
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录