Commit 3e539ad4 authored by Tim Zallmann's avatar Tim Zallmann

Merge branch '213821-add-filters-to-group-level' into 'master'

Add filters to group level

See merge request gitlab-org/gitlab!29156
parents 8792b37b e415590a
<script> <script>
import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue'; import SecurityDashboardLayout from 'ee/security_dashboard/components/security_dashboard_layout.vue';
import GroupSecurityVulnerabilities from './first_class_group_security_dashboard_vulnerabilities.vue'; import GroupSecurityVulnerabilities from 'ee/security_dashboard/components/first_class_group_security_dashboard_vulnerabilities.vue';
import Filters from 'ee/security_dashboard/components/first_class_vulnerability_filters.vue';
import VulnerabilitySeverity from './vulnerability_severity.vue'; import VulnerabilitySeverity from './vulnerability_severity.vue';
export default { export default {
...@@ -8,6 +9,7 @@ export default { ...@@ -8,6 +9,7 @@ export default {
SecurityDashboardLayout, SecurityDashboardLayout,
GroupSecurityVulnerabilities, GroupSecurityVulnerabilities,
VulnerabilitySeverity, VulnerabilitySeverity,
Filters,
}, },
props: { props: {
dashboardDocumentation: { dashboardDocumentation: {
...@@ -27,15 +29,29 @@ export default { ...@@ -27,15 +29,29 @@ 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>
<filters @filterChange="handleFilterChange" />
</template>
<group-security-vulnerabilities <group-security-vulnerabilities
:dashboard-documentation="dashboardDocumentation" :dashboard-documentation="dashboardDocumentation"
:empty-state-svg-path="emptyStateSvgPath" :empty-state-svg-path="emptyStateSvgPath"
:group-full-path="groupFullPath" :group-full-path="groupFullPath"
:filters="filters"
/> />
<template #aside> <template #aside>
<vulnerability-severity :endpoint="vulnerableProjectsEndpoint" /> <vulnerability-severity :endpoint="vulnerableProjectsEndpoint" />
......
...@@ -26,6 +26,11 @@ export default { ...@@ -26,6 +26,11 @@ export default {
type: String, type: String,
required: true, required: true,
}, },
filters: {
type: Object,
required: false,
default: () => ({}),
},
}, },
data() { data() {
return { return {
...@@ -41,6 +46,7 @@ export default { ...@@ -41,6 +46,7 @@ export default {
return { return {
fullPath: this.groupFullPath, fullPath: this.groupFullPath,
first: VULNERABILITIES_PER_PAGE, first: VULNERABILITIES_PER_PAGE,
...this.filters,
}; };
}, },
update: ({ group }) => group.vulnerabilities.nodes, update: ({ group }) => group.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 group($fullPath: ID!, $after: String, $first: Int) { query group(
$fullPath: ID!,
$after: String,
$first: Int,
$severity: [VulnerabilitySeverity!]
$reportType: [VulnerabilityReportType!]
$state: [VulnerabilityState!]
) {
group(fullPath: $fullPath) { group(fullPath: $fullPath) {
vulnerabilities(after:$after, first:$first){ 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 FirstClassGroupDashboard from 'ee/security_dashboard/components/first_class_group_security_dashboard.vue'; import FirstClassGroupDashboard from 'ee/security_dashboard/components/first_class_group_security_dashboard.vue';
import FirstClassGroupVulnerabilities from 'ee/security_dashboard/components/first_class_group_security_dashboard_vulnerabilities.vue'; import FirstClassGroupVulnerabilities from 'ee/security_dashboard/components/first_class_group_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 Group Dashboard Component', () => { describe('First Class Group Dashboard Component', () => {
let wrapper; let wrapper;
...@@ -14,6 +15,7 @@ describe('First Class Group Dashboard Component', () => { ...@@ -14,6 +15,7 @@ describe('First Class Group Dashboard Component', () => {
const findGroupVulnerabilities = () => wrapper.find(FirstClassGroupVulnerabilities); const findGroupVulnerabilities = () => wrapper.find(FirstClassGroupVulnerabilities);
const findVulnerabilitySeverity = () => wrapper.find(VulnerabilitySeverity); const findVulnerabilitySeverity = () => wrapper.find(VulnerabilitySeverity);
const findFilters = () => wrapper.find(Filters);
const createWrapper = () => { const createWrapper = () => {
return shallowMount(FirstClassGroupDashboard, { return shallowMount(FirstClassGroupDashboard, {
...@@ -42,6 +44,20 @@ describe('First Class Group Dashboard Component', () => { ...@@ -42,6 +44,20 @@ describe('First Class Group Dashboard Component', () => {
dashboardDocumentation, dashboardDocumentation,
emptyStateSvgPath, emptyStateSvgPath,
groupFullPath, groupFullPath,
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(findGroupVulnerabilities().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