feat: enhance audit logging, add MCP settings, and production docker setup
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
- Implemented comprehensive audit logging for Tasks, Users, Settings, Goals, Labels, AI Chat, and Rewards. - Added Admin UI for MCP Server settings and Audit Logs. - Created docker-compose-production.yml with Traefik configuration. - Fixed backend bugs (missing storage methods, route closure). - Added Audit Logging Guidelines.
This commit is contained in:
@@ -11,8 +11,12 @@ import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@
|
||||
import { Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList } from '@/components/ui/command';
|
||||
import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover';
|
||||
import { cn } from "@/lib/utils";
|
||||
import { apiRequest, queryClient } from "@/lib/queryClient";
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { Clock, Timer, FileText, Plus, Edit2, Save, X, Calendar, Tag, Link2, Check } from 'lucide-react';
|
||||
import { Clock, Timer, FileText, Plus, Edit2, Save, X, Calendar as CalendarIcon, Tag, Link2, Check, LayoutList, Trash2, ArrowRight } from 'lucide-react';
|
||||
import { Calendar } from '@/components/ui/calendar';
|
||||
import { format } from 'date-fns';
|
||||
import { de, enUS } from 'date-fns/locale';
|
||||
import { Task, Label } from '@shared/schema';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
|
||||
@@ -29,6 +33,7 @@ interface TaskDetailsModalProps {
|
||||
task: Task | null;
|
||||
onSave: (updatedTask: Task) => void;
|
||||
labels?: Label[];
|
||||
onNavigate?: (taskId: string) => void;
|
||||
}
|
||||
|
||||
export default function TaskDetailsModal({
|
||||
@@ -36,9 +41,12 @@ export default function TaskDetailsModal({
|
||||
onClose,
|
||||
task,
|
||||
onSave,
|
||||
labels = []
|
||||
labels = [],
|
||||
onNavigate
|
||||
}: TaskDetailsModalProps) {
|
||||
const { t } = useTranslation();
|
||||
const { t, i18n } = useTranslation();
|
||||
|
||||
const currentLocale = i18n.language === 'de' ? de : enUS;
|
||||
|
||||
// Edit form state
|
||||
const [editedTitle, setEditedTitle] = useState('');
|
||||
@@ -47,9 +55,17 @@ export default function TaskDetailsModal({
|
||||
const [editedPriority, setEditedPriority] = useState<'low' | 'medium' | 'high'>('medium');
|
||||
const [editedLabelId, setEditedLabelId] = useState<string | null>(null);
|
||||
const [editedDueDate, setEditedDueDate] = useState('');
|
||||
const [editedStartDate, setEditedStartDate] = useState('');
|
||||
const [editedEstimatedDuration, setEditedEstimatedDuration] = useState<number | undefined>(undefined);
|
||||
const [editedDependencies, setEditedDependencies] = useState<string[]>([]);
|
||||
const [isDependenciesOpen, setIsDependenciesOpen] = useState(false);
|
||||
|
||||
// Subtasks state
|
||||
|
||||
const [newSubtaskTitle, setNewSubtaskTitle] = useState('');
|
||||
const [isCreatingSubtask, setIsCreatingSubtask] = useState(false);
|
||||
const [isScheduling, setIsScheduling] = useState(false);
|
||||
|
||||
const { data: tasks = [] } = useQuery<Task[]>({
|
||||
queryKey: ['/api/tasks'],
|
||||
});
|
||||
@@ -78,6 +94,8 @@ export default function TaskDetailsModal({
|
||||
setEditedPriority(task.priority as 'low' | 'medium' | 'high');
|
||||
setEditedLabelId(task.labelId || null);
|
||||
setEditedDueDate(task.dueDate ? new Date(task.dueDate).toISOString().split('T')[0] : '');
|
||||
setEditedStartDate(task.startDate ? new Date(task.startDate).toISOString().split('T')[0] : '');
|
||||
setEditedEstimatedDuration(task.estimatedDuration || undefined);
|
||||
setEditedDependencies(task.dependencies || []);
|
||||
|
||||
setNotes(task.notes || '');
|
||||
@@ -123,8 +141,11 @@ export default function TaskDetailsModal({
|
||||
description: editedDescription || null,
|
||||
status: editedStatus,
|
||||
priority: editedPriority,
|
||||
|
||||
labelId: editedLabelId,
|
||||
dueDate: editedDueDate ? new Date(editedDueDate) : null,
|
||||
startDate: editedStartDate ? new Date(editedStartDate) : null,
|
||||
estimatedDuration: editedEstimatedDuration ?? null,
|
||||
dependencies: editedDependencies
|
||||
};
|
||||
onSave(updatedTask);
|
||||
@@ -180,6 +201,55 @@ export default function TaskDetailsModal({
|
||||
console.log(`Time entry saved: ${totalMinutes} minutes for task: ${task.title}`);
|
||||
};
|
||||
|
||||
const handleCreateSubtask = async () => {
|
||||
if (!task || !newSubtaskTitle.trim()) return;
|
||||
|
||||
try {
|
||||
setIsCreatingSubtask(true);
|
||||
const subtaskData = {
|
||||
title: newSubtaskTitle,
|
||||
description: '',
|
||||
status: 'todo',
|
||||
priority: 'medium',
|
||||
parentTaskId: task.id,
|
||||
dueDate: null,
|
||||
estimatedDuration: null
|
||||
};
|
||||
|
||||
await apiRequest('POST', '/api/tasks', subtaskData);
|
||||
await queryClient.invalidateQueries({ queryKey: ['/api/tasks'] });
|
||||
setNewSubtaskTitle('');
|
||||
// Switch to the newly created task? Or just show it in the list.
|
||||
} catch (error) {
|
||||
console.error('Failed to create subtask:', error);
|
||||
} finally {
|
||||
setIsCreatingSubtask(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleAutoSchedule = async () => {
|
||||
if (!task) return;
|
||||
setIsScheduling(true);
|
||||
try {
|
||||
const res = await apiRequest('POST', `/api/tasks/${task.id}/schedule`, {});
|
||||
const data = await res.json();
|
||||
if (data.success && data.scheduledDate) {
|
||||
setEditedDueDate(new Date(data.scheduledDate).toISOString().split('T')[0]);
|
||||
// Also update the local task object immediately for smoother UX, or let queryClient invalidate
|
||||
await queryClient.invalidateQueries({ queryKey: ['/api/tasks'] });
|
||||
} else {
|
||||
console.error("Scheduling failed: ", data.error);
|
||||
// Could add a toast here ideally
|
||||
}
|
||||
} catch (error) {
|
||||
console.error("Auto-schedule error", error);
|
||||
} finally {
|
||||
setIsScheduling(false);
|
||||
}
|
||||
};
|
||||
|
||||
const subtasks = tasks.filter(t => t.parentTaskId === task?.id);
|
||||
|
||||
const handleDeleteTimeEntry = (entryId: string) => {
|
||||
if (!task || entryId === 'tracked-time') {
|
||||
// Don't allow deleting the main tracked time entry
|
||||
@@ -246,6 +316,10 @@ export default function TaskDetailsModal({
|
||||
|
||||
if (!task) return null;
|
||||
|
||||
|
||||
const parentTask = task.parentTaskId ? tasks.find(t => String(t.id) === String(task.parentTaskId)) : null;
|
||||
const isSubtask = !!task.parentTaskId;
|
||||
|
||||
return (
|
||||
<Dialog open={isOpen} onOpenChange={handleClose}>
|
||||
<DialogContent className="sm:max-w-2xl max-h-[90vh] overflow-y-auto">
|
||||
@@ -260,6 +334,16 @@ export default function TaskDetailsModal({
|
||||
{/* Task Information */}
|
||||
<Card className="p-4">
|
||||
<div className="space-y-3">
|
||||
{parentTask && (
|
||||
<div
|
||||
className="flex items-center gap-1 text-sm text-indigo-600 dark:text-indigo-400 bg-indigo-50 dark:bg-indigo-900/30 px-2 py-1 rounded w-fit mb-1 cursor-pointer hover:underline"
|
||||
onClick={() => onNavigate?.(String(parentTask.id))}
|
||||
>
|
||||
<ArrowRight className="w-3 h-3" />
|
||||
<span className="font-medium">{t('taskDetails.subtaskOf')}</span>
|
||||
<span>{parentTask.title}</span>
|
||||
</div>
|
||||
)}
|
||||
<h3 className="font-semibold text-lg" data-testid="text-task-details-title">
|
||||
{task.title}
|
||||
</h3>
|
||||
@@ -287,7 +371,7 @@ export default function TaskDetailsModal({
|
||||
</Card>
|
||||
|
||||
<Tabs defaultValue="edit" className="space-y-4">
|
||||
<TabsList className="grid w-full grid-cols-3">
|
||||
<TabsList className="grid w-full grid-cols-4">
|
||||
<TabsTrigger value="edit" data-testid="tab-edit">
|
||||
<Edit2 className="w-4 h-4 mr-2" />
|
||||
{t('taskDetails.editTab')}
|
||||
@@ -296,12 +380,74 @@ export default function TaskDetailsModal({
|
||||
<FileText className="w-4 h-4 mr-2" />
|
||||
{t('taskDetails.notesTab')}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="subtasks" data-testid="tab-subtasks">
|
||||
<LayoutList className="w-4 h-4 mr-2" />
|
||||
{t('taskDetails.subtasksTab')}
|
||||
</TabsTrigger>
|
||||
<TabsTrigger value="time" data-testid="tab-time">
|
||||
<Clock className="w-4 h-4 mr-2" />
|
||||
{t('taskDetails.timeTab')}
|
||||
</TabsTrigger>
|
||||
</TabsList>
|
||||
|
||||
{/* Subtasks Tab */}
|
||||
<TabsContent value="subtasks" className="space-y-4">
|
||||
<Card className="p-4">
|
||||
<h4 className="font-medium mb-4">{t('taskDetails.subtasks')}</h4>
|
||||
|
||||
{!isSubtask ? (
|
||||
<div className="flex gap-2 mb-4">
|
||||
<Input
|
||||
placeholder={t('taskDetails.newSubtaskPlaceholder')}
|
||||
value={newSubtaskTitle}
|
||||
onChange={(e) => setNewSubtaskTitle(e.target.value)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') handleCreateSubtask();
|
||||
}}
|
||||
/>
|
||||
<Button
|
||||
onClick={handleCreateSubtask}
|
||||
disabled={!newSubtaskTitle.trim() || isCreatingSubtask}
|
||||
>
|
||||
<Plus className="w-4 h-4 mr-1" />
|
||||
{t('taskDetails.createSubtask')}
|
||||
</Button>
|
||||
</div>
|
||||
) : (
|
||||
<div className="mb-4 p-3 bg-yellow-50 dark:bg-yellow-900/20 text-yellow-800 dark:text-yellow-200 text-sm rounded-md border border-yellow-200 dark:border-yellow-900 flex items-center gap-2">
|
||||
<LayoutList className="w-4 h-4" />
|
||||
{t('taskDetails.hierarchyRestriction')}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-2">
|
||||
{subtasks.length === 0 ? (
|
||||
<div className="text-center text-muted-foreground py-4">
|
||||
{t('taskDetails.noSubtasks')}
|
||||
</div>
|
||||
) : (
|
||||
subtasks.map(subtask => (
|
||||
<div
|
||||
key={subtask.id}
|
||||
className="flex items-center justify-between p-3 border rounded-md hover:bg-muted/50 transition-colors cursor-pointer"
|
||||
onClick={() => onNavigate?.(String(subtask.id))}
|
||||
>
|
||||
<div className="flex items-center gap-2">
|
||||
<Badge variant={subtask.status === 'done' ? 'secondary' : 'outline'}>
|
||||
{t(`taskDetails.statusValue.${subtask.status}`)}
|
||||
</Badge>
|
||||
<span className={subtask.status === 'done' ? 'line-through text-muted-foreground' : ''}>
|
||||
{subtask.title}
|
||||
</span>
|
||||
</div>
|
||||
<ArrowRight className="w-4 h-4 text-muted-foreground" />
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
</TabsContent>
|
||||
|
||||
{/* Edit Tab */}
|
||||
<TabsContent value="edit" className="space-y-4">
|
||||
<Card className="p-4">
|
||||
@@ -386,21 +532,111 @@ export default function TaskDetailsModal({
|
||||
</div>
|
||||
|
||||
{/* Due Date */}
|
||||
|
||||
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
{/* Start Date */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2 h-8">
|
||||
<label className="text-sm font-medium">{t('taskDetails.startDate')}</label>
|
||||
</div>
|
||||
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant={"outline"}
|
||||
className={cn(
|
||||
"w-full justify-start text-left font-normal",
|
||||
!editedStartDate && "text-muted-foreground"
|
||||
)}
|
||||
>
|
||||
<CalendarIcon className="mr-2 h-4 w-4" />
|
||||
{editedStartDate ? format(new Date(editedStartDate), "PPP", { locale: i18n.language === 'de' ? de : enUS }) : <span>{t('taskDetails.pickDate')}</span>}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto p-0">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={editedStartDate ? new Date(editedStartDate) : undefined}
|
||||
onSelect={(date) => setEditedStartDate(date ? date.toISOString().split('T')[0] : '')}
|
||||
initialFocus
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
{/* Due Date */}
|
||||
<div>
|
||||
<div className="flex items-center justify-between mb-2 h-8">
|
||||
<label className="text-sm font-medium">{t('taskDetails.dueDate')}</label>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="h-6 px-2 text-xs text-indigo-600 border-indigo-200 hover:text-indigo-700 hover:bg-indigo-50"
|
||||
onClick={handleAutoSchedule}
|
||||
disabled={isScheduling}
|
||||
>
|
||||
<CalendarIcon className="w-3 h-3 mr-1" />
|
||||
{isScheduling ? t('taskDetails.scheduling') : t('taskDetails.autoSchedule')}
|
||||
</Button>
|
||||
</div>
|
||||
<Popover>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
variant={"outline"}
|
||||
className={cn(
|
||||
"w-full justify-start text-left font-normal",
|
||||
!editedDueDate && "text-muted-foreground"
|
||||
)}
|
||||
data-testid="input-due-date"
|
||||
>
|
||||
<CalendarIcon className="mr-2 h-4 w-4" />
|
||||
{editedDueDate ? format(new Date(editedDueDate), "PPP", { locale: i18n.language === 'de' ? de : enUS }) : <span>{t('taskDetails.pickDate')}</span>}
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className="w-auto p-0">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={editedDueDate ? new Date(editedDueDate) : undefined}
|
||||
onSelect={(date) => setEditedDueDate(date ? date.toISOString().split('T')[0] : '')}
|
||||
initialFocus
|
||||
/>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Estimated Duration */}
|
||||
<div>
|
||||
<label className="text-sm font-medium block mb-2">{t('taskDetails.dueDate')}</label>
|
||||
<Input
|
||||
type="date"
|
||||
value={editedDueDate}
|
||||
onChange={(e) => setEditedDueDate(e.target.value)}
|
||||
data-testid="input-due-date"
|
||||
/>
|
||||
<label className="text-sm font-medium block mb-2">{t('taskDetails.estimatedDuration')}</label>
|
||||
<Select
|
||||
value={editedEstimatedDuration ? editedEstimatedDuration.toString() : "0"}
|
||||
onValueChange={(val) => setEditedEstimatedDuration(val === "0" ? undefined : parseInt(val))}
|
||||
>
|
||||
<SelectTrigger>
|
||||
<SelectValue placeholder={t('taskCreation.duration')} />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="0">{t('taskCreation.durationNone')}</SelectItem>
|
||||
<SelectItem value="15">15m</SelectItem>
|
||||
<SelectItem value="30">30m</SelectItem>
|
||||
<SelectItem value="45">45m</SelectItem>
|
||||
<SelectItem value="60">1h</SelectItem>
|
||||
<SelectItem value="90">1.5h</SelectItem>
|
||||
<SelectItem value="120">2h</SelectItem>
|
||||
<SelectItem value="240">4h</SelectItem>
|
||||
<SelectItem value="480">8h (1 Day)</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
|
||||
{/* Dependencies */}
|
||||
<div>
|
||||
<label className="text-sm font-medium flex items-center gap-2 mb-2">
|
||||
<Link2 className="w-4 h-4" />
|
||||
Blocked By
|
||||
{t('taskDetails.blockedBy')}
|
||||
</label>
|
||||
<Popover open={isDependenciesOpen} onOpenChange={setIsDependenciesOpen}>
|
||||
<PopoverTrigger asChild>
|
||||
@@ -772,6 +1008,6 @@ export default function TaskDetailsModal({
|
||||
</div>
|
||||
</div>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</Dialog >
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user