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
bacaf8ca
Commit
bacaf8ca
authored
Sep 16, 2020
by
Scott Hampton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Utilize URLSearchParams API
We can simplify our path creation by using the URLSearchParams utility.
parent
63de0165
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
22 deletions
+27
-22
ee/app/assets/javascripts/analytics/repository_analytics/components/group_repository_analytics.vue
...itory_analytics/components/group_repository_analytics.vue
+14
-8
ee/app/assets/javascripts/analytics/repository_analytics/utils.js
...ssets/javascripts/analytics/repository_analytics/utils.js
+0
-2
ee/spec/frontend/analytics/repository_analytics/components/group_repository_analytics_spec.js
...y_analytics/components/group_repository_analytics_spec.js
+13
-0
ee/spec/frontend/analytics/repository_analytics/utils_spec.js
...pec/frontend/analytics/repository_analytics/utils_spec.js
+0
-12
No files found.
ee/app/assets/javascripts/analytics/repository_analytics/components/group_repository_analytics.vue
View file @
bacaf8ca
...
...
@@ -10,7 +10,6 @@ import {
}
from
'
@gitlab/ui
'
;
import
{
__
,
s__
}
from
'
~/locale
'
;
import
{
pikadayToString
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
getProjectIdQueryParams
}
from
'
../utils
'
;
import
getGroupProjects
from
'
../graphql/queries/get_group_projects.query.graphql
'
;
export
default
{
...
...
@@ -72,7 +71,19 @@ export default {
const
endDate
=
pikadayToString
(
today
);
today
.
setDate
(
today
.
getDate
()
-
this
.
selectedDateRange
.
value
);
const
startDate
=
pikadayToString
(
today
);
return
`
${
this
.
groupAnalyticsCoverageReportsPath
}
&start_date=
${
startDate
}
&end_date=
${
endDate
}${
this
.
selectedProjectIdsParam
}
`
;
const
queryParams
=
new
URLSearchParams
({
start_date
:
startDate
,
end_date
:
endDate
,
project_ids
:
this
.
selectedProjectIdsParam
,
});
if
(
this
.
selectAllProjects
)
{
// not including a project_ids param is the same as selecting all the projects
queryParams
.
delete
(
'
project_ids
'
);
}
return
`
${
this
.
groupAnalyticsCoverageReportsPath
}
&
${
queryParams
.
toString
()}
`
;
},
downloadCSVModalButton
()
{
return
{
...
...
@@ -96,12 +107,7 @@ export default {
);
},
selectedProjectIdsParam
()
{
if
(
this
.
selectAllProjects
)
{
return
''
;
// not including a project_ids param is the same as selecting all the projects
}
return
`&
${
getProjectIdQueryParams
(
this
.
groupProjects
.
filter
(
project
=>
project
.
isSelected
),
)}
`
;
return
this
.
groupProjects
.
filter
(
project
=>
project
.
isSelected
).
map
(
project
=>
project
.
id
);
},
},
methods
:
{
...
...
ee/app/assets/javascripts/analytics/repository_analytics/utils.js
deleted
100644 → 0
View file @
63de0165
export
const
getProjectIdQueryParams
=
projects
=>
`project_ids=
${
projects
.
map
(
project
=>
project
.
id
).
join
(
'
,
'
)}
`
;
ee/spec/frontend/analytics/repository_analytics/components/group_repository_analytics_spec.js
View file @
bacaf8ca
...
...
@@ -82,6 +82,19 @@ describe('Group repository analytics app', () => {
});
});
describe
(
'
with two or more projects selected without selecting all projects
'
,
()
=>
{
beforeEach
(()
=>
{
selectCodeCoverageProjectById
(
groupProjectsData
[
0
].
id
);
selectCodeCoverageProjectById
(
groupProjectsData
[
1
].
id
);
});
it
(
'
renders primary action as a link with two project IDs as parameters
'
,
()
=>
{
const
expectedPath
=
`
${
groupAnalyticsCoverageReportsPathWithDates
}
&project_ids=
${
groupProjectsData
[
0
].
id
}
%2C
${
groupProjectsData
[
1
].
id
}
`
;
expect
(
findCodeCoverageDownloadButton
().
attributes
(
'
href
'
)).
toBe
(
expectedPath
);
});
});
describe
(
'
with one project selected
'
,
()
=>
{
beforeEach
(()
=>
{
selectCodeCoverageProjectById
(
groupProjectsData
[
0
].
id
);
...
...
ee/spec/frontend/analytics/repository_analytics/utils_spec.js
deleted
100644 → 0
View file @
63de0165
import
{
getProjectIdQueryParams
}
from
'
ee/analytics/repository_analytics/utils
'
;
describe
(
'
group repository analytics util functions
'
,
()
=>
{
describe
(
'
getProjectIdQueryParams
'
,
()
=>
{
it
(
'
returns query param string project ids
'
,
()
=>
{
const
projects
=
[{
id
:
1
},
{
id
:
2
}];
const
expectedString
=
'
project_ids=1,2
'
;
expect
(
getProjectIdQueryParams
(
projects
)).
toBe
(
expectedString
);
});
});
});
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