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
1b04fb50
Commit
1b04fb50
authored
Apr 07, 2021
by
Thomas Randolph
Committed by
Mike Greiling
Apr 07, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Sync single-file mode user preference
parent
08c5076e
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
50 additions
and
10 deletions
+50
-10
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+13
-1
changelogs/unreleased/tor-feature-persist-file-by-file-api-save.yml
.../unreleased/tor-feature-persist-file-by-file-api-save.yml
+5
-0
spec/frontend/diffs/store/actions_spec.js
spec/frontend/diffs/store/actions_spec.js
+32
-9
No files found.
app/assets/javascripts/diffs/store/actions.js
View file @
1b04fb50
...
@@ -793,10 +793,22 @@ export const navigateToDiffFileIndex = ({ commit, state }, index) => {
...
@@ -793,10 +793,22 @@ export const navigateToDiffFileIndex = ({ commit, state }, index) => {
commit
(
types
.
VIEW_DIFF_FILE
,
fileHash
);
commit
(
types
.
VIEW_DIFF_FILE
,
fileHash
);
};
};
export
const
setFileByFile
=
({
commit
},
{
fileByFile
})
=>
{
export
const
setFileByFile
=
({
state
,
commit
},
{
fileByFile
})
=>
{
const
fileViewMode
=
fileByFile
?
DIFF_VIEW_FILE_BY_FILE
:
DIFF_VIEW_ALL_FILES
;
const
fileViewMode
=
fileByFile
?
DIFF_VIEW_FILE_BY_FILE
:
DIFF_VIEW_ALL_FILES
;
commit
(
types
.
SET_FILE_BY_FILE
,
fileByFile
);
commit
(
types
.
SET_FILE_BY_FILE
,
fileByFile
);
Cookies
.
set
(
DIFF_FILE_BY_FILE_COOKIE_NAME
,
fileViewMode
);
Cookies
.
set
(
DIFF_FILE_BY_FILE_COOKIE_NAME
,
fileViewMode
);
return
axios
.
put
(
state
.
endpointUpdateUser
,
{
view_diffs_file_by_file
:
fileByFile
,
})
.
then
(()
=>
{
// https://gitlab.com/gitlab-org/gitlab/-/issues/326961
// We can't even do a simple console warning here because
// the pipeline will fail. However, the issue above will
// eventually handle errors appropriately.
// console.warn('Saving the file-by-fil user preference failed.');
});
};
};
export
function
reviewFile
({
commit
,
state
},
{
file
,
reviewed
=
true
})
{
export
function
reviewFile
({
commit
,
state
},
{
file
,
reviewed
=
true
})
{
...
...
changelogs/unreleased/tor-feature-persist-file-by-file-api-save.yml
0 → 100644
View file @
1b04fb50
---
title
:
Sync single-file mode user preference when changed from the MR cog menu checkbox
merge_request
:
55931
author
:
type
:
changed
spec/frontend/diffs/store/actions_spec.js
View file @
1b04fb50
...
@@ -1507,19 +1507,42 @@ describe('DiffsStoreActions', () => {
...
@@ -1507,19 +1507,42 @@ describe('DiffsStoreActions', () => {
});
});
describe
(
'
setFileByFile
'
,
()
=>
{
describe
(
'
setFileByFile
'
,
()
=>
{
const
updateUserEndpoint
=
'
user/prefs
'
;
let
putSpy
;
let
mock
;
beforeEach
(()
=>
{
mock
=
new
MockAdapter
(
axios
);
putSpy
=
jest
.
spyOn
(
axios
,
'
put
'
);
mock
.
onPut
(
updateUserEndpoint
).
reply
(
200
,
{});
});
afterEach
(()
=>
{
mock
.
restore
();
});
it
.
each
`
it
.
each
`
value
value
${
true
}
${
true
}
${
false
}
${
false
}
`
(
'
commits SET_FILE_BY_FILE with the new value $value
'
,
({
value
})
=>
{
`
(
return
testAction
(
'
commits SET_FILE_BY_FILE and persists the File-by-File user preference with the new value $value
'
,
setFileByFile
,
async
({
value
})
=>
{
{
fileByFile
:
value
},
await
testAction
(
{
viewDiffsFileByFile
:
null
},
setFileByFile
,
[{
type
:
types
.
SET_FILE_BY_FILE
,
payload
:
value
}],
{
fileByFile
:
value
},
[],
{
);
viewDiffsFileByFile
:
null
,
});
endpointUpdateUser
:
updateUserEndpoint
,
},
[{
type
:
types
.
SET_FILE_BY_FILE
,
payload
:
value
}],
[],
);
expect
(
putSpy
).
toHaveBeenCalledWith
(
updateUserEndpoint
,
{
view_diffs_file_by_file
:
value
});
},
);
});
});
describe
(
'
reviewFile
'
,
()
=>
{
describe
(
'
reviewFile
'
,
()
=>
{
...
...
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