Commit 00160427 authored by Savas Vedova's avatar Savas Vedova

Add filters to the instance level dashboard

- Rename wrong test names
parent fc4091a5
...@@ -2,12 +2,14 @@ ...@@ -2,12 +2,14 @@
import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue'; import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue';
import InstanceSecurityVulnerabilities from './first_class_instance_security_dashboard_vulnerabilities.vue'; import InstanceSecurityVulnerabilities from './first_class_instance_security_dashboard_vulnerabilities.vue';
import VulnerabilitySeverity from 'ee/security_dashboard/components/vulnerability_severity.vue'; import VulnerabilitySeverity from 'ee/security_dashboard/components/vulnerability_severity.vue';
import Filters from 'ee/security_dashboard/components/first_class_vulnerability_filters.vue';
export default { export default {
components: { components: {
SecurityDashboardLayout, SecurityDashboardLayout,
InstanceSecurityVulnerabilities, InstanceSecurityVulnerabilities,
VulnerabilitySeverity, VulnerabilitySeverity,
Filters,
}, },
props: { props: {
dashboardDocumentation: { dashboardDocumentation: {
...@@ -23,14 +25,31 @@ export default { ...@@ -23,14 +25,31 @@ export default {
required: true, required: true,
}, },
}, },
data() {
return {
filters: {},
};
},
methods: {
handleFilterChange(filters) {
this.filters = filters;
},
},
}; };
</script> </script>
<template> <template>
<security-dashboard-layout> <security-dashboard-layout>
<template #header>
<header class="page-title-holder flex-fill d-flex align-items-center">
<h2 class="page-title">{{ s__('SecurityDashboard|Security Dashboard') }}</h2>
</header>
<filters @filterChange="handleFilterChange" />
</template>
<instance-security-vulnerabilities <instance-security-vulnerabilities
:dashboard-documentation="dashboardDocumentation" :dashboard-documentation="dashboardDocumentation"
:empty-state-svg-path="emptyStateSvgPath" :empty-state-svg-path="emptyStateSvgPath"
:filters="filters"
/> />
<template #aside> <template #aside>
<vulnerability-severity :endpoint="vulnerableProjectsEndpoint" /> <vulnerability-severity :endpoint="vulnerableProjectsEndpoint" />
......
...@@ -22,6 +22,11 @@ export default { ...@@ -22,6 +22,11 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
filters: {
type: Object,
required: false,
default: () => ({}),
},
}, },
data() { data() {
return { return {
...@@ -36,6 +41,7 @@ export default { ...@@ -36,6 +41,7 @@ export default {
variables() { variables() {
return { return {
first: VULNERABILITIES_PER_PAGE, first: VULNERABILITIES_PER_PAGE,
...this.filters,
}; };
}, },
update: ({ vulnerabilities }) => vulnerabilities.nodes, update: ({ vulnerabilities }) => vulnerabilities.nodes,
......
#import "~/graphql_shared/fragments/pageInfo.fragment.graphql" #import "~/graphql_shared/fragments/pageInfo.fragment.graphql"
#import "ee/vulnerabilities/graphql/vulnerability.fragment.graphql" #import "ee/vulnerabilities/graphql/vulnerability.fragment.graphql"
query instance($after: String, $first: Int) { query instance(
vulnerabilities(after:$after, first:$first) { $after: String,
$first: Int
$severity: [VulnerabilitySeverity!]
$reportType: [VulnerabilityReportType!]
$state: [VulnerabilityState!]
) {
vulnerabilities(
after:$after,
first:$first,
severity: $severity
reportType: $reportType
state: $state
) {
nodes { nodes {
...Vulnerability ...Vulnerability
} }
......
...@@ -3,6 +3,7 @@ import SecurityDashboardLayout from 'ee/security_dashboard/components/security_d ...@@ -3,6 +3,7 @@ import SecurityDashboardLayout from 'ee/security_dashboard/components/security_d
import FirstClassInstanceDashboard from 'ee/security_dashboard/components/first_class_instance_security_dashboard.vue'; import FirstClassInstanceDashboard from 'ee/security_dashboard/components/first_class_instance_security_dashboard.vue';
import FirstClassInstanceVulnerabilities from 'ee/security_dashboard/components/first_class_instance_security_dashboard_vulnerabilities.vue'; import FirstClassInstanceVulnerabilities from 'ee/security_dashboard/components/first_class_instance_security_dashboard_vulnerabilities.vue';
import VulnerabilitySeverity from 'ee/security_dashboard/components/vulnerability_severity.vue'; import VulnerabilitySeverity from 'ee/security_dashboard/components/vulnerability_severity.vue';
import Filters from 'ee/security_dashboard/components/first_class_vulnerability_filters.vue';
describe('First Class Instance Dashboard Component', () => { describe('First Class Instance Dashboard Component', () => {
let wrapper; let wrapper;
...@@ -13,6 +14,7 @@ describe('First Class Instance Dashboard Component', () => { ...@@ -13,6 +14,7 @@ describe('First Class Instance Dashboard Component', () => {
const findInstanceVulnerabilities = () => wrapper.find(FirstClassInstanceVulnerabilities); const findInstanceVulnerabilities = () => wrapper.find(FirstClassInstanceVulnerabilities);
const findVulnerabilitySeverity = () => wrapper.find(VulnerabilitySeverity); const findVulnerabilitySeverity = () => wrapper.find(VulnerabilitySeverity);
const findFilters = () => wrapper.find(Filters);
const createWrapper = () => { const createWrapper = () => {
return shallowMount(FirstClassInstanceDashboard, { return shallowMount(FirstClassInstanceDashboard, {
...@@ -39,6 +41,20 @@ describe('First Class Instance Dashboard Component', () => { ...@@ -39,6 +41,20 @@ describe('First Class Instance Dashboard Component', () => {
expect(findInstanceVulnerabilities().props()).toEqual({ expect(findInstanceVulnerabilities().props()).toEqual({
dashboardDocumentation, dashboardDocumentation,
emptyStateSvgPath, emptyStateSvgPath,
filters: {},
});
});
it('has filters', () => {
expect(findFilters().exists()).toBe(true);
});
it('it responds to the filterChange event', () => {
const filters = { severity: 'critical' };
findFilters().vm.$listeners.filterChange(filters);
return wrapper.vm.$nextTick(() => {
expect(wrapper.vm.filters).toEqual(filters);
expect(findInstanceVulnerabilities().props('filters')).toEqual(filters);
}); });
}); });
......
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