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
eb916365
Commit
eb916365
authored
4 years ago
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve usability of the links in the file listing
Closes
https://gitlab.com/gitlab-org/gitlab/-/issues/35172
parent
ef4a021f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
69 additions
and
107 deletions
+69
-107
app/assets/javascripts/repository/components/table/row.vue
app/assets/javascripts/repository/components/table/row.vue
+17
-19
app/assets/stylesheets/framework/files.scss
app/assets/stylesheets/framework/files.scss
+18
-0
spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap
...epository/components/table/__snapshots__/row_spec.js.snap
+32
-26
spec/frontend/repository/components/table/row_spec.js
spec/frontend/repository/components/table/row_spec.js
+2
-62
No files found.
app/assets/javascripts/repository/components/table/row.vue
View file @
eb916365
<
script
>
<
script
>
import
{
escapeRegExp
}
from
'
lodash
'
;
import
{
escapeRegExp
}
from
'
lodash
'
;
import
{
GlBadge
,
GlLink
,
GlSkeletonLoading
,
GlTooltipDirective
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlBadge
,
GlLink
,
GlSkeletonLoading
,
GlTooltipDirective
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
visitUrl
,
escapeFileUrl
}
from
'
~/lib/utils/url_utility
'
;
import
{
escapeFileUrl
}
from
'
~/lib/utils/url_utility
'
;
import
TimeagoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
TimeagoTooltip
from
'
~/vue_shared/components/time_ago_tooltip.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
{
getIconName
}
from
'
../../utils/icon
'
;
import
{
getIconName
}
from
'
../../utils/icon
'
;
...
@@ -117,39 +117,37 @@ export default {
...
@@ -117,39 +117,37 @@ export default {
return
this
.
commit
&&
this
.
commit
.
lockLabel
;
return
this
.
commit
&&
this
.
commit
.
lockLabel
;
},
},
},
},
methods
:
{
openRow
(
e
)
{
if
(
e
.
target
.
tagName
===
'
A
'
)
return
;
if
(
this
.
isFolder
&&
!
e
.
metaKey
)
{
this
.
$router
.
push
(
this
.
routerLinkTo
);
}
else
{
visitUrl
(
this
.
url
,
e
.
metaKey
);
}
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<tr
:class=
"`file_$
{id}`" class="tree-item" @click="openRow
">
<tr
class=
"tree-item
"
>
<td
class=
"tree-item-file-name"
>
<td
class=
"tree-item-file-name
cursor-default position-relative
"
>
<gl-loading-icon
<gl-loading-icon
v-if=
"path === loadingPath"
v-if=
"path === loadingPath"
size=
"sm"
size=
"sm"
inline
inline
class=
"d-inline-block align-text-bottom fa-fw"
class=
"d-inline-block align-text-bottom fa-fw"
/>
/>
<i
v-else
:aria-label=
"type"
role=
"img"
:class=
"iconName"
class=
"fa fa-fw"
></i>
<component
<component
:is=
"linkComponent"
:is=
"linkComponent"
ref=
"link"
ref=
"link"
:to=
"routerLinkTo"
:to=
"routerLinkTo"
:href=
"url"
:href=
"url"
class=
"str-truncated"
:class=
"
{
'is-submodule': isSubmodule,
}"
class="tree-item-link str-truncated"
data-qa-selector="file_name_link"
data-qa-selector="file_name_link"
>
>
{{
fullPath
}}
<i
v-if=
"!loadingPath"
:aria-label=
"type"
role=
"img"
:class=
"iconName"
class=
"fa fa-fw mr-1"
></i
><span
class=
"position-relative"
>
{{
fullPath
}}
</span>
</component>
</component>
<!-- eslint-disable-next-line @gitlab/vue-require-i18n-strings -->
<!-- eslint-disable-next-line @gitlab/vue-require-i18n-strings -->
<gl-badge
v-if=
"lfsOid"
variant=
"default"
class=
"label-lfs ml-1"
>
LFS
</gl-badge>
<gl-badge
v-if=
"lfsOid"
variant=
"default"
class=
"label-lfs ml-1"
>
LFS
</gl-badge>
...
@@ -165,7 +163,7 @@ export default {
...
@@ -165,7 +163,7 @@ export default {
class=
"ml-2 vertical-align-middle"
class=
"ml-2 vertical-align-middle"
/>
/>
</td>
</td>
<td
class=
"d-none d-sm-table-cell tree-commit"
>
<td
class=
"d-none d-sm-table-cell tree-commit
cursor-default
"
>
<gl-link
<gl-link
v-if=
"commit"
v-if=
"commit"
:href=
"commit.commitPath"
:href=
"commit.commitPath"
...
@@ -176,7 +174,7 @@ export default {
...
@@ -176,7 +174,7 @@ export default {
</gl-link>
</gl-link>
<gl-skeleton-loading
v-else
:lines=
"1"
class=
"h-auto"
/>
<gl-skeleton-loading
v-else
:lines=
"1"
class=
"h-auto"
/>
</td>
</td>
<td
class=
"tree-time-ago text-right"
>
<td
class=
"tree-time-ago text-right
cursor-default
"
>
<timeago-tooltip
v-if=
"commit"
:time=
"commit.committedDate"
/>
<timeago-tooltip
v-if=
"commit"
:time=
"commit.committedDate"
/>
<gl-skeleton-loading
v-else
:lines=
"1"
class=
"ml-auto h-auto w-50"
/>
<gl-skeleton-loading
v-else
:lines=
"1"
class=
"ml-auto h-auto w-50"
/>
</td>
</td>
...
...
This diff is collapsed.
Click to expand it.
app/assets/stylesheets/framework/files.scss
View file @
eb916365
...
@@ -511,3 +511,21 @@ span.idiff {
...
@@ -511,3 +511,21 @@ span.idiff {
.code-navigation-popover
{
.code-navigation-popover
{
max-width
:
450px
;
max-width
:
450px
;
}
}
.tree-item-link
{
&
:not
(
.is-submodule
)
{
span
{
z-index
:
2
;
}
&
:
:
before
{
content
:
''
;
position
:
absolute
;
left
:
0
;
top
:
0
;
width
:
100%
;
height
:
100%
;
z-index
:
1
;
}
}
}
This diff is collapsed.
Click to expand it.
spec/frontend/repository/components/table/__snapshots__/row_spec.js.snap
View file @
eb916365
...
@@ -2,25 +2,28 @@
...
@@ -2,25 +2,28 @@
exports[`Repository table row component renders table row 1`] = `
exports[`Repository table row component renders table row 1`] = `
<tr
<tr
class="tree-item
file_1
"
class="tree-item"
>
>
<td
<td
class="tree-item-file-name"
class="tree-item-file-name
cursor-default position-relative
"
>
>
<i
<!---->
aria-label="file"
class="fa fa-fw fa-file-text-o"
role="img"
/>
<a
<a
class="str-truncated"
class="
tree-item-link
str-truncated"
data-qa-selector="file_name_link"
data-qa-selector="file_name_link"
href="https://test.com"
href="https://test.com"
>
>
<i
test
aria-label="file"
class="fa fa-fw mr-1 fa-file-text-o"
role="img"
/>
<span
class="position-relative"
>
test
</span>
</a>
</a>
<!---->
<!---->
...
@@ -31,7 +34,7 @@ exports[`Repository table row component renders table row 1`] = `
...
@@ -31,7 +34,7 @@ exports[`Repository table row component renders table row 1`] = `
</td>
</td>
<td
<td
class="d-none d-sm-table-cell tree-commit"
class="d-none d-sm-table-cell tree-commit
cursor-default
"
>
>
<gl-skeleton-loading-stub
<gl-skeleton-loading-stub
class="h-auto"
class="h-auto"
...
@@ -40,7 +43,7 @@ exports[`Repository table row component renders table row 1`] = `
...
@@ -40,7 +43,7 @@ exports[`Repository table row component renders table row 1`] = `
</td>
</td>
<td
<td
class="tree-time-ago text-right"
class="tree-time-ago text-right
cursor-default
"
>
>
<gl-skeleton-loading-stub
<gl-skeleton-loading-stub
class="ml-auto h-auto w-50"
class="ml-auto h-auto w-50"
...
@@ -52,25 +55,28 @@ exports[`Repository table row component renders table row 1`] = `
...
@@ -52,25 +55,28 @@ exports[`Repository table row component renders table row 1`] = `
exports[`Repository table row component renders table row for path with special character 1`] = `
exports[`Repository table row component renders table row for path with special character 1`] = `
<tr
<tr
class="tree-item
file_1
"
class="tree-item"
>
>
<td
<td
class="tree-item-file-name"
class="tree-item-file-name
cursor-default position-relative
"
>
>
<i
<!---->
aria-label="file"
class="fa fa-fw fa-file-text-o"
role="img"
/>
<a
<a
class="str-truncated"
class="
tree-item-link
str-truncated"
data-qa-selector="file_name_link"
data-qa-selector="file_name_link"
href="https://test.com"
href="https://test.com"
>
>
<i
test
aria-label="file"
class="fa fa-fw mr-1 fa-file-text-o"
role="img"
/>
<span
class="position-relative"
>
test
</span>
</a>
</a>
<!---->
<!---->
...
@@ -81,7 +87,7 @@ exports[`Repository table row component renders table row for path with special
...
@@ -81,7 +87,7 @@ exports[`Repository table row component renders table row for path with special
</td>
</td>
<td
<td
class="d-none d-sm-table-cell tree-commit"
class="d-none d-sm-table-cell tree-commit
cursor-default
"
>
>
<gl-skeleton-loading-stub
<gl-skeleton-loading-stub
class="h-auto"
class="h-auto"
...
@@ -90,7 +96,7 @@ exports[`Repository table row component renders table row for path with special
...
@@ -90,7 +96,7 @@ exports[`Repository table row component renders table row for path with special
</td>
</td>
<td
<td
class="tree-time-ago text-right"
class="tree-time-ago text-right
cursor-default
"
>
>
<gl-skeleton-loading-stub
<gl-skeleton-loading-stub
class="ml-auto h-auto w-50"
class="ml-auto h-auto w-50"
...
...
This diff is collapsed.
Click to expand it.
spec/frontend/repository/components/table/row_spec.js
View file @
eb916365
import
{
shallowMount
,
RouterLinkStub
}
from
'
@vue/test-utils
'
;
import
{
shallowMount
,
RouterLinkStub
}
from
'
@vue/test-utils
'
;
import
{
GlBadge
,
GlLink
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
GlBadge
,
GlLink
,
GlLoadingIcon
}
from
'
@gitlab/ui
'
;
import
{
visitUrl
}
from
'
~/lib/utils/url_utility
'
;
import
TableRow
from
'
~/repository/components/table/row.vue
'
;
import
TableRow
from
'
~/repository/components/table/row.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
import
Icon
from
'
~/vue_shared/components/icon.vue
'
;
jest
.
mock
(
'
~/lib/utils/url_utility
'
,
()
=>
({
...
jest
.
requireActual
(
'
~/lib/utils/url_utility
'
),
visitUrl
:
jest
.
fn
(),
}));
let
vm
;
let
vm
;
let
$router
;
let
$router
;
...
@@ -87,31 +81,6 @@ describe('Repository table row component', () => {
...
@@ -87,31 +81,6 @@ describe('Repository table row component', () => {
});
});
});
});
it
.
each
`
type | pushes
${
'
tree
'
}
|
${
true
}
${
'
file
'
}
|
${
false
}
${
'
commit
'
}
|
${
false
}
`
(
'
pushes new router if type $type is tree
'
,
({
type
,
pushes
})
=>
{
factory
({
id
:
'
1
'
,
sha
:
'
123
'
,
path
:
'
test
'
,
type
,
currentPath
:
'
/
'
,
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
vm
.
trigger
(
'
click
'
);
if
(
pushes
)
{
expect
(
$router
.
push
).
toHaveBeenCalledWith
({
path
:
'
/-/tree/master/test
'
});
}
else
{
expect
(
$router
.
push
).
not
.
toHaveBeenCalled
();
}
});
});
it
.
each
`
it
.
each
`
path
path
${
'
test#
'
}
${
'
test#
'
}
...
@@ -132,7 +101,7 @@ describe('Repository table row component', () => {
...
@@ -132,7 +101,7 @@ describe('Repository table row component', () => {
});
});
});
});
it
(
'
pushes new route
for directory with hash
'
,
()
=>
{
it
(
'
renders link
for directory with hash
'
,
()
=>
{
factory
({
factory
({
id
:
'
1
'
,
id
:
'
1
'
,
sha
:
'
123
'
,
sha
:
'
123
'
,
...
@@ -142,36 +111,7 @@ describe('Repository table row component', () => {
...
@@ -142,36 +111,7 @@ describe('Repository table row component', () => {
});
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
vm
.
trigger
(
'
click
'
);
expect
(
vm
.
find
(
'
.tree-item-link
'
).
props
(
'
to
'
)).
toEqual
({
path
:
'
/-/tree/master/test%23
'
});
expect
(
$router
.
push
).
toHaveBeenCalledWith
({
path
:
'
/-/tree/master/test%23
'
});
});
});
it
.
each
`
type | pushes
${
'
tree
'
}
|
${
true
}
${
'
file
'
}
|
${
false
}
${
'
commit
'
}
|
${
false
}
`
(
'
calls visitUrl if $type is not tree
'
,
({
type
,
pushes
})
=>
{
factory
({
id
:
'
1
'
,
sha
:
'
123
'
,
path
:
'
test
'
,
type
,
currentPath
:
'
/
'
,
});
return
vm
.
vm
.
$nextTick
().
then
(()
=>
{
vm
.
trigger
(
'
click
'
);
if
(
pushes
)
{
expect
(
visitUrl
).
not
.
toHaveBeenCalled
();
}
else
{
const
[
url
,
external
]
=
visitUrl
.
mock
.
calls
[
0
];
expect
(
url
).
toBe
(
'
https://test.com
'
);
expect
(
external
).
toBeFalsy
();
}
});
});
});
});
...
...
This diff is collapsed.
Click to expand it.
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