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
6bcadcf9
Commit
6bcadcf9
authored
Sep 24, 2020
by
Savas Vedova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use gl-badge for vulnerability states
- Add changelog
parent
e1fca753
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
35 additions
and
23 deletions
+35
-23
ee/app/assets/javascripts/vulnerabilities/components/header.vue
.../assets/javascripts/vulnerabilities/components/header.vue
+13
-13
ee/app/assets/javascripts/vulnerabilities/constants.js
ee/app/assets/javascripts/vulnerabilities/constants.js
+0
-3
ee/changelogs/unreleased/218485-use-the-badge.yml
ee/changelogs/unreleased/218485-use-the-badge.yml
+5
-0
ee/spec/frontend/vulnerabilities/header_spec.js
ee/spec/frontend/vulnerabilities/header_spec.js
+17
-7
No files found.
ee/app/assets/javascripts/vulnerabilities/components/header.vue
View file @
6bcadcf9
<
script
>
import
{
GlLoadingIcon
,
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlLoadingIcon
,
GlButton
,
GlBadge
}
from
'
@gitlab/ui
'
;
import
Api
from
'
ee/api
'
;
import
{
CancelToken
}
from
'
axios
'
;
import
SplitButton
from
'
ee/vue_shared/security_reports/components/split_button.vue
'
;
...
...
@@ -20,6 +20,7 @@ export default {
components
:
{
GlLoadingIcon
,
GlButton
,
GlBadge
,
ResolutionAlert
,
VulnerabilityStateDropdown
,
SplitButton
,
...
...
@@ -46,7 +47,16 @@ export default {
};
},
badgeVariants
:
{
confirmed
:
'
danger
'
,
resolved
:
'
success
'
,
detected
:
'
warning
'
,
},
computed
:
{
stateVariant
()
{
return
this
.
$options
.
badgeVariants
[
this
.
vulnerability
.
state
]
||
'
neutral
'
;
},
actionButtons
()
{
const
buttons
=
[];
...
...
@@ -81,10 +91,6 @@ export default {
this
.
hasRemediation
);
},
statusBoxStyle
()
{
// Get the badge variant based on the vulnerability state, defaulting to 'expired'.
return
VULNERABILITY_STATE_OBJECTS
[
this
.
vulnerability
.
state
]?.
statusBoxStyle
||
'
expired
'
;
},
showResolutionAlert
()
{
return
(
this
.
vulnerability
.
resolved_on_default_branch
&&
...
...
@@ -224,15 +230,9 @@ export default {
<div
class=
"detail-page-header"
>
<div
class=
"detail-page-header-body align-items-center"
>
<gl-loading-icon
v-if=
"isLoadingVulnerability"
class=
"mr-2"
/>
<span
v-else
ref=
"badge"
:class=
"
`text-capitalize align-self-center issuable-status-box status-box status-box-$
{statusBoxStyle}`
"
>
<gl-badge
v-else
class=
"gl-mr-4 text-capitalize"
:variant=
"stateVariant"
>
{{
vulnerability
.
state
}}
</
span
>
</
gl-badge
>
<status-description
class=
"issuable-meta"
...
...
ee/app/assets/javascripts/vulnerabilities/constants.js
View file @
6bcadcf9
...
...
@@ -4,21 +4,18 @@ export const VULNERABILITY_STATE_OBJECTS = {
dismissed
:
{
action
:
'
dismiss
'
,
state
:
'
dismissed
'
,
statusBoxStyle
:
'
upcoming
'
,
displayName
:
s__
(
'
Dismiss
'
),
description
:
s__
(
'
VulnerabilityManagement|Will not fix or a false-positive
'
),
},
confirmed
:
{
action
:
'
confirm
'
,
state
:
'
confirmed
'
,
statusBoxStyle
:
'
closed
'
,
displayName
:
s__
(
'
Confirm
'
),
description
:
s__
(
'
VulnerabilityManagement|A true-positive and will fix
'
),
},
resolved
:
{
action
:
'
resolve
'
,
state
:
'
resolved
'
,
statusBoxStyle
:
'
open
'
,
displayName
:
s__
(
'
Resolve
'
),
description
:
s__
(
'
VulnerabilityManagement|Verified as fixed or mitigated
'
),
},
...
...
ee/changelogs/unreleased/218485-use-the-badge.yml
0 → 100644
View file @
6bcadcf9
---
title
:
Use gl-badge for vulnerability states
merge_request
:
43253
author
:
type
:
changed
ee/spec/frontend/vulnerabilities/header_spec.js
View file @
6bcadcf9
import
{
shallowMount
}
from
'
@vue/test-utils
'
;
import
{
GlButton
}
from
'
@gitlab/ui
'
;
import
{
GlButton
,
GlBadge
}
from
'
@gitlab/ui
'
;
import
MockAdapter
from
'
axios-mock-adapter
'
;
import
waitForPromises
from
'
helpers/wait_for_promises
'
;
import
UsersMockHelper
from
'
helpers/user_mock_data_helper
'
;
...
...
@@ -69,7 +69,7 @@ describe('Vulnerability Header', () => {
const
findGlButton
=
()
=>
wrapper
.
find
(
GlButton
);
const
findSplitButton
=
()
=>
wrapper
.
find
(
SplitButton
);
const
findBadge
=
()
=>
wrapper
.
find
(
{
ref
:
'
badge
'
}
);
const
findBadge
=
()
=>
wrapper
.
find
(
GlBadge
);
const
findResolutionAlert
=
()
=>
wrapper
.
find
(
ResolutionAlert
);
const
findStatusDescription
=
()
=>
wrapper
.
find
(
StatusDescription
);
...
...
@@ -78,6 +78,9 @@ describe('Vulnerability Header', () => {
propsData
:
{
initialVulnerability
:
{
...
defaultVulnerability
,
...
vulnerability
},
},
stubs
:
{
GlBadge
,
},
});
};
...
...
@@ -107,7 +110,7 @@ describe('Vulnerability Header', () => {
});
it
(
'
when the vulnerability state dropdown emits a change event, the state badge updates
'
,
()
=>
{
const
newState
=
'
dismiss
'
;
const
newState
=
'
dismiss
ed
'
;
mockAxios
.
onPost
().
reply
(
201
,
{
state
:
newState
});
expect
(
findBadge
().
text
()).
not
.
toBe
(
newState
);
...
...
@@ -121,7 +124,7 @@ describe('Vulnerability Header', () => {
});
it
(
'
when the vulnerability state dropdown emits a change event, the vulnerabilities event bus event is emitted with the proper event
'
,
()
=>
{
const
newState
=
'
dismiss
'
;
const
newState
=
'
dismiss
ed
'
;
mockAxios
.
onPost
().
reply
(
201
,
{
state
:
newState
});
expect
(
findBadge
().
text
()).
not
.
toBe
(
newState
);
...
...
@@ -253,12 +256,19 @@ describe('Vulnerability Header', () => {
});
describe
(
'
state badge
'
,
()
=>
{
it
.
each
(
vulnerabilityStateEntries
)(
const
badgeVariants
=
{
confirmed
:
'
danger
'
,
resolved
:
'
success
'
,
detected
:
'
warning
'
,
dismissed
:
'
neutral
'
,
};
it
.
each
(
Object
.
entries
(
badgeVariants
))(
'
the vulnerability state badge has the correct style for the %s state
'
,
(
state
,
stateObjec
t
)
=>
{
(
state
,
varian
t
)
=>
{
createWrapper
({
state
});
expect
(
findBadge
().
classes
()).
toContain
(
`status-box-
${
stateObject
.
statusBoxStyle
}
`
);
expect
(
findBadge
().
props
(
'
variant
'
)).
toBe
(
variant
);
expect
(
findBadge
().
text
()).
toBe
(
state
);
},
);
...
...
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