### What problem does this PR solve? Fix (search): Search application list supports renaming function #3221 -Update the search application list page and add a renaming operation entry -Modify the search application details interface to support obtaining detailed information -Optimize search settings page layout and style ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue)
60 lines
1.8 KiB
TypeScript
60 lines
1.8 KiB
TypeScript
import { ConfirmDeleteDialog } from '@/components/confirm-delete-dialog';
|
|
import {
|
|
DropdownMenu,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownMenuSeparator,
|
|
DropdownMenuTrigger,
|
|
} from '@/components/ui/dropdown-menu';
|
|
import { PenLine, Trash2 } from 'lucide-react';
|
|
import { MouseEventHandler, PropsWithChildren, useCallback } from 'react';
|
|
import { useTranslation } from 'react-i18next';
|
|
import { ISearchAppProps, useDeleteSearch } from './hooks';
|
|
|
|
export function SearchDropdown({
|
|
children,
|
|
dataset,
|
|
showSearchRenameModal,
|
|
}: PropsWithChildren & {
|
|
dataset: ISearchAppProps;
|
|
showSearchRenameModal: (dataset: ISearchAppProps) => void;
|
|
}) {
|
|
const { t } = useTranslation();
|
|
const { deleteSearch } = useDeleteSearch();
|
|
const handleShowChatRenameModal: MouseEventHandler<HTMLDivElement> =
|
|
useCallback(
|
|
(e) => {
|
|
e.stopPropagation();
|
|
showSearchRenameModal(dataset);
|
|
},
|
|
[dataset, showSearchRenameModal],
|
|
);
|
|
const handleDelete: MouseEventHandler<HTMLDivElement> = useCallback(() => {
|
|
deleteSearch({ search_id: dataset.id });
|
|
}, [dataset.id, deleteSearch]);
|
|
|
|
return (
|
|
<DropdownMenu>
|
|
<DropdownMenuTrigger asChild>{children}</DropdownMenuTrigger>
|
|
<DropdownMenuContent>
|
|
<DropdownMenuItem onClick={handleShowChatRenameModal}>
|
|
{t('common.rename')} <PenLine />
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
<ConfirmDeleteDialog onOk={handleDelete}>
|
|
<DropdownMenuItem
|
|
className="text-text-delete-red"
|
|
onSelect={(e) => {
|
|
e.preventDefault();
|
|
}}
|
|
onClick={(e) => {
|
|
e.stopPropagation();
|
|
}}
|
|
>
|
|
{t('common.delete')} <Trash2 />
|
|
</DropdownMenuItem>
|
|
</ConfirmDeleteDialog>
|
|
</DropdownMenuContent>
|
|
</DropdownMenu>
|
|
);
|
|
}
|