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
484ca2a4
Commit
484ca2a4
authored
Sep 06, 2017
by
Bryce Johnson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use canEdit for clearSearch removal logic.
parent
852ea20a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
39 deletions
+8
-39
app/assets/javascripts/filtered_search/filtered_search_manager.js
...ts/javascripts/filtered_search/filtered_search_manager.js
+8
-7
app/assets/javascripts/service_desk_issues/filtered_search.js
...assets/javascripts/service_desk_issues/filtered_search.js
+0
-7
spec/javascripts/filtered_search/filtered_search_manager_spec.js
...vascripts/filtered_search/filtered_search_manager_spec.js
+0
-25
No files found.
app/assets/javascripts/filtered_search/filtered_search_manager.js
View file @
484ca2a4
...
...
@@ -334,19 +334,20 @@ class FilteredSearchManager {
this
.
clearSearch
();
}
removalValidator
(
token
)
{
const
isToken
=
token
.
classList
.
contains
(
'
js-visual-token
'
);
return
this
.
customRemovalValidator
?
(
this
.
customRemovalValidator
(
token
)
&&
isToken
)
:
isToken
;
}
clearSearch
()
{
this
.
filteredSearchInput
.
value
=
''
;
const
removeElements
=
[];
[].
forEach
.
call
(
this
.
tokensContainer
.
children
,
(
t
)
=>
{
if
(
this
.
removalValidator
(
t
))
{
let
canClearToken
=
t
.
classList
.
contains
(
'
js-visual-token
'
);
if
(
canClearToken
)
{
const
tokenKey
=
t
.
querySelector
(
'
.name
'
).
textContent
.
trim
();
canClearToken
=
this
.
canEdit
&&
this
.
canEdit
(
tokenKey
);
}
if
(
canClearToken
)
{
removeElements
.
push
(
t
);
}
});
...
...
app/assets/javascripts/service_desk_issues/filtered_search.js
View file @
484ca2a4
...
...
@@ -9,13 +9,6 @@ export default class FilteredSearchServiceDesk extends gl.FilteredSearchManager
this
.
supportBotData
=
supportBotData
;
}
customRemovalValidator
(
token
)
{
const
tokenValue
=
token
.
querySelector
(
'
.value-container
'
);
return
tokenValue
?
tokenValue
.
getAttribute
(
'
data-original-value
'
)
!==
`@
${
this
.
supportBotData
.
username
}
`
:
true
;
}
canEdit
(
tokenName
)
{
return
tokenName
!==
'
author
'
;
}
...
...
spec/javascripts/filtered_search/filtered_search_manager_spec.js
View file @
484ca2a4
...
...
@@ -412,31 +412,6 @@ describe('Filtered Search Manager', () => {
});
});
describe
(
'
removalValidator
'
,
()
=>
{
beforeEach
(()
=>
{
Object
.
assign
(
gl
.
FilteredSearchManager
.
prototype
,
{
customRemovalValidator
:
()
=>
true
,
});
spyOn
(
gl
.
FilteredSearchManager
.
prototype
,
'
removalValidator
'
).
and
.
callThrough
();
spyOn
(
gl
.
FilteredSearchManager
.
prototype
,
'
customRemovalValidator
'
).
and
.
callThrough
();
initializeManager
();
});
it
(
'
is called on clearSearch
'
,
()
=>
{
manager
.
clearSearch
();
expect
(
manager
.
removalValidator
).
toHaveBeenCalled
();
});
it
(
'
calls the customRemovalValidator when present
'
,
()
=>
{
manager
.
clearSearch
();
expect
(
manager
.
customRemovalValidator
).
toHaveBeenCalled
();
});
});
describe
(
'
getAllParams
'
,
()
=>
{
beforeEach
(()
=>
{
this
.
paramsArr
=
[
'
key=value
'
,
'
otherkey=othervalue
'
];
...
...
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