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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
d95465db
Commit
d95465db
authored
Oct 15, 2018
by
Phil Hughes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dynamically truncate the text in the file row
parent
2d00e7fc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
15 deletions
+27
-15
app/assets/javascripts/diffs/components/tree_list.vue
app/assets/javascripts/diffs/components/tree_list.vue
+2
-1
app/assets/javascripts/diffs/store/utils.js
app/assets/javascripts/diffs/store/utils.js
+0
-13
app/assets/javascripts/vue_shared/components/file_row.vue
app/assets/javascripts/vue_shared/components/file_row.vue
+25
-1
No files found.
app/assets/javascripts/diffs/components/tree_list.vue
View file @
d95465db
...
@@ -35,7 +35,7 @@ export default {
...
@@ -35,7 +35,7 @@ export default {
return
'
name
'
;
return
'
name
'
;
}
}
return
'
truncatedP
ath
'
;
return
'
p
ath
'
;
},
},
},
},
methods
:
{
methods
:
{
...
@@ -131,6 +131,7 @@ export default {
...
@@ -131,6 +131,7 @@ export default {
:extra-component=
"$options.FileRowStats"
:extra-component=
"$options.FileRowStats"
:show-changed-icon=
"true"
:show-changed-icon=
"true"
:display-text-key=
"rowDisplayTextKey"
:display-text-key=
"rowDisplayTextKey"
:should-truncate-start=
"true"
@
toggleTreeOpen=
"toggleTreeOpen"
@
toggleTreeOpen=
"toggleTreeOpen"
@
clickFile=
"scrollToFile"
@
clickFile=
"scrollToFile"
/>
/>
...
...
app/assets/javascripts/diffs/store/utils.js
View file @
d95465db
...
@@ -275,18 +275,6 @@ export function isDiscussionApplicableToLine({ discussion, diffPosition, latestD
...
@@ -275,18 +275,6 @@ export function isDiscussionApplicableToLine({ discussion, diffPosition, latestD
return
latestDiff
&&
discussion
.
active
&&
lineCode
===
discussion
.
line_code
;
return
latestDiff
&&
discussion
.
active
&&
lineCode
===
discussion
.
line_code
;
}
}
export
const
truncatedName
=
path
=>
{
const
maxLength
=
30
;
if
(
path
.
length
>
maxLength
)
{
const
start
=
path
.
length
-
maxLength
;
const
end
=
start
+
maxLength
;
return
`...
${
path
.
slice
(
start
,
end
)}
`
;
}
return
path
;
};
export
const
generateTreeList
=
files
=>
export
const
generateTreeList
=
files
=>
files
.
reduce
(
files
.
reduce
(
(
acc
,
file
)
=>
{
(
acc
,
file
)
=>
{
...
@@ -302,7 +290,6 @@ export const generateTreeList = files =>
...
@@ -302,7 +290,6 @@ export const generateTreeList = files =>
acc
.
treeEntries
[
path
]
=
{
acc
.
treeEntries
[
path
]
=
{
key
:
path
,
key
:
path
,
path
,
path
,
truncatedPath
:
truncatedName
(
path
),
name
,
name
,
type
,
type
,
tree
:
[],
tree
:
[],
...
...
app/assets/javascripts/vue_shared/components/file_row.vue
View file @
d95465db
...
@@ -39,10 +39,16 @@ export default {
...
@@ -39,10 +39,16 @@ export default {
required
:
false
,
required
:
false
,
default
:
'
name
'
,
default
:
'
name
'
,
},
},
shouldTruncateStart
:
{
type
:
Boolean
,
required
:
false
,
default
:
false
,
},
},
},
data
()
{
data
()
{
return
{
return
{
mouseOver
:
false
,
mouseOver
:
false
,
truncateStart
:
0
,
};
};
},
},
computed
:
{
computed
:
{
...
@@ -65,6 +71,13 @@ export default {
...
@@ -65,6 +71,13 @@ export default {
'
is-open
'
:
this
.
file
.
opened
,
'
is-open
'
:
this
.
file
.
opened
,
};
};
},
},
outputText
()
{
const
text
=
this
.
file
[
this
.
displayTextKey
];
if
(
this
.
truncateStart
===
0
)
return
text
;
return
`...
${
text
.
substring
(
this
.
truncateStart
,
text
.
length
)}
`
;
},
},
},
watch
:
{
watch
:
{
'
file.active
'
:
function
fileActiveWatch
(
active
)
{
'
file.active
'
:
function
fileActiveWatch
(
active
)
{
...
@@ -77,6 +90,15 @@ export default {
...
@@ -77,6 +90,15 @@ export default {
if
(
this
.
hasPathAtCurrentRoute
())
{
if
(
this
.
hasPathAtCurrentRoute
())
{
this
.
scrollIntoView
(
true
);
this
.
scrollIntoView
(
true
);
}
}
if
(
this
.
shouldTruncateStart
)
{
const
{
scrollWidth
,
offsetWidth
}
=
this
.
$refs
.
textOutput
;
const
textOverflow
=
scrollWidth
-
offsetWidth
;
if
(
textOverflow
>
0
)
{
this
.
truncateStart
=
Math
.
ceil
(
textOverflow
/
5
)
+
3
;
}
}
},
},
methods
:
{
methods
:
{
toggleTreeOpen
(
path
)
{
toggleTreeOpen
(
path
)
{
...
@@ -144,6 +166,7 @@ export default {
...
@@ -144,6 +166,7 @@ export default {
class=
"file-row-name-container"
class=
"file-row-name-container"
>
>
<span
<span
ref=
"textOutput"
:style=
"levelIndentation"
:style=
"levelIndentation"
class=
"file-row-name str-truncated"
class=
"file-row-name str-truncated"
>
>
...
@@ -161,7 +184,7 @@ export default {
...
@@ -161,7 +184,7 @@ export default {
:size=
"16"
:size=
"16"
class=
"append-right-5"
class=
"append-right-5"
/>
/>
{{
file
[
displayTextKey
]
}}
{{
outputText
}}
</span>
</span>
<component
<component
:is=
"extraComponent"
:is=
"extraComponent"
...
@@ -181,6 +204,7 @@ export default {
...
@@ -181,6 +204,7 @@ export default {
:extra-component=
"extraComponent"
:extra-component=
"extraComponent"
:show-changed-icon=
"showChangedIcon"
:show-changed-icon=
"showChangedIcon"
:display-text-key=
"displayTextKey"
:display-text-key=
"displayTextKey"
:should-truncate-start=
"shouldTruncateStart"
@
toggleTreeOpen=
"toggleTreeOpen"
@
toggleTreeOpen=
"toggleTreeOpen"
@
clickFile=
"clickedFile"
@
clickFile=
"clickedFile"
/>
/>
...
...
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