All files / ee/app/assets/javascripts/issues_analytics filtered_search_issues_analytics.js

66.67% Statements 6/9
100% Branches 0/0
66.67% Functions 2/3
66.67% Lines 6/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 37 38 39 40 41 42 43                1x       7x 56x         7x                   7x             7x              
import FilteredSearchManager from 'ee_else_ce/filtered_search/filtered_search_manager';
import IssuableFilteredSearchTokenKeys from 'ee_else_ce/filtered_search/issuable_filtered_search_token_keys';
import FilteredSearchTokenKeys from '~/filtered_search/filtered_search_token_keys';
import { historyPushState } from '~/lib/utils/common_utils';
import { queryToObject } from '~/lib/utils/url_utility';
import { __ } from '~/locale';
import issueAnalyticsStore from './stores';
 
const EXCLUDED_TOKENS = ['release'];
 
export default class FilteredSearchIssueAnalytics extends FilteredSearchManager {
  constructor() {
    const issuesAnalyticsTokenKeys = new FilteredSearchTokenKeys(
      IssuableFilteredSearchTokenKeys.tokenKeys.filter(({ key }) => !EXCLUDED_TOKENS.includes(key)), // release filter is not working with the Issues API at the moment
      IssuableFilteredSearchTokenKeys.alternativeTokenKeys,
      IssuableFilteredSearchTokenKeys.conditions,
    );
 
    super({
      page: 'issues_analytics',
      isGroupDecendent: true,
      stateFiltersSelector: '.issues-state-filters',
      isGroup: true,
      useDefaultState: false,
      filteredSearchTokenKeys: issuesAnalyticsTokenKeys,
      placeholder: __('Filter results...'),
    });
 
    this.isHandledAsync = true;
  }
 
  /**
   * Updates issue analytics store and window history
   * with filter path
   */
  updateObject = (path) => {
    historyPushState(path);
 
    const filters = queryToObject(path, { gatherArrays: true });
    issueAnalyticsStore.dispatch('issueAnalytics/setFilters', filters);
  };
}