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
b73d9cd2
Commit
b73d9cd2
authored
Dec 06, 2019
by
Martin Wortschack
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add selectedProject and selectedGroup props
- This allows for passing a group/project to the dropdown via props
parent
a1517120
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
80 additions
and
7 deletions
+80
-7
ee/app/assets/javascripts/analytics/shared/components/groups_dropdown_filter.vue
...ts/analytics/shared/components/groups_dropdown_filter.vue
+6
-1
ee/app/assets/javascripts/analytics/shared/components/projects_dropdown_filter.vue
.../analytics/shared/components/projects_dropdown_filter.vue
+12
-3
ee/spec/frontend/analytics/shared/components/groups_dropdown_filter_spec.js
...nalytics/shared/components/groups_dropdown_filter_spec.js
+32
-2
ee/spec/frontend/analytics/shared/components/projects_dropdown_filter_spec.js
...lytics/shared/components/projects_dropdown_filter_spec.js
+30
-1
No files found.
ee/app/assets/javascripts/analytics/shared/components/groups_dropdown_filter.vue
View file @
b73d9cd2
...
@@ -26,11 +26,16 @@ export default {
...
@@ -26,11 +26,16 @@ export default {
required
:
false
,
required
:
false
,
default
:
()
=>
({}),
default
:
()
=>
({}),
},
},
defaultGroup
:
{
type
:
Object
,
required
:
false
,
default
:
()
=>
({}),
},
},
},
data
()
{
data
()
{
return
{
return
{
loading
:
true
,
loading
:
true
,
selectedGroup
:
{},
selectedGroup
:
this
.
defaultGroup
||
{},
};
};
},
},
computed
:
{
computed
:
{
...
...
ee/app/assets/javascripts/analytics/shared/components/projects_dropdown_filter.vue
View file @
b73d9cd2
...
@@ -35,11 +35,16 @@ export default {
...
@@ -35,11 +35,16 @@ export default {
required
:
false
,
required
:
false
,
default
:
()
=>
({}),
default
:
()
=>
({}),
},
},
defaultProjects
:
{
type
:
Array
,
required
:
false
,
default
:
()
=>
[],
},
},
},
data
()
{
data
()
{
return
{
return
{
loading
:
true
,
loading
:
true
,
selectedProjects
:
[],
selectedProjects
:
this
.
defaultProjects
||
[],
};
};
},
},
computed
:
{
computed
:
{
...
@@ -74,7 +79,7 @@ export default {
...
@@ -74,7 +79,7 @@ export default {
},
},
clicked
:
this
.
onClick
.
bind
(
this
),
clicked
:
this
.
onClick
.
bind
(
this
),
data
:
this
.
fetchData
.
bind
(
this
),
data
:
this
.
fetchData
.
bind
(
this
),
renderRow
:
group
=>
this
.
rowTemplate
(
group
),
renderRow
:
project
=>
this
.
rowTemplate
(
project
),
text
:
project
=>
project
.
name
,
text
:
project
=>
project
.
name
,
opened
:
e
=>
e
.
target
.
querySelector
(
'
.dropdown-input-field
'
).
focus
(),
opened
:
e
=>
e
.
target
.
querySelector
(
'
.dropdown-input-field
'
).
focus
(),
});
});
...
@@ -106,9 +111,13 @@ export default {
...
@@ -106,9 +111,13 @@ export default {
});
});
},
},
rowTemplate
(
project
)
{
rowTemplate
(
project
)
{
const
selected
=
this
.
defaultProjects
.
length
?
this
.
defaultProjects
.
find
(
p
=>
p
.
id
===
project
.
id
)
:
false
;
const
isActiveClass
=
selected
?
'
is-active
'
:
''
;
return
`
return
`
<li>
<li>
<a href='#' class='dropdown-menu-link'>
<a href='#' class='dropdown-menu-link
${
isActiveClass
}
'>
${
this
.
avatarTemplate
(
project
)}
${
this
.
avatarTemplate
(
project
)}
<div class="align-middle">
${
_
.
escape
(
project
.
name
)}
</div>
<div class="align-middle">
${
_
.
escape
(
project
.
name
)}
</div>
</a>
</a>
...
...
ee/spec/frontend/analytics/shared/components/groups_dropdown_filter_spec.js
View file @
b73d9cd2
...
@@ -28,6 +28,15 @@ const groups = [
...
@@ -28,6 +28,15 @@ const groups = [
describe
(
'
GroupsDropdownFilter component
'
,
()
=>
{
describe
(
'
GroupsDropdownFilter component
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
const
createComponent
=
(
props
=
{})
=>
{
wrapper
=
mount
(
GroupsDropdownFilter
,
{
sync
:
false
,
propsData
:
{
...
props
,
},
});
};
afterEach
(()
=>
{
afterEach
(()
=>
{
wrapper
.
destroy
();
wrapper
.
destroy
();
});
});
...
@@ -37,10 +46,9 @@ describe('GroupsDropdownFilter component', () => {
...
@@ -37,10 +46,9 @@ describe('GroupsDropdownFilter component', () => {
Api
.
groups
.
mockImplementation
((
term
,
options
,
callback
)
=>
{
Api
.
groups
.
mockImplementation
((
term
,
options
,
callback
)
=>
{
callback
(
groups
);
callback
(
groups
);
});
});
wrapper
=
mount
(
GroupsDropdownFilter
);
});
});
const
findDropdown
=
()
=>
wrapper
.
find
(
'
.dropdown
'
);
const
findDropdown
=
()
=>
wrapper
.
find
(
{
ref
:
'
groupsDropdown
'
}
);
const
openDropdown
=
()
=>
{
const
openDropdown
=
()
=>
{
$
(
findDropdown
().
element
)
$
(
findDropdown
().
element
)
.
parent
()
.
parent
()
...
@@ -48,13 +56,33 @@ describe('GroupsDropdownFilter component', () => {
...
@@ -48,13 +56,33 @@ describe('GroupsDropdownFilter component', () => {
};
};
const
findDropdownItems
=
()
=>
findDropdown
().
findAll
(
'
a
'
);
const
findDropdownItems
=
()
=>
findDropdown
().
findAll
(
'
a
'
);
const
findDropdownButton
=
()
=>
findDropdown
().
find
(
'
button
'
);
const
findDropdownButton
=
()
=>
findDropdown
().
find
(
'
button
'
);
const
findDropdownButtonAvatar
=
()
=>
findDropdown
().
find
(
'
.gl-avatar
'
);
it
(
'
should call glDropdown
'
,
()
=>
{
it
(
'
should call glDropdown
'
,
()
=>
{
createComponent
();
expect
(
$
.
fn
.
glDropdown
).
toHaveBeenCalled
();
expect
(
$
.
fn
.
glDropdown
).
toHaveBeenCalled
();
});
});
describe
(
'
when passed a defaultGroup as prop
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
defaultGroup
:
groups
[
0
],
});
});
it
(
"
displays the defaultGroup's name
"
,
()
=>
{
expect
(
findDropdownButton
().
text
()).
toContain
(
groups
[
0
].
name
);
});
it
(
"
renders the defaultGroup's avatar
"
,
()
=>
{
expect
(
findDropdownButtonAvatar
().
exists
()).
toBe
(
true
);
});
});
describe
(
'
it renders the items correctly
'
,
()
=>
{
describe
(
'
it renders the items correctly
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
();
openDropdown
();
openDropdown
();
return
wrapper
.
vm
.
$nextTick
();
return
wrapper
.
vm
.
$nextTick
();
...
@@ -102,6 +130,8 @@ describe('GroupsDropdownFilter component', () => {
...
@@ -102,6 +130,8 @@ describe('GroupsDropdownFilter component', () => {
describe
(
'
on group click
'
,
()
=>
{
describe
(
'
on group click
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
();
openDropdown
();
openDropdown
();
return
wrapper
.
vm
.
$nextTick
();
return
wrapper
.
vm
.
$nextTick
();
...
...
ee/spec/frontend/analytics/shared/components/projects_dropdown_filter_spec.js
View file @
b73d9cd2
...
@@ -53,7 +53,7 @@ describe('ProjectsDropdownFilter component', () => {
...
@@ -53,7 +53,7 @@ describe('ProjectsDropdownFilter component', () => {
});
});
});
});
const
findDropdown
=
()
=>
wrapper
.
find
(
'
.dropdown
'
);
const
findDropdown
=
()
=>
wrapper
.
find
(
{
ref
:
'
projectsDropdown
'
}
);
const
openDropdown
=
()
=>
{
const
openDropdown
=
()
=>
{
$
(
findDropdown
().
element
)
$
(
findDropdown
().
element
)
.
parent
()
.
parent
()
...
@@ -61,6 +61,7 @@ describe('ProjectsDropdownFilter component', () => {
...
@@ -61,6 +61,7 @@ describe('ProjectsDropdownFilter component', () => {
};
};
const
findDropdownItems
=
()
=>
findDropdown
().
findAll
(
'
a
'
);
const
findDropdownItems
=
()
=>
findDropdown
().
findAll
(
'
a
'
);
const
findDropdownButton
=
()
=>
findDropdown
().
find
(
'
button
'
);
const
findDropdownButton
=
()
=>
findDropdown
().
find
(
'
button
'
);
const
findDropdownButtonAvatar
=
()
=>
findDropdown
().
find
(
'
.gl-avatar
'
);
describe
(
'
queryParams are applied when fetching data
'
,
()
=>
{
describe
(
'
queryParams are applied when fetching data
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -87,6 +88,34 @@ describe('ProjectsDropdownFilter component', () => {
...
@@ -87,6 +88,34 @@ describe('ProjectsDropdownFilter component', () => {
});
});
});
});
describe
(
'
when passed a an array of defaultProject as prop
'
,
()
=>
{
beforeEach
(()
=>
{
createComponent
({
defaultProjects
:
[
projects
[
0
]],
});
});
it
(
"
displays the defaultProject's name
"
,
()
=>
{
expect
(
findDropdownButton
().
text
()).
toContain
(
projects
[
0
].
name
);
});
it
(
"
renders the defaultProject's avatar
"
,
()
=>
{
expect
(
findDropdownButtonAvatar
().
exists
()).
toBe
(
true
);
});
it
(
'
marks the defaultProject as selected
'
,
()
=>
{
openDropdown
();
return
wrapper
.
vm
.
$nextTick
().
then
(()
=>
{
expect
(
findDropdownItems
()
.
at
(
0
)
.
classes
(
'
is-active
'
),
).
toBe
(
true
);
});
});
});
describe
(
'
when multiSelect is false
'
,
()
=>
{
describe
(
'
when multiSelect is false
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
({
multiSelect
:
false
});
createComponent
({
multiSelect
:
false
});
...
...
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