debian-mirror-gitlab/app/assets/javascripts/deploy_freeze/store/mutations.js

64 lines
1.7 KiB
JavaScript
Raw Normal View History

2020-10-24 23:57:45 +05:30
import { convertObjectPropsToCamelCase } from '~/lib/utils/common_utils';
import * as types from './mutation_types';
const formatTimezoneName = (freezePeriod, timezoneList) =>
convertObjectPropsToCamelCase({
...freezePeriod,
2021-04-29 21:17:54 +05:30
cron_timezone: {
formattedTimezone: timezoneList.find((tz) => tz.identifier === freezePeriod.cron_timezone)
?.name,
2021-06-08 01:23:25 +05:30
identifier: freezePeriod.cron_timezone,
2021-04-29 21:17:54 +05:30
},
2020-10-24 23:57:45 +05:30
});
export default {
[types.REQUEST_FREEZE_PERIODS](state) {
state.isLoading = true;
},
[types.RECEIVE_FREEZE_PERIODS_SUCCESS](state, freezePeriods) {
state.isLoading = false;
2021-03-08 18:12:59 +05:30
state.freezePeriods = freezePeriods.map((freezePeriod) =>
2020-10-24 23:57:45 +05:30
formatTimezoneName(freezePeriod, state.timezoneData),
);
},
[types.REQUEST_ADD_FREEZE_PERIOD](state) {
state.isLoading = true;
},
[types.RECEIVE_ADD_FREEZE_PERIOD_SUCCESS](state) {
state.isLoading = false;
},
[types.RECEIVE_ADD_FREEZE_PERIOD_ERROR](state, error) {
state.isLoading = false;
state.error = error;
},
[types.SET_SELECTED_TIMEZONE](state, timezone) {
state.selectedTimezone = timezone.formattedTimezone;
state.selectedTimezoneIdentifier = timezone.identifier;
},
[types.SET_FREEZE_START_CRON](state, freezeStartCron) {
state.freezeStartCron = freezeStartCron;
},
[types.SET_FREEZE_END_CRON](state, freezeEndCron) {
state.freezeEndCron = freezeEndCron;
},
2021-04-29 21:17:54 +05:30
[types.SET_SELECTED_ID](state, id) {
state.selectedId = id;
},
2020-10-24 23:57:45 +05:30
[types.RESET_MODAL](state) {
state.freezeStartCron = '';
state.freezeEndCron = '';
state.selectedTimezone = '';
state.selectedTimezoneIdentifier = '';
2021-04-29 21:17:54 +05:30
state.selectedId = '';
2020-10-24 23:57:45 +05:30
},
};