2019-05-20 04:41:28 -04:00
|
|
|
import Vue from 'vue';
|
|
|
|
import createRouter from './router';
|
|
|
|
import App from './components/app.vue';
|
2019-05-29 05:24:35 -04:00
|
|
|
import Breadcrumbs from './components/breadcrumbs.vue';
|
2019-05-20 04:41:28 -04:00
|
|
|
import apolloProvider from './graphql';
|
2019-05-24 10:48:29 -04:00
|
|
|
import { setTitle } from './utils/title';
|
2019-05-20 04:41:28 -04:00
|
|
|
|
|
|
|
export default function setupVueRepositoryList() {
|
|
|
|
const el = document.getElementById('js-tree-list');
|
2019-05-29 05:24:35 -04:00
|
|
|
const { projectPath, projectShortPath, ref, fullName } = el.dataset;
|
2019-05-24 10:48:29 -04:00
|
|
|
const router = createRouter(projectPath, ref);
|
2019-05-20 04:41:28 -04:00
|
|
|
|
|
|
|
apolloProvider.clients.defaultClient.cache.writeData({
|
|
|
|
data: {
|
|
|
|
projectPath,
|
2019-05-29 05:24:35 -04:00
|
|
|
projectShortPath,
|
2019-05-20 04:41:28 -04:00
|
|
|
ref,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-05-29 05:24:35 -04:00
|
|
|
router.afterEach(({ params: { pathMatch } }) => {
|
|
|
|
const isRoot = pathMatch === undefined || pathMatch === '/';
|
|
|
|
|
|
|
|
setTitle(pathMatch, ref, fullName);
|
2019-05-28 09:43:33 -04:00
|
|
|
|
|
|
|
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));
|
|
|
|
});
|
2019-05-24 10:48:29 -04:00
|
|
|
|
2019-05-29 05:24:35 -04:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: document.getElementById('js-repo-breadcrumb'),
|
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(Breadcrumbs, {
|
|
|
|
props: {
|
|
|
|
currentPath: this.$route.params.pathMatch,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-05-20 04:41:28 -04:00
|
|
|
return new Vue({
|
|
|
|
el,
|
2019-05-24 10:48:29 -04:00
|
|
|
router,
|
2019-05-20 04:41:28 -04:00
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(App);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|