summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/mr_notes/stores/actions.js
blob: 0200a8aefc87ed9b47f7b9f904b0c7106ab47029 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import axios from '~/lib/utils/axios_utils';

import types from './mutation_types';

export function setActiveTab({ commit }, tab) {
  commit(types.SET_ACTIVE_TAB, tab);
}

export function setEndpoints({ commit }, endpoints) {
  commit(types.SET_ENDPOINTS, endpoints);
}

export async function fetchMrMetadata({ state, commit }) {
  if (state.endpoints?.metadata) {
    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);
    }
  }
}