summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/mr_notes/stores/actions.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/mr_notes/stores/actions.js')
-rw-r--r--app/assets/javascripts/mr_notes/stores/actions.js35
1 files changed, 30 insertions, 5 deletions
diff --git a/app/assets/javascripts/mr_notes/stores/actions.js b/app/assets/javascripts/mr_notes/stores/actions.js
index 426c6a00d5e..bc66d1dd68f 100644
--- a/app/assets/javascripts/mr_notes/stores/actions.js
+++ b/app/assets/javascripts/mr_notes/stores/actions.js
@@ -1,7 +1,32 @@
+import axios from '~/lib/utils/axios_utils';
+
import types from './mutation_types';
-export default {
- setActiveTab({ commit }, tab) {
- commit(types.SET_ACTIVE_TAB, tab);
- },
-};
+export function setActiveTab({ commit }, tab) {
+ commit(types.SET_ACTIVE_TAB, tab);
+}
+
+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 }) {
+ 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.');
+ });
+ }
+}