refactor: optimize agent bot assignment dropdown (#14866)
This commit is contained in:
@@ -6,9 +6,12 @@ class AssignableAgents extends ApiClient {
|
||||
super('assignable_agents', { accountScoped: true });
|
||||
}
|
||||
|
||||
get(inboxIds) {
|
||||
get(inboxIds, { includeAgentBots = false } = {}) {
|
||||
return axios.get(this.url, {
|
||||
params: { inbox_ids: inboxIds },
|
||||
params: {
|
||||
inbox_ids: inboxIds,
|
||||
...(includeAgentBots ? { include_agent_bots: true } : {}),
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,9 +62,10 @@ class ConversationApi extends ApiClient {
|
||||
});
|
||||
}
|
||||
|
||||
assignAgent({ conversationId, agentId }) {
|
||||
assignAgent({ conversationId, agentId, assigneeType }) {
|
||||
return axios.post(`${this.url}/${conversationId}/assignments`, {
|
||||
assignee_id: agentId,
|
||||
assignee_type: assigneeType,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -26,5 +26,15 @@ describe('#AssignableAgentsAPI', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('#getAssignableAgents with agent bots', () => {
|
||||
assignableAgentsAPI.get([1], { includeAgentBots: true });
|
||||
expect(axiosMock.get).toHaveBeenCalledWith('/api/v1/assignable_agents', {
|
||||
params: {
|
||||
inbox_ids: [1],
|
||||
include_agent_bots: true,
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -90,11 +90,16 @@ describe('#ConversationAPI', () => {
|
||||
});
|
||||
|
||||
it('#assignAgent', () => {
|
||||
conversationAPI.assignAgent({ conversationId: 12, agentId: 34 });
|
||||
conversationAPI.assignAgent({
|
||||
conversationId: 12,
|
||||
agentId: 34,
|
||||
assigneeType: 'AgentBot',
|
||||
});
|
||||
expect(axiosMock.post).toHaveBeenCalledWith(
|
||||
`/api/v1/conversations/12/assignments`,
|
||||
{
|
||||
assignee_id: 34,
|
||||
assignee_type: 'AgentBot',
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
@@ -62,7 +62,10 @@ export default {
|
||||
immediate: true,
|
||||
handler(inboxId) {
|
||||
if (inboxId) {
|
||||
this.$store.dispatch('inboxAssignableAgents/fetch', [inboxId]);
|
||||
this.$store.dispatch('inboxAssignableAgents/fetch', {
|
||||
inboxIds: [inboxId],
|
||||
includeAgentBots: true,
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import { getLastMessage } from 'dashboard/helper/conversationHelper';
|
||||
import Avatar from 'next/avatar/Avatar.vue';
|
||||
import Icon from 'dashboard/components-next/icon/Icon.vue';
|
||||
import MessagePreview from './MessagePreview.vue';
|
||||
import InboxName from '../InboxName.vue';
|
||||
import TimeAgo from 'dashboard/components/ui/TimeAgo.vue';
|
||||
@@ -57,6 +58,10 @@ const showMetaSection = computed(() => {
|
||||
);
|
||||
});
|
||||
|
||||
const isAgentBotAssignee = computed(
|
||||
() => props.chat?.meta?.assignee_type === 'AgentBot'
|
||||
);
|
||||
|
||||
const hasSlaPolicyId = computed(
|
||||
() => props.chat?.applied_sla?.id && !props.currentContact?.blocked
|
||||
);
|
||||
@@ -159,10 +164,15 @@ watch(
|
||||
>
|
||||
<span
|
||||
v-if="showAssignee && assignee.name"
|
||||
class="text-n-slate-11 text-xs font-medium leading-3 py-0.5 px-0 inline-flex items-center truncate"
|
||||
class="text-n-slate-11 text-xs font-medium leading-3 py-0.5 px-0 inline-flex items-center gap-px truncate"
|
||||
>
|
||||
<fluent-icon icon="person" size="12" class="text-n-slate-11" />
|
||||
{{ assignee.name }}
|
||||
<Icon
|
||||
:icon="
|
||||
isAgentBotAssignee ? 'i-lucide-bot' : 'i-lucide-user-round'
|
||||
"
|
||||
class="size-3 text-n-slate-11 flex-shrink-0"
|
||||
/>
|
||||
<span class="truncate">{{ assignee.name }}</span>
|
||||
</span>
|
||||
<CardPriorityIcon
|
||||
:priority="chat.priority"
|
||||
|
||||
@@ -123,7 +123,13 @@ export default {
|
||||
$t('EMAIL_TRANSCRIPT.FORM.SEND_TO_CONTACT')
|
||||
}}</label>
|
||||
</div>
|
||||
<div v-if="currentChat.meta.assignee" class="flex items-center gap-2">
|
||||
<div
|
||||
v-if="
|
||||
currentChat.meta.assignee &&
|
||||
currentChat.meta.assignee_type !== 'AgentBot'
|
||||
"
|
||||
class="flex items-center gap-2"
|
||||
>
|
||||
<input
|
||||
id="assignee"
|
||||
v-model="selectedType"
|
||||
|
||||
@@ -33,10 +33,19 @@ defineProps({
|
||||
v-if="variant === 'agent'"
|
||||
:name="option.label"
|
||||
:src="option.thumbnail"
|
||||
:icon-name="option.iconName"
|
||||
:status="option.status === 'online' ? option.status : null"
|
||||
:size="20"
|
||||
class="flex-shrink-0"
|
||||
/>
|
||||
>
|
||||
<template v-if="option.iconName && option.thumbnail" #badge>
|
||||
<div
|
||||
class="absolute z-20 flex items-center justify-center rounded-full outline outline-1 outline-n-weak bg-n-solid-1 -bottom-0.5 ltr:-right-0.5 rtl:-left-0.5 size-3"
|
||||
>
|
||||
<Icon icon="i-lucide-bot" class="text-n-slate-11 size-2" />
|
||||
</div>
|
||||
</template>
|
||||
</Avatar>
|
||||
<p class="menu-label truncate min-w-0 flex-1">
|
||||
{{ option.label }}
|
||||
</p>
|
||||
|
||||
@@ -26,11 +26,12 @@ const mockNoneAgent = {
|
||||
};
|
||||
|
||||
const mockUseMapGetter = (overrides = {}) => {
|
||||
const getAssignableAgents = vi.fn(() => allAgentsData);
|
||||
const defaultGetters = {
|
||||
getCurrentUser: ref(allAgentsData[0]),
|
||||
getSelectedChat: ref({ inbox_id: 1, meta: { assignee: true } }),
|
||||
getCurrentAccountId: ref(1),
|
||||
'inboxAssignableAgents/getAssignableAgents': ref(() => allAgentsData),
|
||||
'inboxAssignableAgents/getAssignableAgents': ref(getAssignableAgents),
|
||||
};
|
||||
|
||||
const mergedGetters = { ...defaultGetters, ...overrides };
|
||||
@@ -53,6 +54,24 @@ describe('useAgentsList', () => {
|
||||
const { agentsList, assignableAgents } = useAgentsList();
|
||||
|
||||
expect(assignableAgents.value).toEqual(allAgentsData);
|
||||
expect(
|
||||
useMapGetter('inboxAssignableAgents/getAssignableAgents').value
|
||||
).toHaveBeenCalledWith(1, { includeAgentBots: false });
|
||||
expect(agentsList.value[0]).toEqual(mockNoneAgent);
|
||||
expect(agentsList.value.length).toBe(
|
||||
formattedAgentsData.slice(1).length + 1
|
||||
);
|
||||
});
|
||||
|
||||
it('requests agent bots when explicitly included', () => {
|
||||
const { agentsList, assignableAgents } = useAgentsList(true, {
|
||||
includeAgentBots: true,
|
||||
});
|
||||
|
||||
expect(assignableAgents.value).toEqual(allAgentsData);
|
||||
expect(
|
||||
useMapGetter('inboxAssignableAgents/getAssignableAgents').value
|
||||
).toHaveBeenCalledWith(1, { includeAgentBots: true });
|
||||
expect(agentsList.value[0]).toEqual(mockNoneAgent);
|
||||
expect(agentsList.value.length).toBe(
|
||||
formattedAgentsData.slice(1).length + 1
|
||||
|
||||
@@ -10,9 +10,14 @@ import {
|
||||
* A composable function that provides a list of agents for assignment.
|
||||
*
|
||||
* @param {boolean} [includeNoneAgent=true] - Whether to include a 'None' agent option.
|
||||
* @param {Object} [options] - Options for the assignable agents list.
|
||||
* @param {boolean} [options.includeAgentBots=false] - Whether to include AgentBot assignees. Only pass this from surfaces that thread `assignee_type` through the assignment request.
|
||||
* @returns {Object} An object containing the agents list and assignable agents.
|
||||
*/
|
||||
export function useAgentsList(includeNoneAgent = true) {
|
||||
export function useAgentsList(
|
||||
includeNoneAgent = true,
|
||||
{ includeAgentBots = false } = {}
|
||||
) {
|
||||
const { t } = useI18n();
|
||||
const currentUser = useMapGetter('getCurrentUser');
|
||||
const currentChat = useMapGetter('getSelectedChat');
|
||||
@@ -39,7 +44,9 @@ export function useAgentsList(includeNoneAgent = true) {
|
||||
* @type {import('vue').ComputedRef<Array>}
|
||||
*/
|
||||
const assignableAgents = computed(() => {
|
||||
return inboxId.value ? assignable.value(inboxId.value) : [];
|
||||
return inboxId.value
|
||||
? assignable.value(inboxId.value, { includeAgentBots })
|
||||
: [];
|
||||
});
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,7 +38,7 @@ export const getAgentsByUpdatedPresence = (
|
||||
currentAccountId
|
||||
) => {
|
||||
const agentsWithDynamicPresenceUpdate = agents.map(item =>
|
||||
item.id === currentUser.id
|
||||
item.id === currentUser.id && (item.assignee_type || 'User') === 'User'
|
||||
? {
|
||||
...item,
|
||||
availability_status: currentUser.accounts.find(
|
||||
|
||||
@@ -25,7 +25,7 @@ export default {
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
const { agentsList } = useAgentsList();
|
||||
const { agentsList } = useAgentsList(true, { includeAgentBots: true });
|
||||
return {
|
||||
agentsList,
|
||||
};
|
||||
@@ -81,18 +81,27 @@ export default {
|
||||
},
|
||||
assignedAgent: {
|
||||
get() {
|
||||
return this.currentChat.meta.assignee;
|
||||
const assignee = this.currentChat.meta.assignee;
|
||||
return (
|
||||
assignee && {
|
||||
...assignee,
|
||||
assignee_type: this.currentChat.meta.assignee_type || 'User',
|
||||
}
|
||||
);
|
||||
},
|
||||
set(agent) {
|
||||
const agentId = agent ? agent.id : null;
|
||||
const assigneeType = agent ? agent.assignee_type || 'User' : null;
|
||||
this.$store.dispatch('setCurrentChatAssignee', {
|
||||
conversationId: this.currentChat.id,
|
||||
assignee: agent,
|
||||
assigneeType,
|
||||
});
|
||||
this.$store
|
||||
.dispatch('assignAgent', {
|
||||
conversationId: this.currentChat.id,
|
||||
agentId,
|
||||
assigneeType,
|
||||
})
|
||||
.then(() => {
|
||||
useAlert(this.$t('CONVERSATION.CHANGE_AGENT'));
|
||||
@@ -152,7 +161,10 @@ export default {
|
||||
if (!this.assignedAgent) {
|
||||
return true;
|
||||
}
|
||||
if (this.assignedAgent.id !== this.currentUser.id) {
|
||||
if (
|
||||
this.assignedAgent.id !== this.currentUser.id ||
|
||||
(this.assignedAgent.assignee_type || 'User') !== 'User'
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -183,7 +195,11 @@ export default {
|
||||
this.assignedAgent = selfAssign;
|
||||
},
|
||||
onClickAssignAgent(selectedItem) {
|
||||
if (this.assignedAgent && this.assignedAgent.id === selectedItem.id) {
|
||||
if (
|
||||
this.assignedAgent?.id === selectedItem.id &&
|
||||
(this.assignedAgent?.assignee_type || 'User') ===
|
||||
(selectedItem.assignee_type || 'User')
|
||||
) {
|
||||
this.assignedAgent = null;
|
||||
} else {
|
||||
this.assignedAgent = selectedItem;
|
||||
|
||||
@@ -208,23 +208,31 @@ const actions = {
|
||||
}
|
||||
},
|
||||
|
||||
assignAgent: async ({ dispatch }, { conversationId, agentId }) => {
|
||||
assignAgent: async (
|
||||
{ dispatch },
|
||||
{ conversationId, agentId, assigneeType }
|
||||
) => {
|
||||
try {
|
||||
const response = await ConversationApi.assignAgent({
|
||||
conversationId,
|
||||
agentId,
|
||||
assigneeType,
|
||||
});
|
||||
dispatch('setCurrentChatAssignee', {
|
||||
conversationId,
|
||||
assignee: response.data,
|
||||
assigneeType,
|
||||
});
|
||||
} catch (error) {
|
||||
// Handle error
|
||||
}
|
||||
},
|
||||
|
||||
setCurrentChatAssignee({ commit }, { conversationId, assignee }) {
|
||||
commit(types.ASSIGN_AGENT, { conversationId, assignee });
|
||||
setCurrentChatAssignee(
|
||||
{ commit },
|
||||
{ conversationId, assignee, assigneeType }
|
||||
) {
|
||||
commit(types.ASSIGN_AGENT, { conversationId, assignee, assigneeType });
|
||||
},
|
||||
|
||||
assignTeam: async ({ dispatch }, { conversationId, teamId }) => {
|
||||
|
||||
@@ -108,10 +108,11 @@ export const mutations = {
|
||||
}
|
||||
},
|
||||
|
||||
[types.ASSIGN_AGENT](_state, { conversationId, assignee }) {
|
||||
[types.ASSIGN_AGENT](_state, { conversationId, assignee, assigneeType }) {
|
||||
const chat = getConversationById(_state)(conversationId);
|
||||
if (chat) {
|
||||
chat.meta.assignee = assignee;
|
||||
chat.meta.assignee_type = assigneeType;
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -7,31 +7,52 @@ const state = {
|
||||
},
|
||||
};
|
||||
|
||||
const recordKey = (inboxId, { includeAgentBots = false } = {}) =>
|
||||
includeAgentBots ? `${inboxId}:with_agent_bots` : inboxId;
|
||||
|
||||
export const types = {
|
||||
SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG: 'SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG',
|
||||
SET_INBOX_ASSIGNABLE_AGENTS: 'SET_INBOX_ASSIGNABLE_AGENTS',
|
||||
};
|
||||
|
||||
export const getters = {
|
||||
getAssignableAgents: $state => inboxId => {
|
||||
const allAgents = $state.records[inboxId] || [];
|
||||
const verifiedAgents = allAgents.filter(record => record.confirmed);
|
||||
return verifiedAgents;
|
||||
},
|
||||
getAssignableAgents:
|
||||
$state =>
|
||||
(inboxId, options = {}) => {
|
||||
const includeAgentBots = options.includeAgentBots || false;
|
||||
const allAgents = $state.records[recordKey(inboxId, options)] || [];
|
||||
const verifiedAgents = allAgents.filter(
|
||||
record =>
|
||||
record.confirmed ||
|
||||
(includeAgentBots && record.assignee_type === 'AgentBot')
|
||||
);
|
||||
return verifiedAgents;
|
||||
},
|
||||
getUIFlags($state) {
|
||||
return $state.uiFlags;
|
||||
},
|
||||
};
|
||||
|
||||
export const actions = {
|
||||
async fetch({ commit }, inboxIds) {
|
||||
async fetch({ commit }, actionPayload) {
|
||||
const inboxIds = Array.isArray(actionPayload)
|
||||
? actionPayload
|
||||
: actionPayload.inboxIds;
|
||||
const includeAgentBots =
|
||||
!Array.isArray(actionPayload) && actionPayload.includeAgentBots;
|
||||
commit(types.SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG, { isFetching: true });
|
||||
try {
|
||||
const {
|
||||
data: { payload },
|
||||
} = await AssignableAgentsAPI.get(inboxIds);
|
||||
} = await AssignableAgentsAPI.get(inboxIds, { includeAgentBots });
|
||||
if (includeAgentBots) {
|
||||
commit(types.SET_INBOX_ASSIGNABLE_AGENTS, {
|
||||
inboxId: inboxIds.join(','),
|
||||
members: payload,
|
||||
});
|
||||
}
|
||||
commit(types.SET_INBOX_ASSIGNABLE_AGENTS, {
|
||||
inboxId: inboxIds.join(','),
|
||||
inboxId: recordKey(inboxIds.join(','), { includeAgentBots }),
|
||||
members: payload,
|
||||
});
|
||||
} catch (error) {
|
||||
|
||||
@@ -357,11 +357,12 @@ describe('#actions', () => {
|
||||
});
|
||||
await actions.assignAgent(
|
||||
{ dispatch },
|
||||
{ conversationId: 1, agentId: 1 }
|
||||
{ conversationId: 1, agentId: 1, assigneeType: 'AgentBot' }
|
||||
);
|
||||
expect(dispatch).toHaveBeenCalledWith('setCurrentChatAssignee', {
|
||||
conversationId: 1,
|
||||
assignee: { id: 1, name: 'User' },
|
||||
assigneeType: 'AgentBot',
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -371,6 +372,7 @@ describe('#actions', () => {
|
||||
const payload = {
|
||||
conversationId: 1,
|
||||
assignee: { id: 1, name: 'User' },
|
||||
assigneeType: 'AgentBot',
|
||||
};
|
||||
await actions.setCurrentChatAssignee({ commit }, payload);
|
||||
expect(commit).toHaveBeenCalledTimes(1);
|
||||
|
||||
@@ -712,8 +712,10 @@ describe('#mutations', () => {
|
||||
mutations[types.ASSIGN_AGENT](state, {
|
||||
conversationId: 1,
|
||||
assignee,
|
||||
assigneeType: 'AgentBot',
|
||||
});
|
||||
expect(state.allConversations[0].meta.assignee).toEqual(assignee);
|
||||
expect(state.allConversations[0].meta.assignee_type).toEqual('AgentBot');
|
||||
expect(state.allConversations[1].meta.assignee).toBeUndefined();
|
||||
});
|
||||
});
|
||||
|
||||
+36
-3
@@ -7,12 +7,21 @@ global.axios = axios;
|
||||
vi.mock('axios');
|
||||
|
||||
describe('#actions', () => {
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
describe('#fetch', () => {
|
||||
it('sends correct actions if API is success', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: { payload: agentsData },
|
||||
});
|
||||
await actions.fetch({ commit }, [1]);
|
||||
expect(axios.get).toHaveBeenCalledWith('/api/v1/assignable_agents', {
|
||||
params: {
|
||||
inbox_ids: [1],
|
||||
},
|
||||
});
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG, { isFetching: true }],
|
||||
[
|
||||
@@ -24,13 +33,37 @@ describe('#actions', () => {
|
||||
});
|
||||
it('sends correct actions if API is error', async () => {
|
||||
axios.get.mockRejectedValue({ message: 'Incorrect header' });
|
||||
await expect(actions.fetch({ commit }, { inboxId: 1 })).rejects.toThrow(
|
||||
Error
|
||||
);
|
||||
await expect(actions.fetch({ commit }, [1])).rejects.toThrow(Error);
|
||||
expect(commit.mock.calls).toEqual([
|
||||
[types.SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG, { isFetching: true }],
|
||||
[types.SET_INBOX_ASSIGNABLE_AGENTS_UI_FLAG, { isFetching: false }],
|
||||
]);
|
||||
});
|
||||
|
||||
it('requests agent bots only when opted in', async () => {
|
||||
axios.get.mockResolvedValue({
|
||||
data: { payload: agentsData },
|
||||
});
|
||||
|
||||
await actions.fetch(
|
||||
{ commit },
|
||||
{ inboxIds: [1], includeAgentBots: true }
|
||||
);
|
||||
|
||||
expect(axios.get).toHaveBeenCalledWith('/api/v1/assignable_agents', {
|
||||
params: {
|
||||
inbox_ids: [1],
|
||||
include_agent_bots: true,
|
||||
},
|
||||
});
|
||||
expect(commit).toHaveBeenCalledWith(types.SET_INBOX_ASSIGNABLE_AGENTS, {
|
||||
inboxId: '1',
|
||||
members: agentsData,
|
||||
});
|
||||
expect(commit).toHaveBeenCalledWith(types.SET_INBOX_ASSIGNABLE_AGENTS, {
|
||||
inboxId: '1:with_agent_bots',
|
||||
members: agentsData,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+21
-2
@@ -1,4 +1,4 @@
|
||||
import { getters } from '../../teamMembers';
|
||||
import { getters } from '../../inboxAssignableAgents';
|
||||
import agentsData from './fixtures';
|
||||
|
||||
describe('#getters', () => {
|
||||
@@ -8,7 +8,26 @@ describe('#getters', () => {
|
||||
1: [agentsData[0]],
|
||||
},
|
||||
};
|
||||
expect(getters.getTeamMembers(state)(1)).toEqual([agentsData[0]]);
|
||||
expect(getters.getAssignableAgents(state)(1)).toEqual([agentsData[0]]);
|
||||
});
|
||||
|
||||
it('keeps agent bots scoped to bot-inclusive lists', () => {
|
||||
const agentBot = {
|
||||
id: 1,
|
||||
name: 'Captain',
|
||||
assignee_type: 'AgentBot',
|
||||
};
|
||||
const state = {
|
||||
records: {
|
||||
1: [agentBot, agentsData[0]],
|
||||
'1:with_agent_bots': [agentBot, agentsData[0]],
|
||||
},
|
||||
};
|
||||
|
||||
expect(getters.getAssignableAgents(state)(1)).toEqual([agentsData[0]]);
|
||||
expect(
|
||||
getters.getAssignableAgents(state)(1, { includeAgentBots: true })
|
||||
).toEqual([agentBot, agentsData[0]]);
|
||||
});
|
||||
|
||||
it('getUIFlags', () => {
|
||||
|
||||
@@ -63,6 +63,14 @@ const hasValue = computed(() => {
|
||||
const hasIcon = computed(() => {
|
||||
return props.selectedItem?.icon || false;
|
||||
});
|
||||
|
||||
const isAgentBot = computed(
|
||||
() => props.selectedItem?.assignee_type === 'AgentBot'
|
||||
);
|
||||
|
||||
const selectedThumbnail = computed(
|
||||
() => props.selectedItem?.thumbnail || props.selectedItem?.avatar_url
|
||||
);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -93,16 +101,25 @@ const hasIcon = computed(() => {
|
||||
</h4>
|
||||
</div>
|
||||
<Avatar
|
||||
v-if="hasValue && hasThumbnail && !hasIcon"
|
||||
:src="selectedItem.thumbnail"
|
||||
v-if="hasValue && hasThumbnail && (isAgentBot || !hasIcon)"
|
||||
:src="selectedThumbnail"
|
||||
:status="selectedItem.availability_status"
|
||||
:name="selectedItem.name"
|
||||
:icon-name="isAgentBot ? 'i-lucide-bot' : undefined"
|
||||
:size="24"
|
||||
hide-offline-status
|
||||
rounded-full
|
||||
/>
|
||||
>
|
||||
<template v-if="isAgentBot && selectedThumbnail" #badge>
|
||||
<div
|
||||
class="absolute z-20 flex items-center justify-center rounded-full outline outline-1 outline-n-weak bg-n-solid-1 -bottom-0.5 ltr:-right-0.5 rtl:-left-0.5 size-3.5"
|
||||
>
|
||||
<Icon icon="i-lucide-bot" class="text-n-slate-11 size-2.5" />
|
||||
</div>
|
||||
</template>
|
||||
</Avatar>
|
||||
<div
|
||||
v-if="hasValue && hasIcon && showEmojiIcon"
|
||||
v-else-if="hasValue && hasIcon && showEmojiIcon"
|
||||
class="flex items-center justify-center flex-shrink-0 text-sm rounded-full size-6 outline outline-1 -outline-offset-1 outline-n-weak"
|
||||
>
|
||||
<EmojiIcon
|
||||
|
||||
@@ -73,7 +73,13 @@ export default {
|
||||
this.$refs.searchbar.focus();
|
||||
},
|
||||
isActive(option) {
|
||||
return this.selectedItems.some(item => item && option.id === item.id);
|
||||
return this.selectedItems.some(item => {
|
||||
if (!item || option.id !== item.id) return false;
|
||||
|
||||
return (
|
||||
(option.assignee_type || 'User') === (item.assignee_type || 'User')
|
||||
);
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
@@ -94,7 +100,10 @@ export default {
|
||||
<div class="flex items-start justify-start flex-auto overflow-auto mt-2">
|
||||
<div class="w-full max-h-[10rem]">
|
||||
<WootDropdownMenu>
|
||||
<WootDropdownItem v-for="option in filteredOptions" :key="option.id">
|
||||
<WootDropdownItem
|
||||
v-for="option in filteredOptions"
|
||||
:key="`${option.assignee_type || 'User'}-${option.id}`"
|
||||
>
|
||||
<NextButton
|
||||
slate
|
||||
:variant="isActive(option) ? 'faded' : 'ghost'"
|
||||
@@ -114,16 +123,38 @@ export default {
|
||||
</span>
|
||||
</div>
|
||||
<Avatar
|
||||
v-if="hasThumbnail && !option.icon"
|
||||
v-if="
|
||||
hasThumbnail &&
|
||||
(!option.icon || option.assignee_type === 'AgentBot')
|
||||
"
|
||||
:src="option.thumbnail"
|
||||
:name="option.name"
|
||||
:status="option.availability_status"
|
||||
:icon-name="
|
||||
option.assignee_type === 'AgentBot'
|
||||
? 'i-lucide-bot'
|
||||
: undefined
|
||||
"
|
||||
:size="24"
|
||||
hide-offline-status
|
||||
rounded-full
|
||||
/>
|
||||
>
|
||||
<template
|
||||
v-if="option.assignee_type === 'AgentBot' && option.thumbnail"
|
||||
#badge
|
||||
>
|
||||
<div
|
||||
class="absolute z-20 flex items-center justify-center rounded-full outline outline-1 outline-n-weak bg-n-solid-1 -bottom-0.5 ltr:-right-0.5 rtl:-left-0.5 size-3.5"
|
||||
>
|
||||
<Icon
|
||||
icon="i-lucide-bot"
|
||||
class="text-n-slate-11 size-2.5"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</Avatar>
|
||||
<div
|
||||
v-if="option.icon && showEmojiIcon"
|
||||
v-else-if="option.icon && showEmojiIcon"
|
||||
class="flex items-center justify-center flex-shrink-0 text-sm rounded-full size-6 outline outline-1 -outline-offset-1 outline-n-weak"
|
||||
>
|
||||
<EmojiIcon
|
||||
|
||||
Reference in New Issue
Block a user