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

30 lines
1 KiB
JavaScript
Raw Normal View History

2020-04-22 19:07:51 +05:30
import { parseBoolean } from '~/lib/utils/common_utils';
2020-03-13 15:44:24 +05:30
import * as types from './mutation_types';
export default {
[types.SET_INITIAL_STATE](state, initialState) {
state.projectId = initialState.projectId;
state.formOptions = {
cadence: JSON.parse(initialState.cadenceOptions),
keepN: JSON.parse(initialState.keepNOptions),
olderThan: JSON.parse(initialState.olderThanOptions),
};
2020-04-22 19:07:51 +05:30
state.enableHistoricEntries = parseBoolean(initialState.enableHistoricEntries);
state.isAdmin = parseBoolean(initialState.isAdmin);
state.adminSettingsPath = initialState.adminSettingsPath;
2020-03-13 15:44:24 +05:30
},
[types.UPDATE_SETTINGS](state, data) {
state.settings = { ...state.settings, ...data.settings };
},
[types.SET_SETTINGS](state, settings) {
2020-04-22 19:07:51 +05:30
state.settings = settings ?? state.settings;
2020-03-13 15:44:24 +05:30
state.original = Object.freeze(settings);
},
[types.RESET_SETTINGS](state) {
2020-05-24 23:13:21 +05:30
state.settings = { ...state.original };
2020-03-13 15:44:24 +05:30
},
[types.TOGGLE_LOADING](state) {
state.isLoading = !state.isLoading;
},
};