merge: resolve conflicts with prerelease branch

This commit is contained in:
Varun committed 2026-04-06 20:18:11 +05:30
commit e814793190
48 files changed
+2382 -258

No files matched your search

+43 -2
View File
@@ -3,6 +3,7 @@ import { Dialog, DialogTitle, DialogContent, DialogHeader, DialogTrigger, Dialog
import { Button, ButtonProps } from '../ui/button';
import { ShareLinkFilters } from '@/types/shareLink';
import { generateShareLink } from '@/handlers/api/shareLink.handler';
import { createShareKey, getShareKey } from '@/handlers/api/share-key.handler';
import { Input } from '../ui/input';
import { Label } from '@radix-ui/react-label';
@@ -22,6 +23,28 @@ export default function ShareAssetsTrigger({ filters, buttonProps }: ShareAssets
const [config, setConfig] = useState<Partial<ShareLinkFilters>>({
expiresIn: "never"
});
const [endpointConfigured, setEndpointConfigured] = useState<boolean | null>(null);
const [shareKeyExists, setShareKeyExists] = useState<boolean | null>(null);
const [creatingKey, setCreatingKey] = useState(false);
const [keyError, setKeyError] = useState<string | null>(null);
const checkShareKey = async () => {
const data = await getShareKey();
setEndpointConfigured(data.endpointConfigured);
setShareKeyExists(data.exists);
};
const handleCreateKey = async () => {
setCreatingKey(true);
setKeyError(null);
try {
await createShareKey();
setShareKeyExists(true);
} catch (err: any) {
setKeyError(err.message ?? 'Failed to create share key');
}
setCreatingKey(false);
};
const handleReset = () => {
setConfig({ expiresIn: "never" });
@@ -66,7 +89,7 @@ export default function ShareAssetsTrigger({ filters, buttonProps }: ShareAssets
return (
<Dialog>
<Dialog onOpenChange={(open) => { if (open) checkShareKey(); }}>
<DialogTrigger asChild>
<Button {...buttonProps}>Share</Button>
</DialogTrigger>
@@ -77,6 +100,24 @@ export default function ShareAssetsTrigger({ filters, buttonProps }: ShareAssets
<DialogDescription>
Generate a share link for the selected assets (either bunch of albums or bunch of people) and share it with your friends and family.
</DialogDescription>
{endpointConfigured === false && (
<div className="rounded-md border border-red-400 bg-red-50 dark:bg-red-950 p-3">
<p className="text-sm text-red-800 dark:text-red-200">
<strong>POWER_TOOLS_ENDPOINT_URL</strong> is not set. Add it to your environment variables to enable share links.
</p>
</div>
)}
{endpointConfigured && shareKeyExists === false && (
<div className="rounded-md border border-yellow-400 bg-yellow-50 dark:bg-yellow-950 p-3 flex flex-col gap-2">
<p className="text-sm text-yellow-800 dark:text-yellow-200">
Serving thumbnails on share links requires a dedicated API key. Create one now with minimal permissions.
</p>
{keyError && <p className="text-xs text-red-500">{keyError}</p>}
<Button size="sm" onClick={handleCreateKey} disabled={creatingKey} className="self-start">
{creatingKey ? 'Creating...' : 'Create API Key'}
</Button>
</div>
)}
{errorMessage && <div className="text-red-500">{errorMessage}</div>}
{generatedLink ? <div className="flex flex-col gap-2">
<Label className='text-sm'>Share Link</Label>
@@ -120,7 +161,7 @@ export default function ShareAssetsTrigger({ filters, buttonProps }: ShareAssets
</SelectContent>
</Select>
</div>
<Button onClick={handleGenerate} disabled={loading}>Generate Share Link</Button>
<Button onClick={handleGenerate} disabled={loading || !endpointConfigured || !shareKeyExists}>Generate Share Link</Button>
</div>
)}
</DialogContent>