summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/boards/stores
diff options
context:
space:
mode:
Diffstat (limited to 'app/assets/javascripts/boards/stores')
-rw-r--r--app/assets/javascripts/boards/stores/actions.js103
-rw-r--r--app/assets/javascripts/boards/stores/boards_store.js145
-rw-r--r--app/assets/javascripts/boards/stores/getters.js18
-rw-r--r--app/assets/javascripts/boards/stores/modal_store.js10
-rw-r--r--app/assets/javascripts/boards/stores/mutation_types.js4
-rw-r--r--app/assets/javascripts/boards/stores/mutations.js40
-rw-r--r--app/assets/javascripts/boards/stores/state.js8
7 files changed, 207 insertions, 121 deletions
diff --git a/app/assets/javascripts/boards/stores/actions.js b/app/assets/javascripts/boards/stores/actions.js
index 59b97eba9fe..1d34f21798a 100644
--- a/app/assets/javascripts/boards/stores/actions.js
+++ b/app/assets/javascripts/boards/stores/actions.js
@@ -12,6 +12,8 @@ import {
fullBoardId,
formatListsPageInfo,
formatIssue,
+ formatIssueInput,
+ updateListPosition,
} from '../boards_util';
import createFlash from '~/flash';
import { __ } from '~/locale';
@@ -27,6 +29,8 @@ import issueSetLabelsMutation from '../graphql/issue_set_labels.mutation.graphql
import issueSetDueDateMutation from '../graphql/issue_set_due_date.mutation.graphql';
import issueSetSubscriptionMutation from '../graphql/issue_set_subscription.mutation.graphql';
import issueSetMilestoneMutation from '../graphql/issue_set_milestone.mutation.graphql';
+import issueSetTitleMutation from '../graphql/issue_set_title.mutation.graphql';
+import groupProjectsQuery from '../graphql/group_projects.query.graphql';
const notImplemented = () => {
/* eslint-disable-next-line @gitlab/require-i18n-strings */
@@ -78,8 +82,7 @@ export default {
},
fetchLists: ({ commit, state, dispatch }) => {
- const { endpoints, boardType, filterParams } = state;
- const { fullPath, boardId } = endpoints;
+ const { boardType, filterParams, fullPath, boardId } = state;
const variables = {
fullPath,
@@ -98,7 +101,7 @@ export default {
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) {
+ if (!lists.nodes.find((l) => l.listType === ListType.backlog) && !hideBacklogList) {
dispatch('createList', { backlog: true });
}
})
@@ -106,7 +109,7 @@ export default {
},
createList: ({ state, commit, dispatch }, { backlog, labelId, milestoneId, assigneeId }) => {
- const { boardId } = state.endpoints;
+ const { boardId } = state;
gqlClient
.mutate({
@@ -131,12 +134,11 @@ export default {
},
addList: ({ commit }, list) => {
- commit(types.RECEIVE_ADD_LIST_SUCCESS, list);
+ commit(types.RECEIVE_ADD_LIST_SUCCESS, updateListPosition(list));
},
fetchLabels: ({ state, commit }, searchTerm) => {
- const { endpoints, boardType } = state;
- const { fullPath } = endpoints;
+ const { fullPath, boardType } = state;
const variables = {
fullPath,
@@ -214,11 +216,17 @@ export default {
listId,
},
})
- .then(({ data: { destroyBoardList: { errors } } }) => {
- if (errors.length > 0) {
- commit(types.REMOVE_LIST_FAILURE, listsBackup);
- }
- })
+ .then(
+ ({
+ data: {
+ destroyBoardList: { errors },
+ },
+ }) => {
+ if (errors.length > 0) {
+ commit(types.REMOVE_LIST_FAILURE, listsBackup);
+ }
+ },
+ )
.catch(() => {
commit(types.REMOVE_LIST_FAILURE, listsBackup);
});
@@ -227,8 +235,7 @@ export default {
fetchIssuesForList: ({ state, commit }, { listId, fetchNext = false }) => {
commit(types.REQUEST_ISSUES_FOR_LIST, { listId, fetchNext });
- const { endpoints, boardType, filterParams } = state;
- const { fullPath, boardId } = endpoints;
+ const { fullPath, boardId, boardType, filterParams } = state;
const variables = {
fullPath,
@@ -271,7 +278,7 @@ export default {
const originalIndex = fromList.indexOf(Number(issueId));
commit(types.MOVE_ISSUE, { originalIssue, fromListId, toListId, moveBeforeId, moveAfterId });
- const { boardId } = state.endpoints;
+ const { boardId } = state;
const [fullProjectPath] = issuePath.split(/[#]/);
gqlClient
@@ -356,10 +363,13 @@ export default {
},
createNewIssue: ({ commit, state }, issueInput) => {
- const input = issueInput;
- const { boardType, endpoints } = state;
+ const { boardConfig } = state;
+
+ const input = formatIssueInput(issueInput, boardConfig);
+
+ const { boardType, fullPath } = state;
if (boardType === BoardType.project) {
- input.projectPath = endpoints.fullPath;
+ input.projectPath = fullPath;
}
return gqlClient
@@ -387,7 +397,7 @@ export default {
commit(types.ADD_ISSUE_TO_LIST, { list, issue, position: 0 });
dispatch('createNewIssue', issueInput)
- .then(res => {
+ .then((res) => {
commit(types.ADD_ISSUE_TO_LIST, {
list,
issue: formatIssue({ ...res, id: getIdFromGraphQLId(res.id) }),
@@ -469,6 +479,61 @@ export default {
});
},
+ setActiveIssueTitle: async ({ commit, getters }, input) => {
+ const { activeIssue } = getters;
+ const { data } = await gqlClient.mutate({
+ mutation: issueSetTitleMutation,
+ variables: {
+ input: {
+ iid: String(activeIssue.iid),
+ projectPath: input.projectPath,
+ title: input.title,
+ },
+ },
+ });
+
+ if (data.updateIssue?.errors?.length > 0) {
+ throw new Error(data.updateIssue.errors);
+ }
+
+ commit(types.UPDATE_ISSUE_BY_ID, {
+ issueId: activeIssue.id,
+ prop: 'title',
+ value: data.updateIssue.issue.title,
+ });
+ },
+
+ fetchGroupProjects: ({ commit, state }, { search = '', fetchNext = false }) => {
+ commit(types.REQUEST_GROUP_PROJECTS, fetchNext);
+
+ const { fullPath } = state;
+
+ const variables = {
+ fullPath,
+ search: search !== '' ? search : undefined,
+ after: fetchNext ? state.groupProjectsFlags.pageInfo.endCursor : undefined,
+ };
+
+ return gqlClient
+ .query({
+ query: groupProjectsQuery,
+ variables,
+ })
+ .then(({ data }) => {
+ const { projects } = data.group;
+ commit(types.RECEIVE_GROUP_PROJECTS_SUCCESS, {
+ projects: projects.nodes,
+ pageInfo: projects.pageInfo,
+ fetchNext,
+ });
+ })
+ .catch(() => commit(types.RECEIVE_GROUP_PROJECTS_FAILURE));
+ },
+
+ setSelectedProject: ({ commit }, project) => {
+ commit(types.SET_SELECTED_PROJECT, project);
+ },
+
fetchBacklog: () => {
notImplemented();
},
diff --git a/app/assets/javascripts/boards/stores/boards_store.js b/app/assets/javascripts/boards/stores/boards_store.js
index 36702b6ca5f..f59530ddf8f 100644
--- a/app/assets/javascripts/boards/stores/boards_store.js
+++ b/app/assets/javascripts/boards/stores/boards_store.js
@@ -101,7 +101,7 @@ const boardsStore = {
},
new(listObj) {
const list = this.addList(listObj);
- const backlogList = this.findList('type', 'backlog', 'backlog');
+ const backlogList = this.findList('type', 'backlog');
list
.save()
@@ -124,7 +124,7 @@ const boardsStore = {
},
findIssueLabel(issue, findLabel) {
- return issue.labels.find(label => label.id === findLabel.id);
+ return issue.labels.find((label) => label.id === findLabel.id);
},
goToNextPage(list) {
@@ -182,15 +182,15 @@ const boardsStore = {
}
},
findListIssue(list, id) {
- return list.issues.find(issue => issue.id === id);
+ return list.issues.find((issue) => issue.id === id);
},
- removeList(id, type = 'blank') {
- const list = this.findList('id', id, type);
+ removeList(id) {
+ const list = this.findList('id', id);
if (!list) return;
- this.state.lists = this.state.lists.filter(list => list.id !== id);
+ this.state.lists = this.state.lists.filter((list) => list.id !== id);
},
moveList(listFrom, orderLists) {
orderLists.forEach((id, i) => {
@@ -205,7 +205,7 @@ const boardsStore = {
let moveBeforeId = null;
let moveAfterId = null;
- const listHasIssues = issues.every(issue => list.findIssue(issue.id));
+ const listHasIssues = issues.every((issue) => list.findIssue(issue.id));
if (!listHasIssues) {
if (newIndex !== undefined) {
@@ -223,21 +223,21 @@ const boardsStore = {
}
if (list.label) {
- issues.forEach(issue => issue.addLabel(list.label));
+ issues.forEach((issue) => issue.addLabel(list.label));
}
if (list.assignee) {
if (listFrom && listFrom.type === 'assignee') {
- issues.forEach(issue => issue.removeAssignee(listFrom.assignee));
+ issues.forEach((issue) => issue.removeAssignee(listFrom.assignee));
}
- issues.forEach(issue => issue.addAssignee(list.assignee));
+ issues.forEach((issue) => issue.addAssignee(list.assignee));
}
if (IS_EE && list.milestone) {
if (listFrom && listFrom.type === 'milestone') {
- issues.forEach(issue => issue.removeMilestone(listFrom.milestone));
+ issues.forEach((issue) => issue.removeMilestone(listFrom.milestone));
}
- issues.forEach(issue => issue.addMilestone(list.milestone));
+ issues.forEach((issue) => issue.addMilestone(list.milestone));
}
if (listFrom) {
@@ -249,7 +249,7 @@ const boardsStore = {
},
removeListIssues(list, removeIssue) {
- list.issues = list.issues.filter(issue => {
+ list.issues = list.issues.filter((issue) => {
const matchesRemove = removeIssue.id === issue.id;
if (matchesRemove) {
@@ -261,9 +261,9 @@ const boardsStore = {
});
},
removeListMultipleIssues(list, removeIssues) {
- const ids = removeIssues.map(issue => issue.id);
+ const ids = removeIssues.map((issue) => issue.id);
- list.issues = list.issues.filter(issue => {
+ list.issues = list.issues.filter((issue) => {
const matchesRemove = ids.includes(issue.id);
if (matchesRemove) {
@@ -289,9 +289,9 @@ const boardsStore = {
},
moveMultipleIssuesToList({ listFrom, listTo, issues, newIndex }) {
- const issueTo = issues.map(issue => listTo.findIssue(issue.id));
- const issueLists = issues.map(issue => issue.getLists()).flat();
- const listLabels = issueLists.map(list => list.label);
+ const issueTo = issues.map((issue) => listTo.findIssue(issue.id));
+ const issueLists = issues.map((issue) => issue.getLists()).flat();
+ const listLabels = issueLists.map((list) => list.label);
const hasMoveableIssues = issueTo.filter(Boolean).length > 0;
if (!hasMoveableIssues) {
@@ -299,30 +299,30 @@ const boardsStore = {
if (
listTo.type === ListType.assignee &&
listFrom.type === ListType.assignee &&
- issues.some(issue => issue.findAssignee(listTo.assignee))
+ issues.some((issue) => issue.findAssignee(listTo.assignee))
) {
- const targetIssues = issues.map(issue => listTo.findIssue(issue.id));
- targetIssues.forEach(targetIssue => targetIssue.removeAssignee(listFrom.assignee));
+ const targetIssues = issues.map((issue) => listTo.findIssue(issue.id));
+ targetIssues.forEach((targetIssue) => targetIssue.removeAssignee(listFrom.assignee));
} else if (listTo.type === 'milestone') {
- const currentMilestones = issues.map(issue => issue.milestone);
+ const currentMilestones = issues.map((issue) => issue.milestone);
const currentLists = this.state.lists
- .filter(list => list.type === 'milestone' && list.id !== listTo.id)
- .filter(list =>
- list.issues.some(listIssue => issues.some(issue => listIssue.id === issue.id)),
+ .filter((list) => list.type === 'milestone' && list.id !== listTo.id)
+ .filter((list) =>
+ list.issues.some((listIssue) => issues.some((issue) => listIssue.id === issue.id)),
);
- issues.forEach(issue => {
- currentMilestones.forEach(milestone => {
+ issues.forEach((issue) => {
+ currentMilestones.forEach((milestone) => {
issue.removeMilestone(milestone);
});
});
- issues.forEach(issue => {
+ issues.forEach((issue) => {
issue.addMilestone(listTo.milestone);
});
- currentLists.forEach(currentList => {
- issues.forEach(issue => {
+ currentLists.forEach((currentList) => {
+ issues.forEach((issue) => {
currentList.removeIssue(issue);
});
});
@@ -334,36 +334,36 @@ const boardsStore = {
}
} else {
listTo.updateMultipleIssues(issues, listFrom);
- issues.forEach(issue => {
+ issues.forEach((issue) => {
issue.removeLabel(listFrom.label);
});
}
if (listTo.type === ListType.closed && listFrom.type !== ListType.backlog) {
- issueLists.forEach(list => {
- issues.forEach(issue => {
+ issueLists.forEach((list) => {
+ issues.forEach((issue) => {
list.removeIssue(issue);
});
});
- issues.forEach(issue => {
+ issues.forEach((issue) => {
issue.removeLabels(listLabels);
});
} else if (listTo.type === ListType.backlog && listFrom.type === ListType.assignee) {
- issues.forEach(issue => {
+ issues.forEach((issue) => {
issue.removeAssignee(listFrom.assignee);
});
- issueLists.forEach(list => {
- issues.forEach(issue => {
+ issueLists.forEach((list) => {
+ issues.forEach((issue) => {
list.removeIssue(issue);
});
});
} else if (listTo.type === ListType.backlog && listFrom.type === ListType.milestone) {
- issues.forEach(issue => {
+ issues.forEach((issue) => {
issue.removeMilestone(listFrom.milestone);
});
- issueLists.forEach(list => {
- issues.forEach(issue => {
+ issueLists.forEach((list) => {
+ issues.forEach((issue) => {
list.removeIssue(issue);
});
});
@@ -380,8 +380,8 @@ const boardsStore = {
if (issues.length === 1) return true;
// Create list of ids for issues involved.
- const listIssueIds = list.issues.map(issue => issue.id);
- const movedIssueIds = issues.map(issue => issue.id);
+ const listIssueIds = list.issues.map((issue) => issue.id);
+ const movedIssueIds = issues.map((issue) => issue.id);
// Check if moved issue IDs is sub-array
// of source list issue IDs (i.e. contiguous selection).
@@ -391,7 +391,7 @@ const boardsStore = {
moveIssueToList(listFrom, listTo, issue, newIndex) {
const issueTo = listTo.findIssue(issue.id);
const issueLists = issue.getLists();
- const listLabels = issueLists.map(listIssue => listIssue.label);
+ const listLabels = issueLists.map((listIssue) => listIssue.label);
if (!issueTo) {
// Check if target list assignee is already present in this issue
@@ -405,12 +405,12 @@ const boardsStore = {
} else if (listTo.type === 'milestone') {
const currentMilestone = issue.milestone;
const currentLists = this.state.lists
- .filter(list => list.type === 'milestone' && list.id !== listTo.id)
- .filter(list => list.issues.some(listIssue => issue.id === listIssue.id));
+ .filter((list) => list.type === 'milestone' && list.id !== listTo.id)
+ .filter((list) => list.issues.some((listIssue) => issue.id === listIssue.id));
issue.removeMilestone(currentMilestone);
issue.addMilestone(listTo.milestone);
- currentLists.forEach(currentList => currentList.removeIssue(issue));
+ currentLists.forEach((currentList) => currentList.removeIssue(issue));
listTo.addIssue(issue, listFrom, newIndex);
} else {
// Add to new lists issues if it doesn't already exist
@@ -422,7 +422,7 @@ const boardsStore = {
}
if (listTo.type === 'closed' && listFrom.type !== 'backlog') {
- issueLists.forEach(list => {
+ issueLists.forEach((list) => {
list.removeIssue(issue);
});
issue.removeLabels(listLabels);
@@ -461,18 +461,11 @@ const boardsStore = {
moveAfterId: afterId,
});
},
- findList(key, val, type = 'label') {
- const filteredList = this.state.lists.filter(list => {
- const byType = type
- ? list.type === type || list.type === 'assignee' || list.type === 'milestone'
- : true;
-
- return list[key] === val && byType;
- });
- return filteredList[0];
+ findList(key, val) {
+ return this.state.lists.find((list) => list[key] === val);
},
findListByLabelId(id) {
- return this.state.lists.find(list => list.type === 'label' && list.label.id === id);
+ return this.state.lists.find((list) => list.type === 'label' && list.label.id === id);
},
toggleFilter(filter) {
@@ -589,8 +582,8 @@ const boardsStore = {
}
return this.createList(entity.id, entityType)
- .then(res => res.data)
- .then(data => {
+ .then((res) => res.data)
+ .then((data) => {
list.id = data.id;
list.type = data.list_type;
list.position = data.position;
@@ -607,7 +600,7 @@ const boardsStore = {
};
if (list.label && data.label_name) {
- data.label_name = data.label_name.filter(label => label !== list.label.title);
+ data.label_name = data.label_name.filter((label) => label !== list.label.title);
}
if (emptyIssues) {
@@ -615,8 +608,8 @@ const boardsStore = {
}
return this.getIssuesForList(list.id, data)
- .then(res => res.data)
- .then(data => {
+ .then((res) => res.data)
+ .then((data) => {
list.loading = false;
list.issuesSize = data.size;
@@ -624,7 +617,7 @@ const boardsStore = {
list.issues = [];
}
- data.issues.forEach(issueObj => {
+ data.issues.forEach((issueObj) => {
list.addIssue(new ListIssue(issueObj));
});
@@ -634,7 +627,7 @@ const boardsStore = {
getIssuesForList(id, filter = {}) {
const data = { id };
- Object.keys(filter).forEach(key => {
+ Object.keys(filter).forEach((key) => {
data[key] = filter[key];
});
@@ -670,13 +663,13 @@ const boardsStore = {
},
moveListMultipleIssues({ list, issues, oldIndicies, newIndex, moveBeforeId, moveAfterId }) {
- oldIndicies.reverse().forEach(index => {
+ oldIndicies.reverse().forEach((index) => {
list.issues.splice(index, 1);
});
list.issues.splice(newIndex, 0, ...issues);
return this.moveMultipleIssues({
- ids: issues.map(issue => issue.id),
+ ids: issues.map((issue) => issue.id),
fromListId: null,
toListId: null,
moveBeforeId,
@@ -703,8 +696,8 @@ const boardsStore = {
}
return this.newIssue(list.id, issue)
- .then(res => res.data)
- .then(data => list.onNewIssueResponse(issue, data));
+ .then((res) => res.data)
+ .then((data) => list.onNewIssueResponse(issue, data));
},
getBacklog(data) {
@@ -717,7 +710,7 @@ const boardsStore = {
},
removeIssueLabel(issue, removeLabel) {
if (removeLabel) {
- issue.labels = issue.labels.filter(label => removeLabel.id !== label.id);
+ issue.labels = issue.labels.filter((label) => removeLabel.id !== label.id);
}
},
@@ -753,16 +746,12 @@ const boardsStore = {
return axios.get(this.state.endpoints.recentBoardsEndpoint);
},
- deleteBoard({ id }) {
- return axios.delete(this.generateBoardsPath(id));
- },
-
setCurrentBoard(board) {
this.state.currentBoard = board;
},
toggleMultiSelect(issue) {
- const selectedIssueIds = this.multiSelect.list.map(issue => issue.id);
+ const selectedIssueIds = this.multiSelect.list.map((issue) => issue.id);
const index = selectedIssueIds.indexOf(issue.id);
if (index === -1) {
@@ -777,12 +766,12 @@ const boardsStore = {
},
removeIssueAssignee(issue, removeAssignee) {
if (removeAssignee) {
- issue.assignees = issue.assignees.filter(assignee => assignee.id !== removeAssignee.id);
+ issue.assignees = issue.assignees.filter((assignee) => assignee.id !== removeAssignee.id);
}
},
findIssueAssignee(issue, findAssignee) {
- return issue.assignees.find(assignee => assignee.id === findAssignee.id);
+ return issue.assignees.find((assignee) => assignee.id === findAssignee.id);
},
clearMultiSelect() {
@@ -837,11 +826,11 @@ const boardsStore = {
}
if (obj.labels) {
- issue.labels = obj.labels.map(label => new ListLabel(label));
+ issue.labels = obj.labels.map((label) => new ListLabel(label));
}
if (obj.assignees) {
- issue.assignees = obj.assignees.map(a => new ListAssignee(a));
+ issue.assignees = obj.assignees.map((a) => new ListAssignee(a));
}
},
addIssueLabel(issue, label) {
diff --git a/app/assets/javascripts/boards/stores/getters.js b/app/assets/javascripts/boards/stores/getters.js
index ca6887b6f45..d72b5c6fb8e 100644
--- a/app/assets/javascripts/boards/stores/getters.js
+++ b/app/assets/javascripts/boards/stores/getters.js
@@ -2,18 +2,18 @@ import { find } from 'lodash';
import { inactiveId } from '../constants';
export default {
- isSidebarOpen: state => state.activeId !== inactiveId,
+ isSidebarOpen: (state) => state.activeId !== inactiveId,
isSwimlanesOn: () => false,
- getIssueById: state => id => {
+ getIssueById: (state) => (id) => {
return state.issues[id] || {};
},
- getIssuesByList: (state, getters) => listId => {
+ getIssuesByList: (state, getters) => (listId) => {
const listIssueIds = state.issuesByListId[listId] || [];
- return listIssueIds.map(id => getters.getIssueById(id));
+ return listIssueIds.map((id) => getters.getIssueById(id));
},
- activeIssue: state => {
+ activeIssue: (state) => {
return state.issues[state.activeId] || {};
},
@@ -22,12 +22,12 @@ export default {
return referencePath.slice(0, referencePath.indexOf('#'));
},
- getListByLabelId: state => labelId => {
- return find(state.boardLists, l => l.label?.id === labelId);
+ getListByLabelId: (state) => (labelId) => {
+ return find(state.boardLists, (l) => l.label?.id === labelId);
},
- getListByTitle: state => title => {
- return find(state.boardLists, l => l.title === title);
+ getListByTitle: (state) => (title) => {
+ return find(state.boardLists, (l) => l.title === title);
},
shouldUseGraphQL: () => {
diff --git a/app/assets/javascripts/boards/stores/modal_store.js b/app/assets/javascripts/boards/stores/modal_store.js
index b7228bf7bf5..8a8fa61361c 100644
--- a/app/assets/javascripts/boards/stores/modal_store.js
+++ b/app/assets/javascripts/boards/stores/modal_store.js
@@ -40,7 +40,7 @@ class ModalStore {
toggleAll() {
const select = this.selectedCount() !== this.store.issues.length;
- this.store.issues.forEach(issue => {
+ this.store.issues.forEach((issue) => {
const issueUpdate = issue;
if (issueUpdate.selected !== select) {
@@ -56,7 +56,7 @@ class ModalStore {
}
getSelectedIssues() {
- return this.store.selectedIssues.filter(issue => issue.selected);
+ return this.store.selectedIssues.filter((issue) => issue.selected);
}
addSelectedIssue(issue) {
@@ -70,13 +70,13 @@ class ModalStore {
removeSelectedIssue(issue, forcePurge = false) {
if (this.store.activeTab === 'all' || forcePurge) {
this.store.selectedIssues = this.store.selectedIssues.filter(
- fIssue => fIssue.id !== issue.id,
+ (fIssue) => fIssue.id !== issue.id,
);
}
}
purgeUnselectedIssues() {
- this.store.selectedIssues.forEach(issue => {
+ this.store.selectedIssues.forEach((issue) => {
if (!issue.selected) {
this.removeSelectedIssue(issue, true);
}
@@ -88,7 +88,7 @@ class ModalStore {
}
findSelectedIssue(issue) {
- return this.store.selectedIssues.filter(filteredIssue => filteredIssue.id === issue.id)[0];
+ return this.store.selectedIssues.filter((filteredIssue) => filteredIssue.id === issue.id)[0];
}
}
diff --git a/app/assets/javascripts/boards/stores/mutation_types.js b/app/assets/javascripts/boards/stores/mutation_types.js
index 2b2c2bee51c..4697f39498a 100644
--- a/app/assets/javascripts/boards/stores/mutation_types.js
+++ b/app/assets/javascripts/boards/stores/mutation_types.js
@@ -36,3 +36,7 @@ export const SET_ACTIVE_ID = 'SET_ACTIVE_ID';
export const UPDATE_ISSUE_BY_ID = 'UPDATE_ISSUE_BY_ID';
export const SET_ASSIGNEE_LOADING = 'SET_ASSIGNEE_LOADING';
export const RESET_ISSUES = 'RESET_ISSUES';
+export const REQUEST_GROUP_PROJECTS = 'REQUEST_GROUP_PROJECTS';
+export const RECEIVE_GROUP_PROJECTS_SUCCESS = 'RECEIVE_GROUP_PROJECTS_SUCCESS';
+export const RECEIVE_GROUP_PROJECTS_FAILURE = 'RECEIVE_GROUP_PROJECTS_FAILURE';
+export const SET_SELECTED_PROJECT = 'SET_SELECTED_PROJECT';
diff --git a/app/assets/javascripts/boards/stores/mutations.js b/app/assets/javascripts/boards/stores/mutations.js
index 8c4e514710f..6c79b22d308 100644
--- a/app/assets/javascripts/boards/stores/mutations.js
+++ b/app/assets/javascripts/boards/stores/mutations.js
@@ -32,8 +32,9 @@ export const addIssueToList = ({ state, listId, issueId, moveBeforeId, moveAfter
export default {
[mutationTypes.SET_INITIAL_BOARD_DATA](state, data) {
- const { boardType, disabled, boardConfig, ...endpoints } = data;
- state.endpoints = endpoints;
+ const { boardType, disabled, boardId, fullPath, boardConfig } = data;
+ state.boardId = boardId;
+ state.fullPath = fullPath;
state.boardType = boardType;
state.disabled = disabled;
state.boardConfig = boardConfig;
@@ -43,7 +44,7 @@ export default {
state.boardLists = lists;
},
- [mutationTypes.RECEIVE_BOARD_LISTS_FAILURE]: state => {
+ [mutationTypes.RECEIVE_BOARD_LISTS_FAILURE]: (state) => {
state.error = s__(
'Boards|An error occurred while fetching the board lists. Please reload the page.',
);
@@ -58,15 +59,15 @@ export default {
state.filterParams = filterParams;
},
- [mutationTypes.CREATE_LIST_FAILURE]: state => {
+ [mutationTypes.CREATE_LIST_FAILURE]: (state) => {
state.error = s__('Boards|An error occurred while creating the list. Please try again.');
},
- [mutationTypes.RECEIVE_LABELS_FAILURE]: state => {
+ [mutationTypes.RECEIVE_LABELS_FAILURE]: (state) => {
state.error = s__('Boards|An error occurred while fetching labels. Please reload the page.');
},
- [mutationTypes.GENERATE_DEFAULT_LISTS_FAILURE]: state => {
+ [mutationTypes.GENERATE_DEFAULT_LISTS_FAILURE]: (state) => {
state.error = s__('Boards|An error occurred while generating lists. Please reload the page.');
},
@@ -128,8 +129,8 @@ export default {
Vue.set(state.listsFlags, listId, { isLoading: false, isLoadingMore: false });
},
- [mutationTypes.RESET_ISSUES]: state => {
- Object.keys(state.issuesByListId).forEach(listId => {
+ [mutationTypes.RESET_ISSUES]: (state) => {
+ Object.keys(state.issuesByListId).forEach((listId) => {
Vue.set(state.issuesByListId, listId, []);
});
},
@@ -205,7 +206,7 @@ export default {
notImplemented();
},
- [mutationTypes.CREATE_ISSUE_FAILURE]: state => {
+ [mutationTypes.CREATE_ISSUE_FAILURE]: (state) => {
state.error = s__('Boards|An error occurred while creating the issue. Please try again.');
},
@@ -236,4 +237,25 @@ export default {
[mutationTypes.TOGGLE_EMPTY_STATE]: () => {
notImplemented();
},
+
+ [mutationTypes.REQUEST_GROUP_PROJECTS]: (state, fetchNext) => {
+ Vue.set(state, 'groupProjectsFlags', {
+ [fetchNext ? 'isLoadingMore' : 'isLoading']: true,
+ pageInfo: state.groupProjectsFlags.pageInfo,
+ });
+ },
+
+ [mutationTypes.RECEIVE_GROUP_PROJECTS_SUCCESS]: (state, { projects, pageInfo, fetchNext }) => {
+ Vue.set(state, 'groupProjects', fetchNext ? [...state.groupProjects, ...projects] : projects);
+ Vue.set(state, 'groupProjectsFlags', { isLoading: false, isLoadingMore: false, pageInfo });
+ },
+
+ [mutationTypes.RECEIVE_GROUP_PROJECTS_FAILURE]: (state) => {
+ state.error = s__('Boards|An error occurred while fetching group projects. Please try again.');
+ Vue.set(state, 'groupProjectsFlags', { isLoading: false, isLoadingMore: false });
+ },
+
+ [mutationTypes.SET_SELECTED_PROJECT]: (state, project) => {
+ state.selectedProject = project;
+ },
};
diff --git a/app/assets/javascripts/boards/stores/state.js b/app/assets/javascripts/boards/stores/state.js
index 573e98e56e0..aba7da373cf 100644
--- a/app/assets/javascripts/boards/stores/state.js
+++ b/app/assets/javascripts/boards/stores/state.js
@@ -1,7 +1,6 @@
import { inactiveId } from '~/boards/constants';
export default () => ({
- endpoints: {},
boardType: null,
disabled: false,
isShowingLabels: true,
@@ -15,6 +14,13 @@ export default () => ({
issues: {},
filterParams: {},
boardConfig: {},
+ groupProjects: [],
+ groupProjectsFlags: {
+ isLoading: false,
+ isLoadingMore: false,
+ pageInfo: {},
+ },
+ selectedProject: {},
error: undefined,
// TODO: remove after ce/ee split of board_content.vue
isShowingEpicsSwimlanes: false,