Commit 3b3f60e7 authored by Winnie Hellmann's avatar Winnie Hellmann

Rename IssuableFilteredSearchTokenKeysEE back to IssuesFilteredSearchTokenKeysEE

The class only applies to issues and not to merge requests (which are issuables, too)
parent 16a3c259
import IssuableFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_filtered_search_token_keys';
import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys';
import FilteredSearchContainer from '../filtered_search/container';
import FilteredSearchManager from '../filtered_search/filtered_search_manager';
......@@ -9,7 +9,7 @@ export default class FilteredSearchBoards extends FilteredSearchManager {
isGroupDecendent: true,
stateFiltersSelector: '.issues-state-filters',
isGroup: true,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeysEE,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeys,
});
this.store = store;
......
import projectSelect from '~/project_select';
import initFilteredSearch from '~/pages/search/init_filtered_search';
import { FILTERED_SEARCH } from '~/pages/constants';
import IssuableFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_filtered_search_token_keys';
import IssuesFilteredSearchTokenKeysEE from 'ee/filtered_search/issues_filtered_search_token_keys';
document.addEventListener('DOMContentLoaded', () => {
initFilteredSearch({
page: FILTERED_SEARCH.ISSUES,
isGroupDecendent: true,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeysEE,
filteredSearchTokenKeys: IssuesFilteredSearchTokenKeysEE,
});
projectSelect();
});
......@@ -6,12 +6,12 @@ import UsersSelect from '~/users_select';
import initFilteredSearch from '~/pages/search/init_filtered_search';
import { FILTERED_SEARCH } from '~/pages/constants';
import { ISSUABLE_INDEX } from '~/pages/projects/constants';
import IssuableFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_filtered_search_token_keys';
import IssuesFilteredSearchTokenKeysEE from 'ee/filtered_search/issues_filtered_search_token_keys';
document.addEventListener('DOMContentLoaded', () => {
initFilteredSearch({
page: FILTERED_SEARCH.ISSUES,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeysEE,
filteredSearchTokenKeys: IssuesFilteredSearchTokenKeysEE,
});
new IssuableIndex(ISSUABLE_INDEX.ISSUE);
......
......@@ -27,14 +27,19 @@ const weightConditions = [
},
];
const IssuableFilteredSearchTokenKeysEE = new FilteredSearchTokenKeys(
/**
* Filter tokens for issues in EE.
*
* @type {FilteredSearchTokenKeys}
*/
const IssuesFilteredSearchTokenKeysEE = new FilteredSearchTokenKeys(
[...tokenKeys, weightTokenKey],
alternativeTokenKeys,
[...conditions, ...weightConditions],
);
// cannot be an arrow function because it needs FilteredSearchTokenKeys instance
IssuableFilteredSearchTokenKeysEE.init = function init(availableFeatures) {
IssuesFilteredSearchTokenKeysEE.init = function init(availableFeatures) {
// Enable multiple assignees when available
if (availableFeatures && availableFeatures.multipleAssignees) {
const assigneeTokenKey = this.tokenKeys.find(tk => tk.key === 'assignee');
......@@ -43,4 +48,4 @@ IssuableFilteredSearchTokenKeysEE.init = function init(availableFeatures) {
}
};
export default IssuableFilteredSearchTokenKeysEE;
export default IssuesFilteredSearchTokenKeysEE;
/* eslint-disable class-methods-use-this */
import FilteredSearchManager from '~/filtered_search/filtered_search_manager';
import IssuableFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_filtered_search_token_keys';
import IssuesFilteredSearchTokenKeysEE from 'ee/filtered_search/issues_filtered_search_token_keys';
const AUTHOR_PARAM_KEY = 'author_username';
......@@ -8,7 +8,7 @@ export default class FilteredSearchServiceDesk extends FilteredSearchManager {
constructor(supportBotData) {
super({
page: 'service_desk',
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeysEE,
filteredSearchTokenKeys: IssuesFilteredSearchTokenKeysEE,
});
this.supportBotData = supportBotData;
......
import IssuableFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_filtered_search_token_keys';
import IssuesFilteredSearchTokenKeysEE from 'ee/filtered_search/issues_filtered_search_token_keys';
describe('Filtered Search Token Keys (Issues EE)', () => {
const weightTokenKey = {
......@@ -14,10 +14,10 @@ describe('Filtered Search Token Keys (Issues EE)', () => {
let tokenKeys;
beforeEach(() => {
IssuableFilteredSearchTokenKeysEE.init({
IssuesFilteredSearchTokenKeysEE.init({
multipleAssignees: true,
});
tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
});
it('should return tokenKeys', () => {
......@@ -34,7 +34,7 @@ describe('Filtered Search Token Keys (Issues EE)', () => {
});
it('should always return the same array', () => {
const tokenKeys2 = IssuableFilteredSearchTokenKeysEE.get();
const tokenKeys2 = IssuesFilteredSearchTokenKeysEE.get();
expect(tokenKeys).toEqual(tokenKeys2);
});
......@@ -47,8 +47,8 @@ describe('Filtered Search Token Keys (Issues EE)', () => {
describe('getKeys', () => {
it('should return keys', () => {
const getKeys = IssuableFilteredSearchTokenKeysEE.getKeys();
const keys = IssuableFilteredSearchTokenKeysEE.get().map(i => i.key);
const getKeys = IssuesFilteredSearchTokenKeysEE.getKeys();
const keys = IssuesFilteredSearchTokenKeysEE.get().map(i => i.key);
keys.forEach((key, i) => {
expect(key).toEqual(getKeys[i]);
......@@ -60,7 +60,7 @@ describe('Filtered Search Token Keys (Issues EE)', () => {
let conditions;
beforeEach(() => {
conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
conditions = IssuesFilteredSearchTokenKeysEE.getConditions();
});
it('should return conditions', () => {
......@@ -79,89 +79,89 @@ describe('Filtered Search Token Keys (Issues EE)', () => {
describe('searchByKey', () => {
it('should return null when key not found', () => {
const tokenKey = IssuableFilteredSearchTokenKeysEE.searchByKey('notakey');
const tokenKey = IssuesFilteredSearchTokenKeysEE.searchByKey('notakey');
expect(tokenKey === null).toBe(true);
});
it('should return tokenKey when found by key', () => {
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const result = IssuableFilteredSearchTokenKeysEE.searchByKey(tokenKeys[0].key);
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const result = IssuesFilteredSearchTokenKeysEE.searchByKey(tokenKeys[0].key);
expect(result).toEqual(tokenKeys[0]);
});
it('should return weight tokenKey when found by weight key', () => {
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const match = tokenKeys.find(tk => tk.key === weightTokenKey.key);
const result = IssuableFilteredSearchTokenKeysEE.searchByKey(weightTokenKey.key);
const result = IssuesFilteredSearchTokenKeysEE.searchByKey(weightTokenKey.key);
expect(result).toEqual(match);
});
});
describe('searchBySymbol', () => {
it('should return null when symbol not found', () => {
const tokenKey = IssuableFilteredSearchTokenKeysEE.searchBySymbol('notasymbol');
const tokenKey = IssuesFilteredSearchTokenKeysEE.searchBySymbol('notasymbol');
expect(tokenKey === null).toBe(true);
});
it('should return tokenKey when found by symbol', () => {
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const result = IssuableFilteredSearchTokenKeysEE.searchBySymbol(tokenKeys[0].symbol);
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const result = IssuesFilteredSearchTokenKeysEE.searchBySymbol(tokenKeys[0].symbol);
expect(result).toEqual(tokenKeys[0]);
});
it('should return weight tokenKey when found by weight symbol', () => {
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const match = tokenKeys.find(tk => tk.key === weightTokenKey.key);
const result = IssuableFilteredSearchTokenKeysEE.searchBySymbol(weightTokenKey.symbol);
const result = IssuesFilteredSearchTokenKeysEE.searchBySymbol(weightTokenKey.symbol);
expect(result).toEqual(match);
});
});
describe('searchByKeyParam', () => {
it('should return null when key param not found', () => {
const tokenKey = IssuableFilteredSearchTokenKeysEE.searchByKeyParam('notakeyparam');
const tokenKey = IssuesFilteredSearchTokenKeysEE.searchByKeyParam('notakeyparam');
expect(tokenKey === null).toBe(true);
});
it('should return tokenKey when found by key param', () => {
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const result = IssuableFilteredSearchTokenKeysEE
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const result = IssuesFilteredSearchTokenKeysEE
.searchByKeyParam(`${tokenKeys[0].key}_${tokenKeys[0].param}`);
expect(result).toEqual(tokenKeys[0]);
});
it('should return alternative tokenKey when found by key param', () => {
const tokenKeys = IssuableFilteredSearchTokenKeysEE.getAlternatives();
const result = IssuableFilteredSearchTokenKeysEE
const tokenKeys = IssuesFilteredSearchTokenKeysEE.getAlternatives();
const result = IssuesFilteredSearchTokenKeysEE
.searchByKeyParam(`${tokenKeys[0].key}_${tokenKeys[0].param}`);
expect(result).toEqual(tokenKeys[0]);
});
it('should return weight tokenKey when found by weight key param', () => {
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const match = tokenKeys.find(tk => tk.key === weightTokenKey.key);
const result = IssuableFilteredSearchTokenKeysEE.searchByKeyParam(weightTokenKey.key);
const result = IssuesFilteredSearchTokenKeysEE.searchByKeyParam(weightTokenKey.key);
expect(result).toEqual(match);
});
});
describe('searchByConditionUrl', () => {
it('should return null when condition url not found', () => {
const condition = IssuableFilteredSearchTokenKeysEE.searchByConditionUrl(null);
const condition = IssuesFilteredSearchTokenKeysEE.searchByConditionUrl(null);
expect(condition === null).toBe(true);
});
it('should return condition when found by url', () => {
const conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
const result = IssuableFilteredSearchTokenKeysEE
const conditions = IssuesFilteredSearchTokenKeysEE.getConditions();
const result = IssuesFilteredSearchTokenKeysEE
.searchByConditionUrl(conditions[0].url);
expect(result).toBe(conditions[0]);
});
it('should return weight condition when found by weight url', () => {
const conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
const conditions = IssuesFilteredSearchTokenKeysEE.getConditions();
const weightConditions = conditions.filter(c => c.tokenKey === 'weight');
const result = IssuableFilteredSearchTokenKeysEE
const result = IssuesFilteredSearchTokenKeysEE
.searchByConditionUrl(weightConditions[0].url);
expect(result).toBe(weightConditions[0]);
});
......@@ -169,22 +169,22 @@ describe('Filtered Search Token Keys (Issues EE)', () => {
describe('searchByConditionKeyValue', () => {
it('should return null when condition tokenKey and value not found', () => {
const condition = IssuableFilteredSearchTokenKeysEE
const condition = IssuesFilteredSearchTokenKeysEE
.searchByConditionKeyValue(null, null);
expect(condition === null).toBe(true);
});
it('should return condition when found by tokenKey and value', () => {
const conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
const result = IssuableFilteredSearchTokenKeysEE
const conditions = IssuesFilteredSearchTokenKeysEE.getConditions();
const result = IssuesFilteredSearchTokenKeysEE
.searchByConditionKeyValue(conditions[0].tokenKey, conditions[0].value);
expect(result).toEqual(conditions[0]);
});
it('should return weight condition when found by weight tokenKey and value', () => {
const conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
const conditions = IssuesFilteredSearchTokenKeysEE.getConditions();
const weightConditions = conditions.filter(c => c.tokenKey === 'weight');
const result = IssuableFilteredSearchTokenKeysEE
const result = IssuesFilteredSearchTokenKeysEE
.searchByConditionKeyValue(weightConditions[0].tokenKey, weightConditions[0].value);
expect(result).toEqual(weightConditions[0]);
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment