Commit 1af360de authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '324283-delete-epic-board-list' into 'master'

Delete epic board list [RUN AS-IF-FOSS]

See merge request gitlab-org/gitlab!60559
parents 269efbd6 b6bbcfe1
......@@ -84,7 +84,7 @@ export default {
return this.list?.label?.description || this.list?.assignee?.name || this.list.title || '';
},
showListHeaderButton() {
return !this.disabled && this.listType !== ListType.closed && !this.isEpicBoard;
return !this.disabled && this.listType !== ListType.closed;
},
showMilestoneListDetails() {
return this.listType === ListType.milestone && this.list.milestone && this.showListDetails;
......
......@@ -29,17 +29,17 @@ export default {
};
},
computed: {
...mapGetters(['isSidebarOpen', 'shouldUseGraphQL']),
...mapGetters(['isSidebarOpen', 'shouldUseGraphQL', 'isEpicBoard']),
...mapState(['activeId', 'sidebarType', 'boardLists']),
isWipLimitsOn() {
return this.glFeatures.wipLimits;
return this.glFeatures.wipLimits && !this.isEpicBoard;
},
activeList() {
/*
Warning: Though a computed property it is not reactive because we are
referencing a List Model class. Reactivity only applies to plain JS objects
*/
if (this.shouldUseGraphQL) {
if (this.shouldUseGraphQL || this.isEpicBoard) {
return this.boardLists[this.activeId];
}
return boardsStore.state.lists.find(({ id }) => id === this.activeId);
......@@ -71,7 +71,7 @@ export default {
deleteBoard() {
// eslint-disable-next-line no-alert
if (window.confirm(__('Are you sure you want to remove this list?'))) {
if (this.shouldUseGraphQL) {
if (this.shouldUseGraphQL || this.isEpicBoard) {
this.removeList(this.activeId);
} else {
this.activeList.destroy();
......
......@@ -2,6 +2,7 @@ import { __ } from '~/locale';
import updateEpicSubscriptionMutation from '~/sidebar/queries/update_epic_subscription.mutation.graphql';
import updateEpicTitleMutation from '~/sidebar/queries/update_epic_title.mutation.graphql';
import boardBlockingIssuesQuery from './graphql/board_blocking_issues.query.graphql';
import destroyBoardListMutation from './graphql/board_list_destroy.mutation.graphql';
import updateBoardListMutation from './graphql/board_list_update.mutation.graphql';
import issueSetSubscriptionMutation from './graphql/issue_set_subscription.mutation.graphql';
import issueSetTitleMutation from './graphql/issue_set_title.mutation.graphql';
......@@ -73,6 +74,12 @@ export const updateListQueries = {
},
};
export const deleteListQueries = {
[issuableTypes.issue]: {
mutation: destroyBoardListMutation,
},
};
export const titleQueries = {
[issuableTypes.issue]: {
mutation: issueSetTitleMutation,
......
......@@ -8,6 +8,7 @@ import {
titleQueries,
subscriptionQueries,
SupportedFilters,
deleteListQueries,
updateListQueries,
} from 'ee_else_ce/boards/constants';
import createBoardListMutation from 'ee_else_ce/boards/graphql/board_list_create.mutation.graphql';
......@@ -31,7 +32,6 @@ import {
getSupportedParams,
} from '../boards_util';
import boardLabelsQuery from '../graphql/board_labels.query.graphql';
import destroyBoardListMutation from '../graphql/board_list_destroy.mutation.graphql';
import groupProjectsQuery from '../graphql/group_projects.query.graphql';
import issueCreateMutation from '../graphql/issue_create.mutation.graphql';
import issueSetDueDateMutation from '../graphql/issue_set_due_date.mutation.graphql';
......@@ -265,14 +265,14 @@ export default {
commit(types.TOGGLE_LIST_COLLAPSED, { listId, collapsed });
},
removeList: ({ state, commit }, listId) => {
const listsBackup = { ...state.boardLists };
removeList: ({ state: { issuableType, boardLists }, commit }, listId) => {
const listsBackup = { ...boardLists };
commit(types.REMOVE_LIST, listId);
return gqlClient
.mutate({
mutation: destroyBoardListMutation,
mutation: deleteListQueries[issuableType].mutation,
variables: {
listId,
},
......
import { issuableTypes } from '~/boards/constants';
import destroyBoardListMutation from '~/boards/graphql/board_list_destroy.mutation.graphql';
import updateBoardListMutation from '~/boards/graphql/board_list_update.mutation.graphql';
import { s__ } from '~/locale';
import destroyEpicBoardListMutation from './graphql/epic_board_list_destroy.mutation.graphql';
import updateEpicBoardListMutation from './graphql/epic_board_list_update.mutation.graphql';
export const DRAGGABLE_TAG = 'div';
......@@ -68,6 +70,15 @@ export const updateListQueries = {
},
};
export const deleteListQueries = {
[issuableTypes.issue]: {
mutation: destroyBoardListMutation,
},
[issuableTypes.epic]: {
mutation: destroyEpicBoardListMutation,
},
};
// re-export some FOSS constants so that lint does not yell
// https://gitlab.com/gitlab-org/gitlab/-/issues/329164
export {
......@@ -82,6 +93,7 @@ export {
} from '~/boards/constants';
export default {
deleteListQueries,
updateListQueries,
DRAGGABLE_TAG,
EpicFilterType,
......
mutation DestroyEpicBoardList($listId: BoardsEpicListID!) {
destroyBoardList: epicBoardListDestroy(input: { listId: $listId }) {
errors
}
}
......@@ -128,6 +128,18 @@ RSpec.describe 'epic boards', :js do
expect(page).to have_selector(selector, text: label.title, count: 1)
end
it 'allows user to delete list from list settings sidebar' do
expect(page).to have_content(label.name)
page.within(find('.board:nth-child(2)')) do
click_button 'List settings'
end
accept_confirm { click_button 'Remove list' }
expect(page).not_to have_content(label.name)
end
end
end
......@@ -189,6 +201,14 @@ RSpec.describe 'epic boards', :js do
end
end
end
it 'does not show Remove list in list settings sidebar' do
page.within(find('.board:nth-child(2)')) do
click_button 'List settings'
end
expect(page).not_to have_button('Remove list')
end
end
context 'filtered search' do
......
......@@ -9,7 +9,7 @@ import {
formatIssue,
getMoveData,
} from '~/boards/boards_util';
import { inactiveId, ISSUABLE, ListType } from '~/boards/constants';
import { inactiveId, ISSUABLE, ListType, issuableTypes } from '~/boards/constants';
import destroyBoardListMutation from '~/boards/graphql/board_list_destroy.mutation.graphql';
import issueCreateMutation from '~/boards/graphql/issue_create.mutation.graphql';
import actions, { gqlClient } from '~/boards/stores/actions';
......@@ -459,7 +459,7 @@ describe('updateList', () => {
boardType: 'group',
disabled: false,
boardLists: [{ type: 'closed' }],
issuableType: 'issue',
issuableType: issuableTypes.issue,
};
testAction(
......@@ -503,6 +503,7 @@ describe('removeList', () => {
beforeEach(() => {
state = {
boardLists: mockListsById,
issuableType: issuableTypes.issue,
};
});
......@@ -1375,7 +1376,7 @@ describe('setActiveItemSubscribed', () => {
[mockActiveIssue.id]: mockActiveIssue,
},
fullPath: 'gitlab-org',
issuableType: 'issue',
issuableType: issuableTypes.issue,
};
const getters = { activeBoardItem: mockActiveIssue, isEpicBoard: false };
const subscribedState = true;
......@@ -1483,7 +1484,7 @@ describe('setActiveIssueMilestone', () => {
describe('setActiveItemTitle', () => {
const state = {
boardItems: { [mockIssue.id]: mockIssue },
issuableType: 'issue',
issuableType: issuableTypes.issue,
fullPath: 'path/f',
};
const getters = { activeBoardItem: mockIssue, isEpicBoard: false };
......
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