Commit cb3d5494 authored by Thomas Randolph's avatar Thomas Randolph

Update action name to be more accurate

When we execute the SET_CURRENT_DIFF_FILE mutation, there is
no toggle. Since that's the only thing this action does, the
name should reflect that it's a setter.
parent 4848ae3d
...@@ -15,14 +15,14 @@ export default { ...@@ -15,14 +15,14 @@ export default {
...mapGetters('batchComments', ['draftsCount', 'sortedDrafts']), ...mapGetters('batchComments', ['draftsCount', 'sortedDrafts']),
}, },
methods: { methods: {
...mapActions('diffs', ['toggleActiveFileByHash']), ...mapActions('diffs', ['setCurrentFileHash']),
...mapActions('batchComments', ['scrollToDraft']), ...mapActions('batchComments', ['scrollToDraft']),
isLast(index) { isLast(index) {
return index === this.sortedDrafts.length - 1; return index === this.sortedDrafts.length - 1;
}, },
async onClickDraft(draft) { async onClickDraft(draft) {
if (this.viewDiffsFileByFile && draft.file_hash) { if (this.viewDiffsFileByFile && draft.file_hash) {
await this.toggleActiveFileByHash(draft.file_hash); await this.setCurrentFileHash(draft.file_hash);
} }
await this.scrollToDraft(draft); await this.scrollToDraft(draft);
......
...@@ -221,7 +221,7 @@ export default { ...@@ -221,7 +221,7 @@ export default {
'toggleFileDiscussions', 'toggleFileDiscussions',
'toggleFileDiscussionWrappers', 'toggleFileDiscussionWrappers',
'toggleFullDiff', 'toggleFullDiff',
'toggleActiveFileByHash', 'setCurrentFileHash',
'reviewFile', 'reviewFile',
'setFileCollapsedByUser', 'setFileCollapsedByUser',
]), ]),
...@@ -244,7 +244,7 @@ export default { ...@@ -244,7 +244,7 @@ export default {
scrollToElement(document.querySelector(selector)); scrollToElement(document.querySelector(selector));
window.location.hash = selector; window.location.hash = selector;
if (!this.viewDiffsFileByFile) { if (!this.viewDiffsFileByFile) {
this.toggleActiveFileByHash(this.diffFile.file_hash); this.setCurrentFileHash(this.diffFile.file_hash);
} }
} }
}, },
......
...@@ -520,7 +520,7 @@ export const toggleTreeOpen = ({ commit }, path) => { ...@@ -520,7 +520,7 @@ export const toggleTreeOpen = ({ commit }, path) => {
commit(types.TOGGLE_FOLDER_OPEN, path); commit(types.TOGGLE_FOLDER_OPEN, path);
}; };
export const toggleActiveFileByHash = ({ commit }, hash) => { export const setCurrentFileHash = ({ commit }, hash) => {
commit(types.SET_CURRENT_DIFF_FILE, hash); commit(types.SET_CURRENT_DIFF_FILE, hash);
}; };
......
...@@ -7,7 +7,7 @@ Vue.use(Vuex); ...@@ -7,7 +7,7 @@ Vue.use(Vuex);
let wrapper; let wrapper;
const toggleActiveFileByHash = jest.fn(); const setCurrentFileHash = jest.fn();
const scrollToDraft = jest.fn(); const scrollToDraft = jest.fn();
function factory({ viewDiffsFileByFile = false, draftsCount = 1, sortedDrafts = [] } = {}) { function factory({ viewDiffsFileByFile = false, draftsCount = 1, sortedDrafts = [] } = {}) {
...@@ -16,7 +16,7 @@ function factory({ viewDiffsFileByFile = false, draftsCount = 1, sortedDrafts = ...@@ -16,7 +16,7 @@ function factory({ viewDiffsFileByFile = false, draftsCount = 1, sortedDrafts =
diffs: { diffs: {
namespaced: true, namespaced: true,
actions: { actions: {
toggleActiveFileByHash, setCurrentFileHash,
}, },
state: { state: {
viewDiffsFileByFile, viewDiffsFileByFile,
...@@ -51,7 +51,7 @@ describe('Batch comments preview dropdown', () => { ...@@ -51,7 +51,7 @@ describe('Batch comments preview dropdown', () => {
await Vue.nextTick(); await Vue.nextTick();
expect(toggleActiveFileByHash).toHaveBeenCalledWith(expect.anything(), 'hash'); expect(setCurrentFileHash).toHaveBeenCalledWith(expect.anything(), 'hash');
expect(scrollToDraft).toHaveBeenCalledWith(expect.anything(), { id: 1, file_hash: 'hash' }); expect(scrollToDraft).toHaveBeenCalledWith(expect.anything(), { id: 1, file_hash: 'hash' });
}); });
......
...@@ -59,7 +59,7 @@ describe('DiffFileHeader component', () => { ...@@ -59,7 +59,7 @@ describe('DiffFileHeader component', () => {
toggleFileDiscussions: jest.fn(), toggleFileDiscussions: jest.fn(),
toggleFileDiscussionWrappers: jest.fn(), toggleFileDiscussionWrappers: jest.fn(),
toggleFullDiff: jest.fn(), toggleFullDiff: jest.fn(),
toggleActiveFileByHash: jest.fn(), setCurrentFileHash: jest.fn(),
setFileCollapsedByUser: jest.fn(), setFileCollapsedByUser: jest.fn(),
reviewFile: jest.fn(), reviewFile: jest.fn(),
}, },
......
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