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
37c2c4a2
Commit
37c2c4a2
authored
Dec 01, 2020
by
Thomas Randolph
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add action to change the fileByFile setting
parent
ecae140f
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
0 deletions
+35
-0
app/assets/javascripts/diffs/constants.js
app/assets/javascripts/diffs/constants.js
+2
-0
app/assets/javascripts/diffs/store/actions.js
app/assets/javascripts/diffs/store/actions.js
+16
-0
spec/frontend/diffs/store/actions_spec.js
spec/frontend/diffs/store/actions_spec.js
+17
-0
No files found.
app/assets/javascripts/diffs/constants.js
View file @
37c2c4a2
...
@@ -80,6 +80,8 @@ export const DIFF_FILE_MANUAL_COLLAPSE = 'manual';
...
@@ -80,6 +80,8 @@ export const DIFF_FILE_MANUAL_COLLAPSE = 'manual';
// Diff view single file mode
// Diff view single file mode
export
const
DIFF_FILE_BY_FILE_COOKIE_NAME
=
'
fileViewMode
'
;
export
const
DIFF_FILE_BY_FILE_COOKIE_NAME
=
'
fileViewMode
'
;
export
const
DIFF_VIEW_FILE_BY_FILE
=
'
single
'
;
export
const
DIFF_VIEW_FILE_BY_FILE
=
'
single
'
;
export
const
DIFF_VIEW_ALL_FILES
=
'
all
'
;
// State machine states
// State machine states
export
const
STATE_IDLING
=
'
idle
'
;
export
const
STATE_IDLING
=
'
idle
'
;
export
const
STATE_LOADING
=
'
loading
'
;
export
const
STATE_LOADING
=
'
loading
'
;
...
...
app/assets/javascripts/diffs/store/actions.js
View file @
37c2c4a2
...
@@ -44,6 +44,9 @@ import {
...
@@ -44,6 +44,9 @@ import {
EVT_PERF_MARK_FILE_TREE_START
,
EVT_PERF_MARK_FILE_TREE_START
,
EVT_PERF_MARK_FILE_TREE_END
,
EVT_PERF_MARK_FILE_TREE_END
,
EVT_PERF_MARK_DIFF_FILES_START
,
EVT_PERF_MARK_DIFF_FILES_START
,
DIFF_VIEW_FILE_BY_FILE
,
DIFF_VIEW_ALL_FILES
,
DIFF_FILE_BY_FILE_COOKIE_NAME
,
}
from
'
../constants
'
;
}
from
'
../constants
'
;
import
{
diffViewerModes
}
from
'
~/ide/constants
'
;
import
{
diffViewerModes
}
from
'
~/ide/constants
'
;
import
{
isCollapsed
}
from
'
../diff_file
'
;
import
{
isCollapsed
}
from
'
../diff_file
'
;
...
@@ -57,6 +60,7 @@ export const setBaseConfig = ({ commit }, options) => {
...
@@ -57,6 +60,7 @@ export const setBaseConfig = ({ commit }, options) => {
projectPath
,
projectPath
,
dismissEndpoint
,
dismissEndpoint
,
showSuggestPopover
,
showSuggestPopover
,
viewDiffsFileByFile
,
}
=
options
;
}
=
options
;
commit
(
types
.
SET_BASE_CONFIG
,
{
commit
(
types
.
SET_BASE_CONFIG
,
{
endpoint
,
endpoint
,
...
@@ -66,6 +70,7 @@ export const setBaseConfig = ({ commit }, options) => {
...
@@ -66,6 +70,7 @@ export const setBaseConfig = ({ commit }, options) => {
projectPath
,
projectPath
,
dismissEndpoint
,
dismissEndpoint
,
showSuggestPopover
,
showSuggestPopover
,
viewDiffsFileByFile
,
});
});
};
};
...
@@ -694,3 +699,14 @@ export const navigateToDiffFileIndex = ({ commit, state }, index) => {
...
@@ -694,3 +699,14 @@ export const navigateToDiffFileIndex = ({ commit, state }, index) => {
commit
(
types
.
VIEW_DIFF_FILE
,
fileHash
);
commit
(
types
.
VIEW_DIFF_FILE
,
fileHash
);
};
};
export
const
setFileByFile
=
({
commit
},
{
fileByFile
})
=>
{
const
fileViewMode
=
fileByFile
?
DIFF_VIEW_FILE_BY_FILE
:
DIFF_VIEW_ALL_FILES
;
commit
(
types
.
SET_FILE_BY_FILE
,
fileByFile
);
Cookies
.
set
(
DIFF_FILE_BY_FILE_COOKIE_NAME
,
fileViewMode
);
historyPushState
(
mergeUrlParams
({
[
DIFF_FILE_BY_FILE_COOKIE_NAME
]:
fileViewMode
},
window
.
location
.
href
),
);
};
spec/frontend/diffs/store/actions_spec.js
View file @
37c2c4a2
...
@@ -48,6 +48,7 @@ import {
...
@@ -48,6 +48,7 @@ import {
moveToNeighboringCommit
,
moveToNeighboringCommit
,
setCurrentDiffFileIdFromNote
,
setCurrentDiffFileIdFromNote
,
navigateToDiffFileIndex
,
navigateToDiffFileIndex
,
setFileByFile
,
}
from
'
~/diffs/store/actions
'
;
}
from
'
~/diffs/store/actions
'
;
import
eventHub
from
'
~/notes/event_hub
'
;
import
eventHub
from
'
~/notes/event_hub
'
;
import
*
as
types
from
'
~/diffs/store/mutation_types
'
;
import
*
as
types
from
'
~/diffs/store/mutation_types
'
;
...
@@ -1455,4 +1456,20 @@ describe('DiffsStoreActions', () => {
...
@@ -1455,4 +1456,20 @@ describe('DiffsStoreActions', () => {
);
);
});
});
});
});
describe
(
'
setFileByFile
'
,
()
=>
{
it
.
each
`
value
${
true
}
${
false
}
`
(
'
commits SET_FILE_BY_FILE with the new value $value
'
,
({
value
})
=>
{
return
testAction
(
setFileByFile
,
{
fileByFile
:
value
},
{
viewDiffsFileByFile
:
null
},
[{
type
:
types
.
SET_FILE_BY_FILE
,
payload
:
value
}],
[],
);
});
});
});
});
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