Commit f6753702 authored by David Pisek's avatar David Pisek Committed by Savas Vedova

Resolve "Vulnerability report shows empty state if there are no pipelines"

parent c3f0b38f
...@@ -15,7 +15,6 @@ import AutoFixUserCallout from './auto_fix_user_callout.vue'; ...@@ -15,7 +15,6 @@ import AutoFixUserCallout from './auto_fix_user_callout.vue';
import CsvExportButton from './csv_export_button.vue'; import CsvExportButton from './csv_export_button.vue';
import ReportNotConfiguredGroup from './empty_states/report_not_configured_group.vue'; import ReportNotConfiguredGroup from './empty_states/report_not_configured_group.vue';
import ReportNotConfiguredInstance from './empty_states/report_not_configured_instance.vue'; import ReportNotConfiguredInstance from './empty_states/report_not_configured_instance.vue';
import ReportNotConfiguredProject from './empty_states/report_not_configured_project.vue';
import ReportNotConfiguredOperational from './empty_states/report_not_configured_operational.vue'; import ReportNotConfiguredOperational from './empty_states/report_not_configured_operational.vue';
import Filters from './filters/filters_layout.vue'; import Filters from './filters/filters_layout.vue';
import ProjectPipelineStatus from './project_pipeline_status.vue'; import ProjectPipelineStatus from './project_pipeline_status.vue';
...@@ -36,7 +35,6 @@ export default { ...@@ -36,7 +35,6 @@ export default {
SurveyRequestBanner, SurveyRequestBanner,
ReportNotConfiguredGroup, ReportNotConfiguredGroup,
ReportNotConfiguredInstance, ReportNotConfiguredInstance,
ReportNotConfiguredProject,
ReportNotConfiguredOperational, ReportNotConfiguredOperational,
PortalTarget, PortalTarget,
ProjectPipelineStatus, ProjectPipelineStatus,
...@@ -107,9 +105,20 @@ export default { ...@@ -107,9 +105,20 @@ export default {
return !this.isPipeline; return !this.isPipeline;
}, },
isDashboardConfigured() { isDashboardConfigured() {
return this.isProject || this.isPipeline // Projects can have manually created vulnerabilities, so we always show the report
? Boolean(this.pipeline?.id) if (this.isProject) {
: this.projects.length > 0 && this.projectsWereFetched; return true;
}
if (this.isPipeline) {
return Boolean(this.pipeline?.id);
}
// Group and Instance Dashboards
return this.projects.length > 0;
},
shouldShowPipelineStatus() {
return this.isProject && Boolean(this.pipeline);
}, },
}, },
methods: { methods: {
...@@ -139,7 +148,6 @@ export default { ...@@ -139,7 +148,6 @@ export default {
<survey-request-banner v-if="shouldShowSurvey" class="gl-mt-5" /> <survey-request-banner v-if="shouldShowSurvey" class="gl-mt-5" />
<report-not-configured-group v-if="isGroup" /> <report-not-configured-group v-if="isGroup" />
<report-not-configured-instance v-else-if="isInstance" /> <report-not-configured-instance v-else-if="isInstance" />
<report-not-configured-project v-else-if="isProject" />
</template> </template>
<template v-else> <template v-else>
<portal-target :name="$options.vulnerabilityReportAlertsPortal" multiple /> <portal-target :name="$options.vulnerabilityReportAlertsPortal" multiple />
...@@ -166,7 +174,11 @@ export default { ...@@ -166,7 +174,11 @@ export default {
</gl-sprintf> </gl-sprintf>
</template> </template>
<template #summary> <template #summary>
<project-pipeline-status v-if="isProject" class="gl-mb-6" :pipeline="pipeline" /> <project-pipeline-status
v-if="shouldShowPipelineStatus"
class="gl-mb-6"
:pipeline="pipeline"
/>
<vulnerabilities-count-list :filters="filters" /> <vulnerabilities-count-list :filters="filters" />
</template> </template>
<template #sticky> <template #sticky>
......
...@@ -11,7 +11,6 @@ import AutoFixUserCallout from 'ee/security_dashboard/components/shared/auto_fix ...@@ -11,7 +11,6 @@ import AutoFixUserCallout from 'ee/security_dashboard/components/shared/auto_fix
import CsvExportButton from 'ee/security_dashboard/components/shared/csv_export_button.vue'; import CsvExportButton from 'ee/security_dashboard/components/shared/csv_export_button.vue';
import ReportNotConfiguredGroup from 'ee/security_dashboard/components/shared/empty_states/report_not_configured_group.vue'; import ReportNotConfiguredGroup from 'ee/security_dashboard/components/shared/empty_states/report_not_configured_group.vue';
import ReportNotConfiguredInstance from 'ee/security_dashboard/components/shared/empty_states/report_not_configured_instance.vue'; import ReportNotConfiguredInstance from 'ee/security_dashboard/components/shared/empty_states/report_not_configured_instance.vue';
import ReportNotConfiguredProject from 'ee/security_dashboard/components/shared/empty_states/report_not_configured_project.vue';
import Filters from 'ee/security_dashboard/components/shared/filters/filters_layout.vue'; import Filters from 'ee/security_dashboard/components/shared/filters/filters_layout.vue';
import ProjectPipelineStatus from 'ee/security_dashboard/components/shared/project_pipeline_status.vue'; import ProjectPipelineStatus from 'ee/security_dashboard/components/shared/project_pipeline_status.vue';
import SurveyRequestBanner from 'ee/security_dashboard/components/shared/survey_request_banner.vue'; import SurveyRequestBanner from 'ee/security_dashboard/components/shared/survey_request_banner.vue';
...@@ -35,7 +34,6 @@ describe('Vulnerability Report', () => { ...@@ -35,7 +34,6 @@ describe('Vulnerability Report', () => {
const findCsvExportButton = () => wrapper.findComponent(CsvExportButton); const findCsvExportButton = () => wrapper.findComponent(CsvExportButton);
const findGroupEmptyState = () => wrapper.findComponent(ReportNotConfiguredGroup); const findGroupEmptyState = () => wrapper.findComponent(ReportNotConfiguredGroup);
const findInstanceEmptyState = () => wrapper.findComponent(ReportNotConfiguredInstance); const findInstanceEmptyState = () => wrapper.findComponent(ReportNotConfiguredInstance);
const findProjectEmptyState = () => wrapper.findComponent(ReportNotConfiguredProject);
const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon); const findLoadingIcon = () => wrapper.findComponent(GlLoadingIcon);
const findFilters = () => wrapper.findComponent(Filters); const findFilters = () => wrapper.findComponent(Filters);
const findVulnerabilitiesCountList = () => wrapper.findComponent(VulnerabilitiesCountList); const findVulnerabilitiesCountList = () => wrapper.findComponent(VulnerabilitiesCountList);
...@@ -183,7 +181,6 @@ describe('Vulnerability Report', () => { ...@@ -183,7 +181,6 @@ describe('Vulnerability Report', () => {
expect(findAlertsPortalTarget().exists()).toBe(false); expect(findAlertsPortalTarget().exists()).toBe(false);
expect(findGroupEmptyState().exists()).toBe(true); expect(findGroupEmptyState().exists()).toBe(true);
expect(findInstanceEmptyState().exists()).toBe(false); expect(findInstanceEmptyState().exists()).toBe(false);
expect(findProjectEmptyState().exists()).toBe(false);
expect(findCsvExportButton().exists()).toBe(false); expect(findCsvExportButton().exists()).toBe(false);
expect(findFilters().exists()).toBe(false); expect(findFilters().exists()).toBe(false);
expect(findVulnerabilitiesCountList().exists()).toBe(false); expect(findVulnerabilitiesCountList().exists()).toBe(false);
...@@ -265,18 +262,23 @@ describe('Vulnerability Report', () => { ...@@ -265,18 +262,23 @@ describe('Vulnerability Report', () => {
}); });
}); });
describe('when uninitialized - project level', () => { describe('manually added vulnerabilities without a pipeline - project level', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createWrapper({ wrapper = createWrapper({
provide: { provide: {
dashboardType: DASHBOARD_TYPES.PROJECT, dashboardType: DASHBOARD_TYPES.PROJECT,
pipeline: null,
}, },
apolloProvider: createApolloProvider(), apolloProvider: createApolloProvider(),
}); });
}); });
it('renders empty project state', () => { it('renders the vulnerabilities project state', () => {
expect(findProjectEmptyState().exists()).toBe(true); expect(findProjectVulnerabilities().exists()).toBe(true);
});
it('does not render the pipeline status', () => {
expect(findProjectPipelineStatus().exists()).toBe(false);
}); });
}); });
}); });
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