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
c9e0609d
Commit
c9e0609d
authored
Feb 28, 2020
by
Neil McCorrison
Committed by
Mark Florian
Feb 28, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to new severity badge design
https://gitlab.com/gitlab-org/gitlab/issues/199134
parent
23a8677f
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
78 additions
and
45 deletions
+78
-45
ee/app/assets/javascripts/security_dashboard/components/vulnerability_chart.vue
...pts/security_dashboard/components/vulnerability_chart.vue
+1
-7
ee/app/assets/javascripts/vue_shared/security_reports/components/severity_badge.vue
...vue_shared/security_reports/components/severity_badge.vue
+28
-38
ee/changelogs/unreleased/199134-update-security-badges.yml
ee/changelogs/unreleased/199134-update-security-badges.yml
+5
-0
ee/spec/frontend/vue_shared/components/security_reports/severity_badge_spec.js
...shared/components/security_reports/severity_badge_spec.js
+44
-0
No files found.
ee/app/assets/javascripts/security_dashboard/components/vulnerability_chart.vue
View file @
c9e0609d
...
...
@@ -135,13 +135,7 @@ export default {
</
template
>
<
template
#cell(severityLevel)=
"{ value }"
>
<div
class=
"gl-font-size-large"
>
<severity-badge
:ref=
"`severityBadge$
{value}`"
:severity="value"
class="d-block p-2 text-center"
/>
</div>
<severity-badge
:ref=
"`severityBadge$
{value}`" :severity="value" />
</
template
>
<
template
#cell(chartData)=
"{ item }"
>
<div
class=
"position-relative h-32-px"
>
...
...
ee/app/assets/javascripts/vue_shared/security_reports/components/severity_badge.vue
View file @
c9e0609d
<
script
>
import
{
SEVERITY_LEVELS
}
from
'
ee/security_dashboard/store/constants
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
export
const
CLASS_NAME_MAP
=
{
critical
:
'
text-danger-800
'
,
high
:
'
text-danger-600
'
,
medium
:
'
text-warning-400
'
,
low
:
'
text-warning-300
'
,
info
:
'
text-primary-400
'
,
unknown
:
'
text-secondary-400
'
,
};
export
default
{
name
:
'
SeverityBadge
'
,
components
:
{
GlIcon
,
},
props
:
{
severity
:
{
type
:
String
,
...
...
@@ -10,51 +23,28 @@ export default {
},
},
computed
:
{
hasSeverityBadge
()
{
return
Object
.
keys
(
CLASS_NAME_MAP
).
includes
(
this
.
severityKey
);
},
severityKey
()
{
return
this
.
severity
.
toLowerCase
();
},
className
()
{
return
`severity-badge-
${
this
.
severity
.
toLowerCase
()}
`
;
return
CLASS_NAME_MAP
[
this
.
severityKey
];
},
iconName
()
{
return
`severity-
${
this
.
severityKey
}
`
;
},
severityTitle
()
{
return
SEVERITY_LEVELS
[
this
.
severity
]
||
this
.
severity
;
return
SEVERITY_LEVELS
[
this
.
severity
Key
]
||
this
.
severity
;
},
},
};
</
script
>
<
template
>
<div
class=
"severity-badge"
:class=
"className"
>
{{
severityTitle
}}
</div>
<div
v-if=
"hasSeverityBadge"
class=
"severity-badge text-left text-nowrap gl-text-gray-900"
>
<span
:class=
"className"
><gl-icon
:name=
"iconName"
:size=
"12"
class=
"append-right-8"
/></span
>
{{
severityTitle
}}
</div>
</
template
>
<
style
>
.severity-badge
{
background-color
:
#f2f2f2
;
border-radius
:
0.3em
;
color
:
#505050
;
display
:
inline-block
;
font-size
:
0.9em
;
font-weight
:
bold
;
line-height
:
1em
;
padding
:
0.6em
0.4em
0.4em
;
text-transform
:
uppercase
;
}
.severity-badge-critical
{
background-color
:
#fae5e1
;
color
:
#c0341e
;
}
.severity-badge-high
{
background-color
:
#fff1de
;
color
:
#de7e00
;
}
.severity-badge-medium
{
background-color
:
#ede8fb
;
color
:
#6d49cb
;
}
.severity-badge-unknown
{
background-color
:
#ffffff
;
border
:
1px
solid
;
color
:
#707070
;
}
</
style
>
ee/changelogs/unreleased/199134-update-security-badges.yml
0 → 100644
View file @
c9e0609d
---
title
:
Update to new severity badge design
merge_request
:
25489
author
:
type
:
other
ee/spec/frontend/vue_shared/components/security_reports/severity_badge_spec.js
0 → 100644
View file @
c9e0609d
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
SeverityBadge
,
{
CLASS_NAME_MAP
,
}
from
'
ee/vue_shared/security_reports/components/severity_badge.vue
'
;
import
{
GlIcon
}
from
'
@gitlab/ui
'
;
describe
(
'
Severity Badge
'
,
()
=>
{
let
wrapper
;
const
factory
=
(
propsData
=
{})
=>
shallowMount
(
SeverityBadge
,
{
propsData
:
{
...
propsData
},
});
describe
.
each
(
Object
.
keys
(
CLASS_NAME_MAP
))(
'
given a valid severity %s
'
,
severity
=>
{
const
className
=
CLASS_NAME_MAP
[
severity
];
it
(
`renders the component with
${
severity
}
badge`
,
()
=>
{
wrapper
=
factory
({
severity
});
expect
(
wrapper
.
find
(
`.
${
className
}
`
).
exists
()).
toBe
(
true
);
});
it
(
'
renders gl-icon with correct name
'
,
()
=>
{
wrapper
=
factory
({
severity
});
const
icon
=
wrapper
.
find
(
GlIcon
);
expect
(
icon
.
props
(
'
name
'
)).
toBe
(
`severity-
${
severity
}
`
);
});
it
(
`renders the component label`
,
()
=>
{
wrapper
=
factory
({
severity
});
expect
(
wrapper
.
text
()).
toMatch
(
new
RegExp
(
severity
,
'
i
'
));
});
});
describe
.
each
([
'
foo
'
,
''
,
'
'
])(
'
given an invalid severity "%s"
'
,
invalidSeverity
=>
{
it
(
`renders an empty component`
,
()
=>
{
wrapper
=
factory
({
severity
:
invalidSeverity
});
expect
(
wrapper
.
isEmpty
()).
toBe
(
true
);
});
});
});
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