Commit 354c8f01 authored by Florie Guibert's avatar Florie Guibert

Delete epic board list

Allow user to delete epic board list for list settings sidebar
parent 4ac79201
...@@ -84,7 +84,7 @@ export default { ...@@ -84,7 +84,7 @@ export default {
return this.list?.label?.description || this.list?.assignee?.name || this.list.title || ''; return this.list?.label?.description || this.list?.assignee?.name || this.list.title || '';
}, },
showListHeaderButton() { showListHeaderButton() {
return !this.disabled && this.listType !== ListType.closed && !this.isEpicBoard; return !this.disabled && this.listType !== ListType.closed;
}, },
showMilestoneListDetails() { showMilestoneListDetails() {
return this.listType === ListType.milestone && this.list.milestone && this.showListDetails; return this.listType === ListType.milestone && this.list.milestone && this.showListDetails;
......
...@@ -29,17 +29,17 @@ export default { ...@@ -29,17 +29,17 @@ export default {
}; };
}, },
computed: { computed: {
...mapGetters(['isSidebarOpen', 'shouldUseGraphQL']), ...mapGetters(['isSidebarOpen', 'shouldUseGraphQL', 'isEpicBoard']),
...mapState(['activeId', 'sidebarType', 'boardLists']), ...mapState(['activeId', 'sidebarType', 'boardLists']),
isWipLimitsOn() { isWipLimitsOn() {
return this.glFeatures.wipLimits; return this.glFeatures.wipLimits && !this.isEpicBoard;
}, },
activeList() { activeList() {
/* /*
Warning: Though a computed property it is not reactive because we are Warning: Though a computed property it is not reactive because we are
referencing a List Model class. Reactivity only applies to plain JS objects 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 this.boardLists[this.activeId];
} }
return boardsStore.state.lists.find(({ id }) => id === this.activeId); return boardsStore.state.lists.find(({ id }) => id === this.activeId);
...@@ -71,7 +71,7 @@ export default { ...@@ -71,7 +71,7 @@ export default {
deleteBoard() { deleteBoard() {
// eslint-disable-next-line no-alert // eslint-disable-next-line no-alert
if (window.confirm(__('Are you sure you want to remove this list?'))) { if (window.confirm(__('Are you sure you want to remove this list?'))) {
if (this.shouldUseGraphQL) { if (this.shouldUseGraphQL || this.isEpicBoard) {
this.removeList(this.activeId); this.removeList(this.activeId);
} else { } else {
this.activeList.destroy(); this.activeList.destroy();
......
...@@ -2,6 +2,7 @@ import { __ } from '~/locale'; ...@@ -2,6 +2,7 @@ import { __ } from '~/locale';
import updateEpicSubscriptionMutation from '~/sidebar/queries/update_epic_subscription.mutation.graphql'; import updateEpicSubscriptionMutation from '~/sidebar/queries/update_epic_subscription.mutation.graphql';
import updateEpicTitleMutation from '~/sidebar/queries/update_epic_title.mutation.graphql'; import updateEpicTitleMutation from '~/sidebar/queries/update_epic_title.mutation.graphql';
import boardBlockingIssuesQuery from './graphql/board_blocking_issues.query.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 updateBoardListMutation from './graphql/board_list_update.mutation.graphql';
import issueSetSubscriptionMutation from './graphql/issue_set_subscription.mutation.graphql'; import issueSetSubscriptionMutation from './graphql/issue_set_subscription.mutation.graphql';
import issueSetTitleMutation from './graphql/issue_set_title.mutation.graphql'; import issueSetTitleMutation from './graphql/issue_set_title.mutation.graphql';
...@@ -73,6 +74,12 @@ export const updateListQueries = { ...@@ -73,6 +74,12 @@ export const updateListQueries = {
}, },
}; };
export const deleteListQueries = {
[issuableTypes.issue]: {
mutation: destroyBoardListMutation,
},
};
export const titleQueries = { export const titleQueries = {
[issuableTypes.issue]: { [issuableTypes.issue]: {
mutation: issueSetTitleMutation, mutation: issueSetTitleMutation,
......
...@@ -8,6 +8,7 @@ import { ...@@ -8,6 +8,7 @@ import {
titleQueries, titleQueries,
subscriptionQueries, subscriptionQueries,
SupportedFilters, SupportedFilters,
deleteListQueries,
updateListQueries, updateListQueries,
} from 'ee_else_ce/boards/constants'; } from 'ee_else_ce/boards/constants';
import createBoardListMutation from 'ee_else_ce/boards/graphql/board_list_create.mutation.graphql'; import createBoardListMutation from 'ee_else_ce/boards/graphql/board_list_create.mutation.graphql';
...@@ -31,7 +32,6 @@ import { ...@@ -31,7 +32,6 @@ import {
getSupportedParams, getSupportedParams,
} from '../boards_util'; } from '../boards_util';
import boardLabelsQuery from '../graphql/board_labels.query.graphql'; 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 groupProjectsQuery from '../graphql/group_projects.query.graphql';
import issueCreateMutation from '../graphql/issue_create.mutation.graphql'; import issueCreateMutation from '../graphql/issue_create.mutation.graphql';
import issueSetDueDateMutation from '../graphql/issue_set_due_date.mutation.graphql'; import issueSetDueDateMutation from '../graphql/issue_set_due_date.mutation.graphql';
...@@ -266,13 +266,14 @@ export default { ...@@ -266,13 +266,14 @@ export default {
}, },
removeList: ({ state, commit }, listId) => { removeList: ({ state, commit }, listId) => {
const { issuableType } = state;
const listsBackup = { ...state.boardLists }; const listsBackup = { ...state.boardLists };
commit(types.REMOVE_LIST, listId); commit(types.REMOVE_LIST, listId);
return gqlClient return gqlClient
.mutate({ .mutate({
mutation: destroyBoardListMutation, mutation: deleteListQueries[issuableType].mutation,
variables: { variables: {
listId, listId,
}, },
......
import { issuableTypes } from '~/boards/constants'; 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 updateBoardListMutation from '~/boards/graphql/board_list_update.mutation.graphql';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import destroyEpicBoardListMutation from './graphql/epic_board_list_destroy.mutation.graphql';
import updateEpicBoardListMutation from './graphql/epic_board_list_update.mutation.graphql'; import updateEpicBoardListMutation from './graphql/epic_board_list_update.mutation.graphql';
export const DRAGGABLE_TAG = 'div'; export const DRAGGABLE_TAG = 'div';
...@@ -68,6 +70,15 @@ export const updateListQueries = { ...@@ -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 // re-export some FOSS constants so that lint does not yell
// https://gitlab.com/gitlab-org/gitlab/-/issues/329164 // https://gitlab.com/gitlab-org/gitlab/-/issues/329164
export { export {
...@@ -82,6 +93,7 @@ export { ...@@ -82,6 +93,7 @@ export {
} from '~/boards/constants'; } from '~/boards/constants';
export default { export default {
deleteListQueries,
updateListQueries, updateListQueries,
DRAGGABLE_TAG, DRAGGABLE_TAG,
EpicFilterType, EpicFilterType,
......
mutation DestroyEpicBoardList($listId: BoardsEpicListID!) {
destroyBoardList: epicBoardListDestroy(input: { listId: $listId }) {
errors
}
}
...@@ -128,6 +128,18 @@ RSpec.describe 'epic boards', :js do ...@@ -128,6 +128,18 @@ RSpec.describe 'epic boards', :js do
expect(page).to have_selector(selector, text: label.title, count: 1) expect(page).to have_selector(selector, text: label.title, count: 1)
end 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
end end
...@@ -189,6 +201,14 @@ RSpec.describe 'epic boards', :js do ...@@ -189,6 +201,14 @@ RSpec.describe 'epic boards', :js do
end end
end 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 end
context 'filtered search' do context 'filtered search' do
......
...@@ -503,6 +503,7 @@ describe('removeList', () => { ...@@ -503,6 +503,7 @@ describe('removeList', () => {
beforeEach(() => { beforeEach(() => {
state = { state = {
boardLists: mockListsById, boardLists: mockListsById,
issuableType: 'issue',
}; };
}); });
......
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