Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/boards/stores')
-rw-r--r--app/assets/javascripts/boards/stores/actions.js159
-rw-r--r--app/assets/javascripts/boards/stores/boards_store.js63
-rw-r--r--app/assets/javascripts/boards/stores/getters.js15
-rw-r--r--app/assets/javascripts/boards/stores/mutation_types.js6
-rw-r--r--app/assets/javascripts/boards/stores/mutations.js89
-rw-r--r--app/assets/javascripts/boards/stores/state.js5
6 files changed, 195 insertions, 142 deletions
diff --git a/app/assets/javascripts/boards/stores/actions.js b/app/assets/javascripts/boards/stores/actions.js
index 4b81d9c73ef..1fed1228106 100644
--- a/app/assets/javascripts/boards/stores/actions.js
+++ b/app/assets/javascripts/boards/stores/actions.js
@@ -1,28 +1,38 @@
import Cookies from 'js-cookie';
-import { sortBy, pick } from 'lodash';
-import createFlash from '~/flash';
+import { pick } from 'lodash';
+
+import boardListsQuery from 'ee_else_ce/boards/queries/board_lists.query.graphql';
import { __ } from '~/locale';
import { parseBoolean } from '~/lib/utils/common_utils';
-import createDefaultClient from '~/lib/graphql';
+import createGqClient, { fetchPolicies } from '~/lib/graphql';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
import { BoardType, ListType, inactiveId } from '~/boards/constants';
import * as types from './mutation_types';
-import { formatListIssues, fullBoardId } from '../boards_util';
+import {
+ formatBoardLists,
+ formatListIssues,
+ fullBoardId,
+ formatListsPageInfo,
+} from '../boards_util';
import boardStore from '~/boards/stores/boards_store';
import listsIssuesQuery from '../queries/lists_issues.query.graphql';
-import projectBoardQuery from '../queries/project_board.query.graphql';
-import groupBoardQuery from '../queries/group_board.query.graphql';
import createBoardListMutation from '../queries/board_list_create.mutation.graphql';
import updateBoardListMutation from '../queries/board_list_update.mutation.graphql';
import issueMoveListMutation from '../queries/issue_move_list.mutation.graphql';
+import issueSetLabels from '../queries/issue_set_labels.mutation.graphql';
const notImplemented = () => {
/* eslint-disable-next-line @gitlab/require-i18n-strings */
throw new Error('Not implemented!');
};
-export const gqlClient = createDefaultClient();
+export const gqlClient = createGqClient(
+ {},
+ {
+ fetchPolicy: fetchPolicies.NO_CACHE,
+ },
+);
export default {
setInitialBoardData: ({ commit }, data) => {
@@ -50,62 +60,46 @@ export default {
},
fetchLists: ({ commit, state, dispatch }) => {
- const { endpoints, boardType } = state;
+ const { endpoints, boardType, filterParams } = state;
const { fullPath, boardId } = endpoints;
- let query;
- if (boardType === BoardType.group) {
- query = groupBoardQuery;
- } else if (boardType === BoardType.project) {
- query = projectBoardQuery;
- } else {
- createFlash(__('Invalid board'));
- return Promise.reject();
- }
-
const variables = {
fullPath,
boardId: fullBoardId(boardId),
+ filters: filterParams,
+ isGroup: boardType === BoardType.group,
+ isProject: boardType === BoardType.project,
};
return gqlClient
.query({
- query,
+ query: boardListsQuery,
variables,
})
.then(({ data }) => {
- let { lists } = data[boardType]?.board;
- // Temporarily using positioning logic from boardStore
- lists = lists.nodes.map(list =>
- boardStore.updateListPosition({
- ...list,
- doNotFetchIssues: true,
- }),
- );
- commit(types.RECEIVE_BOARD_LISTS_SUCCESS, sortBy(lists, 'position'));
- // Backlog list needs to be created if it doesn't exist
- if (!lists.find(l => l.type === ListType.backlog)) {
+ const { lists, hideBacklogList } = data[boardType]?.board;
+ commit(types.RECEIVE_BOARD_LISTS_SUCCESS, formatBoardLists(lists));
+ // 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) && !hideBacklogList) {
dispatch('createList', { backlog: true });
}
dispatch('showWelcomeList');
})
- .catch(() => {
- createFlash(
- __('An error occurred while fetching the board lists. Please reload the page.'),
- );
- });
+ .catch(() => commit(types.RECEIVE_BOARD_LISTS_FAILURE));
},
- // This action only supports backlog list creation at this stage
- // Future iterations will add the ability to create other list types
- createList: ({ state, commit, dispatch }, { backlog = false }) => {
+ createList: ({ state, commit, dispatch }, { backlog, labelId, milestoneId, assigneeId }) => {
const { boardId } = state.endpoints;
+
gqlClient
.mutate({
mutation: createBoardListMutation,
variables: {
boardId: fullBoardId(boardId),
backlog,
+ labelId,
+ milestoneId,
+ assigneeId,
},
})
.then(({ data }) => {
@@ -116,16 +110,15 @@ export default {
dispatch('addList', list);
}
})
- .catch(() => {
- commit(types.CREATE_LIST_FAILURE);
- });
+ .catch(() => commit(types.CREATE_LIST_FAILURE));
},
- addList: ({ state, commit }, list) => {
- const lists = state.boardLists;
+ addList: ({ commit }, list) => {
// Temporarily using positioning logic from boardStore
- lists.push(boardStore.updateListPosition({ ...list, doNotFetchIssues: true }));
- commit(types.RECEIVE_BOARD_LISTS_SUCCESS, sortBy(lists, 'position'));
+ commit(
+ types.RECEIVE_ADD_LIST_SUCCESS,
+ boardStore.updateListPosition({ ...list, doNotFetchIssues: true }),
+ );
},
showWelcomeList: ({ state, dispatch }) => {
@@ -133,7 +126,9 @@ export default {
return;
}
if (
- state.boardLists.find(list => list.type !== ListType.backlog && list.type !== ListType.closed)
+ Object.entries(state.boardLists).find(
+ ([, list]) => list.type !== ListType.backlog && list.type !== ListType.closed,
+ )
) {
return;
}
@@ -155,13 +150,16 @@ export default {
notImplemented();
},
- moveList: ({ state, commit, dispatch }, { listId, newIndex, adjustmentValue }) => {
+ moveList: (
+ { state, commit, dispatch },
+ { listId, replacedListId, newIndex, adjustmentValue },
+ ) => {
const { boardLists } = state;
- const backupList = [...boardLists];
- const movedList = boardLists.find(({ id }) => id === listId);
+ const backupList = { ...boardLists };
+ const movedList = boardLists[listId];
const newPosition = newIndex - 1;
- const listAtNewIndex = boardLists[newIndex];
+ const listAtNewIndex = boardLists[replacedListId];
movedList.position = newPosition;
listAtNewIndex.position += adjustmentValue;
@@ -197,7 +195,9 @@ export default {
notImplemented();
},
- fetchIssuesForList: ({ state, commit }, listId) => {
+ fetchIssuesForList: ({ state, commit }, { listId, fetchNext = false }) => {
+ commit(types.REQUEST_ISSUES_FOR_LIST, { listId, fetchNext });
+
const { endpoints, boardType, filterParams } = state;
const { fullPath, boardId } = endpoints;
@@ -208,6 +208,8 @@ export default {
filters: filterParams,
isGroup: boardType === BoardType.group,
isProject: boardType === BoardType.project,
+ first: 20,
+ after: fetchNext ? state.pageInfoByListId[listId].endCursor : undefined,
};
return gqlClient
@@ -221,36 +223,14 @@ export default {
.then(({ data }) => {
const { lists } = data[boardType]?.board;
const listIssues = formatListIssues(lists);
- commit(types.RECEIVE_ISSUES_FOR_LIST_SUCCESS, { listIssues, listId });
+ const listPageInfo = formatListsPageInfo(lists);
+ commit(types.RECEIVE_ISSUES_FOR_LIST_SUCCESS, { listIssues, listPageInfo, listId });
})
.catch(() => commit(types.RECEIVE_ISSUES_FOR_LIST_FAILURE, listId));
},
- fetchIssuesForAllLists: ({ state, commit }) => {
- commit(types.REQUEST_ISSUES_FOR_ALL_LISTS);
-
- const { endpoints, boardType, filterParams } = state;
- const { fullPath, boardId } = endpoints;
-
- const variables = {
- fullPath,
- boardId: fullBoardId(boardId),
- filters: filterParams,
- isGroup: boardType === BoardType.group,
- isProject: boardType === BoardType.project,
- };
-
- return gqlClient
- .query({
- query: listsIssuesQuery,
- variables,
- })
- .then(({ data }) => {
- const { lists } = data[boardType]?.board;
- const listIssues = formatListIssues(lists);
- commit(types.RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS, listIssues);
- })
- .catch(() => commit(types.RECEIVE_ISSUES_FOR_ALL_LISTS_FAILURE));
+ resetIssues: ({ commit }) => {
+ commit(types.RESET_ISSUES);
},
moveIssue: (
@@ -303,6 +283,31 @@ export default {
commit(types.ADD_ISSUE_TO_LIST_FAILURE, { list, issue });
},
+ setActiveIssueLabels: async ({ commit, getters }, input) => {
+ const activeIssue = getters.getActiveIssue;
+ const { data } = await gqlClient.mutate({
+ mutation: issueSetLabels,
+ variables: {
+ input: {
+ iid: String(activeIssue.iid),
+ addLabelIds: input.addLabelIds ?? [],
+ removeLabelIds: input.removeLabelIds ?? [],
+ projectPath: input.projectPath,
+ },
+ },
+ });
+
+ if (data.updateIssue?.errors?.length > 0) {
+ throw new Error(data.updateIssue.errors);
+ }
+
+ commit(types.UPDATE_ISSUE_BY_ID, {
+ issueId: activeIssue.id,
+ prop: 'labels',
+ value: data.updateIssue.issue.labels.nodes,
+ });
+ },
+
fetchBacklog: () => {
notImplemented();
},
diff --git a/app/assets/javascripts/boards/stores/boards_store.js b/app/assets/javascripts/boards/stores/boards_store.js
index faf4f9ebfd3..d1a5db1bcc5 100644
--- a/app/assets/javascripts/boards/stores/boards_store.js
+++ b/app/assets/javascripts/boards/stores/boards_store.js
@@ -2,7 +2,7 @@
/* global List */
/* global ListIssue */
import $ from 'jquery';
-import { sortBy } from 'lodash';
+import { sortBy, pick } from 'lodash';
import Vue from 'vue';
import Cookies from 'js-cookie';
import BoardsStoreEE from 'ee_else_ce/boards/stores/boards_store_ee';
@@ -12,7 +12,7 @@ import {
parseBoolean,
convertObjectPropsToCamelCase,
} from '~/lib/utils/common_utils';
-import { __ } from '~/locale';
+import createDefaultClient from '~/lib/graphql';
import axios from '~/lib/utils/axios_utils';
import { mergeUrlParams } from '~/lib/utils/url_utility';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
@@ -23,7 +23,11 @@ import ListLabel from '../models/label';
import ListAssignee from '../models/assignee';
import ListMilestone from '../models/milestone';
+import createBoardMutation from '../queries/board.mutation.graphql';
+
const PER_PAGE = 20;
+export const gqlClient = createDefaultClient();
+
const boardsStore = {
disabled: false,
timeTracking: {
@@ -114,7 +118,6 @@ const boardsStore = {
.catch(() => {
// https://gitlab.com/gitlab-org/gitlab-foss/issues/30821
});
- this.removeBlankState();
},
updateNewListDropdown(listId) {
$(`.js-board-list-${listId}`).removeClass('is-active');
@@ -124,22 +127,14 @@ const boardsStore = {
return !this.state.lists.filter(list => list.type !== 'backlog' && list.type !== 'closed')[0];
},
addBlankState() {
- if (!this.shouldAddBlankState() || this.welcomeIsHidden() || this.disabled) return;
-
- this.addList({
- id: 'blank',
- list_type: 'blank',
- title: __('Welcome to your Issue Board!'),
- position: 0,
- });
- },
- removeBlankState() {
- this.removeList('blank');
+ if (!this.shouldAddBlankState() || this.welcomeIsHidden()) return;
- Cookies.set('issue_board_welcome_hidden', 'true', {
- expires: 365 * 10,
- path: '',
- });
+ this.generateDefaultLists()
+ .then(res => res.data)
+ .then(data => Promise.all(data.map(list => this.addList(list))))
+ .catch(() => {
+ this.removeList(undefined, 'label');
+ });
},
findIssueLabel(issue, findLabel) {
@@ -542,6 +537,10 @@ const boardsStore = {
this.timeTracking.limitToHours = parseBoolean(limitToHours);
},
+ generateBoardGid(boardId) {
+ return `gid://gitlab/Board/${boardId}`;
+ },
+
generateBoardsPath(id) {
return `${this.state.endpoints.boardsEndpoint}${id ? `/${id}` : ''}.json`;
},
@@ -800,9 +799,33 @@ const boardsStore = {
}
if (boardPayload.id) {
- return axios.put(this.generateBoardsPath(boardPayload.id), { board: boardPayload });
+ const input = {
+ ...pick(boardPayload, ['hideClosedList', 'hideBacklogList']),
+ id: this.generateBoardGid(boardPayload.id),
+ };
+
+ return Promise.all([
+ axios.put(this.generateBoardsPath(boardPayload.id), { board: boardPayload }),
+ gqlClient.mutate({
+ mutation: createBoardMutation,
+ variables: input,
+ }),
+ ]);
}
- return axios.post(this.generateBoardsPath(), { board: boardPayload });
+
+ return axios
+ .post(this.generateBoardsPath(), { board: boardPayload })
+ .then(resp => resp.data)
+ .then(data => {
+ gqlClient.mutate({
+ mutation: createBoardMutation,
+ variables: {
+ ...pick(boardPayload, ['hideClosedList', 'hideBacklogList']),
+ id: this.generateBoardGid(data.id),
+ },
+ });
+ return data;
+ });
},
deleteBoard({ id }) {
diff --git a/app/assets/javascripts/boards/stores/getters.js b/app/assets/javascripts/boards/stores/getters.js
index 3688476dc5f..89a3b14b262 100644
--- a/app/assets/javascripts/boards/stores/getters.js
+++ b/app/assets/javascripts/boards/stores/getters.js
@@ -1,10 +1,11 @@
+import { find } from 'lodash';
import { inactiveId } from '../constants';
export default {
getLabelToggleState: state => (state.isShowingLabels ? 'on' : 'off'),
isSidebarOpen: state => state.activeId !== inactiveId,
isSwimlanesOn: state => {
- if (!gon?.features?.boardsWithSwimlanes) {
+ if (!gon?.features?.boardsWithSwimlanes && !gon?.features?.swimlanes) {
return false;
}
@@ -22,4 +23,16 @@ export default {
getActiveIssue: state => {
return state.issues[state.activeId] || {};
},
+
+ getListByLabelId: state => labelId => {
+ return find(state.boardLists, l => l.label?.id === labelId);
+ },
+
+ getListByTitle: state => title => {
+ return find(state.boardLists, l => l.title === title);
+ },
+
+ shouldUseGraphQL: () => {
+ return gon?.features?.graphqlBoardLists;
+ },
};
diff --git a/app/assets/javascripts/boards/stores/mutation_types.js b/app/assets/javascripts/boards/stores/mutation_types.js
index f0a283f6161..09ab08062df 100644
--- a/app/assets/javascripts/boards/stores/mutation_types.js
+++ b/app/assets/javascripts/boards/stores/mutation_types.js
@@ -3,6 +3,7 @@ export const SET_FILTERS = 'SET_FILTERS';
export const CREATE_LIST_SUCCESS = 'CREATE_LIST_SUCCESS';
export const CREATE_LIST_FAILURE = 'CREATE_LIST_FAILURE';
export const RECEIVE_BOARD_LISTS_SUCCESS = 'RECEIVE_BOARD_LISTS_SUCCESS';
+export const RECEIVE_BOARD_LISTS_FAILURE = 'RECEIVE_BOARD_LISTS_FAILURE';
export const SHOW_PROMOTION_LIST = 'SHOW_PROMOTION_LIST';
export const REQUEST_ADD_LIST = 'REQUEST_ADD_LIST';
export const RECEIVE_ADD_LIST_SUCCESS = 'RECEIVE_ADD_LIST_SUCCESS';
@@ -12,11 +13,9 @@ export const UPDATE_LIST_FAILURE = 'UPDATE_LIST_FAILURE';
export const REQUEST_REMOVE_LIST = 'REQUEST_REMOVE_LIST';
export const RECEIVE_REMOVE_LIST_SUCCESS = 'RECEIVE_REMOVE_LIST_SUCCESS';
export const RECEIVE_REMOVE_LIST_ERROR = 'RECEIVE_REMOVE_LIST_ERROR';
-export const REQUEST_ISSUES_FOR_ALL_LISTS = 'REQUEST_ISSUES_FOR_ALL_LISTS';
+export const REQUEST_ISSUES_FOR_LIST = 'REQUEST_ISSUES_FOR_LIST';
export const RECEIVE_ISSUES_FOR_LIST_FAILURE = 'RECEIVE_ISSUES_FOR_LIST_FAILURE';
export const RECEIVE_ISSUES_FOR_LIST_SUCCESS = 'RECEIVE_ISSUES_FOR_LIST_SUCCESS';
-export const RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS = 'RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS';
-export const RECEIVE_ISSUES_FOR_ALL_LISTS_FAILURE = 'RECEIVE_ISSUES_FOR_ALL_LISTS_FAILURE';
export const REQUEST_ADD_ISSUE = 'REQUEST_ADD_ISSUE';
export const RECEIVE_ADD_ISSUE_SUCCESS = 'RECEIVE_ADD_ISSUE_SUCCESS';
export const RECEIVE_ADD_ISSUE_ERROR = 'RECEIVE_ADD_ISSUE_ERROR';
@@ -32,3 +31,4 @@ export const SET_CURRENT_PAGE = 'SET_CURRENT_PAGE';
export const TOGGLE_EMPTY_STATE = 'TOGGLE_EMPTY_STATE';
export const SET_ACTIVE_ID = 'SET_ACTIVE_ID';
export const UPDATE_ISSUE_BY_ID = 'UPDATE_ISSUE_BY_ID';
+export const RESET_ISSUES = 'RESET_ISSUES';
diff --git a/app/assets/javascripts/boards/stores/mutations.js b/app/assets/javascripts/boards/stores/mutations.js
index faeb3e25a71..0c7dbc0d2ef 100644
--- a/app/assets/javascripts/boards/stores/mutations.js
+++ b/app/assets/javascripts/boards/stores/mutations.js
@@ -1,8 +1,8 @@
import Vue from 'vue';
-import { sortBy, pull } from 'lodash';
+import { pull, union } from 'lodash';
import { formatIssue, moveIssueListHelper } from '../boards_util';
import * as mutationTypes from './mutation_types';
-import { __ } from '~/locale';
+import { s__ } from '~/locale';
import { getIdFromGraphQLId } from '~/graphql_shared/utils';
const notImplemented = () => {
@@ -10,11 +10,13 @@ const notImplemented = () => {
throw new Error('Not implemented!');
};
-const removeIssueFromList = (state, listId, issueId) => {
+export const removeIssueFromList = ({ state, listId, issueId }) => {
Vue.set(state.issuesByListId, listId, pull(state.issuesByListId[listId], issueId));
+ const list = state.boardLists[listId];
+ Vue.set(state.boardLists, listId, { ...list, issuesSize: list.issuesSize - 1 });
};
-const addIssueToList = ({ state, listId, issueId, moveBeforeId, moveAfterId, atIndex }) => {
+export const addIssueToList = ({ state, listId, issueId, moveBeforeId, moveAfterId, atIndex }) => {
const listIssues = state.issuesByListId[listId];
let newIndex = atIndex || 0;
if (moveBeforeId) {
@@ -24,6 +26,8 @@ const addIssueToList = ({ state, listId, issueId, moveBeforeId, moveAfterId, atI
}
listIssues.splice(newIndex, 0, issueId);
Vue.set(state.issuesByListId, listId, listIssues);
+ const list = state.boardLists[listId];
+ Vue.set(state.boardLists, listId, { ...list, issuesSize: list.issuesSize + 1 });
};
export default {
@@ -39,6 +43,12 @@ export default {
state.boardLists = lists;
},
+ [mutationTypes.RECEIVE_BOARD_LISTS_FAILURE]: state => {
+ state.error = s__(
+ 'Boards|An error occurred while fetching the board lists. Please reload the page.',
+ );
+ },
+
[mutationTypes.SET_ACTIVE_ID](state, { id, sidebarType }) {
state.activeId = id;
state.sidebarType = sidebarType;
@@ -49,15 +59,15 @@ export default {
},
[mutationTypes.CREATE_LIST_FAILURE]: state => {
- state.error = __('An error occurred while creating the list. Please try again.');
+ state.error = s__('Boards|An error occurred while creating the list. Please try again.');
},
[mutationTypes.REQUEST_ADD_LIST]: () => {
notImplemented();
},
- [mutationTypes.RECEIVE_ADD_LIST_SUCCESS]: () => {
- notImplemented();
+ [mutationTypes.RECEIVE_ADD_LIST_SUCCESS]: (state, list) => {
+ Vue.set(state.boardLists, list.id, list);
},
[mutationTypes.RECEIVE_ADD_LIST_ERROR]: () => {
@@ -66,14 +76,12 @@ export default {
[mutationTypes.MOVE_LIST]: (state, { movedList, listAtNewIndex }) => {
const { boardLists } = state;
- const movedListIndex = state.boardLists.findIndex(l => l.id === movedList.id);
- Vue.set(boardLists, movedListIndex, movedList);
- Vue.set(boardLists, movedListIndex.position + 1, listAtNewIndex);
- Vue.set(state, 'boardLists', sortBy(boardLists, 'position'));
+ Vue.set(boardLists, movedList.id, movedList);
+ Vue.set(boardLists, listAtNewIndex.id, listAtNewIndex);
},
[mutationTypes.UPDATE_LIST_FAILURE]: (state, backupList) => {
- state.error = __('An error occurred while updating the list. Please try again.');
+ state.error = s__('Boards|An error occurred while updating the list. Please try again.');
Vue.set(state, 'boardLists', backupList);
},
@@ -89,28 +97,36 @@ export default {
notImplemented();
},
- [mutationTypes.RECEIVE_ISSUES_FOR_LIST_SUCCESS]: (state, { listIssues, listId }) => {
+ [mutationTypes.REQUEST_ISSUES_FOR_LIST]: (state, { listId, fetchNext }) => {
+ Vue.set(state.listsFlags, listId, { [fetchNext ? 'isLoadingMore' : 'isLoading']: true });
+ },
+
+ [mutationTypes.RECEIVE_ISSUES_FOR_LIST_SUCCESS]: (
+ state,
+ { listIssues, listPageInfo, listId },
+ ) => {
const { listData, issues } = listIssues;
Vue.set(state, 'issues', { ...state.issues, ...issues });
- Vue.set(state.issuesByListId, listId, listData[listId]);
- const listIndex = state.boardLists.findIndex(l => l.id === listId);
- Vue.set(state.boardLists[listIndex], 'loading', false);
+ Vue.set(
+ state.issuesByListId,
+ listId,
+ union(state.issuesByListId[listId] || [], listData[listId]),
+ );
+ Vue.set(state.pageInfoByListId, listId, listPageInfo[listId]);
+ Vue.set(state.listsFlags, listId, { isLoading: false, isLoadingMore: false });
},
[mutationTypes.RECEIVE_ISSUES_FOR_LIST_FAILURE]: (state, listId) => {
- state.error = __('An error occurred while fetching the board issues. Please reload the page.');
- const listIndex = state.boardLists.findIndex(l => l.id === listId);
- Vue.set(state.boardLists[listIndex], 'loading', false);
- },
-
- [mutationTypes.REQUEST_ISSUES_FOR_ALL_LISTS]: state => {
- state.isLoadingIssues = true;
+ state.error = s__(
+ 'Boards|An error occurred while fetching the board issues. Please reload the page.',
+ );
+ Vue.set(state.listsFlags, listId, { isLoading: false, isLoadingMore: false });
},
- [mutationTypes.RECEIVE_ISSUES_FOR_ALL_LISTS_SUCCESS]: (state, { listData, issues }) => {
- state.issuesByListId = listData;
- state.issues = issues;
- state.isLoadingIssues = false;
+ [mutationTypes.RESET_ISSUES]: state => {
+ Object.keys(state.issuesByListId).forEach(listId => {
+ Vue.set(state.issuesByListId, listId, []);
+ });
},
[mutationTypes.UPDATE_ISSUE_BY_ID]: (state, { issueId, prop, value }) => {
@@ -122,11 +138,6 @@ export default {
Vue.set(state.issues[issueId], prop, value);
},
- [mutationTypes.RECEIVE_ISSUES_FOR_ALL_LISTS_FAILURE]: state => {
- state.error = __('An error occurred while fetching the board issues. Please reload the page.');
- state.isLoadingIssues = false;
- },
-
[mutationTypes.REQUEST_ADD_ISSUE]: () => {
notImplemented();
},
@@ -143,13 +154,13 @@ export default {
state,
{ originalIssue, fromListId, toListId, moveBeforeId, moveAfterId },
) => {
- const fromList = state.boardLists.find(l => l.id === fromListId);
- const toList = state.boardLists.find(l => l.id === toListId);
+ const fromList = state.boardLists[fromListId];
+ const toList = state.boardLists[toListId];
const issue = moveIssueListHelper(originalIssue, fromList, toList);
Vue.set(state.issues, issue.id, issue);
- removeIssueFromList(state, fromListId, issue.id);
+ removeIssueFromList({ state, listId: fromListId, issueId: issue.id });
addIssueToList({ state, listId: toListId, issueId: issue.id, moveBeforeId, moveAfterId });
},
@@ -162,9 +173,9 @@ export default {
state,
{ originalIssue, fromListId, toListId, originalIndex },
) => {
- state.error = __('An error occurred while moving the issue. Please try again.');
+ state.error = s__('Boards|An error occurred while moving the issue. Please try again.');
Vue.set(state.issues, originalIssue.id, originalIssue);
- removeIssueFromList(state, toListId, originalIssue.id);
+ removeIssueFromList({ state, listId: toListId, issueId: originalIssue.id });
addIssueToList({
state,
listId: fromListId,
@@ -193,8 +204,8 @@ export default {
},
[mutationTypes.ADD_ISSUE_TO_LIST_FAILURE]: (state, { list, issue }) => {
- state.error = __('An error occurred while creating the issue. Please try again.');
- removeIssueFromList(state, list.id, issue.id);
+ state.error = s__('Boards|An error occurred while creating the issue. Please try again.');
+ removeIssueFromList({ state, listId: list.id, issueId: issue.id });
},
[mutationTypes.SET_CURRENT_PAGE]: () => {
diff --git a/app/assets/javascripts/boards/stores/state.js b/app/assets/javascripts/boards/stores/state.js
index be937d68c6c..b91c09f8051 100644
--- a/app/assets/javascripts/boards/stores/state.js
+++ b/app/assets/javascripts/boards/stores/state.js
@@ -8,10 +8,11 @@ export default () => ({
isShowingLabels: true,
activeId: inactiveId,
sidebarType: '',
- boardLists: [],
+ boardLists: {},
+ listsFlags: {},
issuesByListId: {},
+ pageInfoByListId: {},
issues: {},
- isLoadingIssues: false,
filterParams: {},
error: undefined,
// TODO: remove after ce/ee split of board_content.vue