diff options
Diffstat (limited to 'app')
3 files changed, 83 insertions, 55 deletions
diff --git a/app/assets/javascripts/boards/components/board_blank_state.vue b/app/assets/javascripts/boards/components/board_blank_state.vue index 9f26337d153..9a1da810ad0 100644 --- a/app/assets/javascripts/boards/components/board_blank_state.vue +++ b/app/assets/javascripts/boards/components/board_blank_state.vue @@ -29,25 +29,25 @@ export default { }); }); + const loadListIssues = listObj => { + const list = boardsStore.findList('title', listObj.title); + + if (!list) { + return null; + } + + list.id = listObj.id; + list.label.id = listObj.label.id; + return list.getIssues().catch(() => { + // TODO: handle request error + }); + }; + // Save the labels boardsStore .generateDefaultLists() .then(res => res.data) - .then(data => { - data.forEach(listObj => { - const list = boardsStore.findList('title', listObj.title); - - if (!list) { - return; - } - - list.id = listObj.id; - list.label.id = listObj.label.id; - list.getIssues().catch(() => { - // TODO: handle request error - }); - }); - }) + .then(data => Promise.all(data.map(loadListIssues))) .catch(() => { boardsStore.removeList(undefined, 'label'); Cookies.remove('issue_board_welcome_hidden', { diff --git a/app/assets/javascripts/notes/stores/actions.js b/app/assets/javascripts/notes/stores/actions.js index 6c236981a24..004035ea1d4 100644 --- a/app/assets/javascripts/notes/stores/actions.js +++ b/app/assets/javascripts/notes/stores/actions.js @@ -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); diff --git a/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue b/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue index e350264de96..407e5a29aa5 100644 --- a/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue +++ b/app/assets/javascripts/sidebar/components/confidential/confidential_issue_sidebar.vue @@ -66,6 +66,7 @@ export default { <template> <div class="block issuable-sidebar-item confidentiality"> <div + ref="collapseIcon" v-tooltip :title="tooltipLabel" class="sidebar-collapsed-icon" @@ -80,6 +81,7 @@ export default { {{ __('Confidentiality') }} <a v-if="isEditable" + ref="editLink" class="float-right confidential-edit" href="#" data-track-event="click_edit_button" |