broken: halfway through removing turso

This commit is contained in:
2026-02-11 07:45:45 +01:00
parent 3126be4e90
commit a8499626c0
9 changed files with 561 additions and 469 deletions

View File

@@ -46,19 +46,11 @@ const App: React.FC = () => {
setMedia(media as MediaData[]);
}
// Re-configure sync backends from saved credentials
// Re-configure Dropbox sync from saved credentials
const savedCreds = localStorage.getItem('bds-credentials');
if (savedCreds) {
try {
const creds = JSON.parse(savedCreds);
if (creds.tursoUrl && creds.tursoToken) {
await window.electronAPI?.sync.configure({
tursoUrl: creds.tursoUrl,
tursoAuthToken: creds.tursoToken,
autoSync: true,
syncInterval: 5,
});
}
if (creds.dropboxAccessToken && creds.dropboxAppKey) {
await window.electronAPI?.dropbox?.configure({
accessToken: creds.dropboxAccessToken,
@@ -71,7 +63,7 @@ const App: React.FC = () => {
}
}
// Check sync status
// Check sync status (uses Dropbox configuration)
const syncConfigured = await window.electronAPI?.sync.isConfigured();
setSyncConfigured(syncConfigured || false);

View File

@@ -3,8 +3,6 @@ import { showToast } from '../Toast';
import './CredentialsPanel.css';
interface Credentials {
tursoUrl: string;
tursoToken: string;
ftpHost?: string;
ftpUser?: string;
ftpPassword?: string;
@@ -15,8 +13,6 @@ interface Credentials {
export const CredentialsPanel: React.FC = () => {
const [credentials, setCredentials] = useState<Credentials>({
tursoUrl: '',
tursoToken: '',
ftpHost: '',
ftpUser: '',
ftpPassword: '',
@@ -24,7 +20,7 @@ export const CredentialsPanel: React.FC = () => {
sshUser: '',
sshKeyPath: '',
});
const [activeTab, setActiveTab] = useState<'sync' | 'ftp' | 'ssh'>('sync');
const [activeTab, setActiveTab] = useState<'ftp' | 'ssh'>('ftp');
const [showTokens, setShowTokens] = useState(false);
// Load saved credentials (in a real app, use secure storage)
@@ -47,16 +43,6 @@ export const CredentialsPanel: React.FC = () => {
// Save to localStorage (in production, use secure storage)
localStorage.setItem('bds-credentials', JSON.stringify(credentials));
// Configure sync if Turso credentials are set
if (credentials.tursoUrl && credentials.tursoToken) {
await window.electronAPI?.sync.configure({
tursoUrl: credentials.tursoUrl,
tursoAuthToken: credentials.tursoToken,
autoSync: true,
syncInterval: 5,
});
}
showToast.success('Credentials saved');
} catch (error) {
console.error('Failed to save credentials:', error);
@@ -64,13 +50,9 @@ export const CredentialsPanel: React.FC = () => {
}
};
const handleClear = (type: 'sync' | 'ftp' | 'ssh') => {
const handleClear = (type: 'ftp' | 'ssh') => {
const newCreds = { ...credentials };
switch (type) {
case 'sync':
newCreds.tursoUrl = '';
newCreds.tursoToken = '';
break;
case 'ftp':
newCreds.ftpHost = '';
newCreds.ftpUser = '';
@@ -85,31 +67,20 @@ export const CredentialsPanel: React.FC = () => {
setCredentials(newCreds);
};
const handleTestConnection = async (type: 'sync' | 'ftp' | 'ssh') => {
const handleTestConnection = async (type: 'ftp' | 'ssh') => {
showToast.loading(`Testing ${type.toUpperCase()} connection...`);
// Simulate connection test
await new Promise(resolve => setTimeout(resolve, 1500));
// In a real implementation, this would test the actual connection
if (type === 'sync' && credentials.tursoUrl && credentials.tursoToken) {
showToast.dismiss();
showToast.success('Sync connection successful');
} else {
showToast.dismiss();
showToast.error('Connection failed - check credentials');
}
showToast.dismiss();
showToast.error('Connection failed - check credentials');
};
return (
<div className="credentials-panel">
<div className="credentials-tabs">
<button
className={activeTab === 'sync' ? 'active' : ''}
onClick={() => setActiveTab('sync')}
>
Cloud Sync
</button>
<button
className={activeTab === 'ftp' ? 'active' : ''}
onClick={() => setActiveTab('ftp')}
@@ -125,55 +96,6 @@ export const CredentialsPanel: React.FC = () => {
</div>
<div className="credentials-content">
{activeTab === 'sync' && (
<div className="credentials-form">
<div className="credentials-header">
<h4>Turso/LibSQL Cloud Sync</h4>
<p className="text-muted">
Connect to Turso for cloud database synchronization.
</p>
</div>
<div className="credentials-field">
<label>Database URL</label>
<input
type="text"
placeholder="libsql://your-database.turso.io"
value={credentials.tursoUrl}
onChange={(e) => setCredentials({ ...credentials, tursoUrl: e.target.value })}
/>
</div>
<div className="credentials-field">
<label>
Auth Token
<button
className="toggle-visibility"
onClick={() => setShowTokens(!showTokens)}
>
{showTokens ? '👁' : '👁‍🗨'}
</button>
</label>
<input
type={showTokens ? 'text' : 'password'}
placeholder="Your authentication token"
value={credentials.tursoToken}
onChange={(e) => setCredentials({ ...credentials, tursoToken: e.target.value })}
/>
</div>
<div className="credentials-actions">
<button onClick={handleSave}>Save</button>
<button className="secondary" onClick={() => handleTestConnection('sync')}>
Test Connection
</button>
<button className="secondary danger" onClick={() => handleClear('sync')}>
Clear
</button>
</div>
</div>
)}
{activeTab === 'ftp' && (
<div className="credentials-form">
<div className="credentials-header">

View File

@@ -17,9 +17,6 @@ export const scrollToSettingsSection = (category: SettingsCategory) => {
// Settings categories
interface Credentials {
// Turso Cloud Sync
tursoUrl: string;
tursoToken: string;
// Dropbox File Sync
dropboxAccessToken: string;
dropboxAppKey: string;
@@ -35,8 +32,6 @@ interface Credentials {
}
const defaultCredentials: Credentials = {
tursoUrl: '',
tursoToken: '',
dropboxAccessToken: '',
dropboxAppKey: '',
dropboxRemotePath: '/blog',
@@ -173,29 +168,6 @@ export const SettingsView: React.FC = () => {
loadSettings();
}, []);
// Save credentials and configure backends
const handleSaveTurso = async () => {
try {
localStorage.setItem('bds-credentials', JSON.stringify(credentials));
if (credentials.tursoUrl && credentials.tursoToken) {
await window.electronAPI?.sync.configure({
tursoUrl: credentials.tursoUrl,
tursoAuthToken: credentials.tursoToken,
autoSync: true,
syncInterval: 5,
});
useAppStore.getState().setSyncConfigured(true);
showToast.success('Cloud sync configured');
} else {
showToast.success('Credentials saved');
}
} catch (error) {
console.error('Failed to save Turso credentials:', error);
showToast.error('Failed to configure cloud sync');
}
};
const handleSaveDropbox = async () => {
try {
localStorage.setItem('bds-credentials', JSON.stringify(credentials));
@@ -227,14 +199,9 @@ export const SettingsView: React.FC = () => {
}
};
const handleClearCredentials = (type: 'turso' | 'dropbox' | 'ftp' | 'ssh') => {
const handleClearCredentials = (type: 'dropbox' | 'ftp' | 'ssh') => {
const newCreds = { ...credentials };
switch (type) {
case 'turso':
newCreds.tursoUrl = '';
newCreds.tursoToken = '';
useAppStore.getState().setSyncConfigured(false);
break;
case 'dropbox':
newCreds.dropboxAccessToken = '';
newCreds.dropboxAppKey = '';
@@ -270,31 +237,19 @@ export const SettingsView: React.FC = () => {
}
};
const handleTestConnection = async (type: 'turso' | 'dropbox') => {
showToast.loading(`Testing ${type} connection...`);
const handleTestDropboxConnection = async () => {
showToast.loading('Testing Dropbox connection...');
try {
if (type === 'turso') {
// Simulate connection test
await new Promise(resolve => setTimeout(resolve, 1500));
if (credentials.tursoUrl && credentials.tursoToken) {
showToast.dismiss();
showToast.success('Cloud sync connection successful');
} else {
showToast.dismiss();
showToast.error('Missing credentials');
}
const status = await window.electronAPI?.dropbox?.getStatus();
showToast.dismiss();
if (status) {
showToast.success('Dropbox connection active');
} else {
const status = await window.electronAPI?.dropbox?.getStatus();
showToast.dismiss();
if (status) {
showToast.success('Dropbox connection active');
} else {
showToast.error('Dropbox connection failed');
}
showToast.error('Dropbox connection failed');
}
} catch {
showToast.dismiss();
showToast.error(`${type} connection failed`);
showToast.error('Dropbox connection failed');
}
};
@@ -321,7 +276,7 @@ export const SettingsView: React.FC = () => {
const projectKeywords = ['project', 'name', 'description', 'blog', 'site'];
const editorKeywords = ['editor', 'mode', 'wysiwyg', 'markdown', 'preview', 'visual'];
const contentKeywords = ['content', 'categories', 'post', 'article', 'picture', 'aside', 'page'];
const syncKeywords = ['sync', 'turso', 'libsql', 'cloud', 'database', 'dropbox', 'file', 'backup', 'token', 'remote'];
const syncKeywords = ['sync', 'dropbox', 'file', 'backup', 'token', 'remote'];
const publishingKeywords = ['publishing', 'ftp', 'ssh', 'deploy', 'server', 'host', 'upload'];
const dataKeywords = ['data', 'database', 'rebuild', 'maintenance', 'posts', 'media', 'links', 'folder', 'filesystem'];
@@ -485,68 +440,6 @@ export const SettingsView: React.FC = () => {
<>
<SettingSection
id="settings-section-sync"
title="Cloud Sync — Turso/LibSQL"
description="Sync post and media metadata to a Turso cloud database for backup and multi-device access."
hidden={!sectionHasMatches(syncKeywords)}
>
<SettingRow
id="turso-url"
label="Database URL"
description="The Turso/LibSQL database URL. Example: libsql://your-database.turso.io"
>
<input
id="turso-url"
type="text"
placeholder="libsql://your-database.turso.io"
value={credentials.tursoUrl}
onChange={(e) => setCredentials({ ...credentials, tursoUrl: e.target.value })}
/>
</SettingRow>
<SettingRow
id="turso-token"
label="Auth Token"
description="Your Turso database authentication token."
>
<div className="setting-input-group">
<input
id="turso-token"
type={showSecrets ? 'text' : 'password'}
placeholder="Your authentication token"
value={credentials.tursoToken}
onChange={(e) => setCredentials({ ...credentials, tursoToken: e.target.value })}
/>
<button
className="setting-toggle-visibility"
onClick={() => setShowSecrets(!showSecrets)}
title={showSecrets ? 'Hide secrets' : 'Show secrets'}
>
{showSecrets ? '🔒' : '👁'}
</button>
</div>
</SettingRow>
<div className="setting-actions">
<button className="primary" onClick={handleSaveTurso}>
{syncConfigured ? 'Update Configuration' : 'Enable Cloud Sync'}
</button>
<button className="secondary" onClick={() => handleTestConnection('turso')}>
Test Connection
</button>
<button className="secondary danger" onClick={() => handleClearCredentials('turso')}>
Clear
</button>
</div>
{syncConfigured && (
<div className="setting-status success">
<span className="status-icon"></span>
<span>Cloud sync is configured and active</span>
</div>
)}
</SettingSection>
<SettingSection
title="File Sync — Dropbox"
description="Synchronize your blog files (posts and media) to Dropbox for backup and cross-device access."
hidden={!sectionHasMatches(syncKeywords)}
@@ -606,7 +499,7 @@ export const SettingsView: React.FC = () => {
<button className="primary" onClick={handleSaveDropbox}>
{dropboxConfigured ? 'Update Configuration' : 'Enable Dropbox Sync'}
</button>
<button className="secondary" onClick={() => handleTestConnection('dropbox')}>
<button className="secondary" onClick={handleTestDropboxConnection}>
Test Connection
</button>
{dropboxConfigured && (

View File

@@ -71,8 +71,6 @@ export interface TaskProgress {
}
export interface SyncConfig {
tursoUrl: string;
tursoAuthToken: string;
autoSync: boolean;
syncInterval: number;
}