Commit f22c6bcc authored by Coung Ngo's avatar Coung Ngo Committed by Peter Hegman

Remove projects with disabled issues in new issue dropdown

In the group issues page refactor behind feature flag
`vue_issues_list`, the new issue dropdown showed all
projects. The correct behaviour is that it should show only
projects with issues enabled, which this commit fixes.
This logic is tested in `spec/features/groups/issues_spec.rb:121`.

https://gitlab.com/gitlab-org/gitlab/-/issues/322755
parent bb57bbf8
...@@ -71,8 +71,11 @@ export default { ...@@ -71,8 +71,11 @@ export default {
hasSelectedProject() { hasSelectedProject() {
return this.selectedProject.id; return this.selectedProject.id;
}, },
projectsWithIssuesEnabled() {
return this.projects.filter((project) => project.issuesEnabled);
},
showNoSearchResultsText() { showNoSearchResultsText() {
return !this.projects.length && this.search; return !this.projectsWithIssuesEnabled.length && this.search;
}, },
}, },
methods: { methods: {
...@@ -110,7 +113,7 @@ export default { ...@@ -110,7 +113,7 @@ export default {
<gl-loading-icon v-if="$apollo.queries.projects.loading" /> <gl-loading-icon v-if="$apollo.queries.projects.loading" />
<template v-else> <template v-else>
<gl-dropdown-item <gl-dropdown-item
v-for="project of projects" v-for="project of projectsWithIssuesEnabled"
:key="project.id" :key="project.id"
@click="selectProject(project)" @click="selectProject(project)"
> >
......
...@@ -3,6 +3,7 @@ query searchProjects($fullPath: ID!, $search: String) { ...@@ -3,6 +3,7 @@ query searchProjects($fullPath: ID!, $search: String) {
projects(search: $search, includeSubgroups: true) { projects(search: $search, includeSubgroups: true) {
nodes { nodes {
id id
issuesEnabled
name name
nameWithNamespace nameWithNamespace
webUrl webUrl
......
...@@ -8,7 +8,7 @@ import { DASH_SCOPE, joinPaths } from '~/lib/utils/url_utility'; ...@@ -8,7 +8,7 @@ import { DASH_SCOPE, joinPaths } from '~/lib/utils/url_utility';
import { import {
emptySearchProjectsQueryResponse, emptySearchProjectsQueryResponse,
project1, project1,
project2, project3,
searchProjectsQueryResponse, searchProjectsQueryResponse,
} from '../mock_data'; } from '../mock_data';
...@@ -72,7 +72,7 @@ describe('NewIssueDropdown component', () => { ...@@ -72,7 +72,7 @@ describe('NewIssueDropdown component', () => {
expect(inputSpy).toHaveBeenCalledTimes(1); expect(inputSpy).toHaveBeenCalledTimes(1);
}); });
it('renders expected dropdown items', async () => { it('renders projects with issues enabled', async () => {
wrapper = mountComponent({ mountFn: mount }); wrapper = mountComponent({ mountFn: mount });
await showDropdown(); await showDropdown();
...@@ -80,7 +80,7 @@ describe('NewIssueDropdown component', () => { ...@@ -80,7 +80,7 @@ describe('NewIssueDropdown component', () => {
const listItems = wrapper.findAll('li'); const listItems = wrapper.findAll('li');
expect(listItems.at(0).text()).toBe(project1.nameWithNamespace); expect(listItems.at(0).text()).toBe(project1.nameWithNamespace);
expect(listItems.at(1).text()).toBe(project2.nameWithNamespace); expect(listItems.at(1).text()).toBe(project3.nameWithNamespace);
}); });
it('renders `No matches found` when there are no matches', async () => { it('renders `No matches found` when there are no matches', async () => {
......
...@@ -262,6 +262,7 @@ export const urlParamsWithSpecialValues = { ...@@ -262,6 +262,7 @@ export const urlParamsWithSpecialValues = {
export const project1 = { export const project1 = {
id: 'gid://gitlab/Group/26', id: 'gid://gitlab/Group/26',
issuesEnabled: true,
name: 'Super Mario Project', name: 'Super Mario Project',
nameWithNamespace: 'Mushroom Kingdom / Super Mario Project', nameWithNamespace: 'Mushroom Kingdom / Super Mario Project',
webUrl: 'https://127.0.0.1:3000/mushroom-kingdom/super-mario-project', webUrl: 'https://127.0.0.1:3000/mushroom-kingdom/super-mario-project',
...@@ -269,16 +270,25 @@ export const project1 = { ...@@ -269,16 +270,25 @@ export const project1 = {
export const project2 = { export const project2 = {
id: 'gid://gitlab/Group/59', id: 'gid://gitlab/Group/59',
issuesEnabled: false,
name: 'Mario Kart Project', name: 'Mario Kart Project',
nameWithNamespace: 'Mushroom Kingdom / Mario Kart Project', nameWithNamespace: 'Mushroom Kingdom / Mario Kart Project',
webUrl: 'https://127.0.0.1:3000/mushroom-kingdom/mario-kart-project', webUrl: 'https://127.0.0.1:3000/mushroom-kingdom/mario-kart-project',
}; };
export const project3 = {
id: 'gid://gitlab/Group/103',
issuesEnabled: true,
name: 'Mario Party Project',
nameWithNamespace: 'Mushroom Kingdom / Mario Party Project',
webUrl: 'https://127.0.0.1:3000/mushroom-kingdom/mario-party-project',
};
export const searchProjectsQueryResponse = { export const searchProjectsQueryResponse = {
data: { data: {
group: { group: {
projects: { projects: {
nodes: [project1, project2], nodes: [project1, project2, project3],
}, },
}, },
}, },
......
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