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
02b0b69b
Commit
02b0b69b
authored
Oct 17, 2018
by
Kushal Pandya
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use `FilteredSearchTokenKeys` class directly for token handling
parent
916bc63c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
81 deletions
+45
-81
ee/app/assets/javascripts/filtered_search/filtered_search_token_keys_epics.js
...ripts/filtered_search/filtered_search_token_keys_epics.js
+45
-81
No files found.
ee/app/assets/javascripts/filtered_search/filtered_search_token_keys_epics.js
View file @
02b0b69b
const
tokenKeys
=
[{
key
:
'
author
'
,
type
:
'
string
'
,
param
:
'
username
'
,
symbol
:
'
@
'
,
icon
:
'
pencil
'
,
tag
:
'
@author
'
,
},
{
key
:
'
label
'
,
type
:
'
array
'
,
param
:
'
name[]
'
,
symbol
:
'
~
'
,
icon
:
'
labels
'
,
tag
:
'
~label
'
,
}];
const
alternativeTokenKeys
=
[{
key
:
'
label
'
,
type
:
'
string
'
,
param
:
'
name
'
,
symbol
:
'
~
'
,
}];
const
tokenKeysWithAlternative
=
tokenKeys
.
concat
(
alternativeTokenKeys
);
const
conditions
=
[{
url
:
'
label_name[]=No+Label
'
,
tokenKey
:
'
label
'
,
value
:
'
none
'
,
}];
export
default
class
FilteredSearchTokenKeysEpics
{
static
get
()
{
return
tokenKeys
;
}
static
getKeys
()
{
return
tokenKeys
.
map
(
i
=>
i
.
key
);
}
static
getAlternatives
()
{
return
alternativeTokenKeys
;
}
static
getConditions
()
{
return
conditions
;
}
static
searchByKey
(
key
)
{
return
tokenKeys
.
find
(
tokenKey
=>
tokenKey
.
key
===
key
)
||
null
;
}
static
searchBySymbol
(
symbol
)
{
return
tokenKeys
.
find
(
tokenKey
=>
tokenKey
.
symbol
===
symbol
)
||
null
;
}
static
searchByKeyParam
(
keyParam
)
{
return
tokenKeysWithAlternative
.
find
((
tokenKey
)
=>
{
let
tokenKeyParam
=
tokenKey
.
key
;
// Replace hyphen with underscore to compare keyParam with tokenKeyParam
// e.g. 'my-reaction' => 'my_reaction'
tokenKeyParam
=
tokenKeyParam
.
replace
(
'
-
'
,
'
_
'
);
if
(
tokenKey
.
param
)
{
tokenKeyParam
+=
`_
${
tokenKey
.
param
}
`
;
}
return
keyParam
===
tokenKeyParam
;
})
||
null
;
}
static
searchByConditionUrl
(
url
)
{
return
conditions
.
find
(
condition
=>
condition
.
url
===
url
)
||
null
;
}
static
searchByConditionKeyValue
(
key
,
value
)
{
return
conditions
.
find
(
condition
=>
condition
.
tokenKey
===
key
&&
condition
.
value
===
value
)
||
null
;
}
}
import
FilteredSearchTokenKeys
from
'
~/filtered_search/filtered_search_token_keys
'
;
const
tokenKeys
=
[
{
key
:
'
author
'
,
type
:
'
string
'
,
param
:
'
username
'
,
symbol
:
'
@
'
,
icon
:
'
pencil
'
,
tag
:
'
@author
'
,
},
{
key
:
'
label
'
,
type
:
'
array
'
,
param
:
'
name[]
'
,
symbol
:
'
~
'
,
icon
:
'
labels
'
,
tag
:
'
~label
'
,
},
];
const
alternativeTokenKeys
=
[
{
key
:
'
label
'
,
type
:
'
string
'
,
param
:
'
name
'
,
symbol
:
'
~
'
,
},
];
const
conditions
=
[
{
url
:
'
label_name[]=No+Label
'
,
tokenKey
:
'
label
'
,
value
:
'
none
'
,
},
];
const
EpicsFilteredSearchTokenKeysEE
=
new
FilteredSearchTokenKeys
(
[...
tokenKeys
],
alternativeTokenKeys
,
[...
conditions
],
);
export
default
EpicsFilteredSearchTokenKeysEE
;
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