* feat: workspace start of week column * feat(l10n): add workspace setting for the first day of the week Fixes #361 * feat: add Saturday as option * chore: fix migration order * chore: fix merge --------- Co-authored-by: Henry <henry_ball@hotmail.co.uk>
This commit is contained in:
@@ -4,11 +4,10 @@ import { z } from "zod";
|
||||
|
||||
import * as workspaceRepo from "@kan/db/repository/workspace.repo";
|
||||
import * as workspaceSlugRepo from "@kan/db/repository/workspaceSlug.repo";
|
||||
import { generateUID } from "@kan/shared/utils";
|
||||
import { generateAvatarUrl, generateUID } from "@kan/shared/utils";
|
||||
|
||||
import { createTRPCRouter, protectedProcedure, publicProcedure } from "../trpc";
|
||||
import { assertPermission } from "../utils/permissions";
|
||||
import { generateAvatarUrl } from "@kan/shared/utils";
|
||||
|
||||
export const workspaceRouter = createTRPCRouter({
|
||||
all: protectedProcedure
|
||||
@@ -84,8 +83,7 @@ export const workspaceRouter = createTRPCRouter({
|
||||
const isAdmin = userMember?.role === "admin";
|
||||
|
||||
// Show emails if user is admin OR workspace setting allows it
|
||||
const shouldShowEmails =
|
||||
isAdmin || result.showEmailsToMembers === true;
|
||||
const shouldShowEmails = isAdmin || result.showEmailsToMembers === true;
|
||||
|
||||
// Generate presigned URLs for member avatars
|
||||
const membersWithAvatarUrls = await Promise.all(
|
||||
@@ -295,6 +293,9 @@ export const workspaceRouter = createTRPCRouter({
|
||||
.optional(),
|
||||
description: z.string().min(3).max(280).optional(),
|
||||
showEmailsToMembers: z.boolean().optional(),
|
||||
weekStartDay: z
|
||||
.union([z.literal(0), z.literal(1), z.literal(6)])
|
||||
.optional(),
|
||||
}),
|
||||
)
|
||||
.output(z.custom<Awaited<ReturnType<typeof workspaceRepo.update>>>())
|
||||
@@ -356,6 +357,7 @@ export const workspaceRouter = createTRPCRouter({
|
||||
slug: input.slug,
|
||||
description: input.description,
|
||||
showEmailsToMembers: input.showEmailsToMembers,
|
||||
weekStartDay: input.weekStartDay,
|
||||
},
|
||||
);
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ export async function sendWebhooksForWorkspace(
|
||||
db,
|
||||
workspaceId,
|
||||
);
|
||||
const webhooks = allWebhooks.filter((w) =>
|
||||
const webhooksForEvent = allWebhooks.filter((w) =>
|
||||
w.events.includes(payload.event),
|
||||
);
|
||||
|
||||
|
||||
52
packages/db/migrations/20260311065722_AddWeekStartDay.sql
Normal file
52
packages/db/migrations/20260311065722_AddWeekStartDay.sql
Normal file
@@ -0,0 +1,52 @@
|
||||
-- Migrations and snapshots seem to have become out of sync (this should fix that)
|
||||
DO $$
|
||||
BEGIN
|
||||
IF NOT EXISTS (
|
||||
SELECT 1
|
||||
FROM pg_enum e
|
||||
JOIN pg_type t ON e.enumtypid = t.oid
|
||||
WHERE t.typname = 'source'
|
||||
AND e.enumlabel = 'github'
|
||||
) THEN
|
||||
ALTER TYPE "public"."source" ADD VALUE 'github';
|
||||
END IF;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
CREATE TABLE IF NOT EXISTS "workspace_webhooks" (
|
||||
"id" bigserial PRIMARY KEY NOT NULL,
|
||||
"publicId" varchar(12) NOT NULL,
|
||||
"workspaceId" bigint NOT NULL,
|
||||
"name" varchar(255) NOT NULL,
|
||||
"url" varchar(2048) NOT NULL,
|
||||
"secret" text,
|
||||
"events" text NOT NULL,
|
||||
"active" boolean DEFAULT true NOT NULL,
|
||||
"createdBy" uuid NOT NULL,
|
||||
"createdAt" timestamp DEFAULT now() NOT NULL,
|
||||
"updatedAt" timestamp,
|
||||
CONSTRAINT "workspace_webhooks_publicId_unique" UNIQUE("publicId")
|
||||
);
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "workspace_webhooks" ENABLE ROW LEVEL SECURITY;--> statement-breakpoint
|
||||
ALTER TABLE "integration" ALTER COLUMN "accessToken" SET DATA TYPE text;--> statement-breakpoint
|
||||
ALTER TABLE "card_activity" ADD COLUMN IF NOT EXISTS "attachmentId" bigint;--> statement-breakpoint
|
||||
--> statement-breakpoint
|
||||
ALTER TABLE "workspace" ADD COLUMN IF NOT EXISTS "weekStartDay" integer DEFAULT 1 NOT NULL;--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "workspace_webhooks" ADD CONSTRAINT "workspace_webhooks_workspaceId_workspace_id_fk" FOREIGN KEY ("workspaceId") REFERENCES "public"."workspace"("id") ON DELETE cascade ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "workspace_webhooks" ADD CONSTRAINT "workspace_webhooks_createdBy_user_id_fk" FOREIGN KEY ("createdBy") REFERENCES "public"."user"("id") ON DELETE cascade ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
--> statement-breakpoint
|
||||
CREATE INDEX IF NOT EXISTS "workspace_webhooks_workspace_idx" ON "workspace_webhooks" USING btree ("workspaceId");--> statement-breakpoint
|
||||
DO $$ BEGIN
|
||||
ALTER TABLE "card_activity" ADD CONSTRAINT "card_activity_attachmentId_card_attachment_id_fk" FOREIGN KEY ("attachmentId") REFERENCES "public"."card_attachment"("id") ON DELETE cascade ON UPDATE no action;
|
||||
EXCEPTION
|
||||
WHEN duplicate_object THEN null;
|
||||
END $$;
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"id": "dc863226-583e-4985-8b6a-4c360a3b9fa1",
|
||||
"prevId": "4e1ebb8b-bd52-48c5-87d6-8e6e5eb8bbde",
|
||||
"prevId": "d0ce9209-d34a-4ae8-b93e-d73391bfec64",
|
||||
"version": "7",
|
||||
"dialect": "postgresql",
|
||||
"tables": {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
3868
packages/db/migrations/meta/20260311065722_snapshot.json
Normal file
3868
packages/db/migrations/meta/20260311065722_snapshot.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -206,11 +206,18 @@
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 28,
|
||||
"idx": 29,
|
||||
"version": "7",
|
||||
"when": 1771930355536,
|
||||
"tag": "20260224105235_AddGitHubIntegrationSupport",
|
||||
"breakpoints": true
|
||||
},
|
||||
{
|
||||
"idx": 30,
|
||||
"version": "7",
|
||||
"when": 1773212242728,
|
||||
"tag": "20260311065722_AddWeekStartDay",
|
||||
"breakpoints": true
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -127,6 +127,7 @@ export const update = async (
|
||||
plan?: "free" | "pro" | "enterprise";
|
||||
description?: string;
|
||||
showEmailsToMembers?: boolean;
|
||||
weekStartDay?: number;
|
||||
},
|
||||
) => {
|
||||
const [result] = await db
|
||||
@@ -137,6 +138,7 @@ export const update = async (
|
||||
plan: workspaceInput.plan,
|
||||
description: workspaceInput.description,
|
||||
showEmailsToMembers: workspaceInput.showEmailsToMembers,
|
||||
weekStartDay: workspaceInput.weekStartDay,
|
||||
})
|
||||
.where(eq(workspaces.publicId, workspacePublicId))
|
||||
.returning({
|
||||
@@ -147,6 +149,7 @@ export const update = async (
|
||||
description: workspaces.description,
|
||||
plan: workspaces.plan,
|
||||
showEmailsToMembers: workspaces.showEmailsToMembers,
|
||||
weekStartDay: workspaces.weekStartDay,
|
||||
});
|
||||
|
||||
return result;
|
||||
@@ -189,6 +192,7 @@ export const getByPublicIdWithMembers = (
|
||||
name: true,
|
||||
slug: true,
|
||||
showEmailsToMembers: true,
|
||||
weekStartDay: true,
|
||||
},
|
||||
with: {
|
||||
members: {
|
||||
@@ -274,6 +278,7 @@ export const getAllByUserId = async (db: dbClient, userId: string) => {
|
||||
description: true,
|
||||
slug: true,
|
||||
plan: true,
|
||||
weekStartDay: true,
|
||||
deletedAt: true,
|
||||
},
|
||||
// https://github.com/drizzle-team/drizzle-orm/issues/2903
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
bigint,
|
||||
bigserial,
|
||||
boolean,
|
||||
integer,
|
||||
pgEnum,
|
||||
pgTable,
|
||||
text,
|
||||
@@ -45,6 +46,7 @@ export const workspaces = pgTable("workspace", {
|
||||
slug: varchar("slug", { length: 255 }).notNull().unique(),
|
||||
plan: workspacePlanEnum("plan").notNull().default("free"),
|
||||
showEmailsToMembers: boolean("showEmailsToMembers").notNull().default(true),
|
||||
weekStartDay: integer("weekStartDay").notNull().default(1),
|
||||
createdBy: uuid("createdBy").references(() => users.id, {
|
||||
onDelete: "set null",
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user