debian-mirror-gitlab/app/assets/javascripts/mr_notes/stores/actions.js
2022-06-21 17:19:12 +05:30

23 lines
628 B
JavaScript

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);
}
}
}