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
0d308dbd
Commit
0d308dbd
authored
Sep 27, 2019
by
Winnie Hellmann
Committed by
Kushal Pandya
Sep 27, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove nested Promise from notes actions
parent
d109b8f5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
40 deletions
+66
-40
app/assets/javascripts/notes/stores/actions.js
app/assets/javascripts/notes/stores/actions.js
+66
-40
No files found.
app/assets/javascripts/notes/stores/actions.js
View file @
0d308dbd
...
...
@@ -251,58 +251,80 @@ export const saveNote = ({ commit, dispatch }, noteData) => {
}
}
return
dispatch
(
methodToDispatch
,
postData
,
{
root
:
true
}).
then
(
res
=>
{
const
processErrors
=
res
=>
{
const
{
errors
}
=
res
;
const
commandsChanges
=
res
.
commands_changes
;
if
(
!
errors
||
!
Object
.
keys
(
errors
).
length
)
{
return
res
;
}
if
(
errors
&&
Object
.
keys
(
errors
).
length
)
{
/*
The following reply means that quick actions have been successfully applied:
/*
The following reply means that quick actions have been successfully applied:
{"commands_changes":{},"valid":false,"errors":{"commands_only":["Commands applied"]}}
*/
if
(
hasQuickActions
)
{
eTagPoll
.
makeRequest
();
{"commands_changes":{},"valid":false,"errors":{"commands_only":["Commands applied"]}}
*/
if
(
hasQuickActions
)
{
eTagPoll
.
makeRequest
();
$
(
'
.js-gfm-input
'
).
trigger
(
'
clear-commands-cache.atwho
'
);
Flash
(
__
(
'
Commands applied
'
),
'
notice
'
,
noteData
.
flashContainer
);
}
else
{
throw
new
Error
(
__
(
'
Failed to save comment!
'
));
}
$
(
'
.js-gfm-input
'
).
trigger
(
'
clear-commands-cache.atwho
'
);
const
{
commands_only
:
message
}
=
errors
;
Flash
(
message
||
__
(
'
Commands applied
'
),
'
notice
'
,
noteData
.
flashContainer
);
return
res
;
}
if
(
commandsChanges
)
{
if
(
commandsChanges
.
emoji_award
)
{
const
votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
loadAwardsHandler
()
.
then
(
awardsHandler
=>
{
awardsHandler
.
addAwardToEmojiBar
(
votesBlock
,
commandsChanges
.
emoji_award
);
awardsHandler
.
scrollToAwards
();
})
.
catch
(()
=>
{
Flash
(
__
(
'
Something went wrong while adding your award. Please try again.
'
),
'
alert
'
,
noteData
.
flashContainer
,
);
});
}
throw
new
Error
(
__
(
'
Failed to save comment!
'
));
};
if
(
commandsChanges
.
spend_time
!=
null
||
commandsChanges
.
time_estimate
!=
null
)
{
sidebarTimeTrackingEventHub
.
$emit
(
'
timeTrackingUpdated
'
,
res
);
}
const
processEmojiAward
=
res
=>
{
const
{
commands_changes
:
commandsChanges
}
=
res
;
const
{
emoji_award
:
emojiAward
}
=
commandsChanges
||
{};
if
(
!
emojiAward
)
{
return
res
;
}
if
(
errors
&&
errors
.
commands_only
)
{
Flash
(
errors
.
commands_only
,
'
notice
'
,
noteData
.
flashContainer
);
const
votesBlock
=
$
(
'
.js-awards-block
'
).
eq
(
0
);
return
loadAwardsHandler
()
.
then
(
awardsHandler
=>
{
awardsHandler
.
addAwardToEmojiBar
(
votesBlock
,
emojiAward
);
awardsHandler
.
scrollToAwards
();
})
.
catch
(()
=>
{
Flash
(
__
(
'
Something went wrong while adding your award. Please try again.
'
),
'
alert
'
,
noteData
.
flashContainer
,
);
})
.
then
(()
=>
res
);
};
const
processTimeTracking
=
res
=>
{
const
{
commands_changes
:
commandsChanges
}
=
res
;
const
{
spend_time
:
spendTime
,
time_estimate
:
timeEstimate
}
=
commandsChanges
||
{};
if
(
spendTime
!=
null
||
timeEstimate
!=
null
)
{
sidebarTimeTrackingEventHub
.
$emit
(
'
timeTrackingUpdated
'
,
{
commands_changes
:
commandsChanges
,
});
}
return
res
;
};
const
removePlaceholder
=
res
=>
{
if
(
replyId
)
{
commit
(
types
.
REMOVE_PLACEHOLDER_NOTES
);
}
return
res
;
});
};
return
dispatch
(
methodToDispatch
,
postData
,
{
root
:
true
})
.
then
(
processErrors
)
.
then
(
processEmojiAward
)
.
then
(
processTimeTracking
)
.
then
(
removePlaceholder
);
};
const
pollSuccessCallBack
=
(
resp
,
commit
,
state
,
getters
,
dispatch
)
=>
{
...
...
@@ -430,10 +452,13 @@ export const updateResolvableDiscussionsCounts = ({ commit }) =>
export
const
submitSuggestion
=
(
{
commit
,
dispatch
},
{
discussionId
,
noteId
,
suggestionId
,
flashContainer
},
)
=>
Api
.
applySuggestion
(
suggestionId
)
)
=>
{
const
dispatchResolveDiscussion
=
()
=>
dispatch
(
'
resolveDiscussion
'
,
{
discussionId
}).
catch
(()
=>
{});
return
Api
.
applySuggestion
(
suggestionId
)
.
then
(()
=>
commit
(
types
.
APPLY_SUGGESTION
,
{
discussionId
,
noteId
,
suggestionId
}))
.
then
(
()
=>
dispatch
(
'
resolveDiscussion
'
,
{
discussionId
}).
catch
(()
=>
{})
)
.
then
(
dispatchResolveDiscussion
)
.
catch
(
err
=>
{
const
defaultMessage
=
__
(
'
Something went wrong while applying the suggestion. Please try again.
'
,
...
...
@@ -442,6 +467,7 @@ export const submitSuggestion = (
Flash
(
__
(
flashMessage
),
'
alert
'
,
flashContainer
);
});
};
export
const
convertToDiscussion
=
({
commit
},
noteId
)
=>
commit
(
types
.
CONVERT_TO_DISCUSSION
,
noteId
);
...
...
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