Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Disable deleting program links

Kiran K5e1de8826322
diff --git a/apps/web/ui/links/link-controls.tsx b/apps/web/ui/links/link-controls.tsx
index 4ee19aa27c..f2f05b6108 100644
--- a/apps/web/ui/links/link-controls.tsx
+++ b/apps/web/ui/links/link-controls.tsx
@@ -58,6 +58,9 @@ export function LinkControls({ link }: { link: ResponseLink }) {
props: link,
});
+ const isRootLink = link.key === "_root";
+ const isProgramLink = link.programId !== null;
+
// Duplicate link Modal
const {
id: _,
@@ -73,7 +76,7 @@ export function LinkControls({ link }: { link: ResponseLink }) {
// @ts-expect-error
duplicateProps: {
...propsToDuplicate,
- key: link.key === "_root" ? nanoid(7) : `${punycode(link.key)}-copy`,
+ key: isRootLink ? nanoid(7) : `${punycode(link.key)}-copy`,
clicks: 0,
},
});
@@ -231,19 +234,27 @@ export function LinkControls({ link }: { link: ResponseLink }) {
),
})}
/>
- {link.key !== "_root" && (
- <Button
- text="Delete"
- variant="danger-outline"
- onClick={() => {
- setOpenPopover(false);
- setShowDeleteLinkModal(true);
- }}
- icon={<Delete className="h-4 w-4" />}
- shortcut="X"
- className="h-9 px-2 font-medium"
- />
- )}
+
+ <Button
+ text="Delete"
+ variant="danger-outline"
+ onClick={() => {
+ setOpenPopover(false);
+ setShowDeleteLinkModal(true);
+ }}
+ icon={<Delete className="h-4 w-4" />}
+ shortcut="X"
+ className="h-9 px-2 font-medium"
+ disabled={isRootLink || isProgramLink}
+ disabledTooltip={
+ isRootLink
+ ? "You can't delete a custom domain link. You can delete the domain instead."
+ : isProgramLink
+ ? "You can't delete a link that's part of a program."
+ : undefined
+ }
+ />
+
{!slug && ( // this is only shown in admin mode (where there's no slug)
<button
onClick={() => handleBanLink()}