Skip to content
Snippets Groups Projects
Unverified Commit 156a9d39 authored by Filipa Lacerda's avatar Filipa Lacerda
Browse files

Transforms diffs module to a namespaced one to avoid console error due to rewire export.

Detailed: Because of rewire we need to export a default empty object in our actions to prevent it to export the wrong default in karma. Vuex getters are global, and because the Vuex store uses several non namespaced moduled, there was already a getter named default, due to the same empty export.
In order to solve it I chose to namespace the module. Could also be fixed by importing the getters explicitly instead of all of them.
parent 7a17f8d8
No related branches found
No related tags found
1 merge request!10495Merge Requests - Assignee
Showing
with 15 additions and 12 deletions
Loading
Loading
@@ -63,7 +63,8 @@ export default {
plainDiffPath: state => state.diffs.plainDiffPath,
emailPatchPath: state => state.diffs.emailPatchPath,
}),
...mapGetters(['isParallelView', 'isNotesFetched']),
...mapGetters('diffs', ['isParallelView']),
...mapGetters(['isNotesFetched']),
targetBranch() {
return {
branchName: this.targetBranchName,
Loading
Loading
@@ -115,7 +116,7 @@ export default {
this.adjustView();
},
methods: {
...mapActions(['setBaseConfig', 'fetchDiffFiles']),
...mapActions('diffs', ['setBaseConfig', 'fetchDiffFiles']),
fetchData() {
this.fetchDiffFiles().catch(() => {
createFlash(__('Something went wrong on our end. Please try again!'));
Loading
Loading
Loading
Loading
@@ -31,7 +31,7 @@ export default {
};
},
computed: {
...mapGetters(['isInlineView', 'isParallelView', 'areAllFilesCollapsed']),
...mapGetters('diffs', ['isInlineView', 'isParallelView', 'areAllFilesCollapsed']),
sumAddedLines() {
return this.sumValues('addedLines');
},
Loading
Loading
@@ -66,7 +66,7 @@ export default {
document.removeEventListener('scroll', this.handleScroll);
},
methods: {
...mapActions(['setInlineDiffViewType', 'setParallelDiffViewType', 'expandAllFiles']),
...mapActions('diffs', ['setInlineDiffViewType', 'setParallelDiffViewType', 'expandAllFiles']),
pluralize,
handleScroll() {
if (!this.updating) {
Loading
Loading
Loading
Loading
@@ -22,7 +22,7 @@ export default {
projectPath: state => state.diffs.projectPath,
endpoint: state => state.diffs.endpoint,
}),
...mapGetters(['isInlineView', 'isParallelView']),
...mapGetters('diffs', ['isInlineView', 'isParallelView']),
diffMode() {
const diffModeKey = Object.keys(diffModes).find(key => this.diffFile[`${key}File`]);
return diffModes[diffModeKey] || diffModes.replaced;
Loading
Loading
Loading
Loading
@@ -55,7 +55,7 @@ export default {
document.removeEventListener('scroll', this.handleScroll);
},
methods: {
...mapActions(['loadCollapsedDiff']),
...mapActions('diffs', ['loadCollapsedDiff']),
handleToggle() {
const { collapsed, highlightedDiffLines, parallelDiffLines } = this.file;
 
Loading
Loading
Loading
Loading
@@ -108,7 +108,7 @@ export default {
},
},
methods: {
...mapActions(['loadMoreLines', 'showCommentForm']),
...mapActions('diffs', ['loadMoreLines', 'showCommentForm']),
handleCommentButton() {
this.showCommentForm({ lineCode: this.lineCode });
},
Loading
Loading
Loading
Loading
@@ -59,7 +59,8 @@ export default {
}
},
methods: {
...mapActions(['cancelCommentForm', 'saveNote', 'fetchDiscussions']),
...mapActions('diffs', ['cancelCommentForm']),
...mapActions(['saveNote', 'fetchDiscussions']),
handleCancelCommentForm() {
this.autosave.reset();
this.cancelCommentForm({
Loading
Loading
Loading
Loading
@@ -36,7 +36,7 @@ export default {
};
},
computed: {
...mapGetters(['isInlineView']),
...mapGetters('diffs', ['isInlineView']),
isContextLine() {
return this.line.type === CONTEXT_LINE_TYPE;
},
Loading
Loading
Loading
Loading
@@ -20,7 +20,7 @@ export default {
},
},
computed: {
...mapGetters(['commitId']),
...mapGetters('diffs', ['commitId']),
normalizedDiffLines() {
return this.diffLines.map(line => (line.richText ? trimFirstCharOfLineContent(line) : line));
},
Loading
Loading
Loading
Loading
@@ -40,7 +40,7 @@ export default {
};
},
computed: {
...mapGetters(['isParallelView']),
...mapGetters('diffs', ['isParallelView']),
isContextLine() {
return this.line.left.type === CONTEXT_LINE_TYPE;
},
Loading
Loading
Loading
Loading
@@ -21,7 +21,7 @@ export default {
},
},
computed: {
...mapGetters(['commitId']),
...mapGetters('diffs', ['commitId']),
parallelDiffLines() {
return this.diffLines.map(line => {
const parallelLine = Object.assign({}, line);
Loading
Loading
Loading
Loading
@@ -4,6 +4,7 @@ import mutations from '../mutations';
import createState from './diff_state';
 
export default {
namespaced: true,
state: createState(),
getters,
actions,
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment