⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.
TypeScript honoissue-managementissue-trackerjira-alternativekanbanlinear-alternativemcpproject-managementreactself-hostedtypescript
fix(labels): address workspace label review
Tin006056c77a93
diff --git a/apps/api/src/label/controllers/update-label.ts b/apps/api/src/label/controllers/update-label.tsindex a0bcd00ac..789d01a57 100644--- a/apps/api/src/label/controllers/update-label.ts+++ b/apps/api/src/label/controllers/update-label.ts@@ -4,38 +4,40 @@ import db from "../../database";import { labelTable } from "../../database/schema";async function updateLabel(id: string, name: string, color: string) {- const label = await db.query.labelTable.findFirst({- where: (label, { eq }) => eq(label.id, id),- });-- if (!label) {- throw new HTTPException(404, {- message: "Label not found",+ return db.transaction(async (tx) => {+ const label = await tx.query.labelTable.findFirst({+ where: (label, { eq }) => eq(label.id, id),});- }- const [updatedLabel] = await db- .update(labelTable)- .set({ name, color })- .where(eq(labelTable.id, id))- .returning();+ if (!label) {+ throw new HTTPException(404, {+ message: "Label not found",+ });+ }- // If this is a workspace-level label, cascade the changes to all- // task-level copies so existing label assignments reflect the new color/name- if (!label.taskId && label.workspaceId) {- await db+ const [updatedLabel] = await tx.update(labelTable).set({ name, color })- .where(- and(- eq(labelTable.workspaceId, label.workspaceId),- eq(labelTable.name, label.name),- isNotNull(labelTable.taskId),- ),- );- }+ .where(eq(labelTable.id, id))+ .returning();- return updatedLabel;+ // If this is a workspace-level label, cascade the changes to all+ // task-level copies so existing label assignments reflect the new color/name+ if (!label.taskId && label.workspaceId) {+ await tx+ .update(labelTable)+ .set({ name, color })+ .where(+ and(+ eq(labelTable.workspaceId, label.workspaceId),+ eq(labelTable.name, label.name),+ isNotNull(labelTable.taskId),+ ),+ );+ }++ return updatedLabel;+ });}export default updateLabel;diff --git a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/labels.tsx b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/labels.tsxindex 727e6a3fc..fcb9ecfc6 100644--- a/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/labels.tsx+++ b/apps/web/src/routes/_layout/_authenticated/dashboard/settings/workspace/labels.tsx@@ -294,6 +294,10 @@ function RouteComponent() {<Buttonvariant="ghost"size="icon"+ aria-label={t(+ "settings:workspaceLabels.editLabel",+ { defaultValue: "Edit Label" },+ )}className="h-8 w-8"onClick={() =>openEdit({@@ -308,6 +312,10 @@ function RouteComponent() {<Buttonvariant="ghost"size="icon"+ aria-label={t(+ "settings:workspaceLabels.deleteLabel",+ { defaultValue: "Delete" },+ )}className="h-8 w-8 text-destructive hover:text-destructive"onClick={() =>openDelete({