diff options
Diffstat (limited to 'app/assets/javascripts/mr_notes')
4 files changed, 13 insertions, 17 deletions
diff --git a/app/assets/javascripts/mr_notes/stores/actions.js b/app/assets/javascripts/mr_notes/stores/actions.js index bc66d1dd68f..0200a8aefc8 100644 --- a/app/assets/javascripts/mr_notes/stores/actions.js +++ b/app/assets/javascripts/mr_notes/stores/actions.js @@ -10,23 +10,14 @@ export function setEndpoints({ commit }, endpoints) { commit(types.SET_ENDPOINTS, endpoints); } -export function setMrMetadata({ commit }, metadata) { - commit(types.SET_MR_METADATA, metadata); -} - -export function fetchMrMetadata({ dispatch, state }) { +export async function fetchMrMetadata({ state, commit }) { if (state.endpoints?.metadata) { - axios - .get(state.endpoints.metadata) - .then((response) => { - dispatch('setMrMetadata', response.data); - }) - .catch(() => { - // https://gitlab.com/gitlab-org/gitlab/-/issues/324740 - // 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('Failed to load MR Metadata for the Overview tab.'); - }); + commit(types.SET_FAILED_TO_LOAD_METADATA, false); + try { + const { data } = await axios.get(state.endpoints.metadata); + commit(types.SET_MR_METADATA, data); + } catch (error) { + commit(types.SET_FAILED_TO_LOAD_METADATA, true); + } } } diff --git a/app/assets/javascripts/mr_notes/stores/modules/index.js b/app/assets/javascripts/mr_notes/stores/modules/index.js index 52e12ba664c..75b2b2f4dc6 100644 --- a/app/assets/javascripts/mr_notes/stores/modules/index.js +++ b/app/assets/javascripts/mr_notes/stores/modules/index.js @@ -7,6 +7,7 @@ export default () => ({ endpoints: {}, activeTab: null, mrMetadata: {}, + failedToLoadMetadata: false, }, actions, getters, diff --git a/app/assets/javascripts/mr_notes/stores/mutation_types.js b/app/assets/javascripts/mr_notes/stores/mutation_types.js index 88cf6e48988..91d75e77a60 100644 --- a/app/assets/javascripts/mr_notes/stores/mutation_types.js +++ b/app/assets/javascripts/mr_notes/stores/mutation_types.js @@ -2,4 +2,5 @@ export default { SET_ACTIVE_TAB: 'SET_ACTIVE_TAB', SET_ENDPOINTS: 'SET_ENDPOINTS', SET_MR_METADATA: 'SET_MR_METADATA', + SET_FAILED_TO_LOAD_METADATA: 'SET_FAILED_TO_LOAD_METADATA', }; diff --git a/app/assets/javascripts/mr_notes/stores/mutations.js b/app/assets/javascripts/mr_notes/stores/mutations.js index 6af6adb4e18..8b17f63cfb1 100644 --- a/app/assets/javascripts/mr_notes/stores/mutations.js +++ b/app/assets/javascripts/mr_notes/stores/mutations.js @@ -10,4 +10,7 @@ export default { [types.SET_MR_METADATA](state, metadata) { Object.assign(state, { mrMetadata: metadata }); }, + [types.SET_FAILED_TO_LOAD_METADATA](state, value) { + Object.assign(state, { failedToLoadMetadata: value }); + }, }; |