Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

fix: prevent start date after due date and improve activity messages

Andrej61cb4d3f67ce
diff --git a/apps/api/src/activity/index.ts b/apps/api/src/activity/index.ts
index 7d0688f97..069a2d139 100644
--- a/apps/api/src/activity/index.ts
+++ b/apps/api/src/activity/index.ts
@@ -297,7 +297,7 @@ subscribeToEvent<{
title: string;
type: string;
}>("task.due_date_changed", async (data) => {
- const oldDate = formatActivityDate(data.oldDueDate) || "none";
+ const oldDate = formatActivityDate(data.oldDueDate);
if (!data.newDueDate) {
await createActivity(
@@ -312,12 +312,11 @@ subscribeToEvent<{
const newDate = formatActivityDate(data.newDueDate);
if (!newDate) return;
- await createActivity(
- data.taskId,
- data.type,
- data.userId,
- `changed due date from ${oldDate} to ${newDate}`,
- );
+ const message = oldDate
+ ? `changed due date from ${oldDate} to ${newDate}`
+ : `set due date to ${newDate}`;
+
+ await createActivity(data.taskId, data.type, data.userId, message);
});
subscribeToEvent<{
diff --git a/apps/web/src/components/activity/index.tsx b/apps/web/src/components/activity/index.tsx
index ccb601d8f..07592d9de 100644
--- a/apps/web/src/components/activity/index.tsx
+++ b/apps/web/src/components/activity/index.tsx
@@ -191,21 +191,33 @@ function renderActivityContent({
}
if (activity.type === "due_date_changed") {
- const match = content.match(/changed due date from (.+) to (.+)$/i);
- if (!match)
- return <span className="text-sm text-muted-foreground">{content}</span>;
- return (
- <span className="text-sm text-muted-foreground">
- changed due date from{" "}
- <span className="text-foreground">
- {formatActivityDateText(match[1])}
- </span>{" "}
- to{" "}
- <span className="text-foreground">
- {formatActivityDateText(match[2])}
+ const changeMatch = content.match(/changed due date from (.+) to (.+)$/i);
+ if (changeMatch) {
+ return (
+ <span className="text-sm text-muted-foreground">
+ changed due date from{" "}
+ <span className="text-foreground">
+ {formatActivityDateText(changeMatch[1])}
+ </span>{" "}
+ to{" "}
+ <span className="text-foreground">
+ {formatActivityDateText(changeMatch[2])}
+ </span>
</span>
- </span>
- );
+ );
+ }
+ const setMatch = content.match(/set due date to (.+)$/i);
+ if (setMatch) {
+ return (
+ <span className="text-sm text-muted-foreground">
+ set due date to{" "}
+ <span className="text-foreground">
+ {formatActivityDateText(setMatch[1])}
+ </span>
+ </span>
+ );
+ }
+ return <span className="text-sm text-muted-foreground">{content}</span>;
}
if (activity.type === "assignee_changed") {
diff --git a/apps/web/src/components/task/task-due-date-popover.tsx b/apps/web/src/components/task/task-due-date-popover.tsx
index 4fb5a6289..b68f55990 100644
--- a/apps/web/src/components/task/task-due-date-popover.tsx
+++ b/apps/web/src/components/task/task-due-date-popover.tsx
@@ -48,14 +48,17 @@ export default function TaskDueDatePopover({
mode="single"
selected={task.dueDate ? new Date(task.dueDate) : undefined}
onSelect={handleDateChange}
+ disabled={
+ task.startDate ? { before: new Date(task.startDate) } : undefined
+ }
className="w-full bg-popover"
/>
{task.dueDate && (
- <div className="p-0 border-t border-border">
+ <div className="pt-2 border-t border-border">
<Button
variant="ghost"
size="sm"
- className="w-full justify-start gap-2 text-muted-foreground hover:text-foreground rounded-none"
+ className="w-full justify-start gap-2 text-muted-foreground hover:text-foreground"
onClick={() => handleDateChange(undefined)}
>
<X className="h-4 w-4" />
diff --git a/apps/web/src/components/task/task-start-date-popover.tsx b/apps/web/src/components/task/task-start-date-popover.tsx
index c4f26ddfd..26a704ce7 100644
--- a/apps/web/src/components/task/task-start-date-popover.tsx
+++ b/apps/web/src/components/task/task-start-date-popover.tsx
@@ -48,14 +48,17 @@ export default function TaskStartDatePopover({
mode="single"
selected={task.startDate ? new Date(task.startDate) : undefined}
onSelect={handleDateChange}
+ disabled={
+ task.dueDate ? { after: new Date(task.dueDate) } : undefined
+ }
className="w-full bg-popover"
/>
{task.startDate && (
- <div className="p-0 border-t border-border">
+ <div className="pt-2 border-t border-border">
<Button
variant="ghost"
size="sm"
- className="w-full justify-start gap-2 text-muted-foreground hover:text-foreground rounded-none"
+ className="w-full justify-start gap-2 text-muted-foreground hover:text-foreground"
onClick={() => handleDateChange(undefined)}
>
<X className="h-4 w-4" />