<commit_before>const Vuex = require('kolibri.lib.vuex');
const coreStore = require('kolibri.coreVue.vuex.store');
const constants = require('./constants');

const initialState = {
  pageName: constants.PageNames.COACH_CLASS_LIST_PAGE,
  pageState: {},
};

const mutations = {
  SET_PAGE_STATE(state, pageState) {
    state.pageState = pageState;
  },
  SET_PAGE_NAME(state, pageName) {
    state.pageName = pageName;
  },
  SET_CHANNEL_ID(state, channelId) {
    state.pageState.channel_id = channelId;
  },
  SET_CONTENT_SCOPE(state, contentScope) {
    state.pageState.content_scope = contentScope;
  },
  SET_CONTENT_SCOPE_ID(state, contentScopeId) {
    state.pageState.content_scope_id = contentScopeId;
  },
  SET_USER_SCOPE(state, userScope) {
    state.pageState.user_scope = userScope;
  },
  SET_USER_SCOPE_ID(state, userScopeId) {
    state.pageState.user_scope_id = userScopeId;
  },
  SET_ALL_OR_RECENT(state, allOrRecent) {
    state.pageState.all_or_recent = allOrRecent;
  },
  SET_VIEW_BY_CONTENT_OR_LEARNERS(state, viewByContentOrLearners) {
    state.pageState.view_by_content_or_learners = viewByContentOrLearners;
  },
  SET_SORT_COLUMN(state, sortColumn) {
    state.pageState.sort_column = sortColumn;
  },
  SET_SORT_ORDER(state, sortOrder) {
    state.pageState.sort_order = sortOrder;
  },
  SET_CONTENT_SCOPE_SUMMARY(state, contentScopeSummary) {
    state.pageState.content_scope_summary = contentScopeSummary;
  },
  SET_USER_SCOPE_SUMMARY(state, userScopeSummary) {
    state.pageState.user_scope_summary = userScopeSummary;
  },
  SET_TABLE_DATA(state, tableData) {
    state.pageState.table_data = tableData;
  },

  SET_MODAL(state, modalName) {
    state.pageState.modalShown = modalName;
  },
  ADD_GROUP(state, group) {
    state.pageState.groups.push(group);
  },
  RENAME_GROUP(state, groupId, newGroupName) {
    const groupIndex = state.pageState.groups.findIndex((group, index) => {
      if (group.id === groupId) {
        return true;
      }
      return false;
    });
    state.pageState.groups[groupIndex].name = newGroupName;
  },
  DELETE_GROUP(state, groupId) {
    state.pageState.groups = state.pageState.groups.filter(group => group.id !== groupId);
  },
  ADD_USER_TO_GROUP(state, groupId, user) {
    const groupIndex = state.pageState.groups.findIndex((group, index) => {
      if (group.id === groupId) {
        return true;
      }
      return false;
    });
    state.pageState.groups[groupIndex].users.push(user);
  },
  REMOVE_USER_FROM_GROUP(state, groupId, userId) {
    const groupIndex = state.pageState.groups.findIndex((group, index) => {
      if (group.id === groupId) {
        return true;
      }
      return false;
    });
    state.pageState.groups[groupIndex].users =
      state.pageState.groups[groupIndex].users.filter(user => user.id !== userId);
  },
};

// assigns core state and mutations
Object.assign(initialState, coreStore.initialState);
Object.assign(mutations, coreStore.mutations);

module.exports = new Vuex.Store({
  state: initialState,
  mutations,
});<commit_msg>Simplify store logic.<commit_after>const Vuex = require('kolibri.lib.vuex');
const coreStore = require('kolibri.coreVue.vuex.store');
const constants = require('./constants');

const initialState = {
  pageName: constants.PageNames.COACH_CLASS_LIST_PAGE,
  pageState: {},
};

const mutations = {
  SET_PAGE_STATE(state, pageState) {
    state.pageState = pageState;
  },
  SET_PAGE_NAME(state, pageName) {
    state.pageName = pageName;
  },
  SET_CHANNEL_ID(state, channelId) {
    state.pageState.channel_id = channelId;
  },
  SET_CONTENT_SCOPE(state, contentScope) {
    state.pageState.content_scope = contentScope;
  },
  SET_CONTENT_SCOPE_ID(state, contentScopeId) {
    state.pageState.content_scope_id = contentScopeId;
  },
  SET_USER_SCOPE(state, userScope) {
    state.pageState.user_scope = userScope;
  },
  SET_USER_SCOPE_ID(state, userScopeId) {
    state.pageState.user_scope_id = userScopeId;
  },
  SET_ALL_OR_RECENT(state, allOrRecent) {
    state.pageState.all_or_recent = allOrRecent;
  },
  SET_VIEW_BY_CONTENT_OR_LEARNERS(state, viewByContentOrLearners) {
    state.pageState.view_by_content_or_learners = viewByContentOrLearners;
  },
  SET_SORT_COLUMN(state, sortColumn) {
    state.pageState.sort_column = sortColumn;
  },
  SET_SORT_ORDER(state, sortOrder) {
    state.pageState.sort_order = sortOrder;
  },
  SET_CONTENT_SCOPE_SUMMARY(state, contentScopeSummary) {
    state.pageState.content_scope_summary = contentScopeSummary;
  },
  SET_USER_SCOPE_SUMMARY(state, userScopeSummary) {
    state.pageState.user_scope_summary = userScopeSummary;
  },
  SET_TABLE_DATA(state, tableData) {
    state.pageState.table_data = tableData;
  },

  SET_MODAL(state, modalName) {
    state.pageState.modalShown = modalName;
  },

  ADD_GROUP(state, group) {
    state.pageState.groups.push(group);
  },
  RENAME_GROUP(state, groupId, newGroupName) {
    const groupIndex = state.pageState.groups.findIndex(group => group.id === groupId);
    state.pageState.groups[groupIndex].name = newGroupName;
  },
  DELETE_GROUP(state, groupId) {
    state.pageState.groups = state.pageState.groups.filter(group => group.id !== groupId);
  },
  ADD_USER_TO_GROUP(state, groupId, user) {
    const groupIndex = state.pageState.groups.findIndex(group => group.id === groupId);
    state.pageState.groups[groupIndex].users.push(user);
  },
  REMOVE_USER_FROM_GROUP(state, groupId, userId) {
    const groupIndex = state.pageState.groups.findIndex(group => group.id === groupId);
    state.pageState.groups[groupIndex].users =
      state.pageState.groups[groupIndex].users.filter(user => user.id !== userId);
  },
};

// assigns core state and mutations
Object.assign(initialState, coreStore.initialState);
Object.assign(mutations, coreStore.mutations);

module.exports = new Vuex.Store({
  state: initialState,
  mutations,
});
{'fraction_non_alphanumeric': 0.12351543942992874, 'fraction_numerical': 0.0, 'mean_word_length': 4.373746581586144, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '817697', 'n_tokens_mistral': 2047, 'n_tokens_neox': 2011, 'n_words': 282}