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-12-26 22:10:19 +05:30
|
|
|
import TreeActionLink from './components/tree_action_link.vue';
|
|
|
|
import DirectoryDownloadLinks from './components/directory_download_links.vue';
|
2019-09-04 21:01:54 +05:30
|
|
|
import apolloProvider from './graphql';
|
|
|
|
import { setTitle } from './utils/title';
|
2020-01-01 13:55:28 +05:30
|
|
|
import { updateFormAction } from './utils/dom';
|
2019-09-30 21:07:59 +05:30
|
|
|
import { parseBoolean } from '../lib/utils/common_utils';
|
2019-12-26 22:10:19 +05:30
|
|
|
import { webIDEUrl } from '../lib/utils/url_utility';
|
|
|
|
import { __ } from '../locale';
|
2019-09-04 21:01:54 +05:30
|
|
|
|
|
|
|
export default function setupVueRepositoryList() {
|
|
|
|
const el = document.getElementById('js-tree-list');
|
2019-12-26 22:10:19 +05:30
|
|
|
const { dataset } = el;
|
|
|
|
const { projectPath, projectShortPath, ref, fullName } = dataset;
|
2019-09-04 21:01:54 +05:30
|
|
|
const router = createRouter(projectPath, ref);
|
|
|
|
|
|
|
|
apolloProvider.clients.defaultClient.cache.writeData({
|
|
|
|
data: {
|
|
|
|
projectPath,
|
|
|
|
projectShortPath,
|
|
|
|
ref,
|
2020-03-09 13:42:32 +05:30
|
|
|
vueFileListLfsBadge: gon.features?.vueFileListLfsBadge || false,
|
2019-09-30 21:07:59 +05:30
|
|
|
commits: [],
|
2019-09-04 21:01:54 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
router.afterEach(({ params: { path } }) => {
|
|
|
|
setTitle(path, ref, fullName);
|
2019-09-04 21:01:54 +05:30
|
|
|
});
|
|
|
|
|
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,
|
2020-01-01 13:55:28 +05:30
|
|
|
uploadPath,
|
|
|
|
newDirPath,
|
2019-09-30 21:07:59 +05:30
|
|
|
} = breadcrumbEl.dataset;
|
|
|
|
|
2020-03-09 13:42:32 +05:30
|
|
|
router.afterEach(({ params: { path = '/' } }) => {
|
|
|
|
updateFormAction('.js-upload-blob-form', uploadPath, path);
|
|
|
|
updateFormAction('.js-create-dir-form', newDirPath, path);
|
2020-01-01 13:55:28 +05:30
|
|
|
});
|
|
|
|
|
2019-09-30 21:07:59 +05:30
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: breadcrumbEl,
|
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(Breadcrumbs, {
|
|
|
|
props: {
|
2020-03-09 13:42:32 +05:30
|
|
|
currentPath: this.$route.params.path,
|
2019-09-30 21:07:59 +05:30
|
|
|
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: {
|
2020-03-09 13:42:32 +05:30
|
|
|
currentPath: this.$route.params.path,
|
2019-09-04 21:01:54 +05:30
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2019-12-26 22:10:19 +05:30
|
|
|
const treeHistoryLinkEl = document.getElementById('js-tree-history-link');
|
|
|
|
const { historyLink } = treeHistoryLinkEl.dataset;
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: treeHistoryLinkEl,
|
|
|
|
router,
|
|
|
|
render(h) {
|
|
|
|
return h(TreeActionLink, {
|
|
|
|
props: {
|
2020-03-09 13:42:32 +05:30
|
|
|
path: `${historyLink}/${this.$route.params.path ? escape(this.$route.params.path) : ''}`,
|
2019-12-26 22:10:19 +05:30
|
|
|
text: __('History'),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const webIdeLinkEl = document.getElementById('js-tree-web-ide-link');
|
|
|
|
|
|
|
|
if (webIdeLinkEl) {
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: webIdeLinkEl,
|
|
|
|
router,
|
|
|
|
render(h) {
|
|
|
|
return h(TreeActionLink, {
|
|
|
|
props: {
|
2020-03-09 13:42:32 +05:30
|
|
|
path: webIDEUrl(`/${projectPath}/edit/${ref}/-/${this.$route.params.path || ''}`),
|
2019-12-26 22:10:19 +05:30
|
|
|
text: __('Web IDE'),
|
|
|
|
cssClass: 'qa-web-ide-button',
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const directoryDownloadLinks = document.getElementById('js-directory-downloads');
|
|
|
|
|
|
|
|
if (directoryDownloadLinks) {
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: directoryDownloadLinks,
|
|
|
|
router,
|
|
|
|
render(h) {
|
2020-03-09 13:42:32 +05:30
|
|
|
const currentPath = this.$route.params.path || '/';
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
if (currentPath !== '/') {
|
|
|
|
return h(DirectoryDownloadLinks, {
|
|
|
|
props: {
|
|
|
|
currentPath: currentPath.replace(/^\//, ''),
|
|
|
|
links: JSON.parse(directoryDownloadLinks.dataset.links),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
2019-09-04 21:01:54 +05:30
|
|
|
el,
|
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(App);
|
|
|
|
},
|
|
|
|
});
|
2019-12-26 22:10:19 +05:30
|
|
|
|
|
|
|
return { router, data: dataset };
|
2019-09-04 21:01:54 +05:30
|
|
|
}
|