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 { ...@@ -34,11 +34,6 @@ export default {
required: false, required: false,
default: () => ({}), default: () => ({}),
}, },
hasVulnerabilities: {
type: Boolean,
required: false,
default: false,
},
vulnerabilitiesExportEndpoint: { vulnerabilitiesExportEndpoint: {
type: String, type: String,
required: false, required: false,
...@@ -68,7 +63,7 @@ export default { ...@@ -68,7 +63,7 @@ export default {
<template> <template>
<div> <div>
<template v-if="hasVulnerabilities"> <template v-if="pipeline.id">
<auto-fix-user-callout <auto-fix-user-callout
v-if="shoudShowAutoFixUserCallout" v-if="shoudShowAutoFixUserCallout"
:help-page-path="autoFixDocumentation" :help-page-path="autoFixDocumentation"
......
...@@ -47,6 +47,7 @@ export default { ...@@ -47,6 +47,7 @@ export default {
FiltersProducedNoResults, FiltersProducedNoResults,
DashboardHasNoVulnerabilities, DashboardHasNoVulnerabilities,
}, },
inject: ['hasVulnerabilities'],
directives: { directives: {
GlTooltip: GlTooltipDirective, GlTooltip: GlTooltipDirective,
}, },
...@@ -121,9 +122,6 @@ export default { ...@@ -121,9 +122,6 @@ export default {
this.noPipelineRunSecurityScanners.length > 0) this.noPipelineRunSecurityScanners.length > 0)
); );
}, },
hasAnyFiltersSelected() {
return Object.keys(this.filters).length > 0;
},
hasSelectedAllVulnerabilities() { hasSelectedAllVulnerabilities() {
if (!this.filteredVulnerabilities.length) { if (!this.filteredVulnerabilities.length) {
return false; return false;
...@@ -329,7 +327,7 @@ export default { ...@@ -329,7 +327,7 @@ export default {
responsive responsive
hover hover
primary-key="id" primary-key="id"
tbody-tr-class="gl-cursor-pointer" :tbody-tr-class="{ 'gl-cursor-pointer': filteredVulnerabilities.length }"
@sort-changed="handleSortChange" @sort-changed="handleSortChange"
@row-clicked="toggleVulnerability" @row-clicked="toggleVulnerability"
> >
...@@ -450,7 +448,7 @@ export default { ...@@ -450,7 +448,7 @@ export default {
</template> </template>
<template #empty> <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" /> <dashboard-has-no-vulnerabilities v-else-if="!isLoading" />
</template> </template>
</gl-table> </gl-table>
......
...@@ -7,6 +7,7 @@ import UnavailableState from './components/unavailable_state.vue'; ...@@ -7,6 +7,7 @@ import UnavailableState from './components/unavailable_state.vue';
import createStore from './store'; import createStore from './store';
import createRouter from './router'; import createRouter from './router';
import apolloProvider from './graphql/provider'; import apolloProvider from './graphql/provider';
import { parseBoolean } from '~/lib/utils/common_utils';
export default (el, dashboardType) => { export default (el, dashboardType) => {
if (!el) { if (!el) {
...@@ -29,12 +30,10 @@ export default (el, dashboardType) => { ...@@ -29,12 +30,10 @@ export default (el, dashboardType) => {
const provide = {}; const provide = {};
const props = { const props = {
hasVulnerabilities: Boolean(el.dataset.hasVulnerabilities),
securityDashboardHelpPath: el.dataset.securityDashboardHelpPath, securityDashboardHelpPath: el.dataset.securityDashboardHelpPath,
projectAddEndpoint: el.dataset.projectAddEndpoint, projectAddEndpoint: el.dataset.projectAddEndpoint,
projectListEndpoint: el.dataset.projectListEndpoint, projectListEndpoint: el.dataset.projectListEndpoint,
vulnerabilitiesExportEndpoint: el.dataset.vulnerabilitiesExportEndpoint, vulnerabilitiesExportEndpoint: el.dataset.vulnerabilitiesExportEndpoint,
noVulnerabilitiesSvgPath: el.dataset.noVulnerabilitiesSvgPath,
}; };
let component; let component;
...@@ -80,6 +79,7 @@ export default (el, dashboardType) => { ...@@ -80,6 +79,7 @@ export default (el, dashboardType) => {
emptyStateSvgPath: el.dataset.emptyStateSvgPath, emptyStateSvgPath: el.dataset.emptyStateSvgPath,
notEnabledScannersHelpPath: el.dataset.notEnabledScannersHelpPath, notEnabledScannersHelpPath: el.dataset.notEnabledScannersHelpPath,
noPipelineRunScannersHelpPath: el.dataset.noPipelineRunScannersHelpPath, noPipelineRunScannersHelpPath: el.dataset.noPipelineRunScannersHelpPath,
hasVulnerabilities: parseBoolean(el.dataset.hasVulnerabilities),
...provide, ...provide,
}), }),
render(createElement) { render(createElement) {
......
...@@ -212,8 +212,10 @@ module EE ...@@ -212,8 +212,10 @@ module EE
{ {
has_vulnerabilities: 'false', has_vulnerabilities: 'false',
empty_state_svg_path: image_path('illustrations/security-dashboard_empty.svg'), 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 else
{ {
has_vulnerabilities: 'true', 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', () => { ...@@ -24,6 +24,7 @@ describe('First Class Group Dashboard Vulnerabilities Component', () => {
$apollo, $apollo,
fetchNextPage: () => {}, fetchNextPage: () => {},
}, },
provide: { hasVulnerabilities: true },
}); });
}; };
......
...@@ -47,6 +47,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => { ...@@ -47,6 +47,7 @@ describe('First Class Instance Dashboard Vulnerabilities Component', () => {
fetchNextPage: () => {}, fetchNextPage: () => {},
}, },
data, data,
provide: { hasVulnerabilities: true },
}); });
}; };
......
...@@ -184,7 +184,7 @@ describe('First class Project Security Dashboard component', () => { ...@@ -184,7 +184,7 @@ describe('First class Project Security Dashboard component', () => {
beforeEach(() => { beforeEach(() => {
createComponent({ createComponent({
props: { props: {
hasVulnerabilities: false, pipeline: { id: undefined },
}, },
}); });
}); });
......
...@@ -36,6 +36,7 @@ describe('Vulnerability list component', () => { ...@@ -36,6 +36,7 @@ describe('Vulnerability list component', () => {
emptyStateSvgPath: '#', emptyStateSvgPath: '#',
notEnabledScannersHelpPath: '#', notEnabledScannersHelpPath: '#',
noPipelineRunScannersHelpPath: '#', noPipelineRunScannersHelpPath: '#',
hasVulnerabilities: true,
}), }),
}); });
}; };
...@@ -421,24 +422,7 @@ describe('Vulnerability list component', () => { ...@@ -421,24 +422,7 @@ describe('Vulnerability list component', () => {
}); });
}); });
describe('with no vulnerabilities when there are no filters', () => { describe('with no vulnerabilities', () => {
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', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createWrapper({ props: { filters: { someFilter: 'true' } } }); wrapper = createWrapper({ props: { filters: { someFilter: 'true' } } });
}); });
......
...@@ -134,7 +134,9 @@ RSpec.describe ProjectsHelper do ...@@ -134,7 +134,9 @@ RSpec.describe ProjectsHelper do
{ {
has_vulnerabilities: 'false', has_vulnerabilities: 'false',
empty_state_svg_path: start_with('/assets/illustrations/security-dashboard_empty'), 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 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