Commit 20abacca authored by GitLab Bot's avatar GitLab Bot

Add latest changes from gitlab-org/gitlab@12-10-stable-ee

parent 8bdbf220
...@@ -108,14 +108,14 @@ export default { ...@@ -108,14 +108,14 @@ export default {
return acc.concat({ return acc.concat({
name, name,
path, path,
to: `/-/tree/${joinPaths(encodeURIComponent(this.ref), path)}`, to: `/-/tree/${joinPaths(escapeFileUrl(this.ref), path)}`,
}); });
}, },
[ [
{ {
name: this.projectShortPath, name: this.projectShortPath,
path: '/', path: '/',
to: `/-/tree/${encodeURIComponent(this.ref)}/`, to: `/-/tree/${escapeFileUrl(this.ref)}/`,
}, },
], ],
); );
......
<script> <script>
import { GlLoadingIcon } from '@gitlab/ui'; import { GlLoadingIcon } from '@gitlab/ui';
import { escapeFileUrl } from '~/lib/utils/url_utility';
export default { export default {
components: { components: {
...@@ -28,7 +29,7 @@ export default { ...@@ -28,7 +29,7 @@ export default {
return splitArray.map(p => encodeURIComponent(p)).join('/'); return splitArray.map(p => encodeURIComponent(p)).join('/');
}, },
parentRoute() { parentRoute() {
return { path: `/-/tree/${encodeURIComponent(this.commitRef)}/${this.parentPath}` }; return { path: `/-/tree/${escapeFileUrl(this.commitRef)}/${this.parentPath}` };
}, },
}, },
methods: { methods: {
......
...@@ -99,7 +99,7 @@ export default { ...@@ -99,7 +99,7 @@ export default {
computed: { computed: {
routerLinkTo() { routerLinkTo() {
return this.isFolder return this.isFolder
? { path: `/-/tree/${encodeURIComponent(this.ref)}/${escapeFileUrl(this.path)}` } ? { path: `/-/tree/${escapeFileUrl(this.ref)}/${escapeFileUrl(this.path)}` }
: null; : null;
}, },
isFolder() { isFolder() {
......
...@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) { ...@@ -12,7 +12,7 @@ export default function createRouter(base, baseRef) {
base: joinPaths(gon.relative_url_root || '', base), base: joinPaths(gon.relative_url_root || '', base),
routes: [ routes: [
{ {
path: `(/-)?/tree/(${encodeURIComponent(baseRef)}|${baseRef})/:path*`, path: `(/-)?/tree/(${encodeURIComponent(baseRef).replace(/%2F/g, '/')}|${baseRef})/:path*`,
name: 'treePath', name: 'treePath',
component: TreePage, component: TreePage,
props: route => ({ props: route => ({
......
...@@ -180,6 +180,20 @@ describe "User browses files" do ...@@ -180,6 +180,20 @@ describe "User browses files" do
expect(page).to have_content("VERSION") expect(page).to have_content("VERSION")
.and have_content(".gitignore") .and have_content(".gitignore")
.and have_content("LICENSE") .and have_content("LICENSE")
click_link("files")
page.within('.repo-breadcrumb') do
expect(page).to have_link('files')
end
click_link("html")
page.within('.repo-breadcrumb') do
expect(page).to have_link('html')
end
expect(page).to have_link('500.html')
end end
end end
...@@ -193,6 +207,20 @@ describe "User browses files" do ...@@ -193,6 +207,20 @@ describe "User browses files" do
expect(page).to have_content("VERSION") expect(page).to have_content("VERSION")
.and have_content(".gitignore") .and have_content(".gitignore")
.and have_content("LICENSE") .and have_content("LICENSE")
click_link("files")
page.within('.repo-breadcrumb') do
expect(page).to have_link('files')
end
click_link("html")
page.within('.repo-breadcrumb') do
expect(page).to have_link('html')
end
expect(page).to have_link('500.html')
end end
end end
......
...@@ -4,14 +4,15 @@ import createRouter from '~/repository/router'; ...@@ -4,14 +4,15 @@ import createRouter from '~/repository/router';
describe('Repository router spec', () => { describe('Repository router spec', () => {
it.each` it.each`
path | component | componentName path | branch | component | componentName
${'/'} | ${IndexPage} | ${'IndexPage'} ${'/'} | ${'master'} | ${IndexPage} | ${'IndexPage'}
${'/tree/master'} | ${TreePage} | ${'TreePage'} ${'/tree/master'} | ${'master'} | ${TreePage} | ${'TreePage'}
${'/-/tree/master'} | ${TreePage} | ${'TreePage'} ${'/-/tree/master'} | ${'master'} | ${TreePage} | ${'TreePage'}
${'/-/tree/master/app/assets'} | ${TreePage} | ${'TreePage'} ${'/-/tree/master/app/assets'} | ${'master'} | ${TreePage} | ${'TreePage'}
${'/-/tree/123/app/assets'} | ${null} | ${'null'} ${'/-/tree/feature/test-%23/app/assets'} | ${'feature/test-#'} | ${TreePage} | ${'TreePage'}
`('sets component as $componentName for path "$path"', ({ path, component }) => { ${'/-/tree/123/app/assets'} | ${'master'} | ${null} | ${'null'}
const router = createRouter('', 'master'); `('sets component as $componentName for path "$path"', ({ path, component, branch }) => {
const router = createRouter('', branch);
const componentsForRoute = router.getMatchedComponents(path); const componentsForRoute = router.getMatchedComponents(path);
......
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