Commit e3299e80 authored by Phil Hughes's avatar Phil Hughes

Merge branch '196725-fix-status-badge-styling' into 'master'

Fix vulnerability status header style to be more in-line with other headers

See merge request gitlab-org/gitlab!27485
parents 503fb110 f7d307a8
...@@ -7,6 +7,10 @@ ...@@ -7,6 +7,10 @@
a { a {
color: $gl-text-color; color: $gl-text-color;
&.link {
color: $blue-600;
}
} }
.author-link { .author-link {
......
<script> <script>
import { GlLoadingIcon, GlBadge, GlLink, GlSprintf } from '@gitlab/ui'; import { GlLoadingIcon, GlLink, GlSprintf } from '@gitlab/ui';
import Api from 'ee/api'; import Api from 'ee/api';
import LoadingButton from '~/vue_shared/components/loading_button.vue'; import LoadingButton from '~/vue_shared/components/loading_button.vue';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
...@@ -14,7 +14,6 @@ export default { ...@@ -14,7 +14,6 @@ export default {
name: 'VulnerabilityManagementApp', name: 'VulnerabilityManagementApp',
components: { components: {
GlLoadingIcon, GlLoadingIcon,
GlBadge,
GlLink, GlLink,
GlSprintf, GlSprintf,
TimeAgoTooltip, TimeAgoTooltip,
...@@ -51,9 +50,9 @@ export default { ...@@ -51,9 +50,9 @@ export default {
}, },
computed: { computed: {
variant() { statusBoxStyle() {
// Get the badge variant based on the vulnerability state, defaulting to 'warning'. // Get the badge variant based on the vulnerability state, defaulting to 'expired'.
return VULNERABILITY_STATES[this.state]?.variant || 'warning'; return VULNERABILITY_STATES[this.state]?.statusBoxStyle || 'expired';
}, },
}, },
...@@ -102,37 +101,49 @@ export default { ...@@ -102,37 +101,49 @@ export default {
</script> </script>
<template> <template>
<div class="d-flex align-items-center border-bottom pt-2 pb-2"> <div class="detail-page-header">
<gl-loading-icon v-if="isLoadingVulnerability" /> <div class="detail-page-header-body lh-4 align-items-center">
<gl-badge v-else ref="badge" class="text-capitalize" :variant="variant">{{ state }}</gl-badge> <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}`
"
>
{{ state }}
</span>
<span v-if="pipeline" class="mx-2"> <span v-if="pipeline" class="issuable-meta">
<gl-sprintf :message="__('Detected %{timeago} in pipeline %{pipelineLink}')"> <gl-sprintf :message="__('Detected %{timeago} in pipeline %{pipelineLink}')">
<template #timeago> <template #timeago>
<time-ago-tooltip :time="pipeline.created_at" /> <time-ago-tooltip :time="pipeline.created_at" />
</template> </template>
<template v-if="pipeline.id" #pipelineLink> <template v-if="pipeline.id" #pipelineLink>
<gl-link :href="pipeline.url" target="_blank">{{ pipeline.id }}</gl-link> <gl-link :href="pipeline.url" class="link" target="_blank">{{ pipeline.id }}</gl-link>
</template> </template>
</gl-sprintf> </gl-sprintf>
</span> </span>
<time-ago-tooltip v-else class="ml-2" :time="vulnerability.created_at" /> <time-ago-tooltip v-else class="issuable-meta" :time="vulnerability.created_at" />
</div>
<label class="mb-0 ml-auto mr-2">{{ __('Status') }}</label> <div class="detail-page-header-actions align-items-center">
<gl-loading-icon v-if="isLoadingVulnerability" /> <label class="mb-0 mx-2">{{ __('Status') }}</label>
<vulnerability-state-dropdown <gl-loading-icon v-if="isLoadingVulnerability" class="d-inline" />
v-else <vulnerability-state-dropdown
:initial-state="state" v-else
@change="onVulnerabilityStateChange" :initial-state="state"
/> @change="onVulnerabilityStateChange"
<loading-button />
ref="create-issue-btn" <loading-button
class="align-items-center d-inline-flex ml-2" ref="create-issue-btn"
:loading="isCreatingIssue" class="ml-2"
:label="s__('VulnerabilityManagement|Create issue')" :loading="isCreatingIssue"
container-class="btn btn-success btn-inverted" :label="s__('VulnerabilityManagement|Create issue')"
@click="createIssue" container-class="btn btn-success btn-inverted"
/> @click="createIssue"
/>
</div>
</div> </div>
</template> </template>
...@@ -4,19 +4,19 @@ import { s__ } from '~/locale'; ...@@ -4,19 +4,19 @@ import { s__ } from '~/locale';
export const VULNERABILITY_STATES = { export const VULNERABILITY_STATES = {
dismissed: { dismissed: {
action: 'dismiss', action: 'dismiss',
variant: 'light', statusBoxStyle: 'upcoming',
displayName: s__('VulnerabilityManagement|Dismiss'), displayName: s__('VulnerabilityManagement|Dismiss'),
description: s__('VulnerabilityManagement|Will not fix or a false-positive'), description: s__('VulnerabilityManagement|Will not fix or a false-positive'),
}, },
confirmed: { confirmed: {
action: 'confirm', action: 'confirm',
variant: 'danger', statusBoxStyle: 'closed',
displayName: s__('VulnerabilityManagement|Confirm'), displayName: s__('VulnerabilityManagement|Confirm'),
description: s__('VulnerabilityManagement|A true-positive and will fix'), description: s__('VulnerabilityManagement|A true-positive and will fix'),
}, },
resolved: { resolved: {
action: 'resolve', action: 'resolve',
variant: 'success', statusBoxStyle: 'open',
displayName: s__('VulnerabilityManagement|Resolved'), displayName: s__('VulnerabilityManagement|Resolved'),
description: s__('VulnerabilityManagement|Verified as fixed or mitigated'), description: s__('VulnerabilityManagement|Verified as fixed or mitigated'),
}, },
......
import { shallowMount } from '@vue/test-utils'; import { shallowMount } from '@vue/test-utils';
import { GlBadge } from '@gitlab/ui';
import MockAdapter from 'axios-mock-adapter'; import MockAdapter from 'axios-mock-adapter';
import axios from '~/lib/utils/axios_utils'; import axios from '~/lib/utils/axios_utils';
import * as urlUtility from '~/lib/utils/url_utility'; import * as urlUtility from '~/lib/utils/url_utility';
...@@ -34,6 +33,7 @@ describe('Vulnerability management app', () => { ...@@ -34,6 +33,7 @@ describe('Vulnerability management app', () => {
}; };
const findCreateIssueButton = () => wrapper.find({ ref: 'create-issue-btn' }); const findCreateIssueButton = () => wrapper.find({ ref: 'create-issue-btn' });
const findBadge = () => wrapper.find({ ref: 'badge' });
const createWrapper = (state = 'detected') => { const createWrapper = (state = 'detected') => {
wrapper = shallowMount(App, { wrapper = shallowMount(App, {
...@@ -125,13 +125,12 @@ describe('Vulnerability management app', () => { ...@@ -125,13 +125,12 @@ describe('Vulnerability management app', () => {
describe('state badge', () => { describe('state badge', () => {
test.each(vulnerabilityStateEntries)( test.each(vulnerabilityStateEntries)(
'the vulnerability state badge has the correct variant for the %s state', 'the vulnerability state badge has the correct style for the %s state',
(stateString, stateObject) => { (stateString, stateObject) => {
createWrapper(stateString); createWrapper(stateString);
const badge = wrapper.find(GlBadge);
expect(badge.attributes('variant')).toBe(stateObject.variant); expect(findBadge().classes()).toContain(`status-box-${stateObject.statusBoxStyle}`);
expect(badge.text()).toBe(stateString); expect(findBadge().text()).toBe(stateString);
}, },
); );
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment