Commit 57cdcf33 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '267855-swimlanes-do-not-create-backlog-list-when-hidden-from-config' into 'master'

Boards - Do not create backlog list if hidden [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!45483
parents 68e63ea9 748f5700
/* eslint-disable no-underscore-dangle, class-methods-use-this */ /* eslint-disable class-methods-use-this */
import { __ } from '~/locale'; import { __ } from '~/locale';
import ListLabel from './label'; import ListLabel from './label';
import ListAssignee from './assignee'; import ListAssignee from './assignee';
...@@ -34,7 +34,6 @@ const TYPES = { ...@@ -34,7 +34,6 @@ const TYPES = {
class List { class List {
constructor(obj) { constructor(obj) {
this.id = obj.id; this.id = obj.id;
this._uid = this.guid();
this.position = obj.position; this.position = obj.position;
this.title = (obj.list_type || obj.listType) === 'backlog' ? __('Open') : obj.title; this.title = (obj.list_type || obj.listType) === 'backlog' ? __('Open') : obj.title;
this.type = obj.list_type || obj.listType; this.type = obj.list_type || obj.listType;
......
import Cookies from 'js-cookie'; import Cookies from 'js-cookie';
import { pick } from 'lodash'; import { pick } from 'lodash';
import boardListsQuery from 'ee_else_ce/boards/queries/board_lists.query.graphql';
import { __ } from '~/locale'; import { __ } from '~/locale';
import { parseBoolean } from '~/lib/utils/common_utils'; import { parseBoolean } from '~/lib/utils/common_utils';
import createGqClient, { fetchPolicies } from '~/lib/graphql'; import createGqClient, { fetchPolicies } from '~/lib/graphql';
...@@ -15,7 +17,6 @@ import { ...@@ -15,7 +17,6 @@ import {
import boardStore from '~/boards/stores/boards_store'; import boardStore from '~/boards/stores/boards_store';
import listsIssuesQuery from '../queries/lists_issues.query.graphql'; import listsIssuesQuery from '../queries/lists_issues.query.graphql';
import boardListsQuery from '../queries/board_lists.query.graphql';
import createBoardListMutation from '../queries/board_list_create.mutation.graphql'; import createBoardListMutation from '../queries/board_list_create.mutation.graphql';
import updateBoardListMutation from '../queries/board_list_update.mutation.graphql'; import updateBoardListMutation from '../queries/board_list_update.mutation.graphql';
import issueMoveListMutation from '../queries/issue_move_list.mutation.graphql'; import issueMoveListMutation from '../queries/issue_move_list.mutation.graphql';
...@@ -76,10 +77,10 @@ export default { ...@@ -76,10 +77,10 @@ export default {
variables, variables,
}) })
.then(({ data }) => { .then(({ data }) => {
const { lists } = data[boardType]?.board; const { lists, hideBacklogList } = data[boardType]?.board;
commit(types.RECEIVE_BOARD_LISTS_SUCCESS, formatBoardLists(lists)); commit(types.RECEIVE_BOARD_LISTS_SUCCESS, formatBoardLists(lists));
// Backlog list needs to be created if it doesn't exist // Backlog list needs to be created if it doesn't exist and it's not hidden
if (!lists.nodes.find(l => l.listType === ListType.backlog)) { if (!lists.nodes.find(l => l.listType === ListType.backlog) && !hideBacklogList) {
dispatch('createList', { backlog: true }); dispatch('createList', { backlog: true });
} }
dispatch('showWelcomeList'); dispatch('showWelcomeList');
......
#import "ee_else_ce/boards/queries/board_list.fragment.graphql"
query ListIssues(
$fullPath: ID!
$boardId: ID!
$filters: BoardIssueInput
$isGroup: Boolean = false
$isProject: Boolean = false
) {
group(fullPath: $fullPath) @include(if: $isGroup) {
board(id: $boardId) {
hideBacklogList
lists(issueFilters: $filters) {
nodes {
...BoardListFragment
}
}
}
}
project(fullPath: $fullPath) @include(if: $isProject) {
board(id: $boardId) {
hideBacklogList
lists(issueFilters: $filters) {
nodes {
...BoardListFragment
}
}
}
}
}
...@@ -13,7 +13,7 @@ import actions, { gqlClient } from '~/boards/stores/actions'; ...@@ -13,7 +13,7 @@ import actions, { gqlClient } from '~/boards/stores/actions';
import * as types from '~/boards/stores/mutation_types'; import * as types from '~/boards/stores/mutation_types';
import { inactiveId, ListType } from '~/boards/constants'; import { inactiveId, ListType } from '~/boards/constants';
import issueMoveListMutation from '~/boards/queries/issue_move_list.mutation.graphql'; import issueMoveListMutation from '~/boards/queries/issue_move_list.mutation.graphql';
import { fullBoardId, formatListIssues } from '~/boards/boards_util'; import { fullBoardId, formatListIssues, formatBoardLists } from '~/boards/boards_util';
const expectNotImplemented = action => { const expectNotImplemented = action => {
it('is not implemented', () => { it('is not implemented', () => {
...@@ -78,6 +78,80 @@ describe('setActiveId', () => { ...@@ -78,6 +78,80 @@ describe('setActiveId', () => {
}); });
}); });
describe('fetchLists', () => {
const state = {
endpoints: {
fullPath: 'gitlab-org',
boardId: 1,
},
filterParams: {},
boardType: 'group',
};
let queryResponse = {
data: {
group: {
board: {
hideBacklogList: true,
lists: {
nodes: [mockLists[1]],
},
},
},
},
};
const formattedLists = formatBoardLists(queryResponse.data.group.board.lists);
it('should commit mutations RECEIVE_BOARD_LISTS_SUCCESS on success', done => {
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction(
actions.fetchLists,
{},
state,
[
{
type: types.RECEIVE_BOARD_LISTS_SUCCESS,
payload: formattedLists,
},
],
[{ type: 'showWelcomeList' }],
done,
);
});
it('dispatch createList action when backlog list does not exist and is not hidden', done => {
queryResponse = {
data: {
group: {
board: {
hideBacklogList: false,
lists: {
nodes: [mockLists[1]],
},
},
},
},
};
jest.spyOn(gqlClient, 'query').mockResolvedValue(queryResponse);
testAction(
actions.fetchLists,
{},
state,
[
{
type: types.RECEIVE_BOARD_LISTS_SUCCESS,
payload: formattedLists,
},
],
[{ type: 'createList', payload: { backlog: true } }, { type: 'showWelcomeList' }],
done,
);
});
});
describe('showWelcomeList', () => { describe('showWelcomeList', () => {
it('should dispatch addList action', done => { it('should dispatch addList action', done => {
const state = { const state = {
......
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