Commit 3b13c2b5 authored by Fernando's avatar Fernando

Implemeent Vuex module for fetching security configurations

* Impleement actions, mutations, mutation types, and store
parent a2a272b0
import axios from '~/lib/utils/axios_utils';
import { __ } from '~/locale';
import * as types from './mutation_types';
export const setSecurityConfigurationEndpoint = ({ commit }, endpoint) =>
commit(types.SET_SECURITY_CONFIGURATION_ENDPOINT, endpoint);
export const fetchSecurityConfiguration = ({ commit, state }) => {
if (!state.securityConfigurationPath) {
return commit(types.RECEIVE_SECURITY_CONFIGURATION_ERROR);
}
commit(types.REQUEST_SECURITY_CONFIGURATION);
return axios({
method: 'GET',
url: state.securityConfigurationPath,
})
.then(response => {
const { data } = response;
commit(types.RECEIVE_SECURITY_CONFIGURATION_SUCCESS, data);
})
.catch(error => {
Sentry.captureException(error);
commit(types.RECEIVE_SECURITY_CONFIGURATION_ERROR);
});
};
\ No newline at end of file
export const SET_SECURITY_CONFIGURATION_ENDPOINT = 'SET_SECURITY_CONFIGURATION_ENDPOINT';
export const REQUEST_SECURITY_CONFIGURATION = 'REQUEST_SECURITY_CONFIGURATION';
export const RECEIVE_SECURITY_CONFIGURATION_SUCCESS = 'RECEIVE_SECURITY_CONFIGURATION_SUCCESS';
export const RECEIVE_SECURITY_CONFIGURATION_ERROR = 'RECEIVE_SECURITY_CONFIGURATION_ERROR';
\ No newline at end of file
import * as types from './mutation_types';
export default {
[types.SET_SECURITY_CONFIGURATION_ENDPOINT](state, payload) {
state.securityConfigurationPath = payload;
},
[types.REQUEST_SECURITY_CONFIGURATION](state) {
state.isLoading = true;
},
[types.RECEIVE_SECURITY_CONFIGURATION_SUCCESS](state, payload) {
state.isLoading = false;
state.pipelineJobs = payload;
},
[types.RECEIVE_SECURITY_CONFIGURATION_ERROR](state) {
state.isLoading = false;
},
};
export default () => ({
securityConfigurationPath: '',
initialized: false,
isLoading: false,
errorLoading: false,
configuration: [],
});
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment