Commit a82b7432 authored by Luke "Jared" Bennett's avatar Luke "Jared" Bennett

Fix eslint offenses

parent 4ae39ceb
...@@ -103,16 +103,15 @@ const Api = { ...@@ -103,16 +103,15 @@ const Api = {
return $.ajax({ return $.ajax({
url, url,
headers: { headers: {
'PRIVATE_TOKEN': token, PRIVATE_TOKEN: token,
}, },
type: 'POST', type: 'POST',
contentType: "application/json; charset=utf-8", contentType: 'application/json; charset=utf-8',
data: JSON.stringify(data), data: JSON.stringify(data),
dataType: 'json', dataType: 'json',
}) })
.done(commitData => callback(commitData)) .done(commitData => callback(commitData))
.fail(message => callback(message.responseJSON)); .fail(message => callback(message.responseJSON));
}, },
// Return text for a specific license // Return text for a specific license
......
...@@ -77,7 +77,7 @@ import Cookies from 'js-cookie'; ...@@ -77,7 +77,7 @@ import Cookies from 'js-cookie';
}, },
dataType: "json" dataType: "json"
}).done(function(refs) { }).done(function(refs) {
console.log(refs) console.log(refs);
return callback(refs); return callback(refs);
}); });
}, },
......
...@@ -19,12 +19,12 @@ function initRepo() { ...@@ -19,12 +19,12 @@ function initRepo() {
Store.service.url = repo.dataset.url; Store.service.url = repo.dataset.url;
Store.projectName = repo.dataset.projectName; Store.projectName = repo.dataset.projectName;
Store.service.refsUrl = repo.dataset.refsUrl; Store.service.refsUrl = repo.dataset.refsUrl;
Store.currentBranch = $("button.dropdown-menu-toggle").attr('data-ref'); Store.currentBranch = $('button.dropdown-menu-toggle').attr('data-ref');
Store.checkIsCommitable(); Store.checkIsCommitable();
Store.projectId = repo.dataset.projectId; Store.projectId = repo.dataset.projectId;
Store.tempPrivateToken = repo.dataset.tempToken; Store.tempPrivateToken = repo.dataset.tempToken;
new Vue({ this.vm = new Vue({
el: repo, el: repo,
data: () => Store, data: () => Store,
template: ` template: `
...@@ -45,7 +45,7 @@ function initRepo() { ...@@ -45,7 +45,7 @@ function initRepo() {
'repo-file-buttons': RepoFileButtons, 'repo-file-buttons': RepoFileButtons,
'repo-binary-viewer': RepoBinaryViewer, 'repo-binary-viewer': RepoBinaryViewer,
'repo-editor': RepoEditor, 'repo-editor': RepoEditor,
'repo-commit-section': RepoCommitSection 'repo-commit-section': RepoCommitSection,
}, },
}); });
......
<script> <script>
import Vue from 'vue';
import Store from './repo_store'; import Store from './repo_store';
import RepoHelper from './repo_helper'; import RepoHelper from './repo_helper';
......
<script> <script>
import Vue from 'vue'; /* global Flash */
import Store from './repo_store'; import Store from './repo_store';
import Api from '../api' import Api from '../api';
const RepoCommitSection = { const RepoCommitSection = {
data: () => Store, data: () => Store,
...@@ -9,21 +9,21 @@ const RepoCommitSection = { ...@@ -9,21 +9,21 @@ const RepoCommitSection = {
methods: { methods: {
makeCommit() { makeCommit() {
// see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions // see https://docs.gitlab.com/ce/api/commits.html#create-a-commit-with-multiple-files-and-actions
const branch = $("button.dropdown-menu-toggle").attr('data-ref'); const branch = $('button.dropdown-menu-toggle').attr('data-ref');
const commitMessage = this.commitMessage; const commitMessage = this.commitMessage;
const actions = this.changedFiles.map(f => { const actions = this.changedFiles.map((f) => {
const filePath = f.url.split(branch)[1]; const filePath = f.url.split(branch)[1];
return { return {
action: 'update', action: 'update',
file_path: filePath, file_path: filePath,
content: f.newContent, content: f.newContent,
}; };
}); });
const payload = { const payload = {
branch: branch, branch,
commit_message: commitMessage, commit_message: commitMessage,
actions: actions, actions,
} };
Store.submitCommitsLoading = true; Store.submitCommitsLoading = true;
Api.commitMultiple(Store.projectId, payload, (data) => { Api.commitMultiple(Store.projectId, payload, (data) => {
Store.submitCommitsLoading = false; Store.submitCommitsLoading = false;
...@@ -36,7 +36,7 @@ const RepoCommitSection = { ...@@ -36,7 +36,7 @@ const RepoCommitSection = {
this.editMode = false; this.editMode = false;
$('html, body').animate({ scrollTop: 0 }, 'fast'); $('html, body').animate({ scrollTop: 0 }, 'fast');
}, Store.tempPrivateToken); }, Store.tempPrivateToken);
} },
}, },
computed: { computed: {
...@@ -46,7 +46,7 @@ const RepoCommitSection = { ...@@ -46,7 +46,7 @@ const RepoCommitSection = {
return changedFileList; return changedFileList;
}, },
}, },
} };
export default RepoCommitSection; export default RepoCommitSection;
</script> </script>
......
<script> <script>
/* global monaco */ /* global monaco */
import Vue from 'vue';
import Store from './repo_store'; import Store from './repo_store';
import Helper from './repo_helper'; import Helper from './repo_helper';
import monacoLoader from './monaco_loader'; import monacoLoader from './monaco_loader';
...@@ -28,7 +27,7 @@ const RepoEditor = { ...@@ -28,7 +27,7 @@ const RepoEditor = {
const newModel = monaco.editor.createModel(this.blobRaw, 'plaintext'); const newModel = monaco.editor.createModel(this.blobRaw, 'plaintext');
this.monacoInstance.setModel(newModel); this.monacoInstance.setModel(newModel);
}); }).catch(Helper.loadingError);
}); });
}, },
...@@ -55,7 +54,7 @@ const RepoEditor = { ...@@ -55,7 +54,7 @@ const RepoEditor = {
location.hash = `L${e.target.position.lineNumber}`; location.hash = `L${e.target.position.lineNumber}`;
Store.activeLine = e.target.position.lineNumber; Store.activeLine = e.target.position.lineNumber;
} }
} },
}, },
watch: { watch: {
......
<script> <script>
import Vue from 'vue';
import Store from './repo_store'; import Store from './repo_store';
import Helper from './repo_helper'; import Helper from './repo_helper';
import RepoMiniMixin from './repo_mini_mixin'; import RepoMiniMixin from './repo_mini_mixin';
......
...@@ -27,8 +27,8 @@ const RepoHelper = { ...@@ -27,8 +27,8 @@ const RepoHelper = {
}, },
setDirectoryOpen(tree) { setDirectoryOpen(tree) {
let file = tree; const file = tree;
if (!file) return; if (!file) return undefined;
file.opened = true; file.opened = true;
file.icon = 'fa-folder-open'; file.icon = 'fa-folder-open';
...@@ -91,14 +91,12 @@ const RepoHelper = { ...@@ -91,14 +91,12 @@ const RepoHelper = {
return oldList; return oldList;
}, },
compareFilesCaseInsensitive(a,b) { compareFilesCaseInsensitive(a, b) {
const aName = a.name.toLowerCase(); const aName = a.name.toLowerCase();
const bName = b.name.toLowerCase(); const bName = b.name.toLowerCase();
if(a.level > 0) return 0; if (a.level > 0) return 0;
if (aName < bName) if (aName < bName) { return -1; }
return -1; if (aName > bName) { return 1; }
if (aName > bName)
return 1;
return 0; return 0;
}, },
...@@ -109,7 +107,7 @@ const RepoHelper = { ...@@ -109,7 +107,7 @@ const RepoHelper = {
.then((response) => { .then((response) => {
const data = response.data; const data = response.data;
// RepoHelper.setLoading(false, loadingData); // RepoHelper.setLoading(false, loadingData);
if(cb) cb(); if (cb) cb();
Store.isTree = RepoHelper.isTree(data); Store.isTree = RepoHelper.isTree(data);
if (!Store.isTree) { if (!Store.isTree) {
if (!file) file = data; if (!file) file = data;
...@@ -187,15 +185,13 @@ const RepoHelper = { ...@@ -187,15 +185,13 @@ const RepoHelper = {
}; };
}, },
scrollTabsRight() { scrollTabsRight() {
// wait for the transition. 0.1 seconds. // wait for the transition. 0.1 seconds.
setTimeout(() => { setTimeout(() => {
const tabs = document.getElementById('tabs'); const tabs = document.getElementById('tabs');
if(!tabs) return; if (!tabs) return;
tabs.scrollLeft = 12000; tabs.scrollLeft = 12000;
}, 200) }, 200);
}, },
dataToListOfFiles(data) { dataToListOfFiles(data) {
......
import Store from './repo_store';
import axios from 'axios'; import axios from 'axios';
import Store from './repo_store';
const RepoService = { const RepoService = {
url: '', url: '',
...@@ -12,10 +12,10 @@ const RepoService = { ...@@ -12,10 +12,10 @@ const RepoService = {
checkCurrentBranchIsCommitable() { checkCurrentBranchIsCommitable() {
const url = Store.service.refsUrl; const url = Store.service.refsUrl;
return axios.get(url, {params: { return axios.get(url, { params: {
ref: Store.currentBranch, ref: Store.currentBranch,
search: Store.currentBranch search: Store.currentBranch,
}}); } });
}, },
buildParams(url = this.url) { buildParams(url = this.url) {
......
<script> <script>
import Vue from 'vue';
import Service from './repo_service'; import Service from './repo_service';
import Helper from './repo_helper'; import Helper from './repo_helper';
import Store from './repo_store'; import Store from './repo_store';
......
/* global Flash */
import RepoHelper from './repo_helper'; import RepoHelper from './repo_helper';
const RepoStore = { const RepoStore = {
...@@ -37,7 +38,7 @@ const RepoStore = { ...@@ -37,7 +38,7 @@ const RepoStore = {
raw: false, raw: false,
newContent: '', newContent: '',
changed: false, changed: false,
loading: false loading: false,
}, },
activeFileIndex: 0, activeFileIndex: 0,
activeLine: 0, activeLine: 0,
...@@ -64,12 +65,12 @@ const RepoStore = { ...@@ -64,12 +65,12 @@ const RepoStore = {
checkIsCommitable() { checkIsCommitable() {
RepoStore.service.checkCurrentBranchIsCommitable() RepoStore.service.checkCurrentBranchIsCommitable()
.then((data) => { .then((data) => {
// you shouldn't be able to make commits on commits or tags. // you shouldn't be able to make commits on commits or tags.
let {Branches, Commits, Tags} = data.data; const { Branches, Commits, Tags } = data.data;
if(Branches && Branches.length) RepoStore.isCommitable = true; if (Branches && Branches.length) RepoStore.isCommitable = true;
if(Commits && Commits.length) RepoStore.isCommitable = false; if (Commits && Commits.length) RepoStore.isCommitable = false;
if(Tags && Tags.length) RepoStore.isCommitable = false; if (Tags && Tags.length) RepoStore.isCommitable = false;
}); }).catch(() => Flash('Failed to check if branch can be committed to.'));
}, },
addFilesToDirectory(inDirectory, currentList, newList) { addFilesToDirectory(inDirectory, currentList, newList) {
...@@ -126,11 +127,11 @@ const RepoStore = { ...@@ -126,11 +127,11 @@ const RepoStore = {
RepoStore.files = RepoStore.files.filter((file) => { RepoStore.files = RepoStore.files.filter((file) => {
const isItTheTreeWeWant = file.url === treeToClose.url; const isItTheTreeWeWant = file.url === treeToClose.url;
// if it's the next tree // if it's the next tree
if(foundTree && file.type === 'tree' && !isItTheTreeWeWant && file.level === treeToClose.level) { if (foundTree && file.type === 'tree' && !isItTheTreeWeWant && file.level === treeToClose.level) {
wereDone = true; wereDone = true;
return true; return true;
} }
if(wereDone) return true; if (wereDone) return true;
if (isItTheTreeWeWant) foundTree = true; if (isItTheTreeWeWant) foundTree = true;
......
...@@ -16,7 +16,7 @@ const RepoTabs = { ...@@ -16,7 +16,7 @@ const RepoTabs = {
methods: { methods: {
isOverflow() { isOverflow() {
return this.$el.scrollWidth > this.$el.offsetWidth; return this.$el.scrollWidth > this.$el.offsetWidth;
} },
}, },
watch: { watch: {
...@@ -24,9 +24,9 @@ const RepoTabs = { ...@@ -24,9 +24,9 @@ const RepoTabs = {
Vue.nextTick(() => { Vue.nextTick(() => {
this.tabsOverflow = this.isOverflow(); this.tabsOverflow = this.isOverflow();
}); });
} },
} },
} };
export default RepoTabs; export default RepoTabs;
</script> </script>
......
...@@ -20,7 +20,7 @@ describe('RepoTab', () => { ...@@ -20,7 +20,7 @@ describe('RepoTab', () => {
tab, tab,
}); });
const close = vm.$el.querySelector('.close'); const close = vm.$el.querySelector('.close');
const name = vm.$el.querySelector(`a[title="${tab.url}"]`) const name = vm.$el.querySelector(`a[title="${tab.url}"]`);
spyOn(vm, 'xClicked'); spyOn(vm, 'xClicked');
spyOn(vm, 'tabClicked'); spyOn(vm, 'tabClicked');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment