summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/packages/list/stores/mutations.js
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/packages/list/stores/mutations.js')
-rw-r--r--app/assets/javascripts/packages/list/stores/mutations.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/app/assets/javascripts/packages/list/stores/mutations.js b/app/assets/javascripts/packages/list/stores/mutations.js
new file mode 100644
index 00000000000..a47ba356c0a
--- /dev/null
+++ b/app/assets/javascripts/packages/list/stores/mutations.js
@@ -0,0 +1,45 @@
+import * as types from './mutation_types';
+import {
+ parseIntPagination,
+ normalizeHeaders,
+ convertObjectPropsToCamelCase,
+} from '~/lib/utils/common_utils';
+import { GROUP_PAGE_TYPE } from '../constants';
+
+export default {
+ [types.SET_INITIAL_STATE](state, config) {
+ const { comingSoonJson, ...rest } = config;
+ const comingSoonObj = JSON.parse(comingSoonJson);
+
+ state.config = {
+ ...rest,
+ comingSoon: comingSoonObj && convertObjectPropsToCamelCase(comingSoonObj),
+ isGroupPage: config.pageType === GROUP_PAGE_TYPE,
+ };
+ },
+
+ [types.SET_PACKAGE_LIST_SUCCESS](state, packages) {
+ state.packages = packages;
+ },
+
+ [types.SET_MAIN_LOADING](state, isLoading) {
+ state.isLoading = isLoading;
+ },
+
+ [types.SET_PAGINATION](state, headers) {
+ const normalizedHeaders = normalizeHeaders(headers);
+ state.pagination = parseIntPagination(normalizedHeaders);
+ },
+
+ [types.SET_SORTING](state, sorting) {
+ state.sorting = { ...state.sorting, ...sorting };
+ },
+
+ [types.SET_SELECTED_TYPE](state, type) {
+ state.selectedType = type;
+ },
+
+ [types.SET_FILTER](state, query) {
+ state.filterQuery = query;
+ },
+};