Commit 7397bffd authored by Daniel Tian's avatar Daniel Tian Committed by Douglas Barbosa Alexandre

Fix error on vulnerability list when there are no vulnerabilities

Fix various errors on vulnerability list when there are no
vulnerabilities.
parent ba4c33fb
......@@ -34,11 +34,6 @@ export default {
required: false,
default: () => ({}),
},
hasVulnerabilities: {
type: Boolean,
required: false,
default: false,
},
vulnerabilitiesExportEndpoint: {
type: String,
required: false,
......@@ -68,7 +63,7 @@ export default {
<template>
<div>
<template v-if="hasVulnerabilities">
<template v-if="pipeline.id">
<auto-fix-user-callout
v-if="shoudShowAutoFixUserCallout"
:help-page-path="autoFixDocumentation"
......
......@@ -47,6 +47,7 @@ export default {
FiltersProducedNoResults,
DashboardHasNoVulnerabilities,
},
inject: ['hasVulnerabilities'],
directives: {
GlTooltip: GlTooltipDirective,
},
......@@ -121,9 +122,6 @@ export default {
this.noPipelineRunSecurityScanners.length > 0)
);
},
hasAnyFiltersSelected() {
return Object.keys(this.filters).length > 0;
},
hasSelectedAllVulnerabilities() {
if (!this.filteredVulnerabilities.length) {
return false;
......@@ -329,7 +327,7 @@ export default {
responsive
hover
primary-key="id"
tbody-tr-class="gl-cursor-pointer"
:tbody-tr-class="{ 'gl-cursor-pointer': filteredVulnerabilities.length }"
@sort-changed="handleSortChange"
@row-clicked="toggleVulnerability"
>
......@@ -450,7 +448,7 @@ export default {
</template>
<template #empty>
<filters-produced-no-results v-if="hasAnyFiltersSelected && !isLoading" />
<filters-produced-no-results v-if="hasVulnerabilities && !isLoading" />
<dashboard-has-no-vulnerabilities v-else-if="!isLoading" />
</template>
</gl-table>
......
......@@ -7,6 +7,7 @@ import UnavailableState from './components/unavailable_state.vue';
import createStore from './store';
import createRouter from './router';
import apolloProvider from './graphql/provider';
import { parseBoolean } from '~/lib/utils/common_utils';
export default (el, dashboardType) => {
if (!el) {
......@@ -29,12 +30,10 @@ export default (el, dashboardType) => {
const provide = {};
const props = {
hasVulnerabilities: Boolean(el.dataset.hasVulnerabilities),
securityDashboardHelpPath: el.dataset.securityDashboardHelpPath,
projectAddEndpoint: el.dataset.projectAddEndpoint,
projectListEndpoint: el.dataset.projectListEndpoint,
vulnerabilitiesExportEndpoint: el.dataset.vulnerabilitiesExportEndpoint,
noVulnerabilitiesSvgPath: el.dataset.noVulnerabilitiesSvgPath,
};
let component;
......@@ -80,6 +79,7 @@ export default (el, dashboardType) => {
emptyStateSvgPath: el.dataset.emptyStateSvgPath,
notEnabledScannersHelpPath: el.dataset.notEnabledScannersHelpPath,
noPipelineRunScannersHelpPath: el.dataset.noPipelineRunScannersHelpPath,
hasVulnerabilities: parseBoolean(el.dataset.hasVulnerabilities),
...provide,
}),
render(createElement) {
......
......@@ -212,8 +212,10 @@ module EE
{
has_vulnerabilities: 'false',
empty_state_svg_path: image_path('illustrations/security-dashboard_empty.svg'),
security_dashboard_help_path: help_page_path('user/application_security/security_dashboard/index')
}
security_dashboard_help_path: help_page_path('user/application_security/security_dashboard/index'),
no_vulnerabilities_svg_path: image_path('illustrations/issues.svg'),
project_full_path: project.full_path
}.merge!(security_dashboard_pipeline_data(project))
else
{
has_vulnerabilities: 'true',
......
---
title: Fix error on vulnerability list when there are no vulnerabilities
merge_request: 47235
author:
type: fixed
......@@ -24,6 +24,7 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => {
$apollo,
fetchNextPage: () => {},
},
provide: { hasVulnerabilities: true },
});
};
......
......@@ -47,6 +47,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => {
fetchNextPage: () => {},
},
data,
provide: { hasVulnerabilities: true },
});
};
......
......@@ -184,7 +184,7 @@ describe('First class Project Security Dashboard component', () => {
beforeEach(() => {
createComponent({
props: {
hasVulnerabilities: false,
pipeline: { id: undefined },
},
});
});
......
......@@ -36,6 +36,7 @@ describe('Vulnerability list component', () => {
emptyStateSvgPath: '#',
notEnabledScannersHelpPath: '#',
noPipelineRunScannersHelpPath: '#',
hasVulnerabilities: true,
}),
});
};
......@@ -421,24 +422,7 @@ describe('Vulnerability list component', () => {
});
});
describe('with no vulnerabilities when there are no filters', () => {
beforeEach(() => {
wrapper = createWrapper();
});
it('should show the empty state', () => {
expect(findCell('status').exists()).toEqual(false);
expect(findDashboardHasNoVulnerabilities().exists()).toEqual(true);
expect(findFiltersProducedNoResults().exists()).toEqual(false);
});
it('should not show the vulnerability check-all checkbox as checked with no vulnerabilities', () => {
expect(findDataCell('vulnerability-checkbox-all').exists()).toBe(true);
expect(findDataCell('vulnerability-checkbox-all').element.checked).toBe(false);
});
});
describe('with no vulnerabilities when there are filters', () => {
describe('with no vulnerabilities', () => {
beforeEach(() => {
wrapper = createWrapper({ props: { filters: { someFilter: 'true' } } });
});
......
......@@ -134,7 +134,9 @@ RSpec.describe ProjectsHelper do
{
has_vulnerabilities: 'false',
empty_state_svg_path: start_with('/assets/illustrations/security-dashboard_empty'),
security_dashboard_help_path: '/help/user/application_security/security_dashboard/index'
security_dashboard_help_path: '/help/user/application_security/security_dashboard/index',
project_full_path: project.full_path,
no_vulnerabilities_svg_path: start_with('/assets/illustrations/issues-')
}
end
......
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