Commit 1e4e9c98 authored by Scott Stern's avatar Scott Stern Committed by Nicolò Maria Mezzopera

Add flash error for setAssignees failure

When set assignees fail in group issues board,
we show the createFlash banner
parent 8fae18cd
...@@ -134,7 +134,7 @@ export default { ...@@ -134,7 +134,7 @@ export default {
<template> <template>
<board-editable-item :loading="isSettingAssignees" :title="assigneeText" @close="saveAssignees"> <board-editable-item :loading="isSettingAssignees" :title="assigneeText" @close="saveAssignees">
<template #collapsed> <template #collapsed>
<issuable-assignees :users="selected" @assign-self="assignSelf" /> <issuable-assignees :users="activeIssue.assignees" @assign-self="assignSelf" />
</template> </template>
<template #default> <template #default>
......
...@@ -13,7 +13,8 @@ import { ...@@ -13,7 +13,8 @@ import {
formatIssue, formatIssue,
} from '../boards_util'; } from '../boards_util';
import boardStore from '~/boards/stores/boards_store'; import boardStore from '~/boards/stores/boards_store';
import createFlash from '~/flash';
import { __ } from '~/locale';
import updateAssigneesMutation from '~/vue_shared/components/sidebar/queries/updateAssignees.mutation.graphql'; import updateAssigneesMutation from '~/vue_shared/components/sidebar/queries/updateAssignees.mutation.graphql';
import listsIssuesQuery from '../graphql/lists_issues.query.graphql'; import listsIssuesQuery from '../graphql/lists_issues.query.graphql';
import boardLabelsQuery from '../graphql/board_labels.query.graphql'; import boardLabelsQuery from '../graphql/board_labels.query.graphql';
...@@ -340,6 +341,9 @@ export default { ...@@ -340,6 +341,9 @@ export default {
return nodes; return nodes;
}) })
.catch(() => {
createFlash({ message: __('An error occurred while updating assignees.') });
})
.finally(() => { .finally(() => {
commit(types.SET_ASSIGNEE_LOADING, false); commit(types.SET_ASSIGNEE_LOADING, false);
}); });
......
---
title: Add flash message for setAssignees on group issue boards
merge_request: 48277
author:
type: added
...@@ -3297,6 +3297,9 @@ msgstr "" ...@@ -3297,6 +3297,9 @@ msgstr ""
msgid "An error occurred while updating approvers" msgid "An error occurred while updating approvers"
msgstr "" msgstr ""
msgid "An error occurred while updating assignees."
msgstr ""
msgid "An error occurred while updating configuration." msgid "An error occurred while updating configuration."
msgstr "" msgstr ""
......
...@@ -18,6 +18,9 @@ import issueMoveListMutation from '~/boards/graphql/issue_move_list.mutation.gra ...@@ -18,6 +18,9 @@ import issueMoveListMutation from '~/boards/graphql/issue_move_list.mutation.gra
import destroyBoardListMutation from '~/boards/graphql/board_list_destroy.mutation.graphql'; import destroyBoardListMutation from '~/boards/graphql/board_list_destroy.mutation.graphql';
import updateAssignees from '~/vue_shared/components/sidebar/queries/updateAssignees.mutation.graphql'; import updateAssignees from '~/vue_shared/components/sidebar/queries/updateAssignees.mutation.graphql';
import { fullBoardId, formatListIssues, formatBoardLists } from '~/boards/boards_util'; import { fullBoardId, formatListIssues, formatBoardLists } from '~/boards/boards_util';
import createFlash from '~/flash';
jest.mock('~/flash');
const expectNotImplemented = action => { const expectNotImplemented = action => {
it('is not implemented', () => { it('is not implemented', () => {
...@@ -666,6 +669,7 @@ describe('setAssignees', () => { ...@@ -666,6 +669,7 @@ describe('setAssignees', () => {
const refPath = `${projectPath}#3`; const refPath = `${projectPath}#3`;
const iid = '1'; const iid = '1';
describe('when succeeds', () => {
beforeEach(() => { beforeEach(() => {
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({ jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
data: { issueSetAssignees: { issue: { assignees: { nodes: [{ ...node }] } } } }, data: { issueSetAssignees: { issue: { assignees: { nodes: [{ ...node }] } } } },
...@@ -690,23 +694,35 @@ describe('setAssignees', () => { ...@@ -690,23 +694,35 @@ describe('setAssignees', () => {
{}, {},
{ activeIssue: { iid, referencePath: refPath }, commit: () => {} }, { activeIssue: { iid, referencePath: refPath }, commit: () => {} },
[ [
{ { type: types.SET_ASSIGNEE_LOADING, payload: true },
type: 'SET_ASSIGNEE_LOADING',
payload: true,
},
{ {
type: 'UPDATE_ISSUE_BY_ID', type: 'UPDATE_ISSUE_BY_ID',
payload: { prop: 'assignees', issueId: undefined, value: [node] }, payload: { prop: 'assignees', issueId: undefined, value: [node] },
}, },
{ { type: types.SET_ASSIGNEE_LOADING, payload: false },
type: 'SET_ASSIGNEE_LOADING',
payload: false,
},
], ],
[], [],
done, done,
); );
}); });
});
describe('when fails', () => {
beforeEach(() => {
jest.spyOn(gqlClient, 'mutate').mockRejectedValue();
});
it('calls createFlash', async () => {
await actions.setAssignees({
commit: () => {},
getters: { activeIssue: { iid, referencePath: refPath } },
});
expect(createFlash).toHaveBeenCalledWith({
message: 'An error occurred while updating assignees.',
});
});
});
}); });
describe('createNewIssue', () => { describe('createNewIssue', () => {
......
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