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 {
<template>
<board-editable-item :loading="isSettingAssignees" :title="assigneeText" @close="saveAssignees">
<template #collapsed>
<issuable-assignees :users="selected" @assign-self="assignSelf" />
<issuable-assignees :users="activeIssue.assignees" @assign-self="assignSelf" />
</template>
<template #default>
......
......@@ -13,7 +13,8 @@ import {
formatIssue,
} from '../boards_util';
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 listsIssuesQuery from '../graphql/lists_issues.query.graphql';
import boardLabelsQuery from '../graphql/board_labels.query.graphql';
......@@ -340,6 +341,9 @@ export default {
return nodes;
})
.catch(() => {
createFlash({ message: __('An error occurred while updating assignees.') });
})
.finally(() => {
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 ""
msgid "An error occurred while updating approvers"
msgstr ""
msgid "An error occurred while updating assignees."
msgstr ""
msgid "An error occurred while updating configuration."
msgstr ""
......
......@@ -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 updateAssignees from '~/vue_shared/components/sidebar/queries/updateAssignees.mutation.graphql';
import { fullBoardId, formatListIssues, formatBoardLists } from '~/boards/boards_util';
import createFlash from '~/flash';
jest.mock('~/flash');
const expectNotImplemented = action => {
it('is not implemented', () => {
......@@ -666,6 +669,7 @@ describe('setAssignees', () => {
const refPath = `${projectPath}#3`;
const iid = '1';
describe('when succeeds', () => {
beforeEach(() => {
jest.spyOn(gqlClient, 'mutate').mockResolvedValue({
data: { issueSetAssignees: { issue: { assignees: { nodes: [{ ...node }] } } } },
......@@ -690,23 +694,35 @@ describe('setAssignees', () => {
{},
{ activeIssue: { iid, referencePath: refPath }, commit: () => {} },
[
{
type: 'SET_ASSIGNEE_LOADING',
payload: true,
},
{ type: types.SET_ASSIGNEE_LOADING, payload: true },
{
type: 'UPDATE_ISSUE_BY_ID',
payload: { prop: 'assignees', issueId: undefined, value: [node] },
},
{
type: 'SET_ASSIGNEE_LOADING',
payload: false,
},
{ type: types.SET_ASSIGNEE_LOADING, payload: false },
],
[],
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', () => {
......
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