Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Tatuya Kamada
gitlab-ce
Commits
fe1ab405
Commit
fe1ab405
authored
Feb 21, 2017
by
Simon Knox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow searching issues for strings containing colons
parent
dc303fe2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
2 deletions
+32
-2
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
...avascripts/filtered_search/filtered_search_manager.js.es6
+1
-1
app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es6
...ascripts/filtered_search/filtered_search_tokenizer.js.es6
+4
-1
changelogs/unreleased/28357-colon-search.yml
changelogs/unreleased/28357-colon-search.yml
+4
-0
spec/javascripts/filtered_search/filtered_search_tokenizer_spec.js.es6
...pts/filtered_search/filtered_search_tokenizer_spec.js.es6
+23
-0
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js.es6
View file @
fe1ab405
...
@@ -173,7 +173,7 @@
...
@@ -173,7 +173,7 @@
tokens.forEach((token) => {
tokens.forEach((token) => {
const condition = gl.FilteredSearchTokenKeys
const condition = gl.FilteredSearchTokenKeys
.searchByConditionKeyValue(token.key, token.value.toLowerCase());
.searchByConditionKeyValue(token.key, token.value.toLowerCase());
const { param } = gl.FilteredSearchTokenKeys.searchByKey(token.key);
const { param } = gl.FilteredSearchTokenKeys.searchByKey(token.key)
|| {}
;
const keyParam = param ? `${token.key}_${param}` : token.key;
const keyParam = param ? `${token.key}_${param}` : token.key;
let tokenPath = '';
let tokenPath = '';
...
...
app/assets/javascripts/filtered_search/filtered_search_tokenizer.js.es6
View file @
fe1ab405
require('./filtered_search_token_keys');
(() => {
(() => {
class FilteredSearchTokenizer {
class FilteredSearchTokenizer {
static processTokens(input) {
static processTokens(input) {
const allowedKeys = gl.FilteredSearchTokenKeys.get().map(i => i.key);
// Regex extracts `(token):(symbol)(value)`
// Regex extracts `(token):(symbol)(value)`
// Values that start with a double quote must end in a double quote (same for single)
// Values that start with a double quote must end in a double quote (same for single)
const tokenRegex =
/(\w+):([~%@]?)(?:('[^']*'{0,1})|("[^"]*"{0,1})|(\S+))/g
;
const tokenRegex =
new RegExp(`(${allowedKeys.join('|')}):([~%@]?)(?:('[^']*'{0,1})|("[^"]*"{0,1})|(\\S+))`, 'g')
;
const tokens = [];
const tokens = [];
let lastToken = null;
let lastToken = null;
const searchToken = input.replace(tokenRegex, (match, key, symbol, v1, v2, v3) => {
const searchToken = input.replace(tokenRegex, (match, key, symbol, v1, v2, v3) => {
...
...
changelogs/unreleased/28357-colon-search.yml
0 → 100644
View file @
fe1ab405
---
title
:
Allow searching issues for strings containing colons
merge_request
:
author
:
spec/javascripts/filtered_search/filtered_search_tokenizer_spec.js.es6
View file @
fe1ab405
...
@@ -99,6 +99,29 @@ require('~/filtered_search/filtered_search_tokenizer');
...
@@ -99,6 +99,29 @@ require('~/filtered_search/filtered_search_tokenizer');
expect(results.tokens[2].value).toBe('Doing');
expect(results.tokens[2].value).toBe('Doing');
expect(results.tokens[2].symbol).toBe('~');
expect(results.tokens[2].symbol).toBe('~');
});
});
it('returns search value for invalid tokens', () => {
const results = gl.FilteredSearchTokenizer.processTokens('fake:token');
expect(results.lastToken).toBe('fake:token');
expect(results.searchToken).toBe('fake:token');
expect(results.tokens.length).toEqual(0);
});
it('returns search value and token for mix of valid and invalid tokens', () => {
const results = gl.FilteredSearchTokenizer.processTokens('label:real fake:token');
expect(results.tokens.length).toEqual(1);
expect(results.tokens[0].key).toBe('label');
expect(results.tokens[0].value).toBe('real');
expect(results.tokens[0].symbol).toBe('');
expect(results.lastToken).toBe('fake:token');
expect(results.searchToken).toBe('fake:token');
});
it('returns search value for invalid symbols', () => {
const results = gl.FilteredSearchTokenizer.processTokens('std::includes');
expect(results.lastToken).toBe('std::includes');
expect(results.searchToken).toBe('std::includes');
});
});
});
});
});
})();
})();
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment