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
bf4a91ef
Commit
bf4a91ef
authored
Nov 03, 2020
by
Samantha Ming
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Persist loading state while applying MR suggestion
Issue:
https://gitlab.com/gitlab-org/gitlab/-/issues/250859
parent
127db4b9
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
68 additions
and
8 deletions
+68
-8
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+18
-1
app/assets/javascripts/notes/stores/modules/index.js
app/assets/javascripts/notes/stores/modules/index.js
+1
-0
app/assets/javascripts/notes/stores/mutation_types.js
app/assets/javascripts/notes/stores/mutation_types.js
+1
-0
app/assets/javascripts/notes/stores/mutations.js
app/assets/javascripts/notes/stores/mutations.js
+4
-0
changelogs/unreleased/250859-mr-suggestion-retain-spinner.yml
...gelogs/unreleased/250859-mr-suggestion-retain-spinner.yml
+5
-0
spec/frontend/notes/stores/actions_spec.js
spec/frontend/notes/stores/actions_spec.js
+29
-7
spec/frontend/notes/stores/mutation_spec.js
spec/frontend/notes/stores/mutation_spec.js
+10
-0
No files found.
app/assets/javascripts/notes/stores/actions.js
View file @
bf4a91ef
...
...
@@ -435,6 +435,10 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
};
const
pollSuccessCallBack
=
(
resp
,
commit
,
state
,
getters
,
dispatch
)
=>
{
if
(
state
.
isResolvingDiscussion
)
{
return
null
;
}
if
(
resp
.
notes
?.
length
)
{
dispatch
(
'
updateOrCreateNotes
'
,
resp
.
notes
);
dispatch
(
'
startTaskList
'
);
...
...
@@ -574,6 +578,9 @@ export const submitSuggestion = (
const
dispatchResolveDiscussion
=
()
=>
dispatch
(
'
resolveDiscussion
'
,
{
discussionId
}).
catch
(()
=>
{});
commit
(
types
.
SET_RESOLVING_DISCUSSION
,
true
);
dispatch
(
'
stopPolling
'
);
return
Api
.
applySuggestion
(
suggestionId
)
.
then
(()
=>
commit
(
types
.
APPLY_SUGGESTION
,
{
discussionId
,
noteId
,
suggestionId
}))
.
then
(
dispatchResolveDiscussion
)
...
...
@@ -587,6 +594,10 @@ export const submitSuggestion = (
const
flashMessage
=
errorMessage
||
defaultMessage
;
Flash
(
__
(
flashMessage
),
'
alert
'
,
flashContainer
);
})
.
finally
(()
=>
{
commit
(
types
.
SET_RESOLVING_DISCUSSION
,
false
);
dispatch
(
'
restartPolling
'
);
});
};
...
...
@@ -605,6 +616,8 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
});
commit
(
types
.
SET_APPLYING_BATCH_STATE
,
true
);
commit
(
types
.
SET_RESOLVING_DISCUSSION
,
true
);
dispatch
(
'
stopPolling
'
);
return
Api
.
applySuggestionBatch
(
suggestionIds
)
.
then
(()
=>
Promise
.
all
(
applyAllSuggestions
()))
...
...
@@ -621,7 +634,11 @@ export const submitSuggestionBatch = ({ commit, dispatch, state }, { flashContai
Flash
(
__
(
flashMessage
),
'
alert
'
,
flashContainer
);
})
.
finally
(()
=>
commit
(
types
.
SET_APPLYING_BATCH_STATE
,
false
));
.
finally
(()
=>
{
commit
(
types
.
SET_APPLYING_BATCH_STATE
,
false
);
commit
(
types
.
SET_RESOLVING_DISCUSSION
,
false
);
dispatch
(
'
restartPolling
'
);
});
};
export
const
addSuggestionInfoToBatch
=
({
commit
},
{
suggestionId
,
noteId
,
discussionId
})
=>
...
...
app/assets/javascripts/notes/stores/modules/index.js
View file @
bf4a91ef
...
...
@@ -42,6 +42,7 @@ export default () => ({
current_user
:
{},
preview_note_path
:
'
path/to/preview
'
,
},
isResolvingDiscussion
:
false
,
commentsDisabled
:
false
,
resolvableDiscussionsCount
:
0
,
unresolvedDiscussionsCount
:
0
,
...
...
app/assets/javascripts/notes/stores/mutation_types.js
View file @
bf4a91ef
...
...
@@ -38,6 +38,7 @@ export const SET_TIMELINE_VIEW = 'SET_TIMELINE_VIEW';
export
const
SET_SELECTED_COMMENT_POSITION
=
'
SET_SELECTED_COMMENT_POSITION
'
;
export
const
SET_SELECTED_COMMENT_POSITION_HOVER
=
'
SET_SELECTED_COMMENT_POSITION_HOVER
'
;
export
const
SET_FETCHING_DISCUSSIONS
=
'
SET_FETCHING_DISCUSSIONS
'
;
export
const
SET_RESOLVING_DISCUSSION
=
'
SET_RESOLVING_DISCUSSION
'
;
// Issue
export
const
CLOSE_ISSUE
=
'
CLOSE_ISSUE
'
;
...
...
app/assets/javascripts/notes/stores/mutations.js
View file @
bf4a91ef
...
...
@@ -213,6 +213,10 @@ export default {
}
},
[
types
.
SET_RESOLVING_DISCUSSION
](
state
,
isResolving
)
{
state
.
isResolvingDiscussion
=
isResolving
;
},
[
types
.
UPDATE_NOTE
](
state
,
note
)
{
const
noteObj
=
utils
.
findNoteObjectById
(
state
.
discussions
,
note
.
discussion_id
);
...
...
changelogs/unreleased/250859-mr-suggestion-retain-spinner.yml
0 → 100644
View file @
bf4a91ef
---
title
:
Retain spinner when applying MR suggestions
merge_request
:
46203
author
:
type
:
fixed
spec/frontend/notes/stores/actions_spec.js
View file @
bf4a91ef
...
...
@@ -944,10 +944,16 @@ describe('Actions Notes Store', () => {
it
(
'
when service success, commits and resolves discussion
'
,
done
=>
{
testSubmitSuggestion
(
done
,
()
=>
{
expect
(
commit
.
mock
.
calls
).
toEqual
([
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
true
],
[
mutationTypes
.
APPLY_SUGGESTION
,
{
discussionId
,
noteId
,
suggestionId
}],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
false
],
]);
expect
(
dispatch
.
mock
.
calls
).
toEqual
([[
'
resolveDiscussion
'
,
{
discussionId
}]]);
expect
(
dispatch
.
mock
.
calls
).
toEqual
([
[
'
stopPolling
'
],
[
'
resolveDiscussion
'
,
{
discussionId
}],
[
'
restartPolling
'
],
]);
expect
(
Flash
).
not
.
toHaveBeenCalled
();
});
});
...
...
@@ -958,8 +964,11 @@ describe('Actions Notes Store', () => {
Api
.
applySuggestion
.
mockReturnValue
(
Promise
.
reject
(
response
));
testSubmitSuggestion
(
done
,
()
=>
{
expect
(
commit
).
not
.
toHaveBeenCalled
();
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
commit
.
mock
.
calls
).
toEqual
([
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
true
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
false
],
]);
expect
(
dispatch
.
mock
.
calls
).
toEqual
([[
'
stopPolling
'
],
[
'
restartPolling
'
]]);
expect
(
Flash
).
toHaveBeenCalledWith
(
TEST_ERROR_MESSAGE
,
'
alert
'
,
flashContainer
);
});
});
...
...
@@ -970,8 +979,11 @@ describe('Actions Notes Store', () => {
Api
.
applySuggestion
.
mockReturnValue
(
Promise
.
reject
(
response
));
testSubmitSuggestion
(
done
,
()
=>
{
expect
(
commit
).
not
.
toHaveBeenCalled
();
expect
(
dispatch
).
not
.
toHaveBeenCalled
();
expect
(
commit
.
mock
.
calls
).
toEqual
([
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
true
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
false
],
]);
expect
(
dispatch
.
mock
.
calls
).
toEqual
([[
'
stopPolling
'
],
[
'
restartPolling
'
]]);
expect
(
Flash
).
toHaveBeenCalledWith
(
'
Something went wrong while applying the suggestion. Please try again.
'
,
'
alert
'
,
...
...
@@ -1015,15 +1027,19 @@ describe('Actions Notes Store', () => {
testSubmitSuggestionBatch
(
done
,
()
=>
{
expect
(
commit
.
mock
.
calls
).
toEqual
([
[
mutationTypes
.
SET_APPLYING_BATCH_STATE
,
true
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
true
],
[
mutationTypes
.
APPLY_SUGGESTION
,
batchSuggestionsInfo
[
0
]],
[
mutationTypes
.
APPLY_SUGGESTION
,
batchSuggestionsInfo
[
1
]],
[
mutationTypes
.
CLEAR_SUGGESTION_BATCH
],
[
mutationTypes
.
SET_APPLYING_BATCH_STATE
,
false
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
false
],
]);
expect
(
dispatch
.
mock
.
calls
).
toEqual
([
[
'
stopPolling
'
],
[
'
resolveDiscussion
'
,
{
discussionId
:
discussionIds
[
0
]
}],
[
'
resolveDiscussion
'
,
{
discussionId
:
discussionIds
[
1
]
}],
[
'
restartPolling
'
],
]);
expect
(
Flash
).
not
.
toHaveBeenCalled
();
...
...
@@ -1038,10 +1054,12 @@ describe('Actions Notes Store', () => {
testSubmitSuggestionBatch
(
done
,
()
=>
{
expect
(
commit
.
mock
.
calls
).
toEqual
([
[
mutationTypes
.
SET_APPLYING_BATCH_STATE
,
true
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
true
],
[
mutationTypes
.
SET_APPLYING_BATCH_STATE
,
false
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
false
],
]);
expect
(
dispatch
).
not
.
toHaveBeenCalled
(
);
expect
(
dispatch
.
mock
.
calls
).
toEqual
([[
'
stopPolling
'
],
[
'
restartPolling
'
]]
);
expect
(
Flash
).
toHaveBeenCalledWith
(
TEST_ERROR_MESSAGE
,
'
alert
'
,
flashContainer
);
});
});
...
...
@@ -1054,10 +1072,12 @@ describe('Actions Notes Store', () => {
testSubmitSuggestionBatch
(
done
,
()
=>
{
expect
(
commit
.
mock
.
calls
).
toEqual
([
[
mutationTypes
.
SET_APPLYING_BATCH_STATE
,
true
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
true
],
[
mutationTypes
.
SET_APPLYING_BATCH_STATE
,
false
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
false
],
]);
expect
(
dispatch
).
not
.
toHaveBeenCalled
(
);
expect
(
dispatch
.
mock
.
calls
).
toEqual
([[
'
stopPolling
'
],
[
'
restartPolling
'
]]
);
expect
(
Flash
).
toHaveBeenCalledWith
(
'
Something went wrong while applying the batch of suggestions. Please try again.
'
,
'
alert
'
,
...
...
@@ -1072,10 +1092,12 @@ describe('Actions Notes Store', () => {
testSubmitSuggestionBatch
(
done
,
()
=>
{
expect
(
commit
.
mock
.
calls
).
toEqual
([
[
mutationTypes
.
SET_APPLYING_BATCH_STATE
,
true
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
true
],
[
mutationTypes
.
APPLY_SUGGESTION
,
batchSuggestionsInfo
[
0
]],
[
mutationTypes
.
APPLY_SUGGESTION
,
batchSuggestionsInfo
[
1
]],
[
mutationTypes
.
CLEAR_SUGGESTION_BATCH
],
[
mutationTypes
.
SET_APPLYING_BATCH_STATE
,
false
],
[
mutationTypes
.
SET_RESOLVING_DISCUSSION
,
false
],
]);
expect
(
Flash
).
not
.
toHaveBeenCalled
();
...
...
spec/frontend/notes/stores/mutation_spec.js
View file @
bf4a91ef
...
...
@@ -377,6 +377,16 @@ describe('Notes Store mutations', () => {
});
});
describe
(
'
SET_RESOLVING_DISCUSSION
'
,
()
=>
{
it
(
'
should set resolving discussion state
'
,
()
=>
{
const
state
=
{};
mutations
.
SET_RESOLVING_DISCUSSION
(
state
,
true
);
expect
(
state
.
isResolvingDiscussion
).
toEqual
(
true
);
});
});
describe
(
'
UPDATE_NOTE
'
,
()
=>
{
it
(
'
should update a note
'
,
()
=>
{
const
state
=
{
...
...
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