BigW Consortium Gitlab

Commit 8f7cf2ed by Tim Zallmann

Fixed Code review Comments

parent 4b4439e6
...@@ -108,24 +108,24 @@ router.beforeEach((to, from, next) => { ...@@ -108,24 +108,24 @@ router.beforeEach((to, from, next) => {
branchId: mr.source_branch, branchId: mr.source_branch,
}); });
store return store.dispatch('getFiles', {
.dispatch('getFiles', {
projectId: fullProjectId, projectId: fullProjectId,
branchId: mr.source_branch, branchId: mr.source_branch,
});
}) })
.then(() => { .then(() =>
store store.dispatch('getMergeRequestVersions', {
.dispatch('getMergeRequestChanges', {
projectId: fullProjectId, projectId: fullProjectId,
mergeRequestId: to.params.mrid, mergeRequestId: to.params.mrid,
}) }),
.then(mrChanges => { )
store .then(() =>
.dispatch('getMergeRequestVersions', { store.dispatch('getMergeRequestChanges', {
projectId: fullProjectId, projectId: fullProjectId,
mergeRequestId: to.params.mrid, mergeRequestId: to.params.mrid,
}) }),
.then(() => { )
.then(mrChanges => {
mrChanges.changes.forEach((change, ind) => { mrChanges.changes.forEach((change, ind) => {
const changeTreeEntry = store.state.entries[change.new_path]; const changeTreeEntry = store.state.entries[change.new_path];
...@@ -145,23 +145,7 @@ router.beforeEach((to, from, next) => { ...@@ -145,23 +145,7 @@ router.beforeEach((to, from, next) => {
}); });
}) })
.catch(e => { .catch(e => {
flash( flash('Error while loading the merge request. Please try again.');
'Error while loading the merge request versions. Please try again.',
);
throw e;
});
})
.catch(e => {
flash('Error while loading the merge request changes. Please try again.');
throw e;
});
})
.catch(e => {
flash('Error while loading the branch files. Please try again.');
throw e;
});
})
.catch(e => {
throw e; throw e;
}); });
} }
......
...@@ -21,7 +21,6 @@ export default class Model { ...@@ -21,7 +21,6 @@ export default class Model {
new this.monaco.Uri(null, null, this.file.path), new this.monaco.Uri(null, null, this.file.path),
)), )),
); );
if (this.file.mrChange) { if (this.file.mrChange) {
this.disposable.add( this.disposable.add(
(this.baseModel = this.monaco.editor.createModel( (this.baseModel = this.monaco.editor.createModel(
......
...@@ -32,7 +32,7 @@ export default { ...@@ -32,7 +32,7 @@ export default {
} }
return Vue.http return Vue.http
.get(file.rawPath.replace(file.branchId, sha), { .get(file.rawPath.replace(`/raw/${file.branchId}/${file.path}`, `/raw/${sha}/${file.path}`), {
params: { format: 'json' }, params: { format: 'json' },
}) })
.then(res => res.text()); .then(res => res.text());
......
...@@ -53,7 +53,6 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive ...@@ -53,7 +53,6 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive
.getFileData(file.url) .getFileData(file.url)
.then(res => { .then(res => {
const pageTitle = decodeURI(normalizeHeaders(res.headers)['PAGE-TITLE']); const pageTitle = decodeURI(normalizeHeaders(res.headers)['PAGE-TITLE']);
setPageTitle(pageTitle); setPageTitle(pageTitle);
return res.json(); return res.json();
...@@ -61,7 +60,7 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive ...@@ -61,7 +60,7 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive
.then(data => { .then(data => {
commit(types.SET_FILE_DATA, { data, file }); commit(types.SET_FILE_DATA, { data, file });
commit(types.TOGGLE_FILE_OPEN, path); commit(types.TOGGLE_FILE_OPEN, path);
if (makeFileActive) dispatch('setFileActive', file.path); if (makeFileActive) dispatch('setFileActive', path);
commit(types.TOGGLE_LOADING, { entry: file }); commit(types.TOGGLE_LOADING, { entry: file });
}) })
.catch(() => { .catch(() => {
...@@ -71,7 +70,7 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive ...@@ -71,7 +70,7 @@ export const getFileData = ({ state, commit, dispatch }, { path, makeFileActive
}; };
export const setFileMrChange = ({ state, commit }, { file, mrChange }) => { export const setFileMrChange = ({ state, commit }, { file, mrChange }) => {
commit(types.SET_FILE_MR_CHANGE, { file, mrChange }); commit(types.SET_FILE_MERGE_REQUEST_CHANGE, { file, mrChange });
}; };
export const getRawFileData = ({ state, commit, dispatch }, { path, baseSha }) => { export const getRawFileData = ({ state, commit, dispatch }, { path, baseSha }) => {
......
...@@ -46,6 +46,6 @@ export const TOGGLE_FILE_CHANGED = 'TOGGLE_FILE_CHANGED'; ...@@ -46,6 +46,6 @@ export const TOGGLE_FILE_CHANGED = 'TOGGLE_FILE_CHANGED';
export const SET_CURRENT_BRANCH = 'SET_CURRENT_BRANCH'; export const SET_CURRENT_BRANCH = 'SET_CURRENT_BRANCH';
export const SET_ENTRIES = 'SET_ENTRIES'; export const SET_ENTRIES = 'SET_ENTRIES';
export const CREATE_TMP_ENTRY = 'CREATE_TMP_ENTRY'; export const CREATE_TMP_ENTRY = 'CREATE_TMP_ENTRY';
export const SET_FILE_MR_CHANGE = 'SET_FILE_MR_CHANGE'; export const SET_FILE_MERGE_REQUEST_CHANGE = 'SET_FILE_MERGE_REQUEST_CHANGE';
export const UPDATE_VIEWER = 'UPDATE_VIEWER'; export const UPDATE_VIEWER = 'UPDATE_VIEWER';
export const UPDATE_DELAY_VIEWER_CHANGE = 'UPDATE_DELAY_VIEWER_CHANGE'; export const UPDATE_DELAY_VIEWER_CHANGE = 'UPDATE_DELAY_VIEWER_CHANGE';
...@@ -66,8 +66,8 @@ export default { ...@@ -66,8 +66,8 @@ export default {
editorColumn, editorColumn,
}); });
}, },
[types.SET_FILE_MR_CHANGE](state, { file, mrChange }) { [types.SET_FILE_MERGE_REQUEST_CHANGE](state, { file, mrChange }) {
Object.assign(file, { Object.assign(state.entries[file.path], {
mrChange, mrChange,
}); });
}, },
......
...@@ -7,17 +7,15 @@ export default { ...@@ -7,17 +7,15 @@ export default {
}); });
}, },
[types.SET_MERGE_REQUEST](state, { projectPath, mergeRequestId, mergeRequest }) { [types.SET_MERGE_REQUEST](state, { projectPath, mergeRequestId, mergeRequest }) {
// Add client side properties Object.assign(state.projects[projectPath], {
Object.assign(mergeRequest, { mergeRequests: {
[mergeRequestId]: {
...mergeRequest,
active: true, active: true,
changes: [], changes: [],
versions: [], versions: [],
baseCommitSha: null, baseCommitSha: null,
}); },
Object.assign(state.projects[projectPath], {
mergeRequests: {
[mergeRequestId]: mergeRequest,
}, },
}); });
}, },
......
...@@ -100,10 +100,9 @@ export default { ...@@ -100,10 +100,9 @@ export default {
<div v-if="mr.isOpen"> <div v-if="mr.isOpen">
<a <a
:disabled="mr.sourceBranchRemoved" v-if="!mr.sourceBranchRemoved"
:href="webIdePath" :href="webIdePath"
class="btn btn-sm btn-default inline js-web-ide" class="btn btn-sm btn-default inline js-web-ide"
type="button"
> >
{{ s__("mrWidget|Web IDE") }} {{ s__("mrWidget|Web IDE") }}
</a> </a>
......
...@@ -25,12 +25,6 @@ describe('IDE changed file icon', () => { ...@@ -25,12 +25,6 @@ describe('IDE changed file icon', () => {
expect(vm.changedIcon).toBe('file-modified'); expect(vm.changedIcon).toBe('file-modified');
}); });
it('equals git-merge when not a temp file and has no changes', () => {
vm.file.changed = false;
expect(vm.changedIcon).toBe('git-merge');
});
it('equals file-addition when a temp file', () => { it('equals file-addition when a temp file', () => {
vm.file.tempFile = true; vm.file.tempFile = true;
...@@ -43,12 +37,6 @@ describe('IDE changed file icon', () => { ...@@ -43,12 +37,6 @@ describe('IDE changed file icon', () => {
expect(vm.changedIconClass).toContain('multi-file-modified'); expect(vm.changedIconClass).toContain('multi-file-modified');
}); });
it('includes multi-git-merge when a mr changed file', () => {
vm.file.changed = false;
expect(vm.changedIconClass).toContain('multi-git-merge');
});
it('includes multi-file-addition when a temp file', () => { it('includes multi-file-addition when a temp file', () => {
vm.file.tempFile = true; vm.file.tempFile = true;
......
...@@ -151,25 +151,25 @@ describe('RepoEditor', () => { ...@@ -151,25 +151,25 @@ describe('RepoEditor', () => {
describe('setup editor for merge request viewing', () => { describe('setup editor for merge request viewing', () => {
beforeEach(done => { beforeEach(done => {
// Resetting as the main test setup has already done it
vm.$destroy(); vm.$destroy();
resetStore(vm.$store); resetStore(vm.$store);
Editor.editorInstance.modelManager.dispose(); Editor.editorInstance.modelManager.dispose();
const f = file(); const f = {
...file(),
active: true,
tempFile: true,
html: 'testing',
mrChange: { diff: 'ABC' },
baseRaw: 'testing',
content: 'test',
};
const RepoEditor = Vue.extend(repoEditor); const RepoEditor = Vue.extend(repoEditor);
vm = createComponentWithStore(RepoEditor, store, { vm = createComponentWithStore(RepoEditor, store, {
file: f, file: f,
}); });
f.active = true;
f.tempFile = true;
f.html = 'testing';
f.mrChange = { diff: 'ABC' };
f.baseRaw = 'testing';
f.content = 'test';
vm.$store.state.openFiles.push(f); vm.$store.state.openFiles.push(f);
vm.$store.state.entries[f.path] = f; vm.$store.state.entries[f.path] = f;
......
...@@ -125,9 +125,9 @@ describe('IDE store file mutations', () => { ...@@ -125,9 +125,9 @@ describe('IDE store file mutations', () => {
}); });
}); });
describe('SET_FILE_MR_CHANGE', () => { describe('SET_FILE_MERGE_REQUEST_CHANGE', () => {
it('sets file mr change', () => { it('sets file mr change', () => {
mutations.SET_FILE_MR_CHANGE(localState, { mutations.SET_FILE_MERGE_REQUEST_CHANGE(localState, {
file: localFile, file: localFile,
mrChange: { diff: 'ABC' }, mrChange: { diff: 'ABC' },
}); });
......
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