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