Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7e390dcc
Commit
7e390dcc
authored
Aug 13, 2018
by
Tim Zallmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added constants for Render values + Optimised for Loop
parent
53468a77
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
8 deletions
+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
No files found.
app/assets/javascripts/diffs/constants.js
View file @
7e390dcc
...
@@ -25,3 +25,6 @@ export const CONTEXT_LINE_CLASS_NAME = 'diff-expanded';
...
@@ -25,3 +25,6 @@ export const CONTEXT_LINE_CLASS_NAME = 'diff-expanded';
export
const
UNFOLD_COUNT
=
20
;
export
const
UNFOLD_COUNT
=
20
;
export
const
COUNT_OF_AVATARS_IN_GUTTER
=
3
;
export
const
COUNT_OF_AVATARS_IN_GUTTER
=
3
;
export
const
LENGTH_OF_AVATAR_TOOLTIP
=
17
;
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
View file @
7e390dcc
...
@@ -2,6 +2,7 @@ import Vue from 'vue';
...
@@ -2,6 +2,7 @@ import Vue from 'vue';
import
_
from
'
underscore
'
;
import
_
from
'
underscore
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
import
{
findDiffFile
,
addLineReferences
,
removeMatchLine
,
addContextLines
}
from
'
./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
'
;
import
*
as
types
from
'
./mutation_types
'
;
export
default
{
export
default
{
...
@@ -17,31 +18,40 @@ export default {
...
@@ -17,31 +18,40 @@ export default {
[
types
.
SET_DIFF_DATA
](
state
,
data
)
{
[
types
.
SET_DIFF_DATA
](
state
,
data
)
{
const
diffData
=
convertObjectPropsToCamelCase
(
data
,
{
deep
:
true
});
const
diffData
=
convertObjectPropsToCamelCase
(
data
,
{
deep
:
true
});
let
showingLines
=
0
;
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
)
{
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
// eslint-disable-next-line no-param-reassign
if
(
line
.
left
)
delete
line
.
left
.
text
;
if
(
line
.
left
)
delete
line
.
left
.
text
;
// eslint-disable-next-line no-param-reassign
// eslint-disable-next-line no-param-reassign
if
(
line
.
right
)
delete
line
.
right
.
text
;
if
(
line
.
right
)
delete
line
.
right
.
text
;
}
);
}
}
}
if
(
file
.
highlightedDiffLines
)
{
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
// eslint-disable-next-line no-param-reassign
delete
line
.
text
;
delete
line
.
text
;
}
);
}
}
}
if
(
file
.
highlightedDiffLines
)
{
if
(
file
.
highlightedDiffLines
)
{
showingLines
+=
file
.
parallelDiffLines
.
length
;
showingLines
+=
file
.
parallelDiffLines
.
length
;
}
}
Object
.
assign
(
file
,
{
Object
.
assign
(
file
,
{
renderIt
:
showingLines
<
200
,
renderIt
:
showingLines
<
LINES_TO_BE_RENDERED_DIRECTLY
,
collapsed
:
file
.
text
&&
showingLines
>
2000
,
collapsed
:
file
.
text
&&
showingLines
>
MAX_LINES_TO_BE_RENDERED
,
});
});
}
);
}
Object
.
assign
(
state
,
{
Object
.
assign
(
state
,
{
...
diffData
,
...
diffData
,
...
...
spec/javascripts/diffs/store/mutations_spec.js
View file @
7e390dcc
import
mutations
from
'
~/diffs/store/mutations
'
;
import
mutations
from
'
~/diffs/store/mutations
'
;
import
*
as
types
from
'
~/diffs/store/mutation_types
'
;
import
*
as
types
from
'
~/diffs/store/mutation_types
'
;
import
{
INLINE_DIFF_VIEW_TYPE
}
from
'
~/diffs/constants
'
;
import
{
INLINE_DIFF_VIEW_TYPE
}
from
'
~/diffs/constants
'
;
import
diffFileMockData
from
'
../mock_data/diff_file
'
;
describe
(
'
DiffsStoreMutations
'
,
()
=>
{
describe
(
'
DiffsStoreMutations
'
,
()
=>
{
describe
(
'
SET_BASE_CONFIG
'
,
()
=>
{
describe
(
'
SET_BASE_CONFIG
'
,
()
=>
{
...
@@ -24,6 +25,23 @@ describe('DiffsStoreMutations', () => {
...
@@ -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
'
,
()
=>
{
describe
(
'
SET_DIFF_VIEW_TYPE
'
,
()
=>
{
it
(
'
should set diff view type properly
'
,
()
=>
{
it
(
'
should set diff view type properly
'
,
()
=>
{
const
state
=
{};
const
state
=
{};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment