Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
aefff876
Commit
aefff876
authored
May 20, 2020
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up unnecessary actions
parent
1ded6098
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
47 deletions
+11
-47
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+5
-7
spec/frontend/diffs/store/actions_spec.js
spec/frontend/diffs/store/actions_spec.js
+6
-40
No files found.
app/assets/javascripts/diffs/store/actions.js
View file @
aefff876
...
...
@@ -507,9 +507,6 @@ export const cacheTreeListWidth = (_, size) => {
localStorage
.
setItem
(
TREE_LIST_WIDTH_STORAGE_KEY
,
size
);
};
export
const
requestFullDiff
=
({
commit
},
filePath
)
=>
commit
(
types
.
REQUEST_FULL_DIFF
,
filePath
);
export
const
receiveFullDiffSucess
=
({
commit
},
{
filePath
})
=>
commit
(
types
.
RECEIVE_FULL_DIFF_SUCCESS
,
{
filePath
});
export
const
receiveFullDiffError
=
({
commit
},
filePath
)
=>
{
commit
(
types
.
RECEIVE_FULL_DIFF_ERROR
,
filePath
);
createFlash
(
s__
(
'
MergeRequest|Error loading full diff. Please try again.
'
));
...
...
@@ -600,7 +597,7 @@ export const setExpandedDiffLines = ({ commit, state }, { file, data }) => {
}
};
export
const
fetchFullDiff
=
({
dispatch
},
file
)
=>
export
const
fetchFullDiff
=
({
commit
,
dispatch
},
file
)
=>
axios
.
get
(
file
.
context_lines_path
,
{
params
:
{
...
...
@@ -609,15 +606,16 @@ export const fetchFullDiff = ({ dispatch }, file) =>
},
})
.
then
(({
data
})
=>
{
dispatch
(
'
receiveFullDiffSucess
'
,
{
filePath
:
file
.
file_path
});
commit
(
types
.
RECEIVE_FULL_DIFF_SUCCESS
,
{
filePath
:
file
.
file_path
});
dispatch
(
'
setExpandedDiffLines
'
,
{
file
,
data
});
})
.
catch
(()
=>
dispatch
(
'
receiveFullDiffError
'
,
file
.
file_path
));
export
const
toggleFullDiff
=
({
dispatch
,
getters
,
state
},
filePath
)
=>
{
export
const
toggleFullDiff
=
({
dispatch
,
commit
,
getters
,
state
},
filePath
)
=>
{
const
file
=
state
.
diffFiles
.
find
(
f
=>
f
.
file_path
===
filePath
);
dispatch
(
'
requestFullDiff
'
,
filePath
);
commit
(
types
.
REQUEST_FULL_DIFF
,
filePath
);
if
(
file
.
isShowingFullFile
)
{
dispatch
(
'
loadCollapsedDiff
'
,
file
)
...
...
spec/frontend/diffs/store/actions_spec.js
View file @
aefff876
...
...
@@ -35,8 +35,6 @@ import {
setRenderTreeList
,
setShowWhitespace
,
setRenderIt
,
requestFullDiff
,
receiveFullDiffSucess
,
receiveFullDiffError
,
fetchFullDiff
,
toggleFullDiff
,
...
...
@@ -1136,34 +1134,8 @@ describe('DiffsStoreActions', () => {
});
});
describe
(
'
requestFullDiff
'
,
()
=>
{
it
(
'
commits REQUEST_FULL_DIFF
'
,
done
=>
{
testAction
(
requestFullDiff
,
'
file
'
,
{},
[{
type
:
types
.
REQUEST_FULL_DIFF
,
payload
:
'
file
'
}],
[],
done
,
);
});
});
describe
(
'
receiveFullDiffSucess
'
,
()
=>
{
it
(
'
commits REQUEST_FULL_DIFF
'
,
done
=>
{
testAction
(
receiveFullDiffSucess
,
{
filePath
:
'
test
'
},
{},
[{
type
:
types
.
RECEIVE_FULL_DIFF_SUCCESS
,
payload
:
{
filePath
:
'
test
'
}
}],
[],
done
,
);
});
});
describe
(
'
receiveFullDiffError
'
,
()
=>
{
it
(
'
commits REQUEST_FULL_DIFF
'
,
done
=>
{
it
(
'
updates state with the file that did not load
'
,
done
=>
{
testAction
(
receiveFullDiffError
,
'
file
'
,
...
...
@@ -1191,7 +1163,7 @@ describe('DiffsStoreActions', () => {
mock
.
onGet
(
`
${
gl
.
TEST_HOST
}
/context`
).
replyOnce
(
200
,
[
'
test
'
]);
});
it
(
'
dispatches receiveFullDiffSuces
s
'
,
done
=>
{
it
(
'
commits the success and dispatches an action to expand the new line
s
'
,
done
=>
{
const
file
=
{
context_lines_path
:
`
${
gl
.
TEST_HOST
}
/context`
,
file_path
:
'
test
'
,
...
...
@@ -1201,11 +1173,8 @@ describe('DiffsStoreActions', () => {
fetchFullDiff
,
file
,
null
,
[],
[
{
type
:
'
receiveFullDiffSucess
'
,
payload
:
{
filePath
:
'
test
'
}
},
{
type
:
'
setExpandedDiffLines
'
,
payload
:
{
file
,
data
:
[
'
test
'
]
}
},
],
[{
type
:
types
.
RECEIVE_FULL_DIFF_SUCCESS
,
payload
:
{
filePath
:
'
test
'
}
}],
[{
type
:
'
setExpandedDiffLines
'
,
payload
:
{
file
,
data
:
[
'
test
'
]
}
}],
done
,
);
});
...
...
@@ -1243,11 +1212,8 @@ describe('DiffsStoreActions', () => {
toggleFullDiff
,
'
test
'
,
state
,
[],
[
{
type
:
'
requestFullDiff
'
,
payload
:
'
test
'
},
{
type
:
'
fetchFullDiff
'
,
payload
:
state
.
diffFiles
[
0
]
},
],
[{
type
:
types
.
REQUEST_FULL_DIFF
,
payload
:
'
test
'
}],
[{
type
:
'
fetchFullDiff
'
,
payload
:
state
.
diffFiles
[
0
]
}],
done
,
);
});
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment