Fixes repository Vue router hiding elements on root URL

This commit is contained in:
Phil Hughes 2019-05-28 14:43:33 +01:00
parent fe09079707
commit aaa0fb726c
No known key found for this signature in database
GPG Key ID: 32245528C52E0F9F
5 changed files with 17 additions and 11 deletions

View File

@ -50,7 +50,7 @@ export default {
);
},
showParentRow() {
return !this.isLoadingFiles && this.path !== '';
return !this.isLoadingFiles && ['', '/'].indexOf(this.path) === -1;
},
},
watch: {

View File

@ -17,6 +17,19 @@ export default function setupVueRepositoryList() {
});
router.afterEach(({ params: { pathMatch } }) => setTitle(pathMatch, ref, fullName));
router.afterEach(to => {
const isRoot = to.params.pathMatch === undefined || to.params.pathMatch === '/';
if (!isRoot) {
document
.querySelectorAll('.js-keep-hidden-on-navigation')
.forEach(elem => elem.classList.add('hidden'));
}
document
.querySelectorAll('.js-hide-on-navigation')
.forEach(elem => elem.classList.toggle('hidden', !isRoot));
});
return new Vue({
el,

View File

@ -16,15 +16,8 @@ export default function createRouter(base, baseRef) {
name: 'treePath',
component: TreePage,
props: route => ({
path: route.params.pathMatch.replace(/^\//, ''),
path: route.params.pathMatch && route.params.pathMatch.replace(/^\//, ''),
}),
beforeEnter(to, from, next) {
document
.querySelectorAll('.js-hide-on-navigation')
.forEach(el => el.classList.add('hidden'));
next();
},
},
{
path: '/',

View File

@ -14,7 +14,7 @@
= render 'shared/commit_well', commit: commit, ref: ref, project: project
- if is_project_overview
.project-buttons.append-bottom-default{ class: ("js-hide-on-navigation" if vue_file_list) }
.project-buttons.append-bottom-default{ class: ("js-keep-hidden-on-navigation" if vue_file_list) }
= render 'stat_anchor_list', anchors: @project.statistics_buttons(show_auto_devops_callout: show_auto_devops_callout)
- if vue_file_list

View File

@ -1,7 +1,7 @@
- empty_repo = @project.empty_repo?
- show_auto_devops_callout = show_auto_devops_callout?(@project)
- max_project_topic_length = 15
.project-home-panel{ class: [("empty-project" if empty_repo), ("js-hide-on-navigation" if Feature.enabled?(:vue_file_list, @project))] }
.project-home-panel{ class: [("empty-project" if empty_repo), ("js-keep-hidden-on-navigation" if Feature.enabled?(:vue_file_list, @project))] }
.row.append-bottom-8
.home-panel-title-row.col-md-12.col-lg-6.d-flex
.avatar-container.rect-avatar.s64.home-panel-avatar.append-right-default.float-none