Commit 00827a74 authored by Lukas Eipert's avatar Lukas Eipert

Run prettier on 33 files - 15 of 73

Part of our prettier migration; changing the arrow-parens style.
parent 333bad89
...@@ -63,7 +63,7 @@ export default { ...@@ -63,7 +63,7 @@ export default {
return this.openPendingTab({ return this.openPendingTab({
file: this.file, file: this.file,
keyPrefix: this.keyPrefix, keyPrefix: this.keyPrefix,
}).then(changeViewer => { }).then((changeViewer) => {
if (changeViewer) { if (changeViewer) {
this.updateViewer(viewerTypes.diff); this.updateViewer(viewerTypes.diff);
} }
......
...@@ -29,7 +29,7 @@ export default { ...@@ -29,7 +29,7 @@ export default {
'undoFileTemplate', 'undoFileTemplate',
]), ]),
setInitialType() { setInitialType() {
const initialTemplateType = this.templateTypes.find(t => t.name === this.activeFile.name); const initialTemplateType = this.templateTypes.find((t) => t.name === this.activeFile.name);
if (initialTemplateType) { if (initialTemplateType) {
this.setSelectedTemplateType(initialTemplateType); this.setSelectedTemplateType(initialTemplateType);
......
...@@ -44,7 +44,7 @@ export default { ...@@ -44,7 +44,7 @@ export default {
computed: { computed: {
...mapState('fileTemplates', ['templates', 'isLoading']), ...mapState('fileTemplates', ['templates', 'isLoading']),
outputData() { outputData() {
return (this.isAsyncData ? this.templates : this.data).filter(t => { return (this.isAsyncData ? this.templates : this.data).filter((t) => {
if (!this.searchable) return true; if (!this.searchable) return true;
return t.name.toLowerCase().indexOf(this.search.toLowerCase()) >= 0; return t.name.toLowerCase().indexOf(this.search.toLowerCase()) >= 0;
......
...@@ -73,7 +73,7 @@ export default { ...@@ -73,7 +73,7 @@ export default {
}, },
}, },
mounted() { mounted() {
window.onbeforeunload = e => this.onBeforeUnload(e); window.onbeforeunload = (e) => this.onBeforeUnload(e);
if (this.themeName) if (this.themeName)
document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`); document.querySelector('.navbar-gitlab').classList.add(`theme-${this.themeName}`);
......
...@@ -37,7 +37,7 @@ export default { ...@@ -37,7 +37,7 @@ export default {
}, },
methods: { methods: {
isActiveTab(tab) { isActiveTab(tab) {
return this.isOpen && tab.views.some(view => view.name === this.currentView); return this.isOpen && tab.views.some((view) => view.name === this.currentView);
}, },
buttonClasses(tab) { buttonClasses(tab) {
return [ return [
......
...@@ -30,7 +30,7 @@ export default { ...@@ -30,7 +30,7 @@ export default {
const rawContent = encodedContent ? atob(encodedContent) : ''; const rawContent = encodedContent ? atob(encodedContent) : '';
const isText = isTextFile({ content: rawContent, mimeType, name }); const isText = isTextFile({ content: rawContent, mimeType, name });
const emitCreateEvent = content => const emitCreateEvent = (content) =>
this.$emit('create', { this.$emit('create', {
name: `${this.path ? `${this.path}/` : ''}${name}`, name: `${this.path ? `${this.path}/` : ''}${name}`,
type: 'blob', type: 'blob',
...@@ -42,7 +42,7 @@ export default { ...@@ -42,7 +42,7 @@ export default {
if (isText) { if (isText) {
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('load', e => emitCreateEvent(e.target.result), { once: true }); reader.addEventListener('load', (e) => emitCreateEvent(e.target.result), { once: true });
reader.readAsText(file); reader.readAsText(file);
} else { } else {
emitCreateEvent(rawContent); emitCreateEvent(rawContent);
...@@ -51,11 +51,11 @@ export default { ...@@ -51,11 +51,11 @@ export default {
readFile(file) { readFile(file) {
const reader = new FileReader(); const reader = new FileReader();
reader.addEventListener('load', e => this.createFile(e.target, file), { once: true }); reader.addEventListener('load', (e) => this.createFile(e.target, file), { once: true });
reader.readAsDataURL(file); reader.readAsDataURL(file);
}, },
openFile() { openFile() {
Array.from(this.$refs.fileUpload.files).forEach(file => this.readFile(file)); Array.from(this.$refs.fileUpload.files).forEach((file) => this.readFile(file));
}, },
startFileUpload() { startFileUpload() {
this.$refs.fileUpload.click(); this.$refs.fileUpload.click();
......
...@@ -35,13 +35,13 @@ export default { ...@@ -35,13 +35,13 @@ export default {
return `${this.side}Pane`; return `${this.side}Pane`;
}, },
tabs() { tabs() {
return this.extensionTabs.filter(tab => tab.show); return this.extensionTabs.filter((tab) => tab.show);
}, },
tabViews() { tabViews() {
return this.tabs.map(tab => tab.views).flat(); return this.tabs.map((tab) => tab.views).flat();
}, },
aliveTabViews() { aliveTabViews() {
return this.tabViews.filter(view => this.isAliveView(view.name)); return this.tabViews.filter((view) => this.isAliveView(view.name));
}, },
}, },
methods: { methods: {
......
...@@ -108,7 +108,7 @@ export default { ...@@ -108,7 +108,7 @@ export default {
.then(() => { .then(() => {
this.initManager(); this.initManager();
this.listener = listen(e => { this.listener = listen((e) => {
switch (e.type) { switch (e.type) {
case 'done': case 'done':
this.sandpackReady = true; this.sandpackReady = true;
...@@ -139,8 +139,8 @@ export default { ...@@ -139,8 +139,8 @@ export default {
const settings = { const settings = {
fileResolver: { fileResolver: {
isFile: p => Promise.resolve(Boolean(this.entries[createPathWithExt(p)])), isFile: (p) => Promise.resolve(Boolean(this.entries[createPathWithExt(p)])),
readFile: p => this.loadFileContent(createPathWithExt(p)).then(content => content), readFile: (p) => this.loadFileContent(createPathWithExt(p)).then((content) => content),
}, },
...(bundlerURL ? { bundlerURL } : {}), ...(bundlerURL ? { bundlerURL } : {}),
}; };
......
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
}, },
}, },
mounted() { mounted() {
this.listener = listen(e => { this.listener = listen((e) => {
switch (e.type) { switch (e.type) {
case 'urlchange': case 'urlchange':
this.onUrlChange(e); this.onUrlChange(e);
......
...@@ -41,12 +41,12 @@ export default { ...@@ -41,12 +41,12 @@ export default {
file, file,
keyPrefix: file.staged ? stageKeys.staged : stageKeys.unstaged, keyPrefix: file.staged ? stageKeys.staged : stageKeys.unstaged,
}) })
.then(changeViewer => { .then((changeViewer) => {
if (changeViewer) { if (changeViewer) {
this.updateViewer('diff'); this.updateViewer('diff');
} }
}) })
.catch(e => { .catch((e) => {
throw e; throw e;
}); });
}, },
......
...@@ -219,7 +219,7 @@ export default { ...@@ -219,7 +219,7 @@ export default {
.then(() => { .then(() => {
this.createEditorInstance(); this.createEditorInstance();
}) })
.catch(err => { .catch((err) => {
flash( flash(
__('Error setting up editor. Please try again.'), __('Error setting up editor. Please try again.'),
'alert', 'alert',
...@@ -281,7 +281,7 @@ export default { ...@@ -281,7 +281,7 @@ export default {
this.model.updateOptions(this.rules); this.model.updateOptions(this.rules);
this.model.onChange(model => { this.model.onChange((model) => {
const { file } = model; const { file } = model;
if (!file.active) return; if (!file.active) return;
...@@ -329,7 +329,7 @@ export default { ...@@ -329,7 +329,7 @@ export default {
} }
}, },
fetchEditorconfigRules() { fetchEditorconfigRules() {
return getRulesWithTraversal(this.file.path, path => { return getRulesWithTraversal(this.file.path, (path) => {
const entry = this.entries[path]; const entry = this.entries[path];
if (!entry) return Promise.resolve(null); if (!entry) return Promise.resolve(null);
...@@ -339,7 +339,7 @@ export default { ...@@ -339,7 +339,7 @@ export default {
return this.getFileData({ path: entry.path, makeFileActive: false }).then(() => return this.getFileData({ path: entry.path, makeFileActive: false }).then(() =>
this.getRawFileData({ path: entry.path }), this.getRawFileData({ path: entry.path }),
); );
}).then(rules => { }).then((rules) => {
this.rules = mapRulesToMonaco(rules); this.rules = mapRulesToMonaco(rules);
}); });
}, },
...@@ -353,7 +353,7 @@ export default { ...@@ -353,7 +353,7 @@ export default {
event.preventDefault(); event.preventDefault();
event.stopImmediatePropagation(); event.stopImmediatePropagation();
return readFileAsDataURL(file).then(content => { return readFileAsDataURL(file).then((content) => {
const parentPath = getPathParent(this.file.path); const parentPath = getPathParent(this.file.path);
const path = `${parentPath ? `${parentPath}/` : ''}${file.name}`; const path = `${parentPath ? `${parentPath}/` : ''}${file.name}`;
......
...@@ -39,7 +39,7 @@ const EmptyRouterComponent = { ...@@ -39,7 +39,7 @@ const EmptyRouterComponent = {
}, },
}; };
export const createRouter = store => { export const createRouter = (store) => {
const router = new IdeRouter({ const router = new IdeRouter({
mode: 'history', mode: 'history',
base: joinPaths(gon.relative_url_root || '', '/-/ide/'), base: joinPaths(gon.relative_url_root || '', '/-/ide/'),
...@@ -54,11 +54,11 @@ export const createRouter = store => { ...@@ -54,11 +54,11 @@ export const createRouter = store => {
}, },
{ {
path: ':targetmode(edit|tree|blob)/:branchid+/', path: ':targetmode(edit|tree|blob)/:branchid+/',
redirect: to => joinPaths(to.path, '/-/'), redirect: (to) => joinPaths(to.path, '/-/'),
}, },
{ {
path: ':targetmode(edit|tree|blob)', path: ':targetmode(edit|tree|blob)',
redirect: to => joinPaths(to.path, '/master/-/'), redirect: (to) => joinPaths(to.path, '/master/-/'),
}, },
{ {
path: 'merge_requests/:mrid', path: 'merge_requests/:mrid',
...@@ -66,7 +66,7 @@ export const createRouter = store => { ...@@ -66,7 +66,7 @@ export const createRouter = store => {
}, },
{ {
path: '', path: '',
redirect: to => joinPaths(to.path, '/edit/master/-/'), redirect: (to) => joinPaths(to.path, '/edit/master/-/'),
}, },
], ],
}, },
...@@ -110,7 +110,7 @@ export const createRouter = store => { ...@@ -110,7 +110,7 @@ export const createRouter = store => {
}); });
} }
}) })
.catch(e => { .catch((e) => {
flash( flash(
__('Error while loading the project data. Please try again.'), __('Error while loading the project data. Please try again.'),
'alert', 'alert',
......
...@@ -4,11 +4,11 @@ export default class Disposable { ...@@ -4,11 +4,11 @@ export default class Disposable {
} }
add(...disposers) { add(...disposers) {
disposers.forEach(disposer => this.disposers.add(disposer)); disposers.forEach((disposer) => this.disposers.add(disposer));
} }
dispose() { dispose() {
this.disposers.forEach(disposer => disposer.dispose()); this.disposers.forEach((disposer) => disposer.dispose());
this.disposers.clear(); this.disposers.clear();
} }
} }
...@@ -75,7 +75,7 @@ export default class Model { ...@@ -75,7 +75,7 @@ export default class Model {
} }
onChange(cb) { onChange(cb) {
this.events.add(this.disposable.add(this.model.onDidChangeContent(e => cb(this, e)))); this.events.add(this.disposable.add(this.model.onDidChangeContent((e) => cb(this, e))));
} }
onDispose(cb) { onDispose(cb) {
...@@ -121,7 +121,7 @@ export default class Model { ...@@ -121,7 +121,7 @@ export default class Model {
dispose() { dispose() {
if (!this.model.isDisposed()) this.applyCustomOptions(); if (!this.model.isDisposed()) this.applyCustomOptions();
this.events.forEach(cb => { this.events.forEach((cb) => {
if (typeof cb === 'function') cb(); if (typeof cb === 'function') cb();
}); });
......
...@@ -12,13 +12,13 @@ const NEW_LINE = '\n'; ...@@ -12,13 +12,13 @@ const NEW_LINE = '\n';
* *
* - Removes "=======" separator added at the beginning * - Removes "=======" separator added at the beginning
*/ */
const cleanTwoFilesPatch = text => text.replace(/^(=+\s*)/, ''); const cleanTwoFilesPatch = (text) => text.replace(/^(=+\s*)/, '');
const endsWithNewLine = val => !val || val[val.length - 1] === NEW_LINE; const endsWithNewLine = (val) => !val || val[val.length - 1] === NEW_LINE;
const addEndingNewLine = val => (endsWithNewLine(val) ? val : val + NEW_LINE); const addEndingNewLine = (val) => (endsWithNewLine(val) ? val : val + NEW_LINE);
const removeEndingNewLine = val => (endsWithNewLine(val) ? val.substr(0, val.length - 1) : val); const removeEndingNewLine = (val) => (endsWithNewLine(val) ? val.substr(0, val.length - 1) : val);
const diffHead = (prevPath, newPath = '') => const diffHead = (prevPath, newPath = '') =>
`diff --git "a/${prevPath}" "b/${newPath || prevPath}"`; `diff --git "a/${prevPath}" "b/${newPath || prevPath}"`;
...@@ -37,7 +37,7 @@ const createDiffBody = (path, content, isCreate) => { ...@@ -37,7 +37,7 @@ const createDiffBody = (path, content, isCreate) => {
const chunkHead = isCreate ? `@@ -0,0 +1,${lines.length} @@` : `@@ -1,${lines.length} +0,0 @@`; const chunkHead = isCreate ? `@@ -0,0 +1,${lines.length} @@` : `@@ -1,${lines.length} +0,0 @@`;
const chunk = lines const chunk = lines
.map(line => `${prefix}${line}`) .map((line) => `${prefix}${line}`)
.concat(!hasNewLine ? [NO_NEW_LINE] : []) .concat(!hasNewLine ? [NO_NEW_LINE] : [])
.join(NEW_LINE); .join(NEW_LINE);
......
...@@ -11,7 +11,7 @@ export default class DecorationsController { ...@@ -11,7 +11,7 @@ export default class DecorationsController {
const modelDecorations = this.decorations.get(model.url); const modelDecorations = this.decorations.get(model.url);
const decorations = []; const decorations = [];
modelDecorations.forEach(val => decorations.push(...val)); modelDecorations.forEach((val) => decorations.push(...val));
return decorations; return decorations;
} }
......
...@@ -3,7 +3,7 @@ import { throttle } from 'lodash'; ...@@ -3,7 +3,7 @@ import { throttle } from 'lodash';
import DirtyDiffWorker from './diff_worker'; import DirtyDiffWorker from './diff_worker';
import Disposable from '../common/disposable'; import Disposable from '../common/disposable';
export const getDiffChangeType = change => { export const getDiffChangeType = (change) => {
if (change.modified) { if (change.modified) {
return 'modified'; return 'modified';
} else if (change.added) { } else if (change.added) {
...@@ -15,7 +15,7 @@ export const getDiffChangeType = change => { ...@@ -15,7 +15,7 @@ export const getDiffChangeType = change => {
return ''; return '';
}; };
export const getDecorator = change => ({ export const getDecorator = (change) => ({
range: new Range(change.lineNumber, 1, change.endLineNumber, 1), range: new Range(change.lineNumber, 1, change.endLineNumber, 1),
options: { options: {
isWholeLine: true, isWholeLine: true,
...@@ -71,7 +71,7 @@ export default class DirtyDiffController { ...@@ -71,7 +71,7 @@ export default class DirtyDiffController {
} }
decorate({ data }) { decorate({ data }) {
const decorations = data.changes.map(change => getDecorator(change)); const decorations = data.changes.map((change) => getDecorator(change));
const model = this.modelManager.getModel(data.path); const model = this.modelManager.getModel(data.path);
this.decorationsController.addDecorations(model, 'dirtyDiff', decorations); this.decorationsController.addDecorations(model, 'dirtyDiff', decorations);
} }
......
...@@ -11,7 +11,7 @@ export const computeDiff = (originalContent, newContent) => { ...@@ -11,7 +11,7 @@ export const computeDiff = (originalContent, newContent) => {
let lineNumber = 1; let lineNumber = 1;
return changes.reduce((acc, change) => { return changes.reduce((acc, change) => {
const findOnLine = acc.find(c => c.lineNumber === lineNumber); const findOnLine = acc.find((c) => c.lineNumber === lineNumber);
if (findOnLine) { if (findOnLine) {
Object.assign(findOnLine, change, { Object.assign(findOnLine, change, {
......
import { computeDiff } from './diff'; import { computeDiff } from './diff';
// eslint-disable-next-line no-restricted-globals // eslint-disable-next-line no-restricted-globals
self.addEventListener('message', e => { self.addEventListener('message', (e) => {
const { data } = e; const { data } = e;
// eslint-disable-next-line no-restricted-globals // eslint-disable-next-line no-restricted-globals
......
...@@ -12,7 +12,7 @@ import { clearDomElement } from '~/editor/utils'; ...@@ -12,7 +12,7 @@ import { clearDomElement } from '~/editor/utils';
import { registerLanguages } from '../utils'; import { registerLanguages } from '../utils';
function setupThemes() { function setupThemes() {
themes.forEach(theme => { themes.forEach((theme) => {
monacoEditor.defineTheme(theme.name, theme.data); monacoEditor.defineTheme(theme.name, theme.data);
}); });
} }
...@@ -108,7 +108,7 @@ export default class Editor { ...@@ -108,7 +108,7 @@ export default class Editor {
this.instance.updateOptions( this.instance.updateOptions(
editorOptions.reduce((acc, obj) => { editorOptions.reduce((acc, obj) => {
Object.keys(obj).forEach(key => { Object.keys(obj).forEach((key) => {
Object.assign(acc, { Object.assign(acc, {
[key]: obj[key](model), [key]: obj[key](model),
}); });
...@@ -177,7 +177,7 @@ export default class Editor { ...@@ -177,7 +177,7 @@ export default class Editor {
onPositionChange(cb) { onPositionChange(cb) {
if (!this.instance.onDidChangeCursorPosition) return; if (!this.instance.onDidChangeCursorPosition) return;
this.disposable.add(this.instance.onDidChangeCursorPosition(e => cb(this.instance, e))); this.disposable.add(this.instance.onDidChangeCursorPosition((e) => cb(this.instance, e)));
} }
updateDiffView() { updateDiffView() {
...@@ -213,14 +213,14 @@ export default class Editor { ...@@ -213,14 +213,14 @@ export default class Editor {
addCommands() { addCommands() {
const { store } = this; const { store } = this;
const getKeyCode = key => { const getKeyCode = (key) => {
const monacoKeyMod = key.indexOf('KEY_') === 0; const monacoKeyMod = key.indexOf('KEY_') === 0;
return monacoKeyMod ? KeyCode[key] : KeyMod[key]; return monacoKeyMod ? KeyCode[key] : KeyMod[key];
}; };
keymap.forEach(command => { keymap.forEach((command) => {
const keybindings = command.bindings.map(binding => { const keybindings = command.bindings.map((binding) => {
const keys = binding.split('+'); const keys = binding.split('+');
// eslint-disable-next-line no-bitwise // eslint-disable-next-line no-bitwise
......
...@@ -31,7 +31,7 @@ export const defaultModelOptions = { ...@@ -31,7 +31,7 @@ export const defaultModelOptions = {
export const editorOptions = [ export const editorOptions = [
{ {
readOnly: model => Boolean(model.file.file_lock), readOnly: (model) => Boolean(model.file.file_lock),
quickSuggestions: model => !(model.language === 'markdown'), quickSuggestions: (model) => !(model.language === 'markdown'),
}, },
]; ];
...@@ -2,7 +2,7 @@ import { parseString } from 'editorconfig/src/lib/ini'; ...@@ -2,7 +2,7 @@ import { parseString } from 'editorconfig/src/lib/ini';
import minimatch from 'minimatch'; import minimatch from 'minimatch';
import { getPathParents } from '../../utils'; import { getPathParents } from '../../utils';
const dirname = path => path.replace(/\.editorconfig$/, ''); const dirname = (path) => path.replace(/\.editorconfig$/, '');
function isRootConfig(config) { function isRootConfig(config) {
return config.some(([pattern, rules]) => !pattern && rules?.root === 'true'); return config.some(([pattern, rules]) => !pattern && rules?.root === 'true');
...@@ -44,16 +44,16 @@ function getRulesWithConfigs(filePath, configFiles = [], rules = {}) { ...@@ -44,16 +44,16 @@ function getRulesWithConfigs(filePath, configFiles = [], rules = {}) {
export function getRulesWithTraversal(filePath, getFileContent) { export function getRulesWithTraversal(filePath, getFileContent) {
const editorconfigPaths = [ const editorconfigPaths = [
...getPathParents(filePath).map(x => `${x}/.editorconfig`), ...getPathParents(filePath).map((x) => `${x}/.editorconfig`),
'.editorconfig', '.editorconfig',
]; ];
return Promise.all( return Promise.all(
editorconfigPaths.map(path => getFileContent(path).then(content => ({ path, content }))), editorconfigPaths.map((path) => getFileContent(path).then((content) => ({ path, content }))),
).then(results => ).then((results) =>
getRulesWithConfigs( getRulesWithConfigs(
filePath, filePath,
results.filter(x => x.content), results.filter((x) => x.content),
), ),
); );
} }
import { isBoolean, isNumber } from 'lodash'; import { isBoolean, isNumber } from 'lodash';
const map = (key, validValues) => value => const map = (key, validValues) => (value) =>
value in validValues ? { [key]: validValues[value] } : {}; value in validValues ? { [key]: validValues[value] } : {};
const bool = key => value => (isBoolean(value) ? { [key]: value } : {}); const bool = (key) => (value) => (isBoolean(value) ? { [key]: value } : {});
const int = (key, isValid) => value => const int = (key, isValid) => (value) =>
isNumber(value) && isValid(value) ? { [key]: Math.trunc(value) } : {}; isNumber(value) && isValid(value) ? { [key]: Math.trunc(value) } : {};
const rulesMapper = { const rulesMapper = {
indent_style: map('insertSpaces', { tab: false, space: true }), indent_style: map('insertSpaces', { tab: false, space: true }),
indent_size: int('tabSize', n => n > 0), indent_size: int('tabSize', (n) => n > 0),
tab_width: int('tabSize', n => n > 0), tab_width: int('tabSize', (n) => n > 0),
trim_trailing_whitespace: bool('trimTrailingWhitespace'), trim_trailing_whitespace: bool('trimTrailingWhitespace'),
end_of_line: map('endOfLine', { crlf: 1, lf: 0 }), end_of_line: map('endOfLine', { crlf: 1, lf: 0 }),
insert_final_newline: bool('insertFinalNewline'), insert_final_newline: bool('insertFinalNewline'),
}; };
const parseValue = x => { const parseValue = (x) => {
let value = typeof x === 'string' ? x.toLowerCase() : x; let value = typeof x === 'string' ? x.toLowerCase() : x;
if (/^[0-9.-]+$/.test(value)) value = Number(value); if (/^[0-9.-]+$/.test(value)) value = Number(value);
if (value === 'true') value = true; if (value === 'true') value = true;
......
...@@ -6,17 +6,17 @@ const CODEOWNERS_REGEX = /Push.*protected branches.*CODEOWNERS/; ...@@ -6,17 +6,17 @@ const CODEOWNERS_REGEX = /Push.*protected branches.*CODEOWNERS/;
const BRANCH_CHANGED_REGEX = /changed.*since.*start.*edit/; const BRANCH_CHANGED_REGEX = /changed.*since.*start.*edit/;
const BRANCH_ALREADY_EXISTS = /branch.*already.*exists/; const BRANCH_ALREADY_EXISTS = /branch.*already.*exists/;
const createNewBranchAndCommit = store => const createNewBranchAndCommit = (store) =>
store store
.dispatch('commit/updateCommitAction', consts.COMMIT_TO_NEW_BRANCH) .dispatch('commit/updateCommitAction', consts.COMMIT_TO_NEW_BRANCH)
.then(() => store.dispatch('commit/commitChanges')); .then(() => store.dispatch('commit/commitChanges'));
export const createUnexpectedCommitError = message => ({ export const createUnexpectedCommitError = (message) => ({
title: __('Unexpected error'), title: __('Unexpected error'),
messageHTML: escape(message) || __('Could not commit. An unexpected error occurred.'), messageHTML: escape(message) || __('Could not commit. An unexpected error occurred.'),
}); });
export const createCodeownersCommitError = message => ({ export const createCodeownersCommitError = (message) => ({
title: __('CODEOWNERS rule violation'), title: __('CODEOWNERS rule violation'),
messageHTML: escape(message), messageHTML: escape(message),
primaryAction: { primaryAction: {
...@@ -25,7 +25,7 @@ export const createCodeownersCommitError = message => ({ ...@@ -25,7 +25,7 @@ export const createCodeownersCommitError = message => ({
}, },
}); });
export const createBranchChangedCommitError = message => ({ export const createBranchChangedCommitError = (message) => ({
title: __('Branch changed'), title: __('Branch changed'),
messageHTML: `${escape(message)}<br/><br/>${__('Would you like to create a new branch?')}`, messageHTML: `${escape(message)}<br/><br/>${__('Would you like to create a new branch?')}`,
primaryAction: { primaryAction: {
...@@ -34,19 +34,19 @@ export const createBranchChangedCommitError = message => ({ ...@@ -34,19 +34,19 @@ export const createBranchChangedCommitError = message => ({
}, },
}); });
export const branchAlreadyExistsCommitError = message => ({ export const branchAlreadyExistsCommitError = (message) => ({
title: __('Branch already exists'), title: __('Branch already exists'),
messageHTML: `${escape(message)}<br/><br/>${__( messageHTML: `${escape(message)}<br/><br/>${__(
'Would you like to try auto-generating a branch name?', 'Would you like to try auto-generating a branch name?',
)}`, )}`,
primaryAction: { primaryAction: {
text: __('Create new branch'), text: __('Create new branch'),
callback: store => callback: (store) =>
store.dispatch('commit/addSuffixToBranchName').then(() => createNewBranchAndCommit(store)), store.dispatch('commit/addSuffixToBranchName').then(() => createNewBranchAndCommit(store)),
}, },
}); });
export const parseCommitError = e => { export const parseCommitError = (e) => {
const { message } = e?.response?.data || {}; const { message } = e?.response?.data || {};
if (!message) { if (!message) {
......
import { decorateData, sortTree } from '../stores/utils'; import { decorateData, sortTree } from '../stores/utils';
export const splitParent = path => { export const splitParent = (path) => {
const idx = path.lastIndexOf('/'); const idx = path.lastIndexOf('/');
return { return {
...@@ -32,7 +32,7 @@ export const decorateFiles = ({ ...@@ -32,7 +32,7 @@ export const decorateFiles = ({
let file; let file;
let parentPath; let parentPath;
const insertParent = path => { const insertParent = (path) => {
if (!path) { if (!path) {
return null; return null;
} else if (entries[path]) { } else if (entries[path]) {
...@@ -67,7 +67,7 @@ export const decorateFiles = ({ ...@@ -67,7 +67,7 @@ export const decorateFiles = ({
return tree; return tree;
}; };
data.forEach(path => { data.forEach((path) => {
const { parent, name } = splitParent(path); const { parent, name } = splitParent(path);
const fileFolder = parent && insertParent(parent); const fileFolder = parent && insertParent(parent);
......
...@@ -12,23 +12,23 @@ export const MSG_CONNECTION_ERROR = __('Could not connect to Web IDE file mirror ...@@ -12,23 +12,23 @@ export const MSG_CONNECTION_ERROR = __('Could not connect to Web IDE file mirror
const noop = () => {}; const noop = () => {};
export const SERVICE_DELAY = 8000; export const SERVICE_DELAY = 8000;
const cancellableWait = time => { const cancellableWait = (time) => {
let timeoutId = 0; let timeoutId = 0;
const cancel = () => clearTimeout(timeoutId); const cancel = () => clearTimeout(timeoutId);
const promise = new Promise(resolve => { const promise = new Promise((resolve) => {
timeoutId = setTimeout(resolve, time); timeoutId = setTimeout(resolve, time);
}); });
return [promise, cancel]; return [promise, cancel];
}; };
const isErrorResponse = error => error && error.code !== 0; const isErrorResponse = (error) => error && error.code !== 0;
const isErrorPayload = payload => payload && payload.status_code !== 200; const isErrorPayload = (payload) => payload && payload.status_code !== 200;
const getErrorFromResponse = data => { const getErrorFromResponse = (data) => {
if (isErrorResponse(data.error)) { if (isErrorResponse(data.error)) {
return { message: data.error.Message }; return { message: data.error.Message };
} else if (isErrorPayload(data.payload)) { } else if (isErrorPayload(data.payload)) {
...@@ -38,9 +38,9 @@ const getErrorFromResponse = data => { ...@@ -38,9 +38,9 @@ const getErrorFromResponse = data => {
return null; return null;
}; };
const getFullPath = path => mergeUrlParams({ service: SERVICE_NAME }, getWebSocketUrl(path)); const getFullPath = (path) => mergeUrlParams({ service: SERVICE_NAME }, getWebSocketUrl(path));
const createWebSocket = fullPath => const createWebSocket = (fullPath) =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
const socket = new WebSocket(fullPath, [PROTOCOL]); const socket = new WebSocket(fullPath, [PROTOCOL]);
const resetCallbacks = () => { const resetCallbacks = () => {
...@@ -59,7 +59,7 @@ const createWebSocket = fullPath => ...@@ -59,7 +59,7 @@ const createWebSocket = fullPath =>
}; };
}); });
export const canConnect = ({ services = [] }) => services.some(name => name === SERVICE_NAME); export const canConnect = ({ services = [] }) => services.some((name) => name === SERVICE_NAME);
export const createMirror = () => { export const createMirror = () => {
let socket = null; let socket = null;
...@@ -71,23 +71,23 @@ export const createMirror = () => { ...@@ -71,23 +71,23 @@ export const createMirror = () => {
cancelHandler = noop; cancelHandler = noop;
}; };
const onCancelConnect = fn => { const onCancelConnect = (fn) => {
cancelHandler = fn; cancelHandler = fn;
}; };
const receiveMessage = ev => { const receiveMessage = (ev) => {
const handle = nextMessageHandler; const handle = nextMessageHandler;
nextMessageHandler = noop; nextMessageHandler = noop;
handle(JSON.parse(ev.data)); handle(JSON.parse(ev.data));
}; };
const onNextMessage = fn => { const onNextMessage = (fn) => {
nextMessageHandler = fn; nextMessageHandler = fn;
}; };
const waitForNextMessage = () => const waitForNextMessage = () =>
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
onNextMessage(data => { onNextMessage((data) => {
const err = getErrorFromResponse(data); const err = getErrorFromResponse(data);
if (err) { if (err) {
...@@ -133,7 +133,7 @@ export const createMirror = () => { ...@@ -133,7 +133,7 @@ export const createMirror = () => {
return wait return wait
.then(() => createWebSocket(fullPath)) .then(() => createWebSocket(fullPath))
.then(newSocket => { .then((newSocket) => {
socket = newSocket; socket = newSocket;
socket.onmessage = receiveMessage; socket.onmessage = receiveMessage;
}); });
......
...@@ -4,9 +4,9 @@ import Api from '~/api'; ...@@ -4,9 +4,9 @@ import Api from '~/api';
import getUserPermissions from '../queries/getUserPermissions.query.graphql'; import getUserPermissions from '../queries/getUserPermissions.query.graphql';
import { query } from './gql'; import { query } from './gql';
const fetchApiProjectData = projectPath => Api.project(projectPath).then(({ data }) => data); const fetchApiProjectData = (projectPath) => Api.project(projectPath).then(({ data }) => data);
const fetchGqlProjectData = projectPath => const fetchGqlProjectData = (projectPath) =>
query({ query({
query: getUserPermissions, query: getUserPermissions,
variables: { projectPath }, variables: { projectPath },
...@@ -31,7 +31,7 @@ export default { ...@@ -31,7 +31,7 @@ export default {
return axios return axios
.get(file.rawPath, { .get(file.rawPath, {
transformResponse: [f => f], transformResponse: [(f) => f],
...options, ...options,
}) })
.then(({ data }) => data); .then(({ data }) => data);
...@@ -54,7 +54,7 @@ export default { ...@@ -54,7 +54,7 @@ export default {
escapeFileUrl(filePath), escapeFileUrl(filePath),
), ),
{ {
transformResponse: [f => f], transformResponse: [(f) => f],
}, },
) )
.then(({ data }) => data); .then(({ data }) => data);
......
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
export const baseUrl = projectPath => `/${projectPath}/ide_terminals`; export const baseUrl = (projectPath) => `/${projectPath}/ide_terminals`;
export const checkConfig = (projectPath, branch) => export const checkConfig = (projectPath, branch) =>
axios.post(`${baseUrl(projectPath)}/check_config`, { axios.post(`${baseUrl(projectPath)}/check_config`, {
......
...@@ -20,7 +20,7 @@ export const redirectToUrl = (self, url) => visitUrl(url); ...@@ -20,7 +20,7 @@ export const redirectToUrl = (self, url) => visitUrl(url);
export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data); export const setInitialData = ({ commit }, data) => commit(types.SET_INITIAL_DATA, data);
export const discardAllChanges = ({ state, commit, dispatch }) => { export const discardAllChanges = ({ state, commit, dispatch }) => {
state.changedFiles.forEach(file => dispatch('restoreOriginalFile', file.path)); state.changedFiles.forEach((file) => dispatch('restoreOriginalFile', file.path));
commit(types.REMOVE_ALL_CHANGES_FILES); commit(types.REMOVE_ALL_CHANGES_FILES);
}; };
...@@ -106,7 +106,7 @@ export const stageAllChanges = ({ state, commit, dispatch, getters }) => { ...@@ -106,7 +106,7 @@ export const stageAllChanges = ({ state, commit, dispatch, getters }) => {
commit(types.SET_LAST_COMMIT_MSG, ''); commit(types.SET_LAST_COMMIT_MSG, '');
state.changedFiles.forEach(file => state.changedFiles.forEach((file) =>
commit(types.STAGE_CHANGE, { path: file.path, diffInfo: getters.getDiffInfo(file.path) }), commit(types.STAGE_CHANGE, { path: file.path, diffInfo: getters.getDiffInfo(file.path) }),
); );
...@@ -123,7 +123,7 @@ export const stageAllChanges = ({ state, commit, dispatch, getters }) => { ...@@ -123,7 +123,7 @@ export const stageAllChanges = ({ state, commit, dispatch, getters }) => {
export const unstageAllChanges = ({ state, commit, dispatch, getters }) => { export const unstageAllChanges = ({ state, commit, dispatch, getters }) => {
const openFile = state.openFiles[0]; const openFile = state.openFiles[0];
state.stagedFiles.forEach(file => state.stagedFiles.forEach((file) =>
commit(types.UNSTAGE_CHANGE, { path: file.path, diffInfo: getters.getDiffInfo(file.path) }), commit(types.UNSTAGE_CHANGE, { path: file.path, diffInfo: getters.getDiffInfo(file.path) }),
); );
...@@ -194,7 +194,7 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => { ...@@ -194,7 +194,7 @@ export const deleteEntry = ({ commit, dispatch, state }, path) => {
if (entry.opened) dispatch('closeFile', entry); if (entry.opened) dispatch('closeFile', entry);
if (isTree) { if (isTree) {
entry.tree.forEach(f => dispatch('deleteEntry', f.path)); entry.tree.forEach((f) => dispatch('deleteEntry', f.path));
} }
commit(types.DELETE_ENTRY, path); commit(types.DELETE_ENTRY, path);
...@@ -221,7 +221,7 @@ export const renameEntry = ({ dispatch, commit, state, getters }, { path, name, ...@@ -221,7 +221,7 @@ export const renameEntry = ({ dispatch, commit, state, getters }, { path, name,
commit(types.RENAME_ENTRY, { path, name, parentPath }); commit(types.RENAME_ENTRY, { path, name, parentPath });
if (entry.type === 'tree') { if (entry.type === 'tree') {
state.entries[newPath].tree.forEach(f => { state.entries[newPath].tree.forEach((f) => {
dispatch('renameEntry', { dispatch('renameEntry', {
path: f.path, path: f.path,
name: f.name, name: f.name,
...@@ -280,7 +280,7 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force = ...@@ -280,7 +280,7 @@ export const getBranchData = ({ commit, state }, { projectId, branchId, force =
commit(types.SET_BRANCH_WORKING_REFERENCE, { projectId, branchId, reference: id }); commit(types.SET_BRANCH_WORKING_REFERENCE, { projectId, branchId, reference: id });
resolve(data); resolve(data);
}) })
.catch(e => { .catch((e) => {
if (e.response.status === 404) { if (e.response.status === 404) {
reject(e); reject(e);
} else { } else {
......
...@@ -14,7 +14,7 @@ import { viewerTypes, stageKeys } from '../../constants'; ...@@ -14,7 +14,7 @@ import { viewerTypes, stageKeys } from '../../constants';
export const closeFile = ({ commit, state, dispatch, getters }, file) => { export const closeFile = ({ commit, state, dispatch, getters }, file) => {
const { path } = file; const { path } = file;
const indexOfClosedFile = state.openFiles.findIndex(f => f.key === file.key); const indexOfClosedFile = state.openFiles.findIndex((f) => f.key === file.key);
const fileWasActive = file.active; const fileWasActive = file.active;
if (file.pending) { if (file.pending) {
...@@ -108,7 +108,7 @@ export const getFileData = ( ...@@ -108,7 +108,7 @@ export const getFileData = (
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the file.'), text: __('An error occurred while loading the file.'),
action: payload => action: (payload) =>
dispatch('getFileData', payload).then(() => dispatch('setErrorMessage', null)), dispatch('getFileData', payload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: { path, makeFileActive }, actionPayload: { path, makeFileActive },
...@@ -125,13 +125,13 @@ export const setFileMrChange = ({ commit }, { file, mrChange }) => { ...@@ -125,13 +125,13 @@ export const setFileMrChange = ({ commit }, { file, mrChange }) => {
export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) => { export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) => {
const file = state.entries[path]; const file = state.entries[path];
const stagedFile = state.stagedFiles.find(f => f.path === path); const stagedFile = state.stagedFiles.find((f) => f.path === path);
const fileDeletedAndReadded = getters.isFileDeletedAndReadded(path); const fileDeletedAndReadded = getters.isFileDeletedAndReadded(path);
commit(types.TOGGLE_LOADING, { entry: file, forceValue: true }); commit(types.TOGGLE_LOADING, { entry: file, forceValue: true });
return service return service
.getRawFileData(fileDeletedAndReadded ? stagedFile : file) .getRawFileData(fileDeletedAndReadded ? stagedFile : file)
.then(raw => { .then((raw) => {
if (!(file.tempFile && !file.prevPath && !fileDeletedAndReadded)) if (!(file.tempFile && !file.prevPath && !fileDeletedAndReadded))
commit(types.SET_FILE_RAW_DATA, { file, raw, fileDeletedAndReadded }); commit(types.SET_FILE_RAW_DATA, { file, raw, fileDeletedAndReadded });
...@@ -139,7 +139,7 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) = ...@@ -139,7 +139,7 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) =
const baseSha = const baseSha =
(getters.currentMergeRequest && getters.currentMergeRequest.baseCommitSha) || ''; (getters.currentMergeRequest && getters.currentMergeRequest.baseCommitSha) || '';
return service.getBaseRawFileData(file, state.currentProjectId, baseSha).then(baseRaw => { return service.getBaseRawFileData(file, state.currentProjectId, baseSha).then((baseRaw) => {
commit(types.SET_FILE_BASE_RAW_DATA, { commit(types.SET_FILE_BASE_RAW_DATA, {
file, file,
baseRaw, baseRaw,
...@@ -149,10 +149,10 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) = ...@@ -149,10 +149,10 @@ export const getRawFileData = ({ state, commit, dispatch, getters }, { path }) =
} }
return raw; return raw;
}) })
.catch(e => { .catch((e) => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the file content.'), text: __('An error occurred while loading the file content.'),
action: payload => action: (payload) =>
dispatch('getRawFileData', payload).then(() => dispatch('setErrorMessage', null)), dispatch('getRawFileData', payload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: { path }, actionPayload: { path },
...@@ -178,7 +178,7 @@ export const changeFileContent = ({ commit, state, getters }, { path, content }) ...@@ -178,7 +178,7 @@ export const changeFileContent = ({ commit, state, getters }, { path, content })
content, content,
}); });
const indexOfChangedFile = state.changedFiles.findIndex(f => f.path === path); const indexOfChangedFile = state.changedFiles.findIndex((f) => f.path === path);
if (file.changed && indexOfChangedFile === -1) { if (file.changed && indexOfChangedFile === -1) {
commit(types.STAGE_CHANGE, { path, diffInfo: getters.getDiffInfo(path) }); commit(types.STAGE_CHANGE, { path, diffInfo: getters.getDiffInfo(path) });
...@@ -225,7 +225,7 @@ export const discardFileChanges = ({ dispatch, state, commit, getters }, path) = ...@@ -225,7 +225,7 @@ export const discardFileChanges = ({ dispatch, state, commit, getters }, path) =
.then(() => { .then(() => {
dispatch('router/push', getters.getUrlForPath(file.path), { root: true }); dispatch('router/push', getters.getUrlForPath(file.path), { root: true });
}) })
.catch(e => { .catch((e) => {
throw e; throw e;
}); });
} }
...@@ -275,7 +275,7 @@ export const unstageChange = ({ commit, dispatch, getters }, path) => { ...@@ -275,7 +275,7 @@ export const unstageChange = ({ commit, dispatch, getters }, path) => {
export const openPendingTab = ({ commit, dispatch, getters, state }, { file, keyPrefix }) => { export const openPendingTab = ({ commit, dispatch, getters, state }, { file, keyPrefix }) => {
if (getters.activeFile && getters.activeFile.key === `${keyPrefix}-${file.key}`) return false; if (getters.activeFile && getters.activeFile.key === `${keyPrefix}-${file.key}`) return false;
state.openFiles.forEach(f => eventHub.$emit(`editor.update.model.dispose.${f.key}`)); state.openFiles.forEach((f) => eventHub.$emit(`editor.update.model.dispose.${f.key}`));
commit(types.ADD_PENDING_TAB, { file, keyPrefix }); commit(types.ADD_PENDING_TAB, { file, keyPrefix });
......
...@@ -33,7 +33,7 @@ export const getMergeRequestsForBranch = ( ...@@ -33,7 +33,7 @@ export const getMergeRequestsForBranch = (
commit(types.SET_CURRENT_MERGE_REQUEST, `${currentMR.iid}`); commit(types.SET_CURRENT_MERGE_REQUEST, `${currentMR.iid}`);
} }
}) })
.catch(e => { .catch((e) => {
flash( flash(
__(`Error fetching merge requests for ${branchId}`), __(`Error fetching merge requests for ${branchId}`),
'alert', 'alert',
...@@ -66,7 +66,7 @@ export const getMergeRequestData = ( ...@@ -66,7 +66,7 @@ export const getMergeRequestData = (
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the merge request.'), text: __('An error occurred while loading the merge request.'),
action: payload => action: (payload) =>
dispatch('getMergeRequestData', payload).then(() => dispatch('getMergeRequestData', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
), ),
...@@ -99,7 +99,7 @@ export const getMergeRequestChanges = ( ...@@ -99,7 +99,7 @@ export const getMergeRequestChanges = (
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the merge request changes.'), text: __('An error occurred while loading the merge request changes.'),
action: payload => action: (payload) =>
dispatch('getMergeRequestChanges', payload).then(() => dispatch('getMergeRequestChanges', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
), ),
...@@ -121,8 +121,8 @@ export const getMergeRequestVersions = ( ...@@ -121,8 +121,8 @@ export const getMergeRequestVersions = (
if (!state.projects[projectId].mergeRequests[mergeRequestId].versions.length || force) { if (!state.projects[projectId].mergeRequests[mergeRequestId].versions.length || force) {
service service
.getProjectMergeRequestVersions(targetProjectId || projectId, mergeRequestId) .getProjectMergeRequestVersions(targetProjectId || projectId, mergeRequestId)
.then(res => res.data) .then((res) => res.data)
.then(data => { .then((data) => {
commit(types.SET_MERGE_REQUEST_VERSIONS, { commit(types.SET_MERGE_REQUEST_VERSIONS, {
projectPath: projectId, projectPath: projectId,
mergeRequestId, mergeRequestId,
...@@ -133,7 +133,7 @@ export const getMergeRequestVersions = ( ...@@ -133,7 +133,7 @@ export const getMergeRequestVersions = (
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading the merge request version data.'), text: __('An error occurred while loading the merge request version data.'),
action: payload => action: (payload) =>
dispatch('getMergeRequestVersions', payload).then(() => dispatch('getMergeRequestVersions', payload).then(() =>
dispatch('setErrorMessage', null), dispatch('setErrorMessage', null),
), ),
...@@ -156,7 +156,7 @@ export const openMergeRequest = ( ...@@ -156,7 +156,7 @@ export const openMergeRequest = (
targetProjectId, targetProjectId,
mergeRequestId, mergeRequestId,
}) })
.then(mr => { .then((mr) => {
dispatch('setCurrentBranchId', mr.source_branch); dispatch('setCurrentBranchId', mr.source_branch);
return dispatch('getBranchData', { return dispatch('getBranchData', {
...@@ -186,7 +186,7 @@ export const openMergeRequest = ( ...@@ -186,7 +186,7 @@ export const openMergeRequest = (
mergeRequestId, mergeRequestId,
}), }),
) )
.then(mrChanges => { .then((mrChanges) => {
if (mrChanges.changes.length) { if (mrChanges.changes.length) {
dispatch('updateActivityBarView', leftSidebarViews.review.name); dispatch('updateActivityBarView', leftSidebarViews.review.name);
} }
...@@ -210,7 +210,7 @@ export const openMergeRequest = ( ...@@ -210,7 +210,7 @@ export const openMergeRequest = (
} }
}); });
}) })
.catch(e => { .catch((e) => {
flash(__('Error while loading the merge request. Please try again.')); flash(__('Error while loading the merge request. Please try again.'));
throw e; throw e;
}); });
...@@ -11,8 +11,8 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force ...@@ -11,8 +11,8 @@ export const getProjectData = ({ commit, state }, { namespace, projectId, force
commit(types.TOGGLE_LOADING, { entry: state }); commit(types.TOGGLE_LOADING, { entry: state });
service service
.getProjectData(namespace, projectId) .getProjectData(namespace, projectId)
.then(res => res.data) .then((res) => res.data)
.then(data => { .then((data) => {
commit(types.TOGGLE_LOADING, { entry: state }); commit(types.TOGGLE_LOADING, { entry: state });
commit(types.SET_PROJECT, { projectPath: `${namespace}/${projectId}`, project: data }); commit(types.SET_PROJECT, { projectPath: `${namespace}/${projectId}`, project: data });
commit(types.SET_CURRENT_PROJECT, `${namespace}/${projectId}`); commit(types.SET_CURRENT_PROJECT, `${namespace}/${projectId}`);
...@@ -61,7 +61,7 @@ export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch) ...@@ -61,7 +61,7 @@ export const createNewBranchFromDefault = ({ state, dispatch, getters }, branch)
.catch(() => { .catch(() => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred creating the new branch.'), text: __('An error occurred creating the new branch.'),
action: payload => dispatch('createNewBranchFromDefault', payload), action: (payload) => dispatch('createNewBranchFromDefault', payload),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: branch, actionPayload: branch,
}); });
...@@ -76,7 +76,7 @@ export const showBranchNotFoundError = ({ dispatch }, branchId) => { ...@@ -76,7 +76,7 @@ export const showBranchNotFoundError = ({ dispatch }, branchId) => {
}, },
false, false,
), ),
action: payload => dispatch('createNewBranchFromDefault', payload), action: (payload) => dispatch('createNewBranchFromDefault', payload),
actionText: __('Create branch'), actionText: __('Create branch'),
actionPayload: branchId, actionPayload: branchId,
}); });
...@@ -102,7 +102,7 @@ export const loadFile = ({ dispatch, state }, { basePath }) => { ...@@ -102,7 +102,7 @@ export const loadFile = ({ dispatch, state }, { basePath }) => {
if (basePath) { if (basePath) {
const path = basePath.slice(-1) === '/' ? basePath.slice(0, -1) : basePath; const path = basePath.slice(-1) === '/' ? basePath.slice(0, -1) : basePath;
const treeEntryKey = Object.keys(state.entries).find( const treeEntryKey = Object.keys(state.entries).find(
key => key === path && !state.entries[key].pending, (key) => key === path && !state.entries[key].pending,
); );
const treeEntry = state.entries[treeEntryKey]; const treeEntry = state.entries[treeEntryKey];
...@@ -144,7 +144,7 @@ export const loadBranch = ({ dispatch, getters, state }, { projectId, branchId } ...@@ -144,7 +144,7 @@ export const loadBranch = ({ dispatch, getters, state }, { projectId, branchId }
ref: branch.commit.id, ref: branch.commit.id,
}); });
}) })
.catch(err => { .catch((err) => {
dispatch('showBranchNotFoundError', branchId); dispatch('showBranchNotFoundError', branchId);
throw err; throw err;
}); });
......
...@@ -87,10 +87,10 @@ export const getFiles = ({ state, commit, dispatch }, payload = {}) => { ...@@ -87,10 +87,10 @@ export const getFiles = ({ state, commit, dispatch }, payload = {}) => {
resolve(); resolve();
}) })
.catch(e => { .catch((e) => {
dispatch('setErrorMessage', { dispatch('setErrorMessage', {
text: __('An error occurred while loading all the files.'), text: __('An error occurred while loading all the files.'),
action: actionPayload => action: (actionPayload) =>
dispatch('getFiles', actionPayload).then(() => dispatch('setErrorMessage', null)), dispatch('getFiles', actionPayload).then(() => dispatch('setErrorMessage', null)),
actionText: __('Please try again'), actionText: __('Please try again'),
actionPayload: { projectId, branchId }, actionPayload: { projectId, branchId },
......
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