Commit 42bc1f56 authored by Phil Hughes's avatar Phil Hughes

Merge branch 'andr3-fix-file-tree-tooltips' into 'master'

Add proper tooltips with expanded paths

See merge request gitlab-org/gitlab!27437
parents ad5cac4d 89c0b92d
......@@ -39,6 +39,10 @@ export default {
'is-open': this.file.opened,
};
},
textForTitle() {
// don't output a title if we don't have the expanded path
return this.file?.tree?.length ? this.file.tree[0].parentPath : false;
},
},
watch: {
'file.active': function fileActiveWatch(active) {
......@@ -106,7 +110,7 @@ export default {
<div
v-else
:class="fileClass"
:title="file.name"
:title="textForTitle"
class="file-row"
role="button"
@click="clickFile"
......
......@@ -19,7 +19,7 @@ export default {
</script>
<template>
<div class="file-row-header bg-white sticky-top p-2 js-file-row-header">
<div class="file-row-header bg-white sticky-top p-2 js-file-row-header" :title="path">
<span class="bold">{{ truncatedPath }}</span>
</div>
</template>
---
title: Add tooltips with full path to file headers on file tree
merge_request: 27437
author:
type: fixed
......@@ -3,6 +3,7 @@
exports[`File row header component adds multiple ellipsises after 40 characters 1`] = `
<div
class="file-row-header bg-white sticky-top p-2 js-file-row-header"
title="app/assets/javascripts/merge_requests/widget/diffs/notes"
>
<span
class="bold"
......@@ -15,6 +16,7 @@ exports[`File row header component adds multiple ellipsises after 40 characters
exports[`File row header component renders file path 1`] = `
<div
class="file-row-header bg-white sticky-top p-2 js-file-row-header"
title="app/assets"
>
<span
class="bold"
......@@ -27,6 +29,7 @@ exports[`File row header component renders file path 1`] = `
exports[`File row header component trucates path after 40 characters 1`] = `
<div
class="file-row-header bg-white sticky-top p-2 js-file-row-header"
title="app/assets/javascripts/merge_requests"
>
<span
class="bold"
......
......@@ -33,6 +33,35 @@ describe('File row component', () => {
expect(name.text().trim()).toEqual(fileName);
});
it('renders the full path as title', () => {
const filePath = 'path/to/file/with a very long folder name/';
const fileName = 'foo.txt';
createComponent({
file: {
name: fileName,
isHeader: false,
tree: [
{
parentPath: filePath,
},
],
},
level: 1,
});
expect(wrapper.element.title.trim()).toEqual('path/to/file/with a very long folder name/');
});
it('does not render a title attribute if no tree present', () => {
createComponent({
file: file('f1.txt'),
level: 0,
});
expect(wrapper.element.title.trim()).toEqual('');
});
it('emits toggleTreeOpen on click', () => {
const fileName = 't3';
createComponent({
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment