Skip to content

Add share branding toggle #635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/web/actions/organization/update-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { revalidatePath } from "next/cache";
export async function updateOrganizationDetails(
organizationName: string,
allowedEmailDomain: string,
showCapBranding: boolean,
organizationId: string
) {
const user = await getCurrentUser();
Expand All @@ -35,6 +36,7 @@ export async function updateOrganizationDetails(
.set({
name: organizationName,
allowedEmailDomain: allowedEmailDomain || null,
showCapBranding,
})
.where(eq(organizations.id, organizationId));

Expand Down
14 changes: 13 additions & 1 deletion apps/web/app/dashboard/settings/organization/Organization.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ export const Organization = () => {
const [isInviteDialogOpen, setIsInviteDialogOpen] = useState(false);
const ownerToastShown = useRef(false);
const [saveLoading, setSaveLoading] = useState(false);
const [showCapBranding, setShowCapBranding] = useState(
activeOrganization?.organization.showCapBranding ?? true
);

const showOwnerToast = useCallback(() => {
if (!ownerToastShown.current) {
Expand Down Expand Up @@ -52,6 +55,7 @@ export const Organization = () => {
await updateOrganizationDetails(
organizationName,
allowedEmailDomain,
showCapBranding,
activeOrganization?.organization.id as string
);
toast.success("Settings updated successfully");
Expand All @@ -63,7 +67,13 @@ export const Organization = () => {
setSaveLoading(false);
}
},
[isOwner, showOwnerToast, activeOrganization?.organization.id, router]
[
isOwner,
showOwnerToast,
activeOrganization?.organization.id,
router,
showCapBranding,
]
);

const handleManageBilling = useCallback(async () => {
Expand Down Expand Up @@ -102,6 +112,8 @@ export const Organization = () => {
saveLoading={saveLoading}
showOwnerToast={showOwnerToast}
organizationName={organizationName}
showCapBranding={showCapBranding}
setShowCapBranding={setShowCapBranding}
/>
<CustomDomainIconCard
isOwner={isOwner}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
"use client";

import { useSharedContext } from "@/app/dashboard/_components/DynamicSharedLayout";
import {
Button,
Card,
Input,
Label
} from "@cap/ui";
import { Button, Card, Input, Label, Switch } from "@cap/ui";

interface OrganizationDetailsCardProps {
isOwner: boolean;
saveLoading: boolean;
showOwnerToast: () => void;
organizationName: string | undefined;
showCapBranding: boolean;
setShowCapBranding: (value: boolean) => void;
}

export const OrganizationDetailsCard = ({
isOwner,
saveLoading,
showOwnerToast,
organizationName
organizationName,
showCapBranding,
setShowCapBranding,
}: OrganizationDetailsCardProps) => {
const { activeOrganization } = useSharedContext();

Expand Down Expand Up @@ -68,6 +67,21 @@ export const OrganizationDetailsCard = ({
if (!isOwner) showOwnerToast();
}}
/>
<div className="flex items-center gap-2 mt-4">
<Switch
id="showCapBranding"
checked={showCapBranding}
disabled={!isOwner}
onCheckedChange={(checked) => {
if (!isOwner) {
showOwnerToast();
return;
}
setShowCapBranding(checked);
}}
/>
<Label htmlFor="showCapBranding">Show "Recorded with Cap" link</Label>
</div>
</div>
</div>
<Button
Expand Down
27 changes: 17 additions & 10 deletions apps/web/app/s/[videoId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -499,12 +499,14 @@ async function AuthorizedContent({

let customDomain: string | null = null;
let domainVerified = false;
let showCapBranding = true;

if (video.sharedOrganization?.organizationId) {
const organizationData = await db()
.select({
customDomain: organizations.customDomain,
domainVerified: organizations.domainVerified,
showCapBranding: organizations.showCapBranding,
})
.from(organizations)
.where(eq(organizations.id, video.sharedOrganization.organizationId))
Expand All @@ -519,6 +521,7 @@ async function AuthorizedContent({
if (organizationData[0].domainVerified !== null) {
domainVerified = true;
}
showCapBranding = organizationData[0].showCapBranding;
}
}

Expand All @@ -527,6 +530,7 @@ async function AuthorizedContent({
.select({
customDomain: organizations.customDomain,
domainVerified: organizations.domainVerified,
showCapBranding: organizations.showCapBranding,
})
.from(organizations)
.where(eq(organizations.ownerId, video.ownerId))
Expand All @@ -541,6 +545,7 @@ async function AuthorizedContent({
if (ownerOrganizations[0].domainVerified !== null) {
domainVerified = true;
}
showCapBranding = ownerOrganizations[0].showCapBranding;
}
}

Expand Down Expand Up @@ -650,16 +655,18 @@ async function AuthorizedContent({
aiUiEnabled={aiUiEnabled}
/>
</div>
<div className="py-4 mt-auto">
<a
target="_blank"
href={`/?ref=video_${video.id}`}
className="flex justify-center items-center px-4 py-2 mx-auto space-x-2 bg-gray-1 rounded-full new-card-style w-fit"
>
<span className="text-sm">Recorded with</span>
<Logo className="w-14 h-auto" />
</a>
</div>
{showCapBranding && (
<div className="py-4 mt-auto">
<a
target="_blank"
href={`/?ref=video_${video.id}`}
className="flex justify-center items-center px-4 py-2 mx-auto space-x-2 bg-gray-1 rounded-full new-card-style w-fit"
>
<span className="text-sm">Recorded with</span>
<Logo className="w-14 h-auto" />
</a>
</div>
)}
</>
);
}
1 change: 1 addition & 0 deletions packages/database/migrations/0002_disable_cap_branding.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `organizations` ADD `showCapBranding` boolean NOT NULL DEFAULT true;
8 changes: 8 additions & 0 deletions packages/database/migrations/meta/0000_snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -743,6 +743,14 @@
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"showCapBranding": {
"name": "showCapBranding",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "true"
}
},
"indexes": {
Expand Down
8 changes: 8 additions & 0 deletions packages/database/migrations/meta/0001_snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,14 @@
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"showCapBranding": {
"name": "showCapBranding",
"type": "boolean",
"primaryKey": false,
"notNull": true,
"autoincrement": false,
"default": "true"
}
},
"indexes": {
Expand Down
7 changes: 7 additions & 0 deletions packages/database/migrations/meta/_journal.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@
"when": 1749268354138,
"tag": "0001_white_young_avengers",
"breakpoints": true
},
{
"idx": 2,
"version": "5",
"when": 1749268354139,
"tag": "0002_disable_cap_branding",
"breakpoints": true
}
]
}
1 change: 1 addition & 0 deletions packages/database/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export const organizations = mysqlTable(
updatedAt: timestamp("updatedAt").notNull().defaultNow().onUpdateNow(),
workosOrganizationId: varchar("workosOrganizationId", { length: 255 }),
workosConnectionId: varchar("workosConnectionId", { length: 255 }),
showCapBranding: boolean("showCapBranding").notNull().default(true),
},
(table) => ({
ownerIdIndex: index("owner_id_idx").on(table.ownerId),
Expand Down
Loading