mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 00:40:14 +01:00
fix: use proper enum for promptGroup in useResourcePermissions arg and remove console.logs
chore: remove debugging logs chore: remove debugging logs chore: remove unused component
This commit is contained in:
parent
c37e368d98
commit
479ce5df48
4 changed files with 2 additions and 110 deletions
|
|
@ -1,85 +0,0 @@
|
|||
import React from 'react';
|
||||
import { X, FileText, Image, Upload } from 'lucide-react';
|
||||
import type { ExtendedFile } from '~/common';
|
||||
import { useLocalize } from '~/hooks';
|
||||
import { cn } from '~/utils';
|
||||
|
||||
interface PromptFileRowProps {
|
||||
files: ExtendedFile[];
|
||||
onRemoveFile: (fileId: string) => void;
|
||||
isReadOnly?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
const PromptFileRow: React.FC<PromptFileRowProps> = ({
|
||||
files,
|
||||
onRemoveFile,
|
||||
isReadOnly = false,
|
||||
className = '',
|
||||
}) => {
|
||||
const localize = useLocalize();
|
||||
|
||||
if (files.length === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const getFileIcon = (file: ExtendedFile) => {
|
||||
if (file.type?.startsWith('image/')) {
|
||||
return <Image className="h-4 w-4" />;
|
||||
}
|
||||
return <FileText className="h-4 w-4" />;
|
||||
};
|
||||
|
||||
const getFileStatus = (file: ExtendedFile) => {
|
||||
if (file.progress < 1) {
|
||||
return (
|
||||
<div className="flex items-center gap-1 text-xs text-blue-600">
|
||||
<Upload className="h-3 w-3 animate-pulse" />
|
||||
{Math.round(file.progress * 100)}%
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={cn('flex flex-wrap gap-2', className)}>
|
||||
{files.map((file) => (
|
||||
<div
|
||||
key={file.temp_file_id || file.file_id}
|
||||
className={cn(
|
||||
'flex items-center gap-2 rounded-lg border px-3 py-2 text-sm',
|
||||
'border-border-medium bg-surface-secondary',
|
||||
file.progress < 1 && 'opacity-70',
|
||||
)}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
{getFileIcon(file)}
|
||||
<span className="max-w-32 truncate" title={file.filename}>
|
||||
{file.filename}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{getFileStatus(file)}
|
||||
|
||||
{!isReadOnly && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => onRemoveFile(file.temp_file_id || file.file_id || '')}
|
||||
className={cn(
|
||||
'ml-1 flex h-5 w-5 items-center justify-center rounded-full',
|
||||
'text-text-secondary hover:bg-surface-hover hover:text-text-primary',
|
||||
'transition-colors duration-200',
|
||||
)}
|
||||
title={localize('com_ui_remove_file')}
|
||||
>
|
||||
<X className="h-3 w-3" />
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default PromptFileRow;
|
||||
|
|
@ -1 +0,0 @@
|
|||
export { default as PromptFileRow } from './PromptFileRow';
|
||||
|
|
@ -7,7 +7,7 @@ import {
|
|||
DropdownMenuContent,
|
||||
DropdownMenuTrigger,
|
||||
} from '@librechat/client';
|
||||
import { PermissionBits } from 'librechat-data-provider';
|
||||
import { PermissionBits, ResourceType } from 'librechat-data-provider';
|
||||
import type { TPromptGroup } from 'librechat-data-provider';
|
||||
import { useLocalize, useSubmitMessage, useCustomLink, useResourcePermissions } from '~/hooks';
|
||||
import VariableDialog from '~/components/Prompts/Groups/VariableDialog';
|
||||
|
|
@ -34,10 +34,9 @@ function ChatGroupItem({
|
|||
);
|
||||
|
||||
// Check permissions for the promptGroup
|
||||
const { hasPermission } = useResourcePermissions('promptGroup', group._id || '');
|
||||
const { hasPermission } = useResourcePermissions(ResourceType.PROMPTGROUP, group._id || '');
|
||||
const canEdit = hasPermission(PermissionBits.EDIT);
|
||||
|
||||
// Check if prompt has attached files
|
||||
const hasFiles = useMemo(() => {
|
||||
const toolResources = group.productionPrompt?.tool_resources;
|
||||
if (!toolResources) return false;
|
||||
|
|
@ -48,27 +47,16 @@ function ChatGroupItem({
|
|||
}, [group.productionPrompt?.tool_resources]);
|
||||
|
||||
const onCardClick: React.MouseEventHandler<HTMLButtonElement> = () => {
|
||||
console.log('ChatGroupItem.onCardClick called for:', group.name);
|
||||
console.log('Group productionPrompt:', {
|
||||
hasPrompt: !!group.productionPrompt?.prompt,
|
||||
prompt: group.productionPrompt?.prompt?.substring(0, 100) + '...',
|
||||
tool_resources: group.productionPrompt?.tool_resources,
|
||||
hasToolResources: !!group.productionPrompt?.tool_resources,
|
||||
});
|
||||
|
||||
const text = group.productionPrompt?.prompt;
|
||||
if (!text?.trim()) {
|
||||
console.log('No prompt text found');
|
||||
return;
|
||||
}
|
||||
|
||||
if (detectVariables(text)) {
|
||||
console.log('Prompt has variables, opening dialog');
|
||||
setVariableDialogOpen(true);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log('Calling submitPrompt with tool_resources');
|
||||
submitPrompt(text, group.productionPrompt?.tool_resources);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,9 @@ export default function useUpdateFiles(setFiles: FileSetter) {
|
|||
const setFilesToDelete = useSetFilesToDelete();
|
||||
|
||||
const addFile = (newFile: ExtendedFile) => {
|
||||
console.log('useUpdateFiles.addFile called with:', {
|
||||
file_id: newFile.file_id,
|
||||
filename: newFile.filename,
|
||||
type: newFile.type,
|
||||
size: newFile.size,
|
||||
progress: newFile.progress,
|
||||
attached: newFile.attached,
|
||||
});
|
||||
setFiles((currentFiles) => {
|
||||
console.log('Current files before adding:', Array.from(currentFiles.keys()));
|
||||
const updatedFiles = new Map(currentFiles);
|
||||
updatedFiles.set(newFile.file_id, newFile);
|
||||
console.log('Files after adding:', Array.from(updatedFiles.keys()));
|
||||
return updatedFiles;
|
||||
});
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue