All files / ee/app/assets/javascripts/audit_events/store mutations.js

100% Statements 9/9
60% Branches 9/15
100% Functions 4/4
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36                              7x 7x 7x 7x 7x       1x       1x 1x       1x      
import * as types from './mutation_types';
 
export default {
  [types.INITIALIZE_AUDIT_EVENTS](
    state,
    {
      entity_id: entityId = null,
      entity_username: entityUsername = null,
      author_username: authorUsername = null,
      entity_type: type = null,
      created_after: startDate = null,
      created_before: endDate = null,
      sort: sortBy = null,
    } = {},
  ) {
    const data = entityId ?? entityUsername ?? authorUsername;
    state.filterValue = type && data ? [{ type, value: { data, operator: '=' } }] : [];
    state.startDate = startDate;
    state.endDate = endDate;
    state.sortBy = sortBy;
  },
 
  [types.SET_FILTER_VALUE](state, filterValue) {
    state.filterValue = filterValue;
  },
 
  [types.SET_DATE_RANGE](state, { startDate, endDate }) {
    state.startDate = startDate;
    state.endDate = endDate;
  },
 
  [types.SET_SORT_BY](state, sortBy) {
    state.sortBy = sortBy;
  },
};