Commit 54da5cee authored by Jacques's avatar Jacques

Fix blob breadcrumb link

Fixed the incorrect blob breadcrumb link
parent 450f2c4f
...@@ -148,11 +148,16 @@ export default { ...@@ -148,11 +148,16 @@ export default {
.reduce( .reduce(
(acc, name, i) => { (acc, name, i) => {
const path = joinPaths(i > 0 ? acc[i].path : '', escapeFileUrl(name)); const path = joinPaths(i > 0 ? acc[i].path : '', escapeFileUrl(name));
const isLastPath = i === this.currentPath.split('/').length - 1;
const to =
this.isBlobPath && isLastPath
? `/-/blob/${joinPaths(this.escapedRef, path)}`
: `/-/tree/${joinPaths(this.escapedRef, path)}`;
return acc.concat({ return acc.concat({
name, name,
path, path,
to: `/-/tree/${joinPaths(this.escapedRef, path)}`, to,
}); });
}, },
[ [
...@@ -274,9 +279,11 @@ export default { ...@@ -274,9 +279,11 @@ export default {
return items; return items;
}, },
isBlobPath() {
return this.$route.name === 'blobPath' || this.$route.name === 'blobPathDecoded';
},
renderAddToTreeDropdown() { renderAddToTreeDropdown() {
const isBlobPath = this.$route.name === 'blobPath' || this.$route.name === 'blobPathDecoded'; return !this.isBlobPath && (this.canCollaborate || this.canCreateMrFromFork);
return !isBlobPath && (this.canCollaborate || this.canCreateMrFromFork);
}, },
}, },
methods: { methods: {
......
...@@ -59,6 +59,20 @@ describe('Repository breadcrumbs component', () => { ...@@ -59,6 +59,20 @@ describe('Repository breadcrumbs component', () => {
expect(wrapper.findAll(RouterLinkStub).length).toEqual(linkCount); expect(wrapper.findAll(RouterLinkStub).length).toEqual(linkCount);
}); });
it.each`
routeName | path | linkTo
${'treePath'} | ${'app/assets/javascripts'} | ${'/-/tree/app/assets/javascripts'}
${'treePathDecoded'} | ${'app/assets/javascripts'} | ${'/-/tree/app/assets/javascripts'}
${'blobPath'} | ${'app/assets/index.js'} | ${'/-/blob/app/assets/index.js'}
${'blobPathDecoded'} | ${'app/assets/index.js'} | ${'/-/blob/app/assets/index.js'}
`(
'links to the correct router path when routeName is $routeName',
({ routeName, path, linkTo }) => {
factory(path, {}, { name: routeName });
expect(wrapper.findAll(RouterLinkStub).at(3).props('to')).toEqual(linkTo);
},
);
it('escapes hash in directory path', () => { it('escapes hash in directory path', () => {
factory('app/assets/javascripts#'); factory('app/assets/javascripts#');
......
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