2019-09-04 21:01:54 +05:30
|
|
|
import Vue from 'vue';
|
|
|
|
import createRouter from './router';
|
|
|
|
import App from './components/app.vue';
|
|
|
|
import Breadcrumbs from './components/breadcrumbs.vue';
|
2019-09-30 21:07:59 +05:30
|
|
|
import LastCommit from './components/last_commit.vue';
|
2019-09-04 21:01:54 +05:30
|
|
|
import apolloProvider from './graphql';
|
|
|
|
import { setTitle } from './utils/title';
|
2019-09-30 21:07:59 +05:30
|
|
|
import { parseBoolean } from '../lib/utils/common_utils';
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
export default function setupVueRepositoryList() {
|
|
|
|
const el = document.getElementById('js-tree-list');
|
|
|
|
const { projectPath, projectShortPath, ref, fullName } = el.dataset;
|
|
|
|
const router = createRouter(projectPath, ref);
|
|
|
|
|
|
|
|
apolloProvider.clients.defaultClient.cache.writeData({
|
|
|
|
data: {
|
|
|
|
projectPath,
|
|
|
|
projectShortPath,
|
|
|
|
ref,
|
2019-09-30 21:07:59 +05:30
|
|
|
commits: [],
|
2019-09-04 21:01:54 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
router.afterEach(({ params: { pathMatch } }) => {
|
|
|
|
const isRoot = pathMatch === undefined || pathMatch === '/';
|
|
|
|
|
|
|
|
setTitle(pathMatch, ref, fullName);
|
|
|
|
|
|
|
|
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-09-30 21:07:59 +05:30
|
|
|
const breadcrumbEl = document.getElementById('js-repo-breadcrumb');
|
|
|
|
|
|
|
|
if (breadcrumbEl) {
|
|
|
|
const {
|
|
|
|
canCollaborate,
|
|
|
|
canEditTree,
|
|
|
|
newBranchPath,
|
|
|
|
newTagPath,
|
|
|
|
newBlobPath,
|
|
|
|
forkNewBlobPath,
|
|
|
|
forkNewDirectoryPath,
|
|
|
|
forkUploadBlobPath,
|
|
|
|
} = breadcrumbEl.dataset;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: breadcrumbEl,
|
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(Breadcrumbs, {
|
|
|
|
props: {
|
|
|
|
currentPath: this.$route.params.pathMatch,
|
|
|
|
canCollaborate: parseBoolean(canCollaborate),
|
|
|
|
canEditTree: parseBoolean(canEditTree),
|
|
|
|
newBranchPath,
|
|
|
|
newTagPath,
|
|
|
|
newBlobPath,
|
|
|
|
forkNewBlobPath,
|
|
|
|
forkNewDirectoryPath,
|
|
|
|
forkUploadBlobPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
2019-09-30 21:07:59 +05:30
|
|
|
el: document.getElementById('js-last-commit'),
|
2019-09-04 21:01:54 +05:30
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
2019-09-30 21:07:59 +05:30
|
|
|
return h(LastCommit, {
|
2019-09-04 21:01:54 +05:30
|
|
|
props: {
|
|
|
|
currentPath: this.$route.params.pathMatch,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(App);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|