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 {
.reduce(
(acc, name, i) => {
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({
name,
path,
to: `/-/tree/${joinPaths(this.escapedRef, path)}`,
to,
});
},
[
......@@ -274,9 +279,11 @@ export default {
return items;
},
isBlobPath() {
return this.$route.name === 'blobPath' || this.$route.name === 'blobPathDecoded';
},
renderAddToTreeDropdown() {
const isBlobPath = this.$route.name === 'blobPath' || this.$route.name === 'blobPathDecoded';
return !isBlobPath && (this.canCollaborate || this.canCreateMrFromFork);
return !this.isBlobPath && (this.canCollaborate || this.canCreateMrFromFork);
},
},
methods: {
......
......@@ -59,6 +59,20 @@ describe('Repository breadcrumbs component', () => {
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', () => {
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