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,46 +669,59 @@ describe('setAssignees', () => { ...@@ -666,46 +669,59 @@ describe('setAssignees', () => {
const refPath = `${projectPath}#3`; const refPath = `${projectPath}#3`;
const iid = '1'; const iid = '1';
beforeEach(() => { describe('when succeeds', () => {
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({ beforeEach(() => {
data: { issueSetAssignees: { issue: { assignees: { nodes: [{ ...node }] } } } }, jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
data: { issueSetAssignees: { issue: { assignees: { nodes: [{ ...node }] } } } },
});
}); });
});
it('calls mutate with the correct values', async () => { it('calls mutate with the correct values', async () => {
await actions.setAssignees( await actions.setAssignees(
{ commit: () => {}, getters: { activeIssue: { iid, referencePath: refPath } } }, { commit: () => {}, getters: { activeIssue: { iid, referencePath: refPath } } },
[name], [name],
); );
expect(gqlClient.mutate).toHaveBeenCalledWith({ expect(gqlClient.mutate).toHaveBeenCalledWith({
mutation: updateAssignees, mutation: updateAssignees,
variables: { iid, assigneeUsernames: [name], projectPath }, variables: { iid, assigneeUsernames: [name], projectPath },
});
});
it('calls the correct mutation with the correct values', done => {
testAction(
actions.setAssignees,
{},
{ activeIssue: { iid, referencePath: refPath }, commit: () => {} },
[
{ type: types.SET_ASSIGNEE_LOADING, payload: true },
{
type: 'UPDATE_ISSUE_BY_ID',
payload: { prop: 'assignees', issueId: undefined, value: [node] },
},
{ type: types.SET_ASSIGNEE_LOADING, payload: false },
],
[],
done,
);
}); });
}); });
it('calls the correct mutation with the correct values', done => { describe('when fails', () => {
testAction( beforeEach(() => {
actions.setAssignees, jest.spyOn(gqlClient, 'mutate').mockRejectedValue();
{}, });
{ activeIssue: { iid, referencePath: refPath }, commit: () => {} },
[ it('calls createFlash', async () => {
{ await actions.setAssignees({
type: 'SET_ASSIGNEE_LOADING', commit: () => {},
payload: true, getters: { activeIssue: { iid, referencePath: refPath } },
}, });
{
type: 'UPDATE_ISSUE_BY_ID', expect(createFlash).toHaveBeenCalledWith({
payload: { prop: 'assignees', issueId: undefined, value: [node] }, message: 'An error occurred while updating assignees.',
}, });
{ });
type: 'SET_ASSIGNEE_LOADING',
payload: false,
},
],
[],
done,
);
}); });
}); });
......
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