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-06-19 06:32:33 -04:00
|
|
|
import LastCommit from './components/last_commit.vue';
|
2019-10-30 08:06:34 -04:00
|
|
|
import TreeActionLink from './components/tree_action_link.vue';
|
|
|
|
import DirectoryDownloadLinks from './components/directory_download_links.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-11-25 13:06:04 -05:00
|
|
|
import { updateFormAction } from './utils/dom';
|
2019-07-10 08:17:45 -04:00
|
|
|
import { parseBoolean } from '../lib/utils/common_utils';
|
2019-10-30 08:06:34 -04:00
|
|
|
import { webIDEUrl } from '../lib/utils/url_utility';
|
|
|
|
import { __ } from '../locale';
|
2019-05-20 04:41:28 -04:00
|
|
|
|
|
|
|
export default function setupVueRepositoryList() {
|
|
|
|
const el = document.getElementById('js-tree-list');
|
2019-10-29 08:06:40 -04:00
|
|
|
const { dataset } = el;
|
|
|
|
const { projectPath, projectShortPath, ref, fullName } = 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,
|
2020-01-24 07:09:01 -05:00
|
|
|
vueFileListLfsBadge: gon.features?.vueFileListLfsBadge || false,
|
2019-06-25 10:26:55 -04:00
|
|
|
commits: [],
|
2019-05-20 04:41:28 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
|
2020-02-05 10:08:48 -05:00
|
|
|
router.afterEach(({ params: { path } }) => {
|
|
|
|
setTitle(path, ref, fullName);
|
2019-05-28 09:43:33 -04:00
|
|
|
});
|
2019-05-24 10:48:29 -04:00
|
|
|
|
2019-07-10 08:17:45 -04:00
|
|
|
const breadcrumbEl = document.getElementById('js-repo-breadcrumb');
|
|
|
|
|
|
|
|
if (breadcrumbEl) {
|
|
|
|
const {
|
|
|
|
canCollaborate,
|
|
|
|
canEditTree,
|
|
|
|
newBranchPath,
|
|
|
|
newTagPath,
|
|
|
|
newBlobPath,
|
|
|
|
forkNewBlobPath,
|
|
|
|
forkNewDirectoryPath,
|
|
|
|
forkUploadBlobPath,
|
2019-11-25 13:06:04 -05:00
|
|
|
uploadPath,
|
|
|
|
newDirPath,
|
2019-07-10 08:17:45 -04:00
|
|
|
} = breadcrumbEl.dataset;
|
|
|
|
|
2020-02-05 10:08:48 -05:00
|
|
|
router.afterEach(({ params: { path = '/' } }) => {
|
|
|
|
updateFormAction('.js-upload-blob-form', uploadPath, path);
|
|
|
|
updateFormAction('.js-create-dir-form', newDirPath, path);
|
2019-11-25 13:06:04 -05:00
|
|
|
});
|
|
|
|
|
2019-07-10 08:17:45 -04:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: breadcrumbEl,
|
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(Breadcrumbs, {
|
|
|
|
props: {
|
2020-02-05 10:08:48 -05:00
|
|
|
currentPath: this.$route.params.path,
|
2019-07-10 08:17:45 -04:00
|
|
|
canCollaborate: parseBoolean(canCollaborate),
|
|
|
|
canEditTree: parseBoolean(canEditTree),
|
|
|
|
newBranchPath,
|
|
|
|
newTagPath,
|
|
|
|
newBlobPath,
|
|
|
|
forkNewBlobPath,
|
|
|
|
forkNewDirectoryPath,
|
|
|
|
forkUploadBlobPath,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
2019-05-29 05:24:35 -04:00
|
|
|
|
2019-06-28 08:36:18 -04:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
|
|
|
el: document.getElementById('js-last-commit'),
|
|
|
|
router,
|
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(LastCommit, {
|
|
|
|
props: {
|
2020-02-05 10:08:48 -05:00
|
|
|
currentPath: this.$route.params.path,
|
2019-06-28 08:36:18 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
2019-06-19 06:32:33 -04:00
|
|
|
|
2019-10-30 08:06:34 -04:00
|
|
|
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-04-21 11:21:10 -04:00
|
|
|
path: `${historyLink}/${
|
|
|
|
this.$route.params.path ? encodeURIComponent(this.$route.params.path) : ''
|
|
|
|
}`,
|
2019-10-30 08:06:34 -04:00
|
|
|
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-02-05 10:08:48 -05:00
|
|
|
path: webIDEUrl(`/${projectPath}/edit/${ref}/-/${this.$route.params.path || ''}`),
|
2019-10-30 08:06:34 -04:00
|
|
|
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-02-05 10:08:48 -05:00
|
|
|
const currentPath = this.$route.params.path || '/';
|
2019-10-30 08:06:34 -04:00
|
|
|
|
|
|
|
if (currentPath !== '/') {
|
|
|
|
return h(DirectoryDownloadLinks, {
|
|
|
|
props: {
|
|
|
|
currentPath: currentPath.replace(/^\//, ''),
|
|
|
|
links: JSON.parse(directoryDownloadLinks.dataset.links),
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2019-10-29 08:06:40 -04:00
|
|
|
// eslint-disable-next-line no-new
|
|
|
|
new Vue({
|
2019-05-20 04:41:28 -04:00
|
|
|
el,
|
2019-05-24 10:48:29 -04:00
|
|
|
router,
|
2019-05-20 04:41:28 -04:00
|
|
|
apolloProvider,
|
|
|
|
render(h) {
|
|
|
|
return h(App);
|
|
|
|
},
|
|
|
|
});
|
2019-10-29 08:06:40 -04:00
|
|
|
|
|
|
|
return { router, data: dataset };
|
2019-05-20 04:41:28 -04:00
|
|
|
}
|