2017-08-03 11:20:23 -04:00
|
|
|
import Vue from 'vue';
|
2017-10-26 06:14:31 -04:00
|
|
|
import { mapActions } from 'vuex';
|
2017-10-13 05:08:10 -04:00
|
|
|
import { convertPermissionToBoolean } from '../lib/utils/common_utils';
|
2017-08-03 11:20:23 -04:00
|
|
|
import Repo from './components/repo.vue';
|
|
|
|
import RepoEditButton from './components/repo_edit_button.vue';
|
2017-10-23 06:57:23 -04:00
|
|
|
import newBranchForm from './components/new_branch_form.vue';
|
2017-10-12 05:55:11 -04:00
|
|
|
import newDropdown from './components/new_dropdown/index.vue';
|
2017-10-26 12:36:27 -04:00
|
|
|
import store from './stores';
|
2017-08-03 11:20:23 -04:00
|
|
|
import Translate from '../vue_shared/translate';
|
2017-07-31 05:48:22 -04:00
|
|
|
|
2017-08-03 11:20:23 -04:00
|
|
|
function initRepo(el) {
|
2017-10-31 06:18:56 -04:00
|
|
|
if (!el) return null;
|
|
|
|
|
2017-08-03 11:20:23 -04:00
|
|
|
return new Vue({
|
|
|
|
el,
|
2017-10-26 12:36:27 -04:00
|
|
|
store,
|
2017-08-03 11:20:23 -04:00
|
|
|
components: {
|
|
|
|
repo: Repo,
|
|
|
|
},
|
2017-10-26 06:14:31 -04:00
|
|
|
methods: {
|
|
|
|
...mapActions([
|
|
|
|
'setInitialData',
|
|
|
|
]),
|
|
|
|
},
|
|
|
|
created() {
|
|
|
|
const data = el.dataset;
|
|
|
|
|
|
|
|
this.setInitialData({
|
|
|
|
project: {
|
|
|
|
id: data.projectId,
|
|
|
|
name: data.projectName,
|
2017-10-26 10:12:34 -04:00
|
|
|
url: data.projectUrl,
|
2017-10-26 06:14:31 -04:00
|
|
|
},
|
|
|
|
endpoints: {
|
|
|
|
rootEndpoint: data.url,
|
|
|
|
newMergeRequestUrl: data.newMergeRequestUrl,
|
|
|
|
rootUrl: data.rootUrl,
|
|
|
|
},
|
|
|
|
canCommit: convertPermissionToBoolean(data.canCommit),
|
|
|
|
onTopOfBranch: convertPermissionToBoolean(data.onTopOfBranch),
|
|
|
|
currentRef: data.ref,
|
2017-10-26 10:12:34 -04:00
|
|
|
path: data.currentPath,
|
2017-10-31 06:18:56 -04:00
|
|
|
currentBranch: data.currentBranch,
|
2017-10-26 06:14:31 -04:00
|
|
|
isRoot: convertPermissionToBoolean(data.root),
|
|
|
|
isInitialRoot: convertPermissionToBoolean(data.root),
|
|
|
|
});
|
|
|
|
},
|
2017-08-15 14:16:42 -04:00
|
|
|
render(createElement) {
|
|
|
|
return createElement('repo');
|
|
|
|
},
|
2017-08-03 11:20:23 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function initRepoEditButton(el) {
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2017-10-26 12:36:27 -04:00
|
|
|
store,
|
2017-08-03 11:20:23 -04:00
|
|
|
components: {
|
|
|
|
repoEditButton: RepoEditButton,
|
|
|
|
},
|
2017-10-26 12:36:27 -04:00
|
|
|
render(createElement) {
|
|
|
|
return createElement('repo-edit-button');
|
|
|
|
},
|
2017-08-03 11:20:23 -04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-12 05:55:11 -04:00
|
|
|
function initNewDropdown(el) {
|
|
|
|
return new Vue({
|
|
|
|
el,
|
2017-10-26 12:36:27 -04:00
|
|
|
store,
|
2017-10-12 05:55:11 -04:00
|
|
|
components: {
|
|
|
|
newDropdown,
|
|
|
|
},
|
|
|
|
render(createElement) {
|
|
|
|
return createElement('new-dropdown');
|
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-23 06:57:23 -04:00
|
|
|
function initNewBranchForm() {
|
|
|
|
const el = document.querySelector('.js-new-branch-dropdown');
|
|
|
|
|
|
|
|
if (!el) return null;
|
|
|
|
|
|
|
|
return new Vue({
|
|
|
|
el,
|
|
|
|
components: {
|
|
|
|
newBranchForm,
|
|
|
|
},
|
2017-10-26 12:36:27 -04:00
|
|
|
store,
|
2017-10-23 06:57:23 -04:00
|
|
|
render(createElement) {
|
2017-10-26 06:14:31 -04:00
|
|
|
return createElement('new-branch-form');
|
2017-10-23 06:57:23 -04:00
|
|
|
},
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-10-26 06:14:31 -04:00
|
|
|
const repo = document.getElementById('repo');
|
|
|
|
const editButton = document.querySelector('.editable-mode');
|
|
|
|
const newDropdownHolder = document.querySelector('.js-new-dropdown');
|
2017-07-19 16:45:39 -04:00
|
|
|
|
2017-10-26 06:14:31 -04:00
|
|
|
Vue.use(Translate);
|
2017-07-19 16:45:39 -04:00
|
|
|
|
2017-10-26 06:14:31 -04:00
|
|
|
initRepo(repo);
|
|
|
|
initRepoEditButton(editButton);
|
|
|
|
initNewBranchForm();
|
|
|
|
initNewDropdown(newDropdownHolder);
|