Commit fe32a9f6 authored by Lukas Eipert's avatar Lukas Eipert

Fix naming and import paths of issuable_filtered_search_token_keys

There has been a mismatch between CE and EE regarding the naming
convention of `issuable_filtered_search_token_keys` and some imports
pointed to the wrong file.
parent 3566b5b0
import IssuesFilteredSearchTokenKeysEE from 'ee/filtered_search/issues_filtered_search_token_keys';
import IssuableFilteredSearchTokenKeysEE from 'ee/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: IssuesFilteredSearchTokenKeysEE,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeysEE,
});
this.store = store;
......
import FilteredSearchTokenKeys from './filtered_search_token_keys';
const tokenKeys = [{
export const tokenKeys = [{
key: 'author',
type: 'string',
param: 'username',
......@@ -42,14 +42,14 @@ if (gon.current_user_id) {
});
}
const alternativeTokenKeys = [{
export const alternativeTokenKeys = [{
key: 'label',
type: 'string',
param: 'name',
symbol: '~',
}];
const conditions = [{
export const conditions = [{
url: 'assignee_id=0',
tokenKey: 'assignee',
value: 'none',
......
......@@ -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 IssuesFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_filtered_search_token_keys';
import IssuableFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_filtered_search_token_keys';
document.addEventListener('DOMContentLoaded', () => {
initFilteredSearch({
page: FILTERED_SEARCH.ISSUES,
filteredSearchTokenKeys: IssuesFilteredSearchTokenKeysEE,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeysEE,
});
new IssuableIndex(ISSUABLE_INDEX.ISSUE);
......
......@@ -3,7 +3,7 @@ import {
tokenKeys,
alternativeTokenKeys,
conditions,
} from '~/filtered_search/issues_filtered_search_token_keys';
} from '~/filtered_search/issuable_filtered_search_token_keys';
const weightTokenKey = {
key: 'weight',
......@@ -27,14 +27,14 @@ const weightConditions = [
},
];
const IssuesFilteredSearchTokenKeysEE = new FilteredSearchTokenKeys(
const IssuableFilteredSearchTokenKeysEE = new FilteredSearchTokenKeys(
[...tokenKeys, weightTokenKey],
alternativeTokenKeys,
[...conditions, ...weightConditions],
);
// cannot be an arrow function because it needs FilteredSearchTokenKeys instance
IssuesFilteredSearchTokenKeysEE.init = function init(availableFeatures) {
IssuableFilteredSearchTokenKeysEE.init = function init(availableFeatures) {
// Enable multiple assignees when available
if (availableFeatures && availableFeatures.multipleAssignees) {
const assigneeTokenKey = this.tokenKeys.find(tk => tk.key === 'assignee');
......@@ -43,4 +43,4 @@ IssuesFilteredSearchTokenKeysEE.init = function init(availableFeatures) {
}
};
export default IssuesFilteredSearchTokenKeysEE;
export default IssuableFilteredSearchTokenKeysEE;
/* eslint-disable class-methods-use-this */
import FilteredSearchManager from '~/filtered_search/filtered_search_manager';
import IssuesFilteredSearchTokenKeysEE from 'ee/filtered_search/issues_filtered_search_token_keys';
import IssuableFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_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: IssuesFilteredSearchTokenKeysEE,
filteredSearchTokenKeys: IssuableFilteredSearchTokenKeysEE,
});
this.supportBotData = supportBotData;
......
import IssuesFilteredSearchTokenKeysEE from 'ee/filtered_search/issues_filtered_search_token_keys';
import IssuableFilteredSearchTokenKeysEE from 'ee/filtered_search/issuable_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(() => {
IssuesFilteredSearchTokenKeysEE.init({
IssuableFilteredSearchTokenKeysEE.init({
multipleAssignees: true,
});
tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
tokenKeys = IssuableFilteredSearchTokenKeysEE.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 = IssuesFilteredSearchTokenKeysEE.get();
const tokenKeys2 = IssuableFilteredSearchTokenKeysEE.get();
expect(tokenKeys).toEqual(tokenKeys2);
});
......@@ -47,8 +47,8 @@ describe('Filtered Search Token Keys (Issues EE)', () => {
describe('getKeys', () => {
it('should return keys', () => {
const getKeys = IssuesFilteredSearchTokenKeysEE.getKeys();
const keys = IssuesFilteredSearchTokenKeysEE.get().map(i => i.key);
const getKeys = IssuableFilteredSearchTokenKeysEE.getKeys();
const keys = IssuableFilteredSearchTokenKeysEE.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 = IssuesFilteredSearchTokenKeysEE.getConditions();
conditions = IssuableFilteredSearchTokenKeysEE.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 = IssuesFilteredSearchTokenKeysEE.searchByKey('notakey');
const tokenKey = IssuableFilteredSearchTokenKeysEE.searchByKey('notakey');
expect(tokenKey === null).toBe(true);
});
it('should return tokenKey when found by key', () => {
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const result = IssuesFilteredSearchTokenKeysEE.searchByKey(tokenKeys[0].key);
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const result = IssuableFilteredSearchTokenKeysEE.searchByKey(tokenKeys[0].key);
expect(result).toEqual(tokenKeys[0]);
});
it('should return weight tokenKey when found by weight key', () => {
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const match = tokenKeys.find(tk => tk.key === weightTokenKey.key);
const result = IssuesFilteredSearchTokenKeysEE.searchByKey(weightTokenKey.key);
const result = IssuableFilteredSearchTokenKeysEE.searchByKey(weightTokenKey.key);
expect(result).toEqual(match);
});
});
describe('searchBySymbol', () => {
it('should return null when symbol not found', () => {
const tokenKey = IssuesFilteredSearchTokenKeysEE.searchBySymbol('notasymbol');
const tokenKey = IssuableFilteredSearchTokenKeysEE.searchBySymbol('notasymbol');
expect(tokenKey === null).toBe(true);
});
it('should return tokenKey when found by symbol', () => {
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const result = IssuesFilteredSearchTokenKeysEE.searchBySymbol(tokenKeys[0].symbol);
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const result = IssuableFilteredSearchTokenKeysEE.searchBySymbol(tokenKeys[0].symbol);
expect(result).toEqual(tokenKeys[0]);
});
it('should return weight tokenKey when found by weight symbol', () => {
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const match = tokenKeys.find(tk => tk.key === weightTokenKey.key);
const result = IssuesFilteredSearchTokenKeysEE.searchBySymbol(weightTokenKey.symbol);
const result = IssuableFilteredSearchTokenKeysEE.searchBySymbol(weightTokenKey.symbol);
expect(result).toEqual(match);
});
});
describe('searchByKeyParam', () => {
it('should return null when key param not found', () => {
const tokenKey = IssuesFilteredSearchTokenKeysEE.searchByKeyParam('notakeyparam');
const tokenKey = IssuableFilteredSearchTokenKeysEE.searchByKeyParam('notakeyparam');
expect(tokenKey === null).toBe(true);
});
it('should return tokenKey when found by key param', () => {
const tokenKeys = IssuesFilteredSearchTokenKeysEE.get();
const result = IssuesFilteredSearchTokenKeysEE
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const result = IssuableFilteredSearchTokenKeysEE
.searchByKeyParam(`${tokenKeys[0].key}_${tokenKeys[0].param}`);
expect(result).toEqual(tokenKeys[0]);
});
it('should return alternative tokenKey when found by key param', () => {
const tokenKeys = IssuesFilteredSearchTokenKeysEE.getAlternatives();
const result = IssuesFilteredSearchTokenKeysEE
const tokenKeys = IssuableFilteredSearchTokenKeysEE.getAlternatives();
const result = IssuableFilteredSearchTokenKeysEE
.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 = IssuesFilteredSearchTokenKeysEE.get();
const tokenKeys = IssuableFilteredSearchTokenKeysEE.get();
const match = tokenKeys.find(tk => tk.key === weightTokenKey.key);
const result = IssuesFilteredSearchTokenKeysEE.searchByKeyParam(weightTokenKey.key);
const result = IssuableFilteredSearchTokenKeysEE.searchByKeyParam(weightTokenKey.key);
expect(result).toEqual(match);
});
});
describe('searchByConditionUrl', () => {
it('should return null when condition url not found', () => {
const condition = IssuesFilteredSearchTokenKeysEE.searchByConditionUrl(null);
const condition = IssuableFilteredSearchTokenKeysEE.searchByConditionUrl(null);
expect(condition === null).toBe(true);
});
it('should return condition when found by url', () => {
const conditions = IssuesFilteredSearchTokenKeysEE.getConditions();
const result = IssuesFilteredSearchTokenKeysEE
const conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
const result = IssuableFilteredSearchTokenKeysEE
.searchByConditionUrl(conditions[0].url);
expect(result).toBe(conditions[0]);
});
it('should return weight condition when found by weight url', () => {
const conditions = IssuesFilteredSearchTokenKeysEE.getConditions();
const conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
const weightConditions = conditions.filter(c => c.tokenKey === 'weight');
const result = IssuesFilteredSearchTokenKeysEE
const result = IssuableFilteredSearchTokenKeysEE
.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 = IssuesFilteredSearchTokenKeysEE
const condition = IssuableFilteredSearchTokenKeysEE
.searchByConditionKeyValue(null, null);
expect(condition === null).toBe(true);
});
it('should return condition when found by tokenKey and value', () => {
const conditions = IssuesFilteredSearchTokenKeysEE.getConditions();
const result = IssuesFilteredSearchTokenKeysEE
const conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
const result = IssuableFilteredSearchTokenKeysEE
.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 = IssuesFilteredSearchTokenKeysEE.getConditions();
const conditions = IssuableFilteredSearchTokenKeysEE.getConditions();
const weightConditions = conditions.filter(c => c.tokenKey === 'weight');
const result = IssuesFilteredSearchTokenKeysEE
const result = IssuableFilteredSearchTokenKeysEE
.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