Commit 7974883f authored by Martin Wortschack's avatar Martin Wortschack

Merge branch...

Merge branch '196650-replace-underscore-with-lodash-for-app-assets-javascripts-filtered_search' into 'master'

Replace underscore with lodash for ./app/assets/javascripts/filtered_search

Closes #196650

See merge request gitlab-org/gitlab!26629
parents a3e0be40 50c3fe0a
import _ from 'underscore'; import { last } from 'lodash';
import FilteredSearchContainer from './container'; import FilteredSearchContainer from './container';
import FilteredSearchTokenizer from './filtered_search_tokenizer'; import FilteredSearchTokenizer from './filtered_search_tokenizer';
import FilteredSearchDropdownManager from './filtered_search_dropdown_manager'; import FilteredSearchDropdownManager from './filtered_search_dropdown_manager';
...@@ -70,11 +70,11 @@ export default class DropdownUtils { ...@@ -70,11 +70,11 @@ export default class DropdownUtils {
if (!allowMultiple && itemInExistingTokens) { if (!allowMultiple && itemInExistingTokens) {
updatedItem.droplab_hidden = true; updatedItem.droplab_hidden = true;
} else if (!isSearchItem && (!lastKey || _.last(searchInput.split('')) === ' ')) { } else if (!isSearchItem && (!lastKey || last(searchInput.split('')) === ' ')) {
updatedItem.droplab_hidden = false; updatedItem.droplab_hidden = false;
} else if (lastKey) { } else if (lastKey) {
const split = lastKey.split(':'); const split = lastKey.split(':');
const tokenName = _.last(split[0].split(' ')); const tokenName = last(split[0].split(' '));
const match = isSearchItem const match = isSearchItem
? allowedKeys.some(key => key.startsWith(tokenName.toLowerCase())) ? allowedKeys.some(key => key.startsWith(tokenName.toLowerCase()))
...@@ -129,7 +129,7 @@ export default class DropdownUtils { ...@@ -129,7 +129,7 @@ export default class DropdownUtils {
const values = []; const values = [];
if (untilInput) { if (untilInput) {
const inputIndex = _.findIndex(tokens, t => t.classList.contains('input-token')); const inputIndex = tokens.findIndex(t => t.classList.contains('input-token'));
// Add one to include input-token to the tokens array // Add one to include input-token to the tokens array
tokens.splice(inputIndex + 1); tokens.splice(inputIndex + 1);
} }
......
import { last } from 'lodash';
import AvailableDropdownMappings from 'ee_else_ce/filtered_search/available_dropdown_mappings'; import AvailableDropdownMappings from 'ee_else_ce/filtered_search/available_dropdown_mappings';
import _ from 'underscore';
import DropLab from '~/droplab/drop_lab'; import DropLab from '~/droplab/drop_lab';
import FilteredSearchContainer from './container'; import FilteredSearchContainer from './container';
import FilteredSearchTokenKeys from './filtered_search_token_keys'; import FilteredSearchTokenKeys from './filtered_search_token_keys';
...@@ -184,8 +184,8 @@ export default class FilteredSearchDropdownManager { ...@@ -184,8 +184,8 @@ export default class FilteredSearchDropdownManager {
// Eg. token = 'label:' // Eg. token = 'label:'
const split = lastToken.split(':'); const split = lastToken.split(':');
const dropdownName = _.last(split[0].split(' ')); const dropdownName = last(split[0].split(' '));
const possibleOperatorToken = _.last(split[1]); const possibleOperatorToken = last(split[1]);
const hasOperator = FilteredSearchVisualTokens.permissibleOperatorValues.includes( const hasOperator = FilteredSearchVisualTokens.permissibleOperatorValues.includes(
possibleOperatorToken && possibleOperatorToken.trim(), possibleOperatorToken && possibleOperatorToken.trim(),
......
import _ from 'underscore'; import { last } from 'lodash';
import recentSearchesStorageKeys from 'ee_else_ce/filtered_search/recent_searches_storage_keys'; import recentSearchesStorageKeys from 'ee_else_ce/filtered_search/recent_searches_storage_keys';
import { getParameterByName, getUrlParamsArray } from '~/lib/utils/common_utils'; import { getParameterByName, getUrlParamsArray } from '~/lib/utils/common_utils';
import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys'; import IssuableFilteredSearchTokenKeys from '~/filtered_search/issuable_filtered_search_token_keys';
...@@ -456,7 +456,7 @@ export default class FilteredSearchManager { ...@@ -456,7 +456,7 @@ export default class FilteredSearchManager {
if (fragments.length > 1) { if (fragments.length > 1) {
const inputValues = fragments[0].split(' '); const inputValues = fragments[0].split(' ');
const tokenKey = _.last(inputValues); const tokenKey = last(inputValues);
if (inputValues.length > 1) { if (inputValues.length > 1) {
inputValues.pop(); inputValues.pop();
......
import { flatten } from 'underscore'; import { flattenDeep } from 'lodash';
import FilteredSearchTokenKeys from './filtered_search_token_keys'; import FilteredSearchTokenKeys from './filtered_search_token_keys';
import { __ } from '~/locale'; import { __ } from '~/locale';
...@@ -73,7 +73,7 @@ export const alternativeTokenKeys = [ ...@@ -73,7 +73,7 @@ export const alternativeTokenKeys = [
}, },
]; ];
export const conditions = flatten( export const conditions = flattenDeep(
[ [
{ {
url: 'assignee_id=None', url: 'assignee_id=None',
......
import _ from 'underscore'; import { uniq } from 'lodash';
class RecentSearchesStore { class RecentSearchesStore {
constructor(initialState = {}, allowedKeys) { constructor(initialState = {}, allowedKeys) {
...@@ -20,7 +20,7 @@ class RecentSearchesStore { ...@@ -20,7 +20,7 @@ class RecentSearchesStore {
setRecentSearches(searches = []) { setRecentSearches(searches = []) {
const trimmedSearches = searches.map(search => search.trim()); const trimmedSearches = searches.map(search => search.trim());
this.state.recentSearches = _.uniq(trimmedSearches).slice(0, 5); this.state.recentSearches = uniq(trimmedSearches).slice(0, 5);
return this.state.recentSearches; return this.state.recentSearches;
} }
} }
......
import _ from 'underscore'; import { escape as esc } from 'lodash';
import { USER_TOKEN_TYPES } from 'ee_else_ce/filtered_search/constants'; import { USER_TOKEN_TYPES } from 'ee_else_ce/filtered_search/constants';
import FilteredSearchContainer from '~/filtered_search/container'; import FilteredSearchContainer from '~/filtered_search/container';
import FilteredSearchVisualTokens from '~/filtered_search/filtered_search_visual_tokens'; import FilteredSearchVisualTokens from '~/filtered_search/filtered_search_visual_tokens';
...@@ -48,7 +48,7 @@ export default class VisualTokenValue { ...@@ -48,7 +48,7 @@ export default class VisualTokenValue {
tokenValueContainer.dataset.originalValue = tokenValue; tokenValueContainer.dataset.originalValue = tokenValue;
tokenValueElement.innerHTML = ` tokenValueElement.innerHTML = `
<img class="avatar s20" src="${user.avatar_url}" alt=""> <img class="avatar s20" src="${user.avatar_url}" alt="">
${_.escape(user.name)} ${esc(user.name)}
`; `;
/* eslint-enable no-param-reassign */ /* eslint-enable no-param-reassign */
}) })
......
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