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
9a11d79e
Commit
9a11d79e
authored
Apr 20, 2021
by
Scott Stern
Committed by
Natalia Tepluhina
Apr 20, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add filtering of data to boards with param support
parent
20a537c8
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
174 additions
and
39 deletions
+174
-39
ee/app/assets/javascripts/boards/components/epic_filtered_search.vue
...ts/javascripts/boards/components/epic_filtered_search.vue
+87
-17
ee/app/assets/javascripts/boards/epic_filtered_search.js
ee/app/assets/javascripts/boards/epic_filtered_search.js
+6
-3
ee/app/assets/javascripts/boards/graphql/group_members.query.graphql
...ts/javascripts/boards/graphql/group_members.query.graphql
+1
-1
ee/spec/features/epic_boards/epic_boards_spec.rb
ee/spec/features/epic_boards/epic_boards_spec.rb
+26
-9
ee/spec/frontend/boards/components/epic_filtered_search_spec.js
...c/frontend/boards/components/epic_filtered_search_spec.js
+54
-9
No files found.
ee/app/assets/javascripts/boards/components/epic_filtered_search.vue
View file @
9a11d79e
<
script
>
<
script
>
import
{
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
mapActions
,
mapState
}
from
'
vuex
'
;
import
{
historyPushState
}
from
'
~/lib/utils/common_utils
'
;
import
{
updateHistory
,
setUrlParams
}
from
'
~/lib/utils/url_utility
'
;
import
{
setUrlParams
}
from
'
~/lib/utils/url_utility
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
FilteredSearch
from
'
~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue
'
;
import
FilteredSearch
from
'
~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue
'
;
import
AuthorToken
from
'
~/vue_shared/components/filtered_search_bar/tokens/author_token.vue
'
;
import
AuthorToken
from
'
~/vue_shared/components/filtered_search_bar/tokens/author_token.vue
'
;
...
@@ -12,20 +11,24 @@ import groupUsersQuery from '../graphql/group_members.query.graphql';
...
@@ -12,20 +11,24 @@ import groupUsersQuery from '../graphql/group_members.query.graphql';
export
default
{
export
default
{
i18n
:
{
i18n
:
{
search
:
__
(
'
Search
'
),
search
:
__
(
'
Search
'
),
label
:
__
(
'
Label
'
),
author
:
__
(
'
Author
'
),
},
},
components
:
{
FilteredSearch
},
components
:
{
FilteredSearch
},
inject
:
[
'
search
'
],
inject
:
[
'
initialFilterParams
'
],
data
()
{
return
{
filterParams
:
this
.
initialFilterParams
,
};
},
computed
:
{
computed
:
{
...
mapState
([
'
fullPath
'
]),
...
mapState
([
'
fullPath
'
]),
initialSearch
()
{
return
[{
type
:
'
filtered-search-term
'
,
value
:
{
data
:
this
.
search
}
}];
},
tokens
()
{
tokens
()
{
return
[
return
[
{
{
icon
:
'
labels
'
,
icon
:
'
labels
'
,
title
:
__
(
'
Label
'
)
,
title
:
this
.
$options
.
i18n
.
label
,
type
:
'
label
s
'
,
type
:
'
label
_name
'
,
operators
:
[{
value
:
'
=
'
,
description
:
'
is
'
}],
operators
:
[{
value
:
'
=
'
,
description
:
'
is
'
}],
token
:
LabelToken
,
token
:
LabelToken
,
unique
:
false
,
unique
:
false
,
...
@@ -34,8 +37,8 @@ export default {
...
@@ -34,8 +37,8 @@ export default {
},
},
{
{
icon
:
'
pencil
'
,
icon
:
'
pencil
'
,
title
:
__
(
'
Author
'
)
,
title
:
this
.
$options
.
i18n
.
author
,
type
:
'
author
'
,
type
:
'
author
_username
'
,
operators
:
[{
value
:
'
=
'
,
description
:
'
is
'
}],
operators
:
[{
value
:
'
=
'
,
description
:
'
is
'
}],
symbol
:
'
@
'
,
symbol
:
'
@
'
,
token
:
AuthorToken
,
token
:
AuthorToken
,
...
@@ -44,9 +47,74 @@ export default {
...
@@ -44,9 +47,74 @@ export default {
},
},
];
];
},
},
urlParams
()
{
const
{
authorUsername
,
labelName
,
search
}
=
this
.
filterParams
;
return
{
author_username
:
authorUsername
,
'
label_name[]
'
:
labelName
,
search
,
};
},
},
},
methods
:
{
methods
:
{
...
mapActions
([
'
performSearch
'
]),
...
mapActions
([
'
performSearch
'
]),
getFilteredSearchValue
()
{
const
{
authorUsername
,
labelName
,
search
}
=
this
.
filterParams
;
const
filteredSearchValue
=
[];
if
(
authorUsername
)
{
filteredSearchValue
.
push
({
type
:
'
author_username
'
,
value
:
{
data
:
authorUsername
},
});
}
if
(
labelName
?.
length
)
{
filteredSearchValue
.
push
(
...
labelName
.
map
((
label
)
=>
({
type
:
'
label_name
'
,
value
:
{
data
:
label
},
})),
);
}
if
(
search
)
{
filteredSearchValue
.
push
(
search
);
}
return
filteredSearchValue
;
},
getFilterParams
(
filters
=
[])
{
const
filterParams
=
{};
const
labels
=
[];
const
plainText
=
[];
filters
.
forEach
((
filter
)
=>
{
switch
(
filter
.
type
)
{
case
'
author_username
'
:
filterParams
.
authorUsername
=
filter
.
value
.
data
;
break
;
case
'
label_name
'
:
labels
.
push
(
filter
.
value
.
data
);
break
;
case
'
filtered-search-term
'
:
if
(
filter
.
value
.
data
)
plainText
.
push
(
filter
.
value
.
data
);
break
;
default
:
break
;
}
});
if
(
labels
.
length
)
{
filterParams
.
labelName
=
labels
;
}
if
(
plainText
.
length
)
{
filterParams
.
search
=
plainText
.
join
(
'
'
);
}
return
filterParams
;
},
fetchAuthors
(
authorsSearchTerm
)
{
fetchAuthors
(
authorsSearchTerm
)
{
return
this
.
$apollo
return
this
.
$apollo
.
query
({
.
query
({
...
@@ -69,11 +137,13 @@ export default {
...
@@ -69,11 +137,13 @@ export default {
})
})
.
then
(({
data
})
=>
data
.
group
?.
labels
.
nodes
||
[]);
.
then
(({
data
})
=>
data
.
group
?.
labels
.
nodes
||
[]);
},
},
handleSearch
(
filters
=
[])
{
handleFilterEpics
(
filters
)
{
const
[
item
]
=
filters
;
this
.
filterParams
=
this
.
getFilterParams
(
filters
);
const
search
=
item
?.
value
?.
data
||
''
;
updateHistory
({
url
:
setUrlParams
(
this
.
urlParams
,
window
.
location
.
href
,
true
,
false
,
true
),
historyPushState
(
setUrlParams
({
search
}));
title
:
document
.
title
,
replace
:
true
,
});
this
.
performSearch
();
this
.
performSearch
();
},
},
...
@@ -88,7 +158,7 @@ export default {
...
@@ -88,7 +158,7 @@ export default {
namespace=
""
namespace=
""
:tokens=
"tokens"
:tokens=
"tokens"
:search-input-placeholder=
"$options.i18n.search"
:search-input-placeholder=
"$options.i18n.search"
:initial-filter-value=
"
initialSearch
"
:initial-filter-value=
"
getFilteredSearchValue()
"
@
onFilter=
"handle
Search
"
@
onFilter=
"handle
FilterEpics
"
/>
/>
</
template
>
</
template
>
ee/app/assets/javascripts/boards/epic_filtered_search.js
View file @
9a11d79e
import
Vue
from
'
vue
'
;
import
Vue
from
'
vue
'
;
import
EpicFilteredSearch
from
'
ee_component/boards/components/epic_filtered_search.vue
'
;
import
EpicFilteredSearch
from
'
ee_component/boards/components/epic_filtered_search.vue
'
;
import
store
from
'
~/boards/stores
'
;
import
store
from
'
~/boards/stores
'
;
import
{
queryToObject
}
from
'
~/lib/utils/url_utility
'
;
import
{
urlParamsToObject
,
convertObjectPropsToCamelCase
}
from
'
~/lib/utils/common_utils
'
;
export
default
(
apolloProvider
)
=>
{
export
default
(
apolloProvider
)
=>
{
const
queryParams
=
queryToObject
(
window
.
location
.
search
);
const
el
=
document
.
getElementById
(
'
js-board-filtered-search
'
);
const
el
=
document
.
getElementById
(
'
js-board-filtered-search
'
);
const
rawFilterParams
=
urlParamsToObject
(
window
.
location
.
search
);
const
initialFilterParams
=
{
...
convertObjectPropsToCamelCase
(
rawFilterParams
,
{}),
};
if
(
!
el
)
{
if
(
!
el
)
{
return
null
;
return
null
;
...
@@ -14,7 +17,7 @@ export default (apolloProvider) => {
...
@@ -14,7 +17,7 @@ export default (apolloProvider) => {
return
new
Vue
({
return
new
Vue
({
el
,
el
,
provide
:
{
provide
:
{
search
:
queryParams
?.
search
||
''
,
initialFilterParams
,
},
},
store
,
// TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/324094
store
,
// TODO: https://gitlab.com/gitlab-org/gitlab/-/issues/324094
apolloProvider
,
apolloProvider
,
...
...
ee/app/assets/javascripts/boards/graphql/group_members.query.graphql
View file @
9a11d79e
query
EpicUsers
(
$fullPath
:
ID
!,
$search
:
String
)
{
query
EpicUsers
(
$fullPath
:
ID
!,
$search
:
String
)
{
group
(
fullPath
:
$fullPath
)
{
group
(
fullPath
:
$fullPath
)
{
groupMembers
(
relations
:
[
DIRECT
,
DESCENDANTS
],
search
:
$search
)
{
groupMembers
(
relations
:
[
DIRECT
,
DESCENDANTS
,
INHERITED
],
search
:
$search
)
{
nodes
{
nodes
{
user
{
user
{
id
id
...
...
ee/spec/features/epic_boards/epic_boards_spec.rb
View file @
9a11d79e
...
@@ -16,7 +16,7 @@ RSpec.describe 'epic boards', :js do
...
@@ -16,7 +16,7 @@ RSpec.describe 'epic boards', :js do
let_it_be
(
:backlog_list
)
{
create
(
:epic_list
,
epic_board:
epic_board
,
list_type: :backlog
)
}
let_it_be
(
:backlog_list
)
{
create
(
:epic_list
,
epic_board:
epic_board
,
list_type: :backlog
)
}
let_it_be
(
:closed_list
)
{
create
(
:epic_list
,
epic_board:
epic_board
,
list_type: :closed
)
}
let_it_be
(
:closed_list
)
{
create
(
:epic_list
,
epic_board:
epic_board
,
list_type: :closed
)
}
let_it_be
(
:epic1
)
{
create
(
:epic
,
group:
group
,
labels:
[
label
],
title:
'Epic1'
)
}
let_it_be
(
:epic1
)
{
create
(
:epic
,
group:
group
,
labels:
[
label
],
author:
user
,
title:
'Epic1'
)
}
let_it_be
(
:epic2
)
{
create
(
:epic
,
group:
group
,
title:
'Epic2'
)
}
let_it_be
(
:epic2
)
{
create
(
:epic
,
group:
group
,
title:
'Epic2'
)
}
let_it_be
(
:epic3
)
{
create
(
:epic
,
group:
group
,
labels:
[
label2
],
title:
'Epic3'
)
}
let_it_be
(
:epic3
)
{
create
(
:epic
,
group:
group
,
labels:
[
label2
],
title:
'Epic3'
)
}
...
@@ -166,22 +166,39 @@ RSpec.describe 'epic boards', :js do
...
@@ -166,22 +166,39 @@ RSpec.describe 'epic boards', :js do
group
.
add_guest
(
user
)
group
.
add_guest
(
user
)
sign_in
(
user
)
sign_in
(
user
)
visit_epic_boards_page
visit_epic_boards_page
# Focus on search field
find_field
(
'Search'
).
click
end
end
it
'can select an Author and Label'
do
it
'can select a Label in order to filter the board'
do
page
.
find
(
'[data-testid="epic-filtered-search"]'
).
click
page
.
within
(
'[data-testid="epic-filtered-search"]'
)
do
click_link
'Label'
click_link
label
.
title
find
(
'input'
).
native
.
send_keys
(
:return
)
end
wait_for_requests
expect
(
page
).
to
have_content
(
'Epic1'
)
expect
(
page
).
not_to
have_content
(
'Epic2'
)
expect
(
page
).
not_to
have_content
(
'Epic3'
)
end
it
'can select an Author in order to filter the board'
do
page
.
within
(
'[data-testid="epic-filtered-search"]'
)
do
page
.
within
(
'[data-testid="epic-filtered-search"]'
)
do
click_link
'Author'
click_link
'Author'
wait_for_requests
click_link
user
.
name
click_link
user
.
name
click_link
'Label'
find
(
'input'
).
native
.
send_keys
(
:return
)
end
wait_for_requests
wait_for_requests
click_link
label
.
title
expect
(
page
).
to
have_text
(
"Author =
#{
user
.
name
}
Label = ~
#{
label
.
title
}
"
)
expect
(
page
).
to
have_content
(
'Epic1'
)
end
expect
(
page
).
not_to
have_content
(
'Epic2'
)
expect
(
page
).
not_to
have_content
(
'Epic3'
)
end
end
end
end
...
...
ee/spec/frontend/boards/components/epic_filtered_search_spec.js
View file @
9a11d79e
...
@@ -2,7 +2,7 @@ import { createLocalVue, shallowMount } from '@vue/test-utils';
...
@@ -2,7 +2,7 @@ import { createLocalVue, shallowMount } from '@vue/test-utils';
import
Vuex
from
'
vuex
'
;
import
Vuex
from
'
vuex
'
;
import
EpicFilteredSearch
from
'
ee_component/boards/components/epic_filtered_search.vue
'
;
import
EpicFilteredSearch
from
'
ee_component/boards/components/epic_filtered_search.vue
'
;
import
{
createStore
}
from
'
~/boards/stores
'
;
import
{
createStore
}
from
'
~/boards/stores
'
;
import
*
as
commonUtils
from
'
~/lib/utils/common_utils
'
;
import
*
as
urlUtility
from
'
~/lib/utils/url_utility
'
;
import
{
__
}
from
'
~/locale
'
;
import
{
__
}
from
'
~/locale
'
;
import
FilteredSearchBarRoot
from
'
~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue
'
;
import
FilteredSearchBarRoot
from
'
~/vue_shared/components/filtered_search_bar/filtered_search_bar_root.vue
'
;
import
AuthorToken
from
'
~/vue_shared/components/filtered_search_bar/tokens/author_token.vue
'
;
import
AuthorToken
from
'
~/vue_shared/components/filtered_search_bar/tokens/author_token.vue
'
;
...
@@ -15,10 +15,10 @@ describe('EpicFilteredSearch', () => {
...
@@ -15,10 +15,10 @@ describe('EpicFilteredSearch', () => {
let
wrapper
;
let
wrapper
;
let
store
;
let
store
;
const
createComponent
=
()
=>
{
const
createComponent
=
(
{
initialFilterParams
=
{}
}
=
{}
)
=>
{
wrapper
=
shallowMount
(
EpicFilteredSearch
,
{
wrapper
=
shallowMount
(
EpicFilteredSearch
,
{
localVue
,
localVue
,
provide
:
{
search
:
''
},
provide
:
{
initialFilterParams
},
store
,
store
,
});
});
};
};
...
@@ -52,7 +52,7 @@ describe('EpicFilteredSearch', () => {
...
@@ -52,7 +52,7 @@ describe('EpicFilteredSearch', () => {
{
{
icon
:
'
labels
'
,
icon
:
'
labels
'
,
title
:
__
(
'
Label
'
),
title
:
__
(
'
Label
'
),
type
:
'
label
s
'
,
type
:
'
label
_name
'
,
operators
:
[{
value
:
'
=
'
,
description
:
'
is
'
}],
operators
:
[{
value
:
'
=
'
,
description
:
'
is
'
}],
token
:
LabelToken
,
token
:
LabelToken
,
unique
:
false
,
unique
:
false
,
...
@@ -62,7 +62,7 @@ describe('EpicFilteredSearch', () => {
...
@@ -62,7 +62,7 @@ describe('EpicFilteredSearch', () => {
{
{
icon
:
'
pencil
'
,
icon
:
'
pencil
'
,
title
:
__
(
'
Author
'
),
title
:
__
(
'
Author
'
),
type
:
'
author
'
,
type
:
'
author
_username
'
,
operators
:
[{
value
:
'
=
'
,
description
:
'
is
'
}],
operators
:
[{
value
:
'
=
'
,
description
:
'
is
'
}],
symbol
:
'
@
'
,
symbol
:
'
@
'
,
token
:
AuthorToken
,
token
:
AuthorToken
,
...
@@ -82,13 +82,58 @@ describe('EpicFilteredSearch', () => {
...
@@ -82,13 +82,58 @@ describe('EpicFilteredSearch', () => {
});
});
it
(
'
calls historyPushState
'
,
()
=>
{
it
(
'
calls historyPushState
'
,
()
=>
{
jest
.
spyOn
(
commonUtils
,
'
historyPushState
'
);
jest
.
spyOn
(
urlUtility
,
'
updateHistory
'
);
findFilteredSearch
().
vm
.
$emit
(
'
onFilter
'
,
[{
value
:
{
data
:
'
searchQuery
'
}
}]);
findFilteredSearch
().
vm
.
$emit
(
'
onFilter
'
,
[{
value
:
{
data
:
'
searchQuery
'
}
}]);
expect
(
commonUtils
.
historyPushState
).
toHaveBeenCalledWith
(
expect
(
urlUtility
.
updateHistory
).
toHaveBeenCalledWith
({
'
http://test.host/?search=searchQuery
'
,
replace
:
true
,
);
title
:
''
,
url
:
'
http://test.host/
'
,
});
});
});
});
});
});
});
describe
(
'
when searching
'
,
()
=>
{
beforeEach
(()
=>
{
store
=
createStore
();
jest
.
spyOn
(
store
,
'
dispatch
'
);
createComponent
();
});
it
(
'
sets the url params to the correct results
'
,
async
()
=>
{
const
mockFilters
=
[
{
type
:
'
author_username
'
,
value
:
{
data
:
'
root
'
}
},
{
type
:
'
label_name
'
,
value
:
{
data
:
'
label
'
}
},
{
type
:
'
label_name
'
,
value
:
{
data
:
'
label2
'
}
},
];
jest
.
spyOn
(
urlUtility
,
'
updateHistory
'
);
findFilteredSearch
().
vm
.
$emit
(
'
onFilter
'
,
mockFilters
);
expect
(
urlUtility
.
updateHistory
).
toHaveBeenCalledWith
({
title
:
''
,
replace
:
true
,
url
:
'
http://test.host/?author_username=root&label_name[]=label&label_name[]=label2
'
,
});
});
});
describe
(
'
when url params are already set
'
,
()
=>
{
beforeEach
(()
=>
{
store
=
createStore
();
jest
.
spyOn
(
store
,
'
dispatch
'
);
createComponent
({
initialFilterParams
:
{
authorUsername
:
'
root
'
,
labelName
:
[
'
label
'
]
}
});
});
it
(
'
passes the correct props to FitlerSearchBar
'
,
async
()
=>
{
expect
(
findFilteredSearch
().
props
(
'
initialFilterValue
'
)).
toEqual
([
{
type
:
'
author_username
'
,
value
:
{
data
:
'
root
'
}
},
{
type
:
'
label_name
'
,
value
:
{
data
:
'
label
'
}
},
]);
});
});
});
});
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