Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | 6x 1x 6x 1x 1x 6x 1x 1x 6x 1x 1x 6x 1x 6x 2x 2x 2x 1x 1x 6x 1x 1x 6x 1x 1x 1x 6x 1x 1x 1x 6x 1x 1x 6x 1x 6x 2x 2x 1x 1x 6x 6x 6x 6x 6x 2x | import { mapApprovalRuleRequest, mapApprovalSettingsResponse, mapApprovalFallbackRuleRequest, } from 'ee/approvals/mappers'; import { createAlert } from '~/alert'; import axios from '~/lib/utils/axios_utils'; import { __ } from '~/locale'; import * as types from '../base/mutation_types'; export const requestRules = ({ commit }) => { commit(types.SET_LOADING, true); }; export const receiveRulesSuccess = ({ commit }, approvalSettings) => { commit(types.SET_APPROVAL_SETTINGS, approvalSettings); commit(types.SET_LOADING, false); }; export const openCreateDrawer = ({ commit }, rule) => { commit(types.SET_DRAWER_OPEN, true); commit(types.SET_EDIT_RULE, rule); }; export const closeCreateDrawer = ({ commit }) => { commit(types.SET_DRAWER_OPEN, false); commit(types.SET_EDIT_RULE, null); }; export const receiveRulesError = () => { createAlert({ message: __('An error occurred fetching the approval rules.'), }); }; export const fetchRules = ({ rootState, dispatch }) => { dispatch('requestRules'); const { rulesPath } = rootState.settings; return axios .get(rulesPath) .then((response) => dispatch('receiveRulesSuccess', mapApprovalSettingsResponse(response.data))) .catch(() => dispatch('receiveRulesError')); }; export const postRuleSuccess = ({ dispatch }) => { dispatch('createModal/close'); dispatch('fetchRules'); }; export const postRule = ({ rootState, dispatch }, rule) => { const { rulesPath } = rootState.settings; return axios .post(rulesPath, mapApprovalRuleRequest(rule)) .then(() => dispatch('postRuleSuccess')); }; export const putRule = ({ rootState, dispatch }, { id, ...newRule }) => { const { rulesPath } = rootState.settings; return axios .put(`${rulesPath}/${id}`, mapApprovalRuleRequest(newRule)) .then(() => dispatch('postRuleSuccess')); }; export const deleteRuleSuccess = ({ dispatch }) => { dispatch('deleteModal/close'); dispatch('fetchRules'); }; export const deleteRuleError = () => { createAlert({ message: __('An error occurred while deleting the approvers group'), }); }; export const deleteRule = ({ rootState, dispatch }, id) => { const { rulesPath } = rootState.settings; return axios .delete(`${rulesPath}/${id}`) .then(() => dispatch('deleteRuleSuccess')) .catch(() => dispatch('deleteRuleError')); }; export const putFallbackRuleSuccess = ({ dispatch }) => { dispatch('createModal/close'); dispatch('fetchRules'); }; export const putFallbackRule = ({ rootState, dispatch }, fallback) => { const { projectPath } = rootState.settings; return axios .put(projectPath, mapApprovalFallbackRuleRequest(fallback)) .then(() => dispatch('putFallbackRuleSuccess')); }; export const requestEditRule = ({ dispatch }, rule) => { if (gon.features.approvalRulesDrawer) { dispatch('openCreateDrawer', rule); } else { dispatch('createModal/open', rule); } }; export const requestDeleteRule = ({ dispatch }, rule) => { dispatch('deleteModal/open', rule); }; export const addEmptyRule = ({ commit }) => { commit(types.ADD_EMPTY_RULE); }; |