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
9c7902f6
Commit
9c7902f6
authored
Apr 06, 2022
by
Jacques
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Address code review comments
Addressed general code review comments
parent
c191dfbb
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
24 deletions
+36
-24
app/assets/javascripts/code_navigation/store/actions.js
app/assets/javascripts/code_navigation/store/actions.js
+2
-2
app/assets/javascripts/code_navigation/utils/index.js
app/assets/javascripts/code_navigation/utils/index.js
+1
-1
app/assets/stylesheets/framework/files.scss
app/assets/stylesheets/framework/files.scss
+0
-4
spec/frontend/code_navigation/store/actions_spec.js
spec/frontend/code_navigation/store/actions_spec.js
+10
-6
spec/frontend/code_navigation/utils/index_spec.js
spec/frontend/code_navigation/utils/index_spec.js
+23
-11
No files found.
app/assets/javascripts/code_navigation/store/actions.js
View file @
9c7902f6
...
@@ -22,7 +22,7 @@ export default {
...
@@ -22,7 +22,7 @@ export default {
...
d
,
...
d
,
definitionLineNumber
:
parseInt
(
d
.
definition_path
?.
split
(
'
#L
'
).
pop
()
||
0
,
10
),
definitionLineNumber
:
parseInt
(
d
.
definition_path
?.
split
(
'
#L
'
).
pop
()
||
0
,
10
),
};
};
addInteractionClass
(
path
,
d
,
state
.
wrapTextNodes
);
addInteractionClass
(
{
path
,
d
,
wrapTextNodes
:
state
.
wrapTextNodes
}
);
}
}
return
acc
;
return
acc
;
},
{});
},
{});
...
@@ -35,7 +35,7 @@ export default {
...
@@ -35,7 +35,7 @@ export default {
showBlobInteractionZones
({
state
},
path
)
{
showBlobInteractionZones
({
state
},
path
)
{
if
(
state
.
data
&&
state
.
data
[
path
])
{
if
(
state
.
data
&&
state
.
data
[
path
])
{
Object
.
values
(
state
.
data
[
path
]).
forEach
((
d
)
=>
Object
.
values
(
state
.
data
[
path
]).
forEach
((
d
)
=>
addInteractionClass
(
path
,
d
,
state
.
wrapTextNodes
),
addInteractionClass
(
{
path
,
d
,
wrapTextNodes
:
state
.
wrapTextNodes
}
),
);
);
}
}
},
},
...
...
app/assets/javascripts/code_navigation/utils/index.js
View file @
9c7902f6
...
@@ -5,7 +5,7 @@ export const cachedData = new Map();
...
@@ -5,7 +5,7 @@ export const cachedData = new Map();
export
const
getCurrentHoverElement
=
()
=>
cachedData
.
get
(
'
current
'
);
export
const
getCurrentHoverElement
=
()
=>
cachedData
.
get
(
'
current
'
);
export
const
setCurrentHoverElement
=
(
el
)
=>
cachedData
.
set
(
'
current
'
,
el
);
export
const
setCurrentHoverElement
=
(
el
)
=>
cachedData
.
set
(
'
current
'
,
el
);
export
const
addInteractionClass
=
(
path
,
d
,
wrapTextNodes
)
=>
{
export
const
addInteractionClass
=
(
{
path
,
d
,
wrapTextNodes
}
)
=>
{
const
lineNumber
=
d
.
start_line
+
1
;
const
lineNumber
=
d
.
start_line
+
1
;
const
lines
=
document
const
lines
=
document
.
querySelector
(
`[data-path="
${
path
}
"]`
)
.
querySelector
(
`[data-path="
${
path
}
"]`
)
...
...
app/assets/stylesheets/framework/files.scss
View file @
9c7902f6
...
@@ -506,10 +506,6 @@ span.idiff {
...
@@ -506,10 +506,6 @@ span.idiff {
text-indent
:
-
$grid-size
*
2
;
text-indent
:
-
$grid-size
*
2
;
}
}
.blob-viewer
.code-navigation-popover
.code
{
text-indent
:
$grid-size
*
2
;
}
.tree-item-link
{
.tree-item-link
{
&
:not
(
.is-submodule
)
{
&
:not
(
.is-submodule
)
{
span
{
span
{
...
...
spec/frontend/code_navigation/store/actions_spec.js
View file @
9c7902f6
...
@@ -111,15 +111,15 @@ describe('Code navigation actions', () => {
...
@@ -111,15 +111,15 @@ describe('Code navigation actions', () => {
[],
[],
)
)
.
then
(()
=>
{
.
then
(()
=>
{
expect
(
addInteractionClass
).
toHaveBeenCalledWith
(
expect
(
addInteractionClass
).
toHaveBeenCalledWith
(
{
'
index.js
'
,
path
:
'
index.js
'
,
{
d
:
{
start_line
:
0
,
start_line
:
0
,
start_char
:
0
,
start_char
:
0
,
hover
:
{
value
:
'
123
'
},
hover
:
{
value
:
'
123
'
},
},
},
wrapTextNodes
,
wrapTextNodes
,
);
}
);
})
})
.
then
(
done
)
.
then
(
done
)
.
catch
(
done
.
fail
);
.
catch
(
done
.
fail
);
...
@@ -157,8 +157,12 @@ describe('Code navigation actions', () => {
...
@@ -157,8 +157,12 @@ describe('Code navigation actions', () => {
expect
(
addInteractionClass
).
toHaveBeenCalled
();
expect
(
addInteractionClass
).
toHaveBeenCalled
();
expect
(
addInteractionClass
.
mock
.
calls
.
length
).
toBe
(
2
);
expect
(
addInteractionClass
.
mock
.
calls
.
length
).
toBe
(
2
);
expect
(
addInteractionClass
.
mock
.
calls
[
0
]).
toEqual
([
'
index.js
'
,
'
test
'
,
wrapTextNodes
]);
expect
(
addInteractionClass
.
mock
.
calls
[
0
]).
toEqual
([
expect
(
addInteractionClass
.
mock
.
calls
[
1
]).
toEqual
([
'
index.js
'
,
'
console.log
'
,
wrapTextNodes
]);
{
path
:
'
index.js
'
,
d
:
'
test
'
,
wrapTextNodes
},
]);
expect
(
addInteractionClass
.
mock
.
calls
[
1
]).
toEqual
([
{
path
:
'
index.js
'
,
d
:
'
console.log
'
,
wrapTextNodes
},
]);
});
});
it
(
'
does not call addInteractionClass when no data exists
'
,
()
=>
{
it
(
'
does not call addInteractionClass when no data exists
'
,
()
=>
{
...
...
spec/frontend/code_navigation/utils/index_spec.js
View file @
9c7902f6
...
@@ -49,7 +49,7 @@ describe('addInteractionClass', () => {
...
@@ -49,7 +49,7 @@ describe('addInteractionClass', () => {
`
(
`
(
'
it sets code navigation attributes for line $line and character $char
'
,
'
it sets code navigation attributes for line $line and character $char
'
,
({
line
,
char
,
index
})
=>
{
({
line
,
char
,
index
})
=>
{
addInteractionClass
(
'
index.js
'
,
{
start_line
:
line
,
start_char
:
char
});
addInteractionClass
(
{
path
:
'
index.js
'
,
d
:
{
start_line
:
line
,
start_char
:
char
}
});
expect
(
document
.
querySelectorAll
(
`#LC
${
line
+
1
}
span`
)[
index
].
classList
).
toContain
(
expect
(
document
.
querySelectorAll
(
`#LC
${
line
+
1
}
span`
)[
index
].
classList
).
toContain
(
'
js-code-navigation
'
,
'
js-code-navigation
'
,
...
@@ -57,18 +57,30 @@ describe('addInteractionClass', () => {
...
@@ -57,18 +57,30 @@ describe('addInteractionClass', () => {
},
},
);
);
it
(
'
wraps text nodes and spaces
'
,
()
=>
{
describe
(
'
wrapTextNodes
'
,
()
=>
{
setFixtures
(
beforeEach
(()
=>
{
'
<div data-path="index.js"><div class="blob-content"><div id="LC1" class="line"> Text </div></div></div>
'
,
setFixtures
(
);
'
<div data-path="index.js"><div class="blob-content"><div id="LC1" class="line"> Text </div></div></div>
'
,
);
});
const
params
=
{
path
:
'
index.js
'
,
d
:
{
start_line
:
0
,
start_char
:
0
}
};
const
findAllSpans
=
()
=>
document
.
querySelectorAll
(
'
#LC1 span
'
);
addInteractionClass
(
'
index.js
'
,
{
start_line
:
0
,
start_char
:
0
},
true
);
it
(
'
does not wrap text nodes by default
'
,
()
=>
{
addInteractionClass
(
params
);
const
spans
=
findAllSpans
();
expect
(
spans
.
length
).
toBe
(
0
);
});
const
spans
=
document
.
querySelectorAll
(
`#LC1 span`
);
it
(
'
wraps text nodes if wrapTextNodes is true
'
,
()
=>
{
addInteractionClass
({
...
params
,
wrapTextNodes
:
true
});
const
spans
=
findAllSpans
();
expect
(
spans
.
length
).
toBe
(
3
);
expect
(
spans
.
length
).
toBe
(
3
);
expect
(
spans
[
0
].
textContent
).
toBe
(
'
'
);
expect
(
spans
[
0
].
textContent
).
toBe
(
'
'
);
expect
(
spans
[
1
].
textContent
).
toBe
(
'
Text
'
);
expect
(
spans
[
1
].
textContent
).
toBe
(
'
Text
'
);
expect
(
spans
[
2
].
textContent
).
toBe
(
'
'
);
expect
(
spans
[
2
].
textContent
).
toBe
(
'
'
);
});
});
});
});
});
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