Commit b5a9fea5 authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch '233017-load-projects-only-once-in-group-security-dashboard' into 'master'

Load project list only during loading the Security Dashboard

See merge request gitlab-org/gitlab!39263
parents 55c3ea37 16bf2c5f
...@@ -4,6 +4,7 @@ import SecurityDashboardLayout from 'ee/security_dashboard/components/security_d ...@@ -4,6 +4,7 @@ import SecurityDashboardLayout from 'ee/security_dashboard/components/security_d
import GroupSecurityVulnerabilities from 'ee/security_dashboard/components/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 Filters from 'ee/security_dashboard/components/first_class_vulnerability_filters.vue';
import CsvExportButton from './csv_export_button.vue'; import CsvExportButton from './csv_export_button.vue';
import vulnerableProjectsQuery from '../graphql/vulnerable_projects.query.graphql';
import DashboardNotConfigured from './empty_states/group_dashboard_not_configured.vue'; import DashboardNotConfigured from './empty_states/group_dashboard_not_configured.vue';
export default { export default {
...@@ -25,6 +26,23 @@ export default { ...@@ -25,6 +26,23 @@ export default {
required: true, required: true,
}, },
}, },
apollo: {
projects: {
query: vulnerableProjectsQuery,
variables() {
return { fullPath: this.groupFullPath };
},
update(data) {
return data.group.projects.nodes;
},
result() {
this.projectsWereFetched = true;
},
error() {
this.projectsWereFetched = false;
},
},
},
data() { data() {
return { return {
filters: {}, filters: {},
...@@ -41,10 +59,6 @@ export default { ...@@ -41,10 +59,6 @@ export default {
handleFilterChange(filters) { handleFilterChange(filters) {
this.filters = filters; this.filters = filters;
}, },
handleProjectsFetch(projects) {
this.projects = projects;
this.projectsWereFetched = true;
},
}, },
}; };
</script> </script>
...@@ -65,11 +79,7 @@ export default { ...@@ -65,11 +79,7 @@ export default {
<template #sticky> <template #sticky>
<filters :projects="projects" @filterChange="handleFilterChange" /> <filters :projects="projects" @filterChange="handleFilterChange" />
</template> </template>
<group-security-vulnerabilities <group-security-vulnerabilities :group-full-path="groupFullPath" :filters="filters" />
:group-full-path="groupFullPath"
:filters="filters"
@projectFetch="handleProjectsFetch"
/>
</security-dashboard-layout> </security-dashboard-layout>
</div> </div>
</template> </template>
...@@ -41,7 +41,6 @@ export default { ...@@ -41,7 +41,6 @@ export default {
}, },
update: ({ group }) => group.vulnerabilities.nodes, update: ({ group }) => group.vulnerabilities.nodes,
result({ data }) { result({ data }) {
this.$emit('projectFetch', data.group.projects.nodes);
this.pageInfo = data.group.vulnerabilities.pageInfo; this.pageInfo = data.group.vulnerabilities.pageInfo;
}, },
error() { error() {
......
#import "~/graphql_shared/fragments/pageInfo.fragment.graphql" #import "~/graphql_shared/fragments/pageInfo.fragment.graphql"
#import "./vulnerability.fragment.graphql" #import "./vulnerability.fragment.graphql"
#import "./project.fragment.graphql"
query group( query group(
$fullPath: ID! $fullPath: ID!
...@@ -13,11 +12,6 @@ query group( ...@@ -13,11 +12,6 @@ query group(
$state: [VulnerabilityState!] $state: [VulnerabilityState!]
) { ) {
group(fullPath: $fullPath) { group(fullPath: $fullPath) {
projects(includeSubgroups: true, hasVulnerabilities: true) {
nodes {
...Project
}
}
vulnerabilities( vulnerabilities(
after: $after after: $after
first: $first first: $first
......
#import "./project.fragment.graphql"
query group($fullPath: ID!) {
group(fullPath: $fullPath) {
projects(includeSubgroups: true, hasVulnerabilities: true) {
nodes {
...Project
}
}
}
}
---
title: Load project list only during loading the Security Dashboard
merge_request: 39263
author:
type: performance
...@@ -64,7 +64,7 @@ describe('First Class Group Dashboard Component', () => { ...@@ -64,7 +64,7 @@ describe('First Class Group Dashboard Component', () => {
describe('when has projects', () => { describe('when has projects', () => {
beforeEach(() => { beforeEach(() => {
wrapper = createWrapper({ wrapper = createWrapper({
data: () => ({ projects: [{ id: 1 }], projectsWereFetched: true }), data: () => ({ projects: [{ id: 1, name: 'GitLab Org' }], projectsWereFetched: true }),
}); });
}); });
...@@ -79,12 +79,9 @@ describe('First Class Group Dashboard Component', () => { ...@@ -79,12 +79,9 @@ describe('First Class Group Dashboard Component', () => {
expect(findFilters().exists()).toBe(true); expect(findFilters().exists()).toBe(true);
}); });
it('responds to the projectFetch event', () => { it('loads projects from data', () => {
const projects = [{ id: 1, name: 'GitLab Org' }]; const projects = [{ id: 1, name: 'GitLab Org' }];
findGroupVulnerabilities().vm.$listeners.projectFetch(projects); expect(findFilters().props('projects')).toEqual(projects);
return wrapper.vm.$nextTick(() => {
expect(findFilters().props('projects')).toEqual(projects);
});
}); });
it('responds to the filterChange event', () => { it('responds to the filterChange event', () => {
......
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