Skip to content

Commit 4f094c3

Browse files
authored
Merge pull request #1616 from mfts/marc/pm-271-add-link-presets-to-incoming-hooks
feat: add presetId to incoming webhooks
2 parents 17c9992 + aee3d68 commit 4f094c3

File tree

3 files changed

+285
-29
lines changed

3 files changed

+285
-29
lines changed

components/documents/folder-card.tsx

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useEffect, useRef, useState } from "react";
55
import { TeamContextType } from "@/context/team-context";
66
import {
77
BetweenHorizontalStartIcon,
8+
ClipboardCopyIcon,
9+
CopyIcon,
810
FolderIcon,
911
FolderInputIcon,
1012
FolderPenIcon,
@@ -15,6 +17,10 @@ import {
1517
import { toast } from "sonner";
1618
import { mutate } from "swr";
1719

20+
import { DataroomFolderWithCount } from "@/lib/swr/use-dataroom";
21+
import { FolderWithCount } from "@/lib/swr/use-documents";
22+
import { timeAgo } from "@/lib/utils";
23+
1824
import { Button } from "@/components/ui/button";
1925
import {
2026
DropdownMenu,
@@ -25,10 +31,6 @@ import {
2531
DropdownMenuTrigger,
2632
} from "@/components/ui/dropdown-menu";
2733

28-
import { DataroomFolderWithCount } from "@/lib/swr/use-dataroom";
29-
import { FolderWithCount } from "@/lib/swr/use-documents";
30-
import { timeAgo } from "@/lib/utils";
31-
3234
import { MoveToDataroomFolderModal } from "../datarooms/move-dataroom-folder-modal";
3335
import { EditFolderModal } from "../folders/edit-folder-modal";
3436
import { AddFolderToDataroomModal } from "./add-folder-to-dataroom-modal";
@@ -244,7 +246,7 @@ export default function FolderCard({
244246
<MoreVertical className="h-4 w-4" />
245247
</Button>
246248
</DropdownMenuTrigger>
247-
<DropdownMenuContent align="end" ref={dropdownRef}>
249+
<DropdownMenuContent align="end" ref={dropdownRef} className="w-64">
248250
<DropdownMenuLabel>Actions</DropdownMenuLabel>
249251
<DropdownMenuItem
250252
onClick={(e) => {
@@ -286,6 +288,23 @@ export default function FolderCard({
286288
? "Copy folder to other dataroom"
287289
: "Add folder to dataroom"}
288290
</DropdownMenuItem>
291+
<DropdownMenuItem
292+
onClick={(e) => {
293+
e.preventDefault();
294+
e.stopPropagation();
295+
navigator.clipboard.writeText(folder.id);
296+
toast.success("Folder ID copied to clipboard");
297+
}}
298+
className="group/folderid"
299+
>
300+
<CopyIcon className="mr-2 h-4 w-4" />
301+
<span className="inline group-hover/folderid:hidden">
302+
Copy Folder ID
303+
</span>
304+
<span className="hidden group-hover/folderid:inline group-hover/folderid:cursor-copy">
305+
{folder.id}
306+
</span>
307+
</DropdownMenuItem>
289308
<DropdownMenuSeparator />
290309

291310
<DropdownMenuItem

lib/utils.ts

Lines changed: 33 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { NextRouter } from "next/router";
2+
13
import slugify from "@sindresorhus/slugify";
24
import { upload } from "@vercel/blob/client";
35
import { Message } from "ai";
@@ -6,7 +8,6 @@ import { type ClassValue, clsx } from "clsx";
68
import crypto from "crypto";
79
import ms from "ms";
810
import { customAlphabet } from "nanoid";
9-
import { NextRouter } from "next/router";
1011
import { ThreadMessage } from "openai/resources/beta/threads/messages/messages";
1112
import { rgb } from "pdf-lib";
1213
import { ParsedUrlQuery } from "querystring";
@@ -394,6 +395,10 @@ export function constructMetadata({
394395
};
395396
}
396397

398+
export const isDataUrl = (str: string): boolean => {
399+
return str?.startsWith("data:");
400+
};
401+
397402
export const convertDataUrlToFile = ({
398403
dataUrl,
399404
filename = "logo.png",
@@ -422,6 +427,30 @@ export const convertDataUrlToFile = ({
422427
return new File([u8arr], filename, { type: mime });
423428
};
424429

430+
export const convertDataUrlToBuffer = (
431+
dataUrl: string,
432+
): { buffer: Buffer; mimeType: string; filename: string } => {
433+
// Extract mime type
434+
const match = dataUrl.match(/:(.*?);/);
435+
const mimeType = match ? match[1] : "";
436+
437+
// Extract base64 data
438+
const base64Data = dataUrl.split(",")[1];
439+
const buffer = Buffer.from(base64Data, "base64");
440+
441+
// Determine filename based on mime type
442+
const filename =
443+
mimeType === "image/png"
444+
? "image.png"
445+
: mimeType === "image/jpeg"
446+
? "image.jpg"
447+
: mimeType === "image/x-icon" || mimeType === "image/vnd.microsoft.icon"
448+
? "favicon.ico"
449+
: "image";
450+
451+
return { buffer, mimeType, filename };
452+
};
453+
425454
export const validateImageDimensions = (
426455
image: string,
427456
minSize: number,
@@ -563,15 +592,15 @@ export const getBreadcrumbPath = (path: string[]) => {
563592
};
564593

565594
export const handleInvitationStatus = (
566-
invitationStatus: 'accepted' | 'teamMember',
595+
invitationStatus: "accepted" | "teamMember",
567596
queryParams: ParsedUrlQuery,
568597
router: NextRouter,
569598
) => {
570599
switch (invitationStatus) {
571-
case 'accepted':
600+
case "accepted":
572601
toast.success("Welcome to the team! You've successfully joined.");
573602
break;
574-
case 'teamMember':
603+
case "teamMember":
575604
toast.error("You've already accepted this invitation!");
576605
break;
577606
default:

0 commit comments

Comments
 (0)