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
cda29c62
Commit
cda29c62
authored
Jul 14, 2021
by
Ezekiel Kigbo
Committed by
Martin Wortschack
Jul 14, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Prevents autoclose for the shared projects filter
parent
983fe9da
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
19 deletions
+94
-19
app/assets/javascripts/analytics/shared/components/projects_dropdown_filter.vue
.../analytics/shared/components/projects_dropdown_filter.vue
+30
-6
ee/app/assets/javascripts/analytics/cycle_analytics/components/base.vue
...javascripts/analytics/cycle_analytics/components/base.vue
+0
-1
ee/app/assets/javascripts/analytics/cycle_analytics/store/actions.js
...ts/javascripts/analytics/cycle_analytics/store/actions.js
+12
-3
ee/spec/frontend/analytics/cycle_analytics/store/actions_spec.js
.../frontend/analytics/cycle_analytics/store/actions_spec.js
+46
-6
spec/frontend/analytics/shared/components/projects_dropdown_filter_spec.js
...lytics/shared/components/projects_dropdown_filter_spec.js
+6
-3
No files found.
app/assets/javascripts/analytics/shared/components/projects_dropdown_filter.vue
View file @
cda29c62
...
@@ -62,6 +62,7 @@ export default {
...
@@ -62,6 +62,7 @@ export default {
projects
:
[],
projects
:
[],
selectedProjects
:
this
.
defaultProjects
||
[],
selectedProjects
:
this
.
defaultProjects
||
[],
searchTerm
:
''
,
searchTerm
:
''
,
isDirty
:
false
,
};
};
},
},
computed
:
{
computed
:
{
...
@@ -124,6 +125,24 @@ export default {
...
@@ -124,6 +125,24 @@ export default {
this
.
setSelectedProjects
(
project
,
!
isSelected
);
this
.
setSelectedProjects
(
project
,
!
isSelected
);
this
.
$emit
(
'
selected
'
,
this
.
selectedProjects
);
this
.
$emit
(
'
selected
'
,
this
.
selectedProjects
);
},
},
onMultiSelectClick
({
project
,
isSelected
})
{
this
.
setSelectedProjects
(
project
,
!
isSelected
);
this
.
isDirty
=
true
;
},
onSelected
(
ev
)
{
if
(
this
.
multiSelect
)
{
this
.
onMultiSelectClick
(
ev
);
}
else
{
this
.
onClick
(
ev
);
}
},
onHide
()
{
if
(
this
.
multiSelect
&&
this
.
isDirty
)
{
this
.
$emit
(
'
selected
'
,
this
.
selectedProjects
);
}
this
.
searchTerm
=
''
;
this
.
isDirty
=
false
;
},
fetchData
()
{
fetchData
()
{
this
.
loading
=
true
;
this
.
loading
=
true
;
...
@@ -158,12 +177,12 @@ export default {
...
@@ -158,12 +177,12 @@ export default {
},
},
};
};
</
script
>
</
script
>
<
template
>
<
template
>
<gl-dropdown
<gl-dropdown
ref=
"projectsDropdown"
ref=
"projectsDropdown"
class=
"dropdown dropdown-projects"
class=
"dropdown dropdown-projects"
toggle-class=
"gl-shadow-none"
toggle-class=
"gl-shadow-none"
@
hide=
"onHide"
>
>
<template
#button-content
>
<template
#button-content
>
<div
class=
"gl-display-flex gl-flex-grow-1"
>
<div
class=
"gl-display-flex gl-flex-grow-1"
>
...
@@ -181,15 +200,18 @@ export default {
...
@@ -181,15 +200,18 @@ export default {
</div>
</div>
<gl-icon
class=
"gl-ml-2"
name=
"chevron-down"
/>
<gl-icon
class=
"gl-ml-2"
name=
"chevron-down"
/>
</
template
>
</
template
>
<gl-dropdown-section-header>
{{ __('Projects') }}
</gl-dropdown-section-header>
<
template
#header
>
<gl-search-box-by-type
v-model.trim=
"searchTerm"
/>
<gl-dropdown-section-header>
{{
__
(
'
Projects
'
)
}}
</gl-dropdown-section-header>
<gl-search-box-by-type
v-model.trim=
"searchTerm"
/>
</
template
>
<gl-dropdown-item
<gl-dropdown-item
v-for=
"project in availableProjects"
v-for=
"project in availableProjects"
:key=
"project.id"
:key=
"project.id"
:is-check-item=
"true"
:is-check-item=
"true"
:is-checked=
"isProjectSelected(project.id)"
:is-checked=
"isProjectSelected(project.id)"
@
click.prevent=
"onClick({ project, isSelected: isProjectSelected(project.id) })"
@
click.native.capture.stop=
"
onSelected({ project, isSelected: isProjectSelected(project.id) })
"
>
>
<div
class=
"gl-display-flex"
>
<div
class=
"gl-display-flex"
>
<gl-avatar
<gl-avatar
...
@@ -203,7 +225,9 @@ export default {
...
@@ -203,7 +225,9 @@ export default {
/>
/>
<div>
<div>
<div
data-testid=
"project-name"
>
{{ project.name }}
</div>
<div
data-testid=
"project-name"
>
{{ project.name }}
</div>
<div
class=
"gl-text-gray-500"
data-testid=
"project-full-path"
>
{{ project.fullPath }}
</div>
<div
class=
"gl-text-gray-500"
data-testid=
"project-full-path"
>
{{ project.fullPath }}
</div>
</div>
</div>
</div>
</div>
</gl-dropdown-item>
</gl-dropdown-item>
...
...
ee/app/assets/javascripts/analytics/cycle_analytics/components/base.vue
View file @
cda29c62
...
@@ -121,7 +121,6 @@ export default {
...
@@ -121,7 +121,6 @@ export default {
]),
]),
onProjectsSelect
(
projects
)
{
onProjectsSelect
(
projects
)
{
this
.
setSelectedProjects
(
projects
);
this
.
setSelectedProjects
(
projects
);
this
.
fetchCycleAnalyticsData
();
},
},
onStageSelect
(
stage
)
{
onStageSelect
(
stage
)
{
if
(
stage
.
slug
===
OVERVIEW_STAGE_ID
)
{
if
(
stage
.
slug
===
OVERVIEW_STAGE_ID
)
{
...
...
ee/app/assets/javascripts/analytics/cycle_analytics/store/actions.js
View file @
cda29c62
...
@@ -27,8 +27,18 @@ export const setPaths = ({ dispatch }, options) => {
...
@@ -27,8 +27,18 @@ export const setPaths = ({ dispatch }, options) => {
export
const
setFeatureFlags
=
({
commit
},
featureFlags
)
=>
export
const
setFeatureFlags
=
({
commit
},
featureFlags
)
=>
commit
(
types
.
SET_FEATURE_FLAGS
,
featureFlags
);
commit
(
types
.
SET_FEATURE_FLAGS
,
featureFlags
);
export
const
setSelectedProjects
=
({
commit
},
projects
)
=>
const
refreshData
=
({
selectedStage
,
isOverviewStageSelected
,
dispatch
})
=>
{
if
(
selectedStage
&&
!
isOverviewStageSelected
)
dispatch
(
'
fetchStageData
'
,
selectedStage
.
id
);
return
dispatch
(
'
fetchCycleAnalyticsData
'
);
};
export
const
setSelectedProjects
=
(
{
commit
,
dispatch
,
getters
:
{
isOverviewStageSelected
},
state
:
{
selectedStage
}
},
projects
,
)
=>
{
commit
(
types
.
SET_SELECTED_PROJECTS
,
projects
);
commit
(
types
.
SET_SELECTED_PROJECTS
,
projects
);
return
refreshData
({
dispatch
,
selectedStage
,
isOverviewStageSelected
});
};
export
const
setSelectedStage
=
({
commit
},
stage
)
=>
commit
(
types
.
SET_SELECTED_STAGE
,
stage
);
export
const
setSelectedStage
=
({
commit
},
stage
)
=>
commit
(
types
.
SET_SELECTED_STAGE
,
stage
);
...
@@ -383,8 +393,7 @@ export const setFilters = ({
...
@@ -383,8 +393,7 @@ export const setFilters = ({
getters
:
{
isOverviewStageSelected
},
getters
:
{
isOverviewStageSelected
},
state
:
{
selectedStage
},
state
:
{
selectedStage
},
})
=>
{
})
=>
{
if
(
selectedStage
&&
!
isOverviewStageSelected
)
dispatch
(
'
fetchStageData
'
,
selectedStage
.
id
);
return
refreshData
({
dispatch
,
isOverviewStageSelected
,
selectedStage
});
return
dispatch
(
'
fetchCycleAnalyticsData
'
);
};
};
export
const
updateStageTablePagination
=
(
export
const
updateStageTablePagination
=
(
...
...
ee/spec/frontend/analytics/cycle_analytics/store/actions_spec.js
View file @
cda29c62
...
@@ -5,7 +5,12 @@ import * as actions from 'ee/analytics/cycle_analytics/store/actions';
...
@@ -5,7 +5,12 @@ import * as actions from 'ee/analytics/cycle_analytics/store/actions';
import
*
as
getters
from
'
ee/analytics/cycle_analytics/store/getters
'
;
import
*
as
getters
from
'
ee/analytics/cycle_analytics/store/getters
'
;
import
*
as
types
from
'
ee/analytics/cycle_analytics/store/mutation_types
'
;
import
*
as
types
from
'
ee/analytics/cycle_analytics/store/mutation_types
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
testAction
from
'
helpers/vuex_action_helper
'
;
import
{
createdAfter
,
createdBefore
,
currentGroup
}
from
'
jest/cycle_analytics/mock_data
'
;
import
{
createdAfter
,
createdBefore
,
currentGroup
,
selectedProjects
,
}
from
'
jest/cycle_analytics/mock_data
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
httpStatusCodes
from
'
~/lib/utils/http_status
'
;
import
httpStatusCodes
from
'
~/lib/utils/http_status
'
;
import
{
import
{
...
@@ -47,6 +52,7 @@ jest.mock('~/flash');
...
@@ -47,6 +52,7 @@ jest.mock('~/flash');
describe
(
'
Value Stream Analytics actions
'
,
()
=>
{
describe
(
'
Value Stream Analytics actions
'
,
()
=>
{
let
state
;
let
state
;
let
stateWithOverview
=
null
;
let
mock
;
let
mock
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
...
@@ -68,9 +74,8 @@ describe('Value Stream Analytics actions', () => {
...
@@ -68,9 +74,8 @@ describe('Value Stream Analytics actions', () => {
});
});
it
.
each
`
it
.
each
`
action | type | stateKey | payload
action | type | stateKey | payload
${
'
setFeatureFlags
'
}
|
${
'
SET_FEATURE_FLAGS
'
}
|
${
'
featureFlags
'
}
|
${{
someFeatureFlag
:
true
}
}
${
'
setFeatureFlags
'
}
|
${
'
SET_FEATURE_FLAGS
'
}
|
${
'
featureFlags
'
}
|
${{
someFeatureFlag
:
true
}
}
${
'
setSelectedProjects
'
}
|
${
'
SET_SELECTED_PROJECTS
'
}
|
${
'
selectedProjectIds
'
}
|
${[
10
,
20
,
30
,
40
]}
`
(
'
$action should set $stateKey with $payload and type $type
'
,
({
action
,
type
,
payload
})
=>
{
`
(
'
$action should set $stateKey with $payload and type $type
'
,
({
action
,
type
,
payload
})
=>
{
return
testAction
(
return
testAction
(
actions
[
action
],
actions
[
action
],
...
@@ -86,6 +91,43 @@ describe('Value Stream Analytics actions', () => {
...
@@ -86,6 +91,43 @@ describe('Value Stream Analytics actions', () => {
);
);
});
});
describe
(
'
setSelectedProjects
'
,
()
=>
{
describe
(
'
with `overview` stage selected
'
,
()
=>
{
beforeEach
(()
=>
{
stateWithOverview
=
{
...
state
,
isOverviewStageSelected
:
()
=>
true
};
});
it
(
'
will dispatch the "fetchCycleAnalyticsData" action
'
,
()
=>
{
return
testAction
(
actions
.
setSelectedProjects
,
selectedProjects
,
stateWithOverview
,
[{
type
:
types
.
SET_SELECTED_PROJECTS
,
payload
:
selectedProjects
}],
[{
type
:
'
fetchCycleAnalyticsData
'
}],
);
});
});
describe
(
'
with non overview stage selected
'
,
()
=>
{
beforeEach
(()
=>
{
state
=
{
...
state
,
selectedStage
};
});
it
(
'
will dispatch the "fetchStageData" and "fetchCycleAnalyticsData" actions
'
,
()
=>
{
return
testAction
(
actions
.
setSelectedProjects
,
selectedProjects
,
state
,
[{
type
:
types
.
SET_SELECTED_PROJECTS
,
payload
:
selectedProjects
}],
[
{
type
:
'
fetchStageData
'
,
payload
:
selectedStage
.
id
},
{
type
:
'
fetchCycleAnalyticsData
'
},
],
);
});
});
});
describe
(
'
setSelectedStage
'
,
()
=>
{
describe
(
'
setSelectedStage
'
,
()
=>
{
const
data
=
{
id
:
'
someStageId
'
};
const
data
=
{
id
:
'
someStageId
'
};
...
@@ -961,8 +1003,6 @@ describe('Value Stream Analytics actions', () => {
...
@@ -961,8 +1003,6 @@ describe('Value Stream Analytics actions', () => {
${
actions
.
setDateRange
}
|
${{
createdAfter
,
createdBefore
}
} |
${[{
type
:
'
SET_DATE_RANGE
'
,
payload
:
{
createdAfter
,
createdBefore
}
}]}
${
actions
.
setDateRange
}
|
${{
createdAfter
,
createdBefore
}
} |
${[{
type
:
'
SET_DATE_RANGE
'
,
payload
:
{
createdAfter
,
createdBefore
}
}]}
$
{
actions
.
setFilters
}
|
${
''
}
|
${[]}
$
{
actions
.
setFilters
}
|
${
''
}
|
${[]}
`
(
'
$action
'
,
({
targetAction
,
payload
,
mutations
})
=>
{
`
(
'
$action
'
,
({
targetAction
,
payload
,
mutations
})
=>
{
let
stateWithOverview
=
null
;
beforeEach
(()
=>
{
beforeEach
(()
=>
{
stateWithOverview
=
{
...
state
,
isOverviewStageSelected
:
()
=>
true
};
stateWithOverview
=
{
...
state
,
isOverviewStageSelected
:
()
=>
true
};
});
});
...
...
spec/frontend/analytics/shared/components/projects_dropdown_filter_spec.js
View file @
cda29c62
...
@@ -78,6 +78,8 @@ describe('ProjectsDropdownFilter component', () => {
...
@@ -78,6 +78,8 @@ describe('ProjectsDropdownFilter component', () => {
const
selectDropdownItemAtIndex
=
(
index
)
=>
const
selectDropdownItemAtIndex
=
(
index
)
=>
findDropdownAtIndex
(
index
).
find
(
'
button
'
).
trigger
(
'
click
'
);
findDropdownAtIndex
(
index
).
find
(
'
button
'
).
trigger
(
'
click
'
);
const
selectedIds
=
()
=>
wrapper
.
vm
.
selectedProjects
.
map
(({
id
})
=>
id
);
describe
(
'
queryParams are applied when fetching data
'
,
()
=>
{
describe
(
'
queryParams are applied when fetching data
'
,
()
=>
{
beforeEach
(()
=>
{
beforeEach
(()
=>
{
createComponent
({
createComponent
({
...
@@ -238,14 +240,15 @@ describe('ProjectsDropdownFilter component', () => {
...
@@ -238,14 +240,15 @@ describe('ProjectsDropdownFilter component', () => {
selectDropdownItemAtIndex
(
0
);
selectDropdownItemAtIndex
(
0
);
selectDropdownItemAtIndex
(
1
);
selectDropdownItemAtIndex
(
1
);
expect
(
wrapper
.
emitted
().
selected
).
toEqual
([[[
projects
[
0
]]],
[[
projects
[
0
],
projects
[
1
]]]
]);
expect
(
selectedIds
()).
toEqual
([
projects
[
0
].
id
,
projects
[
1
].
id
]);
});
});
it
(
'
should remove from selection when clicked again
'
,
()
=>
{
it
(
'
should remove from selection when clicked again
'
,
()
=>
{
selectDropdownItemAtIndex
(
0
);
selectDropdownItemAtIndex
(
0
);
selectDropdownItemAtIndex
(
0
);
expect
(
selectedIds
()).
toEqual
([
projects
[
0
].
id
]
);
expect
(
wrapper
.
emitted
().
selected
).
toEqual
([[[
projects
[
0
]]],
[[]]]);
selectDropdownItemAtIndex
(
0
);
expect
(
selectedIds
()).
toEqual
([]);
});
});
it
(
'
renders the correct placeholder text when multiple projects are selected
'
,
async
()
=>
{
it
(
'
renders the correct placeholder text when multiple projects are selected
'
,
async
()
=>
{
...
...
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