mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-20 10:20:15 +01:00
selected view only agents injected in the drop down
This commit is contained in:
parent
6a28d01b20
commit
94c1f5f518
2 changed files with 13 additions and 12 deletions
|
|
@ -433,7 +433,7 @@ const getListAgentsHandler = async (req, res) => {
|
||||||
});
|
});
|
||||||
const publiclyAccessibleIds = await findPubliclyAccessibleResources({
|
const publiclyAccessibleIds = await findPubliclyAccessibleResources({
|
||||||
resourceType: 'agent',
|
resourceType: 'agent',
|
||||||
requiredPermissions: requiredPermission,
|
requiredPermissions: PermissionBits.VIEW,
|
||||||
});
|
});
|
||||||
// Use the new ACL-aware function
|
// Use the new ACL-aware function
|
||||||
const data = await getListAgentsByAccess({
|
const data = await getListAgentsByAccess({
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ import React, { useRef, useState, useEffect } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
import type t from 'librechat-data-provider';
|
import type t from 'librechat-data-provider';
|
||||||
|
import { AgentListResponse, PERMISSION_BITS, QueryKeys } from 'librechat-data-provider';
|
||||||
interface SupportContact {
|
interface SupportContact {
|
||||||
name?: string;
|
name?: string;
|
||||||
email?: string;
|
email?: string;
|
||||||
|
|
@ -14,17 +14,10 @@ interface AgentWithSupport extends t.Agent {
|
||||||
|
|
||||||
import useLocalize from '~/hooks/useLocalize';
|
import useLocalize from '~/hooks/useLocalize';
|
||||||
import { useToast } from '~/hooks';
|
import { useToast } from '~/hooks';
|
||||||
import {
|
import { Dialog, DialogContent, Button } from '~/components/ui';
|
||||||
Dialog,
|
|
||||||
DialogContent,
|
|
||||||
Button,
|
|
||||||
DropdownMenu,
|
|
||||||
DropdownMenuContent,
|
|
||||||
DropdownMenuItem,
|
|
||||||
DropdownMenuTrigger,
|
|
||||||
} from '~/components/ui';
|
|
||||||
import { DotsIcon } from '~/components/svg';
|
import { DotsIcon } from '~/components/svg';
|
||||||
import { renderAgentAvatar } from '~/utils/agents';
|
import { renderAgentAvatar } from '~/utils/agents';
|
||||||
|
import { Query, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
interface AgentDetailProps {
|
interface AgentDetailProps {
|
||||||
agent: AgentWithSupport; // The agent data to display
|
agent: AgentWithSupport; // The agent data to display
|
||||||
|
|
@ -42,7 +35,7 @@ const AgentDetail: React.FC<AgentDetailProps> = ({ agent, isOpen, onClose }) =>
|
||||||
const dialogRef = useRef<HTMLDivElement>(null);
|
const dialogRef = useRef<HTMLDivElement>(null);
|
||||||
const dropdownRef = useRef<HTMLDivElement>(null);
|
const dropdownRef = useRef<HTMLDivElement>(null);
|
||||||
const [dropdownOpen, setDropdownOpen] = useState(false);
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
||||||
|
const queryClient = useQueryClient();
|
||||||
// Close dropdown when clicking outside the dropdown menu
|
// Close dropdown when clicking outside the dropdown menu
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleClickOutside = (event: MouseEvent) => {
|
const handleClickOutside = (event: MouseEvent) => {
|
||||||
|
|
@ -66,6 +59,14 @@ const AgentDetail: React.FC<AgentDetailProps> = ({ agent, isOpen, onClose }) =>
|
||||||
*/
|
*/
|
||||||
const handleStartChat = () => {
|
const handleStartChat = () => {
|
||||||
if (agent) {
|
if (agent) {
|
||||||
|
const keys = [QueryKeys.agents, { requiredPermission: PERMISSION_BITS.EDIT }];
|
||||||
|
const listResp = queryClient.getQueryData<AgentListResponse>(keys);
|
||||||
|
if (listResp != null) {
|
||||||
|
if (!listResp.data.some((a) => a.id === agent.id)) {
|
||||||
|
const currentAgents = [agent, ...JSON.parse(JSON.stringify(listResp.data))];
|
||||||
|
queryClient.setQueryData<AgentListResponse>(keys, { ...listResp, data: currentAgents });
|
||||||
|
}
|
||||||
|
}
|
||||||
navigate(`/c/new?agent_id=${agent.id}`);
|
navigate(`/c/new?agent_id=${agent.id}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue