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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
edb5dcdb
Commit
edb5dcdb
authored
Mar 28, 2017
by
Alfredo Sumaran
Committed by
Clement Ho
Mar 28, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove duplicated tokens in issuable search bar
parent
c82ddfe2
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
41 additions
and
5 deletions
+41
-5
app/assets/javascripts/filtered_search/filtered_search_tokenizer.js
.../javascripts/filtered_search/filtered_search_tokenizer.js
+15
-5
changelogs/unreleased/27293-remove-repeated-labels.yml
changelogs/unreleased/27293-remove-repeated-labels.yml
+4
-0
spec/javascripts/filtered_search/filtered_search_manager_spec.js
...vascripts/filtered_search/filtered_search_manager_spec.js
+14
-0
spec/javascripts/filtered_search/filtered_search_tokenizer_spec.js
...scripts/filtered_search/filtered_search_tokenizer_spec.js
+8
-0
No files found.
app/assets/javascripts/filtered_search/filtered_search_tokenizer.js
View file @
edb5dcdb
...
...
@@ -8,21 +8,31 @@ require('./filtered_search_token_keys');
// Values that start with a double quote must end in a double quote (same for single)
const
tokenRegex
=
new
RegExp
(
`(
${
allowedKeys
.
join
(
'
|
'
)}
):([~%@]?)(?:('[^']*'{0,1})|("[^"]*"{0,1})|(\\S+))`
,
'
g
'
);
const
tokens
=
[];
const
tokenIndexes
=
[];
// stores key+value for simple search
let
lastToken
=
null
;
const
searchToken
=
input
.
replace
(
tokenRegex
,
(
match
,
key
,
symbol
,
v1
,
v2
,
v3
)
=>
{
let
tokenValue
=
v1
||
v2
||
v3
;
let
tokenSymbol
=
symbol
;
let
tokenIndex
=
''
;
if
(
tokenValue
===
'
~
'
||
tokenValue
===
'
%
'
||
tokenValue
===
'
@
'
)
{
tokenSymbol
=
tokenValue
;
tokenValue
=
''
;
}
tokenIndex
=
`
${
key
}
:
${
tokenValue
}
`
;
// Prevent adding duplicates
if
(
tokenIndexes
.
indexOf
(
tokenIndex
)
===
-
1
)
{
tokenIndexes
.
push
(
tokenIndex
);
tokens
.
push
({
key
,
value
:
tokenValue
||
''
,
symbol
:
tokenSymbol
||
''
,
});
}
return
''
;
}).
replace
(
/
\s{2,}
/g
,
'
'
).
trim
()
||
''
;
...
...
changelogs/unreleased/27293-remove-repeated-labels.yml
0 → 100644
View file @
edb5dcdb
---
title
:
Remove duplicated tokens in issuable search bar
merge_request
:
author
:
spec/javascripts/filtered_search/filtered_search_manager_spec.js
View file @
edb5dcdb
...
...
@@ -92,6 +92,20 @@ const FilteredSearchSpecHelper = require('../helpers/filtered_search_spec_helper
manager
.
search
();
});
it
(
'
removes duplicated tokens
'
,
(
done
)
=>
{
tokensContainer
.
innerHTML
=
FilteredSearchSpecHelper
.
createTokensContainerHTML
(
`
${
FilteredSearchSpecHelper
.
createFilterVisualTokenHTML
(
'
label
'
,
'
~bug
'
)}
${
FilteredSearchSpecHelper
.
createFilterVisualTokenHTML
(
'
label
'
,
'
~bug
'
)}
`
);
spyOn
(
gl
.
utils
,
'
visitUrl
'
).
and
.
callFake
((
url
)
=>
{
expect
(
url
).
toEqual
(
`
${
defaultParams
}
&label_name[]=bug`
);
done
();
});
manager
.
search
();
});
});
describe
(
'
handleInputPlaceholder
'
,
()
=>
{
...
...
spec/javascripts/filtered_search/filtered_search_tokenizer_spec.js
View file @
edb5dcdb
...
...
@@ -122,6 +122,14 @@ require('~/filtered_search/filtered_search_tokenizer');
expect
(
results
.
lastToken
).
toBe
(
'
std::includes
'
);
expect
(
results
.
searchToken
).
toBe
(
'
std::includes
'
);
});
it
(
'
removes duplicated values
'
,
()
=>
{
const
results
=
gl
.
FilteredSearchTokenizer
.
processTokens
(
'
label:~foo label:~foo
'
);
expect
(
results
.
tokens
.
length
).
toBe
(
1
);
expect
(
results
.
tokens
[
0
].
key
).
toBe
(
'
label
'
);
expect
(
results
.
tokens
[
0
].
value
).
toBe
(
'
foo
'
);
expect
(
results
.
tokens
[
0
].
symbol
).
toBe
(
'
~
'
);
});
});
});
})();
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