2020-03-13 15:44:24 +05:30
|
|
|
import Api from '~/api';
|
|
|
|
import * as types from './mutation_types';
|
|
|
|
|
|
|
|
export const setInitialState = ({ commit }, data) => commit(types.SET_INITIAL_STATE, data);
|
|
|
|
export const updateSettings = ({ commit }, data) => commit(types.UPDATE_SETTINGS, data);
|
|
|
|
export const toggleLoading = ({ commit }) => commit(types.TOGGLE_LOADING);
|
|
|
|
export const receiveSettingsSuccess = ({ commit }, data) => {
|
2020-04-22 19:07:51 +05:30
|
|
|
commit(types.SET_SETTINGS, data);
|
2020-03-13 15:44:24 +05:30
|
|
|
};
|
|
|
|
export const resetSettings = ({ commit }) => commit(types.RESET_SETTINGS);
|
|
|
|
|
|
|
|
export const fetchSettings = ({ dispatch, state }) => {
|
|
|
|
dispatch('toggleLoading');
|
|
|
|
return Api.project(state.projectId)
|
|
|
|
.then(({ data: { container_expiration_policy } }) =>
|
|
|
|
dispatch('receiveSettingsSuccess', container_expiration_policy),
|
|
|
|
)
|
|
|
|
.finally(() => dispatch('toggleLoading'));
|
|
|
|
};
|
|
|
|
|
|
|
|
export const saveSettings = ({ dispatch, state }) => {
|
|
|
|
dispatch('toggleLoading');
|
|
|
|
return Api.updateProject(state.projectId, {
|
|
|
|
container_expiration_policy_attributes: state.settings,
|
|
|
|
})
|
|
|
|
.then(({ data: { container_expiration_policy } }) =>
|
|
|
|
dispatch('receiveSettingsSuccess', container_expiration_policy),
|
|
|
|
)
|
|
|
|
.finally(() => dispatch('toggleLoading'));
|
|
|
|
};
|