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
9b4f5801
Commit
9b4f5801
authored
Mar 11, 2021
by
Savas Vedova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include toolbox for the trends chart
parent
da75cd82
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
13 deletions
+63
-13
ee/app/assets/javascripts/security_dashboard/components/project_security_charts.vue
...security_dashboard/components/project_security_charts.vue
+42
-12
ee/changelogs/unreleased/285476-add-icons-to-trends-chart.yml
...hangelogs/unreleased/285476-add-icons-to-trends-chart.yml
+5
-0
ee/spec/frontend/security_dashboard/components/project_security_charts_spec.js
...rity_dashboard/components/project_security_charts_spec.js
+16
-1
No files found.
ee/app/assets/javascripts/security_dashboard/components/project_security_charts.vue
View file @
9b4f5801
...
@@ -3,6 +3,7 @@ import { GlLoadingIcon } from '@gitlab/ui';
...
@@ -3,6 +3,7 @@ import { GlLoadingIcon } from '@gitlab/ui';
import
{
GlLineChart
}
from
'
@gitlab/ui/dist/charts
'
;
import
{
GlLineChart
}
from
'
@gitlab/ui/dist/charts
'
;
import
createFlash
from
'
~/flash
'
;
import
createFlash
from
'
~/flash
'
;
import
{
formatDate
,
getDateInPast
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
formatDate
,
getDateInPast
}
from
'
~/lib/utils/datetime_utility
'
;
import
{
getSvgIconPathContent
}
from
'
~/lib/utils/icon_utils
'
;
import
{
s__
,
__
}
from
'
~/locale
'
;
import
{
s__
,
__
}
from
'
~/locale
'
;
import
projectsHistoryQuery
from
'
../graphql/queries/project_vulnerabilities_by_day_and_count.query.graphql
'
;
import
projectsHistoryQuery
from
'
../graphql/queries/project_vulnerabilities_by_day_and_count.query.graphql
'
;
import
{
createProjectLoadingError
}
from
'
../helpers
'
;
import
{
createProjectLoadingError
}
from
'
../helpers
'
;
...
@@ -68,6 +69,7 @@ export default {
...
@@ -68,6 +69,7 @@ export default {
return
{
return
{
chartWidth
:
0
,
chartWidth
:
0
,
trendsByDay
:
[],
trendsByDay
:
[],
svgs
:
{},
};
};
},
},
computed
:
{
computed
:
{
...
@@ -109,21 +111,49 @@ export default {
...
@@ -109,21 +111,49 @@ export default {
shouldShowEmptyState
()
{
shouldShowEmptyState
()
{
return
!
this
.
hasVulnerabilities
;
return
!
this
.
hasVulnerabilities
;
},
},
chartOptions
()
{
return
{
xAxis
:
{
name
:
__
(
'
Time
'
),
key
:
'
time
'
,
type
:
'
category
'
,
},
yAxis
:
{
name
:
__
(
'
Vulnerabilities
'
),
key
:
'
vulnerabilities
'
,
type
:
'
value
'
,
minInterval
:
1
,
},
toolbox
:
{
feature
:
{
dataZoom
:
{
icon
:
{
zoom
:
this
.
svgs
[
'
marquee-selection
'
],
back
:
this
.
svgs
.
redo
},
},
restore
:
{
icon
:
this
.
svgs
.
repeat
,
},
saveAsImage
:
{
icon
:
this
.
svgs
.
download
,
},
},
},
};
},
},
},
mounted
()
{
mounted
()
{
this
.
chartWidth
=
this
.
$refs
.
layout
.
$el
.
clientWidth
;
this
.
chartWidth
=
this
.
$refs
.
layout
.
$el
.
clientWidth
;
},
},
c
hartOptions
:
{
c
reated
()
{
xAxis
:
{
[
'
marquee-selection
'
,
'
redo
'
,
'
repeat
'
,
'
download
'
].
forEach
(
this
.
setSvg
);
name
:
__
(
'
Time
'
)
,
}
,
key
:
'
time
'
,
methods
:
{
type
:
'
category
'
,
async
setSvg
(
name
)
{
},
try
{
yAxis
:
{
this
.
$set
(
this
.
svgs
,
name
,
`path://
${
await
getSvgIconPathContent
(
name
)}
`
);
name
:
__
(
'
Vulnerabilities
'
),
}
catch
(
e
)
{
key
:
'
vulnerabilities
'
,
// eslint-disable-next-line no-console, @gitlab/require-i18n-strings
type
:
'
value
'
,
console
.
error
(
'
SVG could not be rendered correctly:
'
,
e
);
minInterval
:
1
,
}
},
},
},
},
};
};
...
@@ -139,7 +169,7 @@ export default {
...
@@ -139,7 +169,7 @@ export default {
class=
"gl-mt-6"
class=
"gl-mt-6"
:width=
"chartWidth"
:width=
"chartWidth"
:data=
"dataSeries"
:data=
"dataSeries"
:option=
"
$options.
chartOptions"
:option=
"chartOptions"
:include-legend-avg-max=
"false"
:include-legend-avg-max=
"false"
/>
/>
</
template
>
</
template
>
...
...
ee/changelogs/unreleased/285476-add-icons-to-trends-chart.yml
0 → 100644
View file @
9b4f5801
---
title
:
Add toolbox for the trends chart in project security dashboard
merge_request
:
56316
author
:
type
:
added
ee/spec/frontend/security_dashboard/components/project_security_charts_spec.js
View file @
9b4f5801
...
@@ -15,6 +15,10 @@ import {
...
@@ -15,6 +15,10 @@ import {
const
localVue
=
createLocalVue
();
const
localVue
=
createLocalVue
();
localVue
.
use
(
VueApollo
);
localVue
.
use
(
VueApollo
);
jest
.
mock
(
'
~/lib/utils/icon_utils
'
,
()
=>
({
getSvgIconPathContent
:
jest
.
fn
().
mockResolvedValue
(
'
mockSvgPathContent
'
),
}));
describe
(
'
Project Security Charts component
'
,
()
=>
{
describe
(
'
Project Security Charts component
'
,
()
=>
{
let
wrapper
;
let
wrapper
;
...
@@ -87,13 +91,24 @@ describe('Project Security Charts component', () => {
...
@@ -87,13 +91,24 @@ describe('Project Security Charts component', () => {
return
wrapper
.
vm
.
$nextTick
();
return
wrapper
.
vm
.
$nextTick
();
});
});
it
(
'
should display the chart with data
'
,
async
()
=>
{
it
(
'
should display the chart with data
'
,
()
=>
{
expect
(
findLineChart
().
props
(
'
data
'
)).
toMatchSnapshot
();
expect
(
findLineChart
().
props
(
'
data
'
)).
toMatchSnapshot
();
});
});
it
(
'
should not display the loading icon
'
,
()
=>
{
it
(
'
should not display the loading icon
'
,
()
=>
{
expect
(
findLoadingIcon
().
exists
()).
toBe
(
false
);
expect
(
findLoadingIcon
().
exists
()).
toBe
(
false
);
});
});
it
.
each
([[
'
restore
'
],
[
'
saveAsImage
'
]])(
'
should contain %i icon
'
,
(
icon
)
=>
{
const
option
=
findLineChart
().
props
(
'
option
'
).
toolbox
.
feature
;
expect
(
option
[
icon
].
icon
).
toBe
(
'
path://mockSvgPathContent
'
);
});
it
(
'
contains dataZoom config
'
,
()
=>
{
const
option
=
findLineChart
().
props
(
'
option
'
).
toolbox
.
feature
;
expect
(
option
.
dataZoom
.
icon
.
zoom
).
toBe
(
'
path://mockSvgPathContent
'
);
expect
(
option
.
dataZoom
.
icon
.
back
).
toBe
(
'
path://mockSvgPathContent
'
);
});
});
});
describe
(
'
when there is no history data
'
,
()
=>
{
describe
(
'
when there is no history data
'
,
()
=>
{
...
...
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