mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Fix: Fixed the issue where the agent and chat cards on the home page could not be deleted #3221 (#9864)
### What problem does this PR solve? Fix: Fixed the issue where the agent and chat cards on the home page could not be deleted #3221 ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
This commit is contained in:
@ -1,18 +1,48 @@
|
|||||||
|
import { MoreButton } from '@/components/more-button';
|
||||||
|
import { RenameDialog } from '@/components/rename-dialog';
|
||||||
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
||||||
import { useFetchAgentListByPage } from '@/hooks/use-agent-request';
|
import { useFetchAgentListByPage } from '@/hooks/use-agent-request';
|
||||||
|
import { AgentDropdown } from '../agents/agent-dropdown';
|
||||||
|
import { useRenameAgent } from '../agents/use-rename-agent';
|
||||||
import { ApplicationCard } from './application-card';
|
import { ApplicationCard } from './application-card';
|
||||||
|
|
||||||
export function Agents() {
|
export function Agents() {
|
||||||
const { data } = useFetchAgentListByPage();
|
const { data } = useFetchAgentListByPage();
|
||||||
const { navigateToAgent } = useNavigatePage();
|
const { navigateToAgent } = useNavigatePage();
|
||||||
|
const {
|
||||||
|
agentRenameLoading,
|
||||||
|
initialAgentName,
|
||||||
|
onAgentRenameOk,
|
||||||
|
agentRenameVisible,
|
||||||
|
hideAgentRenameModal,
|
||||||
|
showAgentRenameModal,
|
||||||
|
} = useRenameAgent();
|
||||||
|
|
||||||
return data
|
return (
|
||||||
.slice(0, 10)
|
<>
|
||||||
.map((x) => (
|
{data.slice(0, 10).map((x) => (
|
||||||
<ApplicationCard
|
<ApplicationCard
|
||||||
key={x.id}
|
key={x.id}
|
||||||
app={x}
|
app={x}
|
||||||
onClick={navigateToAgent(x.id)}
|
onClick={navigateToAgent(x.id)}
|
||||||
></ApplicationCard>
|
moreDropdown={
|
||||||
));
|
<AgentDropdown
|
||||||
|
showAgentRenameModal={showAgentRenameModal}
|
||||||
|
agent={x}
|
||||||
|
>
|
||||||
|
<MoreButton></MoreButton>
|
||||||
|
</AgentDropdown>
|
||||||
|
}
|
||||||
|
></ApplicationCard>
|
||||||
|
))}
|
||||||
|
{agentRenameVisible && (
|
||||||
|
<RenameDialog
|
||||||
|
hideModal={hideAgentRenameModal}
|
||||||
|
onOk={onAgentRenameOk}
|
||||||
|
initialName={initialAgentName}
|
||||||
|
loading={agentRenameLoading}
|
||||||
|
></RenameDialog>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,3 @@
|
|||||||
import { MoreButton } from '@/components/more-button';
|
|
||||||
import { RAGFlowAvatar } from '@/components/ragflow-avatar';
|
import { RAGFlowAvatar } from '@/components/ragflow-avatar';
|
||||||
import { Card, CardContent } from '@/components/ui/card';
|
import { Card, CardContent } from '@/components/ui/card';
|
||||||
import { formatDate } from '@/utils/date';
|
import { formatDate } from '@/utils/date';
|
||||||
@ -11,9 +10,14 @@ type ApplicationCardProps = {
|
|||||||
update_time: number;
|
update_time: number;
|
||||||
};
|
};
|
||||||
onClick?(): void;
|
onClick?(): void;
|
||||||
|
moreDropdown: React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export function ApplicationCard({ app, onClick }: ApplicationCardProps) {
|
export function ApplicationCard({
|
||||||
|
app,
|
||||||
|
onClick,
|
||||||
|
moreDropdown,
|
||||||
|
}: ApplicationCardProps) {
|
||||||
return (
|
return (
|
||||||
<Card className="w-[264px]" onClick={onClick}>
|
<Card className="w-[264px]" onClick={onClick}>
|
||||||
<CardContent className="p-2.5 group flex justify-between">
|
<CardContent className="p-2.5 group flex justify-between">
|
||||||
@ -32,8 +36,7 @@ export function ApplicationCard({ app, onClick }: ApplicationCardProps) {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{moreDropdown}
|
||||||
<MoreButton className=""></MoreButton>
|
|
||||||
</CardContent>
|
</CardContent>
|
||||||
</Card>
|
</Card>
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,20 +1,53 @@
|
|||||||
|
import { MoreButton } from '@/components/more-button';
|
||||||
|
import { RenameDialog } from '@/components/rename-dialog';
|
||||||
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
import { useNavigatePage } from '@/hooks/logic-hooks/navigate-hooks';
|
||||||
import { useFetchDialogList } from '@/hooks/use-chat-request';
|
import { useFetchDialogList } from '@/hooks/use-chat-request';
|
||||||
|
import { useTranslation } from 'react-i18next';
|
||||||
|
import { ChatDropdown } from '../next-chats/chat-dropdown';
|
||||||
|
import { useRenameChat } from '../next-chats/hooks/use-rename-chat';
|
||||||
import { ApplicationCard } from './application-card';
|
import { ApplicationCard } from './application-card';
|
||||||
|
|
||||||
export function ChatList() {
|
export function ChatList() {
|
||||||
|
const { t } = useTranslation();
|
||||||
const { data } = useFetchDialogList();
|
const { data } = useFetchDialogList();
|
||||||
const { navigateToChat } = useNavigatePage();
|
const { navigateToChat } = useNavigatePage();
|
||||||
|
|
||||||
return data.dialogs.slice(0, 10).map((x) => (
|
const {
|
||||||
<ApplicationCard
|
initialChatName,
|
||||||
key={x.id}
|
chatRenameVisible,
|
||||||
app={{
|
showChatRenameModal,
|
||||||
avatar: x.icon,
|
hideChatRenameModal,
|
||||||
title: x.name,
|
onChatRenameOk,
|
||||||
update_time: x.update_time,
|
chatRenameLoading,
|
||||||
}}
|
} = useRenameChat();
|
||||||
onClick={navigateToChat(x.id)}
|
|
||||||
></ApplicationCard>
|
return (
|
||||||
));
|
<>
|
||||||
|
{data.dialogs.slice(0, 10).map((x) => (
|
||||||
|
<ApplicationCard
|
||||||
|
key={x.id}
|
||||||
|
app={{
|
||||||
|
avatar: x.icon,
|
||||||
|
title: x.name,
|
||||||
|
update_time: x.update_time,
|
||||||
|
}}
|
||||||
|
onClick={navigateToChat(x.id)}
|
||||||
|
moreDropdown={
|
||||||
|
<ChatDropdown chat={x} showChatRenameModal={showChatRenameModal}>
|
||||||
|
<MoreButton></MoreButton>
|
||||||
|
</ChatDropdown>
|
||||||
|
}
|
||||||
|
></ApplicationCard>
|
||||||
|
))}
|
||||||
|
{chatRenameVisible && (
|
||||||
|
<RenameDialog
|
||||||
|
hideModal={hideChatRenameModal}
|
||||||
|
onOk={onChatRenameOk}
|
||||||
|
initialName={initialChatName}
|
||||||
|
loading={chatRenameLoading}
|
||||||
|
title={initialChatName || t('chat.createChat')}
|
||||||
|
></RenameDialog>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user