feat: Make Upload-Post API key required and warn on every screen
Treat the Upload-Post key as mandatory like the Gemini key: block /api/process when either is missing, mark the Settings section as Required, and show a persistent banner plus a header pill on every screen until both keys are configured. The missing-key modal now lets the user paste each key inline. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6a83ebdcd7
commit
42ca76c48b
1 changed files with 107 additions and 43 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect } from 'react';
|
||||||
import { Upload, FileVideo, Sparkles, Youtube, Instagram, Share2, LogOut, ChevronDown, Check, Activity, LayoutDashboard, Settings, PlusCircle, History, Menu, X, Terminal, Shield, LayoutGrid, Image, Globe, RotateCcw, Calendar } from 'lucide-react';
|
import { Upload, FileVideo, Sparkles, Youtube, Instagram, Share2, LogOut, ChevronDown, Check, Activity, LayoutDashboard, Settings, PlusCircle, History, Menu, X, Terminal, Shield, LayoutGrid, Image, Globe, RotateCcw, Calendar, AlertTriangle, KeyRound } from 'lucide-react';
|
||||||
import KeyInput from './components/KeyInput';
|
import KeyInput from './components/KeyInput';
|
||||||
import MediaInput from './components/MediaInput';
|
import MediaInput from './components/MediaInput';
|
||||||
import ResultCard from './components/ResultCard';
|
import ResultCard from './components/ResultCard';
|
||||||
|
|
@ -321,7 +321,7 @@ function App() {
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleProcess = async (data) => {
|
const handleProcess = async (data) => {
|
||||||
if (!apiKey) {
|
if (!apiKey || !uploadPostKey) {
|
||||||
setShowKeyModal(true);
|
setShowKeyModal(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -494,14 +494,48 @@ function App() {
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{!apiKey && (
|
{(!apiKey || !uploadPostKey) && (
|
||||||
<span className="text-xs text-amber-500 bg-amber-500/10 px-3 py-1 rounded-full border border-amber-500/20">
|
<button
|
||||||
API Key Missing
|
onClick={() => setActiveTab('settings')}
|
||||||
</span>
|
className="text-xs text-amber-400 bg-amber-500/10 hover:bg-amber-500/20 px-3 py-1 rounded-full border border-amber-500/30 transition-colors flex items-center gap-1.5"
|
||||||
|
title="Click to configure your API keys"
|
||||||
|
>
|
||||||
|
<AlertTriangle size={12} />
|
||||||
|
{!apiKey && !uploadPostKey
|
||||||
|
? 'Gemini & Upload-Post keys missing'
|
||||||
|
: !apiKey
|
||||||
|
? 'Gemini API Key Missing'
|
||||||
|
: 'Upload-Post API Key Missing'}
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
{/* Persistent Missing Keys Banner — visible on every screen */}
|
||||||
|
{(!apiKey || !uploadPostKey) && activeTab !== 'settings' && (
|
||||||
|
<div className="mx-6 mt-3 p-3 bg-amber-500/10 border border-amber-500/30 rounded-xl flex items-center justify-between gap-4 shrink-0 animate-[fadeIn_0.3s_ease-out]">
|
||||||
|
<div className="flex items-center gap-3 text-sm text-amber-200">
|
||||||
|
<KeyRound size={16} className="shrink-0 text-amber-400" />
|
||||||
|
<div>
|
||||||
|
<span className="font-semibold">Required API keys missing.</span>{' '}
|
||||||
|
<span className="text-amber-200/80">
|
||||||
|
{!apiKey && !uploadPostKey
|
||||||
|
? 'Set your Gemini and Upload-Post API keys to use OpenShorts.'
|
||||||
|
: !apiKey
|
||||||
|
? 'Set your Gemini API key to use OpenShorts.'
|
||||||
|
: 'Set your Upload-Post API key to use OpenShorts.'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
onClick={() => setActiveTab('settings')}
|
||||||
|
className="shrink-0 text-xs font-medium px-3 py-1.5 rounded-lg bg-amber-500 hover:bg-amber-400 text-black transition-colors"
|
||||||
|
>
|
||||||
|
Go to Settings
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{/* Session Recovery Banner */}
|
{/* Session Recovery Banner */}
|
||||||
{sessionRecovered && (
|
{sessionRecovered && (
|
||||||
<div className="mx-6 mt-2 p-3 bg-primary/10 border border-primary/20 rounded-xl flex items-center justify-between animate-[fadeIn_0.3s_ease-out] shrink-0">
|
<div className="mx-6 mt-2 p-3 bg-primary/10 border border-primary/20 rounded-xl flex items-center justify-between animate-[fadeIn_0.3s_ease-out] shrink-0">
|
||||||
|
|
@ -530,15 +564,14 @@ function App() {
|
||||||
</div>
|
</div>
|
||||||
<KeyInput onKeySet={setApiKey} savedKey={apiKey} />
|
<KeyInput onKeySet={setApiKey} savedKey={apiKey} />
|
||||||
|
|
||||||
<div className="glass-panel p-6 mt-8">
|
<div className={`glass-panel p-6 mt-8 ${!uploadPostKey ? 'border-amber-500/30 ring-1 ring-amber-500/20' : ''}`}>
|
||||||
<div className="flex items-center justify-between mb-4">
|
<div className="flex items-center justify-between mb-4">
|
||||||
<h2 className="text-lg font-semibold">Social Integration</h2>
|
<h2 className="text-lg font-semibold">Social Integration</h2>
|
||||||
<span className="text-[10px] bg-white/5 border border-white/5 px-2 py-0.5 rounded text-zinc-500 uppercase tracking-wider">Optional</span>
|
<span className="text-[10px] bg-amber-500/10 border border-amber-500/30 px-2 py-0.5 rounded text-amber-400 uppercase tracking-wider">Required</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="text-xs text-zinc-500 mb-6 leading-relaxed">
|
<p className="text-xs text-zinc-500 mb-6 leading-relaxed">
|
||||||
Automatically publish your clips to TikTok, Instagram Reels, and YouTube Shorts via <strong>Upload-Post</strong>.
|
Required to publish your clips to TikTok, Instagram Reels, and YouTube Shorts via <strong>Upload-Post</strong>.
|
||||||
Includes a <strong>free tier</strong> (no credit card required).
|
Includes a <strong>free tier</strong> (no credit card required).
|
||||||
If you prefer, you can skip this and manually download/upload your videos.
|
|
||||||
</p>
|
</p>
|
||||||
<div className="space-y-4">
|
<div className="space-y-4">
|
||||||
<label className="block text-sm text-zinc-400">Upload-Post API Key</label>
|
<label className="block text-sm text-zinc-400">Upload-Post API Key</label>
|
||||||
|
|
@ -856,43 +889,74 @@ function App() {
|
||||||
{showKeyModal && (
|
{showKeyModal && (
|
||||||
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" onClick={() => setShowKeyModal(false)}>
|
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm" onClick={() => setShowKeyModal(false)}>
|
||||||
<div className="bg-[#18181b] border border-white/10 rounded-2xl p-6 max-w-md w-full mx-4 space-y-4 shadow-2xl" onClick={(e) => e.stopPropagation()}>
|
<div className="bg-[#18181b] border border-white/10 rounded-2xl p-6 max-w-md w-full mx-4 space-y-4 shadow-2xl" onClick={(e) => e.stopPropagation()}>
|
||||||
<h2 className="text-lg font-bold text-white">Gemini API Key Required</h2>
|
<h2 className="text-lg font-bold text-white">
|
||||||
|
{!apiKey && !uploadPostKey
|
||||||
|
? 'Required API Keys Missing'
|
||||||
|
: !apiKey
|
||||||
|
? 'Gemini API Key Required'
|
||||||
|
: 'Upload-Post API Key Required'}
|
||||||
|
</h2>
|
||||||
<p className="text-sm text-zinc-400">
|
<p className="text-sm text-zinc-400">
|
||||||
You need a Google Gemini API key to use the Clip Generator. It's free and takes 30 seconds to get.
|
OpenShorts needs both a <strong className="text-zinc-200">Gemini</strong> API key and an <strong className="text-zinc-200">Upload-Post</strong> API key. Both have free tiers.
|
||||||
</p>
|
</p>
|
||||||
<div className="bg-white/5 border border-white/10 rounded-lg p-4 space-y-2">
|
|
||||||
<p className="text-xs font-semibold text-zinc-300">How to get your free key:</p>
|
|
||||||
<ol className="text-xs text-zinc-400 space-y-1 list-decimal list-inside">
|
|
||||||
<li>Go to <a href="https://aistudio.google.com/app/apikey" target="_blank" rel="noopener noreferrer" className="text-blue-400 underline">aistudio.google.com/app/apikey</a></li>
|
|
||||||
<li>Sign in with your Google account</li>
|
|
||||||
<li>Click "Create API Key"</li>
|
|
||||||
<li>Copy the key and paste it below</li>
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
placeholder="Paste your Gemini API key here..."
|
|
||||||
className="w-full bg-black/50 border border-white/20 rounded-lg px-4 py-2.5 text-sm text-white placeholder-zinc-600 focus:outline-none focus:border-blue-500"
|
|
||||||
onKeyDown={(e) => {
|
|
||||||
if (e.key === 'Enter' && e.target.value.trim()) {
|
|
||||||
setApiKey(e.target.value.trim());
|
|
||||||
setShowKeyModal(false);
|
|
||||||
}
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{/* Upload-Post info */}
|
{/* Gemini block */}
|
||||||
<div className="bg-violet-500/5 border border-violet-500/20 rounded-lg p-4 space-y-2">
|
<div className={`rounded-lg p-4 space-y-2 border ${!apiKey ? 'bg-blue-500/5 border-blue-500/30' : 'bg-white/5 border-white/10 opacity-70'}`}>
|
||||||
<p className="text-xs font-semibold text-violet-300">Optional: Auto-publish to social media</p>
|
<p className="text-xs font-semibold text-zinc-200 flex items-center gap-2">
|
||||||
<p className="text-xs text-zinc-400">
|
{apiKey ? <Check size={12} className="text-green-400" /> : <AlertTriangle size={12} className="text-amber-400" />}
|
||||||
With an <strong className="text-zinc-300">Upload-Post</strong> API key you can publish your clips directly to TikTok, Instagram Reels, and YouTube Shorts — or schedule them for later. Free tier available, no credit card needed.
|
Gemini API Key {apiKey && <span className="text-green-400">— set</span>}
|
||||||
</p>
|
</p>
|
||||||
<ol className="text-xs text-zinc-400 space-y-1 list-decimal list-inside">
|
{!apiKey && (
|
||||||
<li>Register at <a href="https://app.upload-post.com/login" target="_blank" rel="noopener noreferrer" className="text-violet-400 underline">app.upload-post.com</a></li>
|
<>
|
||||||
<li>Connect your TikTok, Instagram, or YouTube accounts</li>
|
<ol className="text-xs text-zinc-400 space-y-1 list-decimal list-inside">
|
||||||
<li>Go to API Keys and generate one</li>
|
<li>Go to <a href="https://aistudio.google.com/app/apikey" target="_blank" rel="noopener noreferrer" className="text-blue-400 underline">aistudio.google.com/app/apikey</a></li>
|
||||||
<li>Paste it in Settings — done!</li>
|
<li>Sign in with your Google account</li>
|
||||||
</ol>
|
<li>Click "Create API Key"</li>
|
||||||
|
<li>Copy the key and paste it below</li>
|
||||||
|
</ol>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Paste your Gemini API key here..."
|
||||||
|
className="w-full bg-black/50 border border-white/20 rounded-lg px-4 py-2.5 text-sm text-white placeholder-zinc-600 focus:outline-none focus:border-blue-500"
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter' && e.target.value.trim()) {
|
||||||
|
setApiKey(e.target.value.trim());
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Upload-Post block */}
|
||||||
|
<div className={`rounded-lg p-4 space-y-2 border ${!uploadPostKey ? 'bg-violet-500/5 border-violet-500/30' : 'bg-white/5 border-white/10 opacity-70'}`}>
|
||||||
|
<p className="text-xs font-semibold text-zinc-200 flex items-center gap-2">
|
||||||
|
{uploadPostKey ? <Check size={12} className="text-green-400" /> : <AlertTriangle size={12} className="text-amber-400" />}
|
||||||
|
Upload-Post API Key {uploadPostKey && <span className="text-green-400">— set</span>}
|
||||||
|
</p>
|
||||||
|
{!uploadPostKey && (
|
||||||
|
<>
|
||||||
|
<p className="text-xs text-zinc-400">
|
||||||
|
Required to publish your clips to TikTok, Instagram Reels, and YouTube Shorts. Free tier available, no credit card needed.
|
||||||
|
</p>
|
||||||
|
<ol className="text-xs text-zinc-400 space-y-1 list-decimal list-inside">
|
||||||
|
<li>Register at <a href="https://app.upload-post.com/login" target="_blank" rel="noopener noreferrer" className="text-violet-400 underline">app.upload-post.com</a></li>
|
||||||
|
<li>Connect your TikTok, Instagram, or YouTube accounts</li>
|
||||||
|
<li>Go to <a href="https://app.upload-post.com/api-keys" target="_blank" rel="noopener noreferrer" className="text-violet-400 underline">API Keys</a> and generate one</li>
|
||||||
|
<li>Paste it below</li>
|
||||||
|
</ol>
|
||||||
|
<input
|
||||||
|
type="text"
|
||||||
|
placeholder="Paste your Upload-Post API key here..."
|
||||||
|
className="w-full bg-black/50 border border-white/20 rounded-lg px-4 py-2.5 text-sm text-white placeholder-zinc-600 focus:outline-none focus:border-violet-500"
|
||||||
|
onKeyDown={(e) => {
|
||||||
|
if (e.key === 'Enter' && e.target.value.trim()) {
|
||||||
|
setUploadPostKey(e.target.value.trim());
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-3">
|
<div className="flex gap-3">
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue