diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-08-20 21:42:06 +0300 |
commit | 6e4e1050d9dba2b7b2523fdd1768823ab85feef4 (patch) | |
tree | 78be5963ec075d80116a932011d695dd33910b4e /app/assets/javascripts/deploy_freeze/store/actions.js | |
parent | 1ce776de4ae122aba3f349c02c17cebeaa8ecf07 (diff) |
Add latest changes from gitlab-org/gitlab@13-3-stable-ee
Diffstat (limited to 'app/assets/javascripts/deploy_freeze/store/actions.js')
-rw-r--r-- | app/assets/javascripts/deploy_freeze/store/actions.js | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/app/assets/javascripts/deploy_freeze/store/actions.js b/app/assets/javascripts/deploy_freeze/store/actions.js new file mode 100644 index 00000000000..2fbbba5a128 --- /dev/null +++ b/app/assets/javascripts/deploy_freeze/store/actions.js @@ -0,0 +1,63 @@ +import * as types from './mutation_types'; +import Api from '~/api'; +import { deprecatedCreateFlash as createFlash } from '~/flash'; +import { __ } from '~/locale'; + +export const requestAddFreezePeriod = ({ commit }) => { + commit(types.REQUEST_ADD_FREEZE_PERIOD); +}; + +export const receiveAddFreezePeriodSuccess = ({ commit }) => { + commit(types.RECEIVE_ADD_FREEZE_PERIOD_SUCCESS); +}; + +export const receiveAddFreezePeriodError = ({ commit }, error) => { + commit(types.RECEIVE_ADD_FREEZE_PERIOD_ERROR, error); +}; + +export const addFreezePeriod = ({ state, dispatch, commit }) => { + dispatch('requestAddFreezePeriod'); + + return Api.createFreezePeriod(state.projectId, { + freeze_start: state.freezeStartCron, + freeze_end: state.freezeEndCron, + cron_timezone: state.selectedTimezoneIdentifier, + }) + .then(() => { + dispatch('receiveAddFreezePeriodSuccess'); + commit(types.RESET_MODAL); + dispatch('fetchFreezePeriods'); + }) + .catch(error => { + createFlash(__('Error: Unable to create deploy freeze')); + dispatch('receiveAddFreezePeriodError', error); + }); +}; + +export const fetchFreezePeriods = ({ commit, state }) => { + commit(types.REQUEST_FREEZE_PERIODS); + + return Api.freezePeriods(state.projectId) + .then(({ data }) => { + commit(types.RECEIVE_FREEZE_PERIODS_SUCCESS, data); + }) + .catch(() => { + createFlash(__('There was an error fetching the deploy freezes.')); + }); +}; + +export const setSelectedTimezone = ({ commit }, timezone) => { + commit(types.SET_SELECTED_TIMEZONE, timezone); +}; + +export const setFreezeStartCron = ({ commit }, { freezeStartCron }) => { + commit(types.SET_FREEZE_START_CRON, freezeStartCron); +}; + +export const setFreezeEndCron = ({ commit }, { freezeEndCron }) => { + commit(types.SET_FREEZE_END_CRON, freezeEndCron); +}; + +export const resetModal = ({ commit }) => { + commit(types.RESET_MODAL); +}; |