fixes
This commit is contained in:
parent
eb02c1073d
commit
95780a9911
4 changed files with 48 additions and 34 deletions
|
|
@ -429,35 +429,36 @@ export function useDashboardInputForm(instanceId: string) {
|
||||||
// Immediately remove document from UI for instant feedback
|
// Immediately remove document from UI for instant feedback
|
||||||
setDeletedDocumentFileIds(prev => new Set([...prev, file.fileId]));
|
setDeletedDocumentFileIds(prev => new Set([...prev, file.fileId]));
|
||||||
|
|
||||||
const success = await fileContext.handleFileDelete(file.fileId, () => {
|
if (workflowId && file.messageId) {
|
||||||
setPendingFiles(prev => prev.filter(f => f.fileId !== file.fileId));
|
// Document in a message: only remove the ChatDocument reference, keep the file itself
|
||||||
});
|
try {
|
||||||
|
await deleteFileFromMessageApi(request, workflowId, file.messageId, file.fileId);
|
||||||
if (success) {
|
} catch (error) {
|
||||||
setPendingFiles(prev => prev.filter(f => f.fileId !== file.fileId));
|
// Restore document in UI on failure
|
||||||
|
setDeletedDocumentFileIds(prev => {
|
||||||
if (workflowId) {
|
const next = new Set(prev);
|
||||||
const messagesWithFile = messages.filter((msg: WorkflowMessage) => {
|
next.delete(file.fileId);
|
||||||
const docs = (msg as any).documents as MessageDocument[] | undefined;
|
return next;
|
||||||
return docs?.some(doc => doc.fileId === file.fileId);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
for (const message of messagesWithFile) {
|
|
||||||
try {
|
|
||||||
await deleteFileFromMessageApi(request, workflowId, message.id, file.fileId);
|
|
||||||
} catch (error) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Restore document in UI on failure
|
// Standalone file (pending file not yet in a message): delete the actual file
|
||||||
setDeletedDocumentFileIds(prev => {
|
const success = await fileContext.handleFileDelete(file.fileId, () => {
|
||||||
const next = new Set(prev);
|
setPendingFiles(prev => prev.filter(f => f.fileId !== file.fileId));
|
||||||
next.delete(file.fileId);
|
|
||||||
return next;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
setPendingFiles(prev => prev.filter(f => f.fileId !== file.fileId));
|
||||||
|
} else {
|
||||||
|
// Restore document in UI on failure
|
||||||
|
setDeletedDocumentFileIds(prev => {
|
||||||
|
const next = new Set(prev);
|
||||||
|
next.delete(file.fileId);
|
||||||
|
return next;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [workflowId, messages, fileContext, request]);
|
}, [workflowId, fileContext, request]);
|
||||||
|
|
||||||
// handleFileView is a no-op because ViewActionButton's ContentPreview handles the preview internally
|
// handleFileView is a no-op because ViewActionButton's ContentPreview handles the preview internally
|
||||||
const handleFileView = useCallback(async (_file: WorkflowFile) => {
|
const handleFileView = useCallback(async (_file: WorkflowFile) => {
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,13 @@ export function useApiRequest<RequestData = any, ResponseData = any>() {
|
||||||
// Generate cache key for GET requests (only cache GET requests)
|
// Generate cache key for GET requests (only cache GET requests)
|
||||||
const cacheKey = method === 'get' ? generateCacheKey(url, method, params) : null;
|
const cacheKey = method === 'get' ? generateCacheKey(url, method, params) : null;
|
||||||
|
|
||||||
|
// Mutating requests (POST/PUT/DELETE) invalidate the entire GET cache.
|
||||||
|
// This ensures refetch() after create/update/delete returns fresh data.
|
||||||
|
if (method !== 'get') {
|
||||||
|
requestCache.clear();
|
||||||
|
cacheTimestamps.clear();
|
||||||
|
}
|
||||||
|
|
||||||
// Check if we have a valid cached request for GET requests
|
// Check if we have a valid cached request for GET requests
|
||||||
if (cacheKey && requestCache.has(cacheKey) && isCacheValid(cacheKey)) {
|
if (cacheKey && requestCache.has(cacheKey) && isCacheValid(cacheKey)) {
|
||||||
console.log('🔧 useApiRequest: Using cached request', { url, method, cacheKey });
|
console.log('🔧 useApiRequest: Using cached request', { url, method, cacheKey });
|
||||||
|
|
|
||||||
|
|
@ -81,16 +81,6 @@ function MandateContent({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={hierarchyStyles.mandateContentInner}>
|
<div className={hierarchyStyles.mandateContentInner}>
|
||||||
<div className={hierarchyStyles.levelMandate}>
|
|
||||||
<span className={hierarchyStyles.mandateIcon} />
|
|
||||||
<div className={hierarchyStyles.mandateContent}>
|
|
||||||
<span className={hierarchyStyles.mandateLabel}>{mandateName}</span>
|
|
||||||
<span className={hierarchyStyles.mandateMeta}>
|
|
||||||
{mandateMeta.featureCount} Feature{mandateMeta.featureCount !== 1 ? 's' : ''} · {mandateMeta.instanceCount} Instanz{mandateMeta.instanceCount !== 1 ? 'en' : ''}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
{Object.entries(byFeature).map(([featureCode, featureInstances]) => {
|
{Object.entries(byFeature).map(([featureCode, featureInstances]) => {
|
||||||
const featureUserCount = featureInstances.reduce(
|
const featureUserCount = featureInstances.reduce(
|
||||||
(sum, inst) => sum + (instanceUsersMap[inst.id]?.length ?? 0),
|
(sum, inst) => sum + (instanceUsersMap[inst.id]?.length ?? 0),
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,17 @@ export const PromptsPage: React.FC = () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Handle duplicate prompt
|
||||||
|
const handleDuplicate = async (prompt: Prompt) => {
|
||||||
|
const result = await handlePromptCreate({
|
||||||
|
name: `Kopie von ${prompt.name || 'Prompt'}`,
|
||||||
|
content: prompt.content || ''
|
||||||
|
});
|
||||||
|
if (result?.success) {
|
||||||
|
refetch();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Handle delete single prompt (confirmation handled by DeleteActionButton)
|
// Handle delete single prompt (confirmation handled by DeleteActionButton)
|
||||||
const handleDelete = async (prompt: Prompt) => {
|
const handleDelete = async (prompt: Prompt) => {
|
||||||
const success = await handlePromptDelete(prompt.id);
|
const success = await handlePromptDelete(prompt.id);
|
||||||
|
|
@ -217,6 +228,11 @@ export const PromptsPage: React.FC = () => {
|
||||||
sortable={true}
|
sortable={true}
|
||||||
selectable={false}
|
selectable={false}
|
||||||
actionButtons={[
|
actionButtons={[
|
||||||
|
...(canCreate ? [{
|
||||||
|
type: 'copy' as const,
|
||||||
|
title: 'Duplizieren',
|
||||||
|
onAction: handleDuplicate,
|
||||||
|
}] : []),
|
||||||
...(canUpdate ? [{
|
...(canUpdate ? [{
|
||||||
type: 'edit' as const,
|
type: 'edit' as const,
|
||||||
onAction: handleEditClick,
|
onAction: handleEditClick,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue