Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
import { Button } from "@cap/ui-solid";
import { useNavigate } from "@solidjs/router";
import { createResource, For, onMount } from "solid-js";
import IconLucideDatabase from "~icons/lucide/database";
import "@total-typescript/ts-reset/filter-boolean";
import { authStore } from "~/store";
import { createSelectedOrganization } from "~/utils/organization-branding";
import { commands } from "~/utils/tauri";
import { apiClient, protectedHeaders } from "~/utils/web-api";
import { Section, SectionCard, SettingsPageContent } from "../Setting";
const GoogleDriveIcon = (props: { class?: string }) => (
<svg
class={props.class}
viewBox="0 0 87.3 78"
xmlns="http://www.w3.org/2000/svg"
aria-hidden="true"
>
<path
d="m6.6 66.85 3.85 6.65c.8 1.4 1.95 2.5 3.3 3.3l13.75-23.8h-27.5c0 1.55.4 3.1 1.2 4.5z"
fill="#0066da"
/>
<path
d="m43.65 25-13.75-23.8c-1.35.8-2.5 1.9-3.3 3.3l-25.4 44a9.06 9.06 0 0 0 -1.2 4.5h27.5z"
fill="#00ac47"
/>
<path
d="m73.55 76.8c1.35-.8 2.5-1.9 3.3-3.3l1.6-2.75 7.65-13.25c.8-1.4 1.2-2.95 1.2-4.5h-27.502l5.852 11.5z"
fill="#ea4335"
/>
<path
d="m43.65 25 13.75-23.8c-1.35-.8-2.9-1.2-4.5-1.2h-18.5c-1.6 0-3.15.45-4.5 1.2z"
fill="#00832d"
/>
<path
d="m59.8 53h-32.3l-13.75 23.8c1.35.8 2.9 1.2 4.5 1.2h50.8c1.6 0 3.15-.45 4.5-1.2z"
fill="#2684fc"
/>
<path
d="m73.4 26.5-12.7-22c-.8-1.4-1.95-2.5-3.3-3.3l-13.75 23.8 16.15 28h27.45c0-1.55-.4-3.1-1.2-4.5z"
fill="#ffba00"
/>
</svg>
);
export default function AppsTab() {
const navigate = useNavigate();
const auth = authStore.createQuery();
const organizationSelection = createSelectedOrganization();
const [storage] = createResource(
() => {
// Only query storage integrations when we have a valid signed-in
// session with organization data. A stale persisted organizationId can
// otherwise make `selectedOrganizationId()` truthy while signed out,
// firing an unauthenticated request that surfaces a raw fetch error.
if (!organizationSelection.signedIn()) return null;
return organizationSelection.selectedOrganizationId();
},
async (orgId) => {
try {
const response = await apiClient.desktop.getStorageIntegrations({
query: { orgId },
headers: await protectedHeaders(),
});
if (response.status !== 200) return null;
return response.body;
} catch (error) {
console.error("Failed to load storage integrations", error);
return null;
}
},
);
const isPro = () => auth.data?.plan?.upgraded;
const managedByOrganization = () => storage()?.managedByOrganization ?? null;
onMount(() => {
void commands.checkUpgradedAndUpdate();
});
const apps = [
{
name: "Google Drive",
description:
"Connect Google Drive for new shareable link uploads. Cap stores new videos in a private Cap folder in your Drive and continues serving them through Cap after normal access checks.",
icon: GoogleDriveIcon,
url: "/settings/integrations/google-drive-config",
pro: true,
},
{
name: "S3 Config",
description:
"Connect your own S3 bucket for complete control over your data storage. All new shareable link uploads will be automatically uploaded to your configured S3 bucket, ensuring you maintain complete ownership and control over your content. Perfect for organizations requiring data sovereignty and custom storage policies.",
icon: IconLucideDatabase,
url: "/settings/integrations/s3-config",
pro: true,
},
];
const handleAppClick = async (app: (typeof apps)[number]) => {
try {
if (managedByOrganization()) return;
if (app.pro && !isPro()) {
await commands.showWindow("Upgrade");
return;
}
navigate(app.url);
} catch (error) {
console.error("Error handling app click:", error);
}
};
return (
<div class="cap-settings-page flex flex-col h-full custom-scroll">
<SettingsPageContent>
<Section
title="Integrations"
description="Configure integrations to extend Cap's functionality and connect with third-party services."
>
<div class="space-y-3">
<For each={apps}>
{(app) => (
<SectionCard padded class="space-y-3">
<div class="flex justify-between items-center gap-3">
<div class="flex gap-2 items-center min-w-0">
<app.icon class="w-4 h-4 shrink-0 text-gray-12" />
<p class="text-[13px] text-gray-12">{app.name}</p>
</div>
<Button
size="sm"
variant="primary"
disabled={!!managedByOrganization()}
onClick={() => handleAppClick(app)}
>
{managedByOrganization()
? "Managed by your organization"
: app.pro && !isPro()
? "Upgrade to Pro"
: "Configure"}
</Button>
</div>
<p class="text-xs leading-snug text-gray-10">
{app.description}
</p>
</SectionCard>
)}
</For>
</div>
</Section>
</SettingsPageContent>
</div>
);
}