feat: Add assign team option to the context menu (#5153)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
co-authored by
Pranav Raj S
parent
9bea84e2b5
commit
fc9699d993
@@ -121,14 +121,14 @@ const actions = {
|
||||
conversationId,
|
||||
teamId,
|
||||
});
|
||||
dispatch('setCurrentChatTeam', response.data);
|
||||
dispatch('setCurrentChatTeam', { team: response.data, conversationId });
|
||||
} catch (error) {
|
||||
// Handle error
|
||||
}
|
||||
},
|
||||
|
||||
setCurrentChatTeam({ commit }, team) {
|
||||
commit(types.ASSIGN_TEAM, team);
|
||||
setCurrentChatTeam({ commit }, { team, conversationId }) {
|
||||
commit(types.ASSIGN_TEAM, { team, conversationId });
|
||||
},
|
||||
|
||||
toggleStatus: async (
|
||||
|
||||
@@ -68,8 +68,8 @@ export const mutations = {
|
||||
Vue.set(chat.meta, 'assignee', assignee);
|
||||
},
|
||||
|
||||
[types.ASSIGN_TEAM](_state, team) {
|
||||
const [chat] = getSelectedChatConversation(_state);
|
||||
[types.ASSIGN_TEAM](_state, { team, conversationId }) {
|
||||
const [chat] = _state.allConversations.filter(c => c.id === conversationId);
|
||||
Vue.set(chat.meta, 'team', team);
|
||||
},
|
||||
|
||||
|
||||
@@ -327,10 +327,13 @@ describe('#actions', () => {
|
||||
axios.post.mockResolvedValue({
|
||||
data: { id: 1, name: 'Team' },
|
||||
});
|
||||
await actions.setCurrentChatTeam({ commit }, { id: 1, name: 'Team' });
|
||||
await actions.setCurrentChatTeam(
|
||||
{ commit },
|
||||
{ team: { id: 1, name: 'Team' }, conversationId: 1 }
|
||||
);
|
||||
expect(commit).toHaveBeenCalledTimes(1);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
['ASSIGN_TEAM', { id: 1, name: 'Team' }],
|
||||
['ASSIGN_TEAM', { team: { id: 1, name: 'Team' }, conversationId: 1 }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -37,6 +37,19 @@ describe('#mutations', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('#ASSIGN_TEAM', () => {
|
||||
it('clears current chat window', () => {
|
||||
const state = { allConversations: [{ id: 1, meta: {} }] };
|
||||
mutations[types.ASSIGN_TEAM](state, {
|
||||
team: { id: 1, name: 'Team 1' },
|
||||
conversationId: 1,
|
||||
});
|
||||
expect(state.allConversations).toEqual([
|
||||
{ id: 1, meta: { team: { id: 1, name: 'Team 1' } } },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#SET_CURRENT_CHAT_WINDOW', () => {
|
||||
it('set current chat window', () => {
|
||||
const state = { selectedChatId: 1 };
|
||||
|
||||
Reference in New Issue
Block a user