chore: clean git cache
This commit is contained in:
@@ -1,117 +0,0 @@
|
||||
import { AlertTriangle } from 'lucide-react'
|
||||
|
||||
interface CertificateCleanupDialogProps {
|
||||
onConfirm: (deleteCerts: boolean) => void
|
||||
onCancel: () => void
|
||||
certificates: Array<{ id: number; name: string; domain: string }>
|
||||
hostNames: string[]
|
||||
isBulk?: boolean
|
||||
}
|
||||
|
||||
export default function CertificateCleanupDialog({
|
||||
onConfirm,
|
||||
onCancel,
|
||||
certificates,
|
||||
hostNames,
|
||||
isBulk = false
|
||||
}: CertificateCleanupDialogProps) {
|
||||
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
|
||||
e.preventDefault()
|
||||
const formData = new FormData(e.currentTarget)
|
||||
const deleteCerts = formData.get('delete_certs') === 'on'
|
||||
onConfirm(deleteCerts)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="fixed inset-0 bg-black/50 flex items-center justify-center z-50"
|
||||
onClick={onCancel}
|
||||
>
|
||||
<div
|
||||
className="bg-dark-card border border-orange-900/50 rounded-lg p-6 max-w-lg w-full mx-4"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
>
|
||||
<form onSubmit={handleSubmit}>
|
||||
<div className="flex items-start gap-3 mb-4">
|
||||
<div className="flex-shrink-0 w-10 h-10 rounded-full bg-orange-900/30 flex items-center justify-center">
|
||||
<AlertTriangle className="h-5 w-5 text-orange-400" />
|
||||
</div>
|
||||
<div className="flex-1">
|
||||
<h2 className="text-xl font-bold text-white">
|
||||
Delete {isBulk ? `${hostNames.length} Proxy Hosts` : 'Proxy Host'}?
|
||||
</h2>
|
||||
<p className="text-sm text-gray-400 mt-1">
|
||||
{isBulk ? 'These hosts will be permanently deleted.' : 'This host will be permanently deleted.'}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Host names */}
|
||||
<div className="bg-gray-900/50 border border-gray-800 rounded-lg p-4 mb-4">
|
||||
<p className="text-xs font-medium text-gray-400 uppercase mb-2">
|
||||
{isBulk ? 'Hosts to be deleted:' : 'Host to be deleted:'}
|
||||
</p>
|
||||
<ul className="space-y-1 max-h-32 overflow-y-auto">
|
||||
{hostNames.map((name, idx) => (
|
||||
<li key={idx} className="text-sm text-white flex items-center gap-2">
|
||||
<span className="text-red-400">•</span>
|
||||
<span className="font-medium">{name}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{/* Certificate cleanup option */}
|
||||
{certificates.length > 0 && (
|
||||
<div className="bg-orange-900/10 border border-orange-800/50 rounded-lg p-4 mb-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<input
|
||||
type="checkbox"
|
||||
id="delete_certs"
|
||||
name="delete_certs"
|
||||
className="mt-1 w-4 h-4 rounded border-gray-600 text-orange-500 focus:ring-orange-500 focus:ring-offset-0 bg-gray-700"
|
||||
/>
|
||||
<div className="flex-1">
|
||||
<label htmlFor="delete_certs" className="text-sm text-orange-300 font-medium cursor-pointer">
|
||||
Also delete {certificates.length === 1 ? 'orphaned certificate' : `${certificates.length} orphaned certificates`}
|
||||
</label>
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
{certificates.length === 1
|
||||
? 'This custom/staging certificate will no longer be used by any hosts.'
|
||||
: 'These custom/staging certificates will no longer be used by any hosts.'}
|
||||
</p>
|
||||
<ul className="mt-2 space-y-1">
|
||||
{certificates.map((cert) => (
|
||||
<li key={cert.id} className="text-xs text-gray-300 flex items-center gap-2">
|
||||
<span className="text-orange-400">→</span>
|
||||
<span className="font-medium">{cert.name || cert.domain}</span>
|
||||
<span className="text-gray-500">({cert.domain})</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Confirmation buttons */}
|
||||
<div className="flex justify-end gap-2">
|
||||
<button
|
||||
type="button"
|
||||
onClick={onCancel}
|
||||
className="px-4 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg font-medium transition-colors"
|
||||
>
|
||||
Cancel
|
||||
</button>
|
||||
<button
|
||||
type="submit"
|
||||
className="px-4 py-2 bg-red-600 hover:bg-red-700 text-white rounded-lg font-medium transition-colors"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,143 +0,0 @@
|
||||
import { CheckCircle, Plus, RefreshCw, SkipForward, AlertCircle, Info } from 'lucide-react'
|
||||
|
||||
export interface ImportSuccessModalProps {
|
||||
visible: boolean
|
||||
onClose: () => void
|
||||
onNavigateDashboard: () => void
|
||||
onNavigateHosts: () => void
|
||||
results: {
|
||||
created: number
|
||||
updated: number
|
||||
skipped: number
|
||||
errors: string[]
|
||||
} | null
|
||||
}
|
||||
|
||||
export default function ImportSuccessModal({
|
||||
visible,
|
||||
onClose,
|
||||
onNavigateDashboard,
|
||||
onNavigateHosts,
|
||||
results,
|
||||
}: ImportSuccessModalProps) {
|
||||
if (!visible || !results) return null
|
||||
|
||||
const { created, updated, skipped, errors } = results
|
||||
const hasErrors = errors.length > 0
|
||||
const totalProcessed = created + updated + skipped
|
||||
|
||||
return (
|
||||
<div className="fixed inset-0 z-50 flex items-center justify-center">
|
||||
<div className="absolute inset-0 bg-black/60" onClick={onClose} />
|
||||
<div className="relative bg-dark-card rounded-lg p-6 w-[500px] max-w-full mx-4 border border-gray-800">
|
||||
{/* Header */}
|
||||
<div className="flex items-center gap-3 mb-6">
|
||||
<div className="flex-shrink-0 w-12 h-12 rounded-full bg-green-900/30 flex items-center justify-center">
|
||||
<CheckCircle className="h-6 w-6 text-green-400" />
|
||||
</div>
|
||||
<div>
|
||||
<h2 className="text-xl font-bold text-white">Import Completed</h2>
|
||||
<p className="text-sm text-gray-400">
|
||||
{totalProcessed} host{totalProcessed !== 1 ? 's' : ''} processed
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Results Summary */}
|
||||
<div className="bg-gray-900/50 border border-gray-800 rounded-lg p-4 mb-4 space-y-3">
|
||||
{created > 0 && (
|
||||
<div className="flex items-center gap-3">
|
||||
<Plus className="h-4 w-4 text-green-400" />
|
||||
<span className="text-sm text-white">
|
||||
<span className="font-medium text-green-400">{created}</span> host{created !== 1 ? 's' : ''} created
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{updated > 0 && (
|
||||
<div className="flex items-center gap-3">
|
||||
<RefreshCw className="h-4 w-4 text-blue-400" />
|
||||
<span className="text-sm text-white">
|
||||
<span className="font-medium text-blue-400">{updated}</span> host{updated !== 1 ? 's' : ''} updated
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{skipped > 0 && (
|
||||
<div className="flex items-center gap-3">
|
||||
<SkipForward className="h-4 w-4 text-gray-400" />
|
||||
<span className="text-sm text-white">
|
||||
<span className="font-medium text-gray-400">{skipped}</span> host{skipped !== 1 ? 's' : ''} skipped
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
{totalProcessed === 0 && (
|
||||
<div className="flex items-center gap-3">
|
||||
<Info className="h-4 w-4 text-gray-400" />
|
||||
<span className="text-sm text-gray-400">No hosts were processed</span>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Errors Section */}
|
||||
{hasErrors && (
|
||||
<div className="bg-red-900/20 border border-red-800/50 rounded-lg p-4 mb-4">
|
||||
<div className="flex items-center gap-2 mb-2">
|
||||
<AlertCircle className="h-4 w-4 text-red-400" />
|
||||
<span className="text-sm font-medium text-red-400">
|
||||
{errors.length} error{errors.length !== 1 ? 's' : ''} encountered
|
||||
</span>
|
||||
</div>
|
||||
<ul className="space-y-1 max-h-24 overflow-y-auto">
|
||||
{errors.map((error, idx) => (
|
||||
<li key={idx} className="text-xs text-red-300 flex items-start gap-2">
|
||||
<span className="text-red-500 mt-0.5">•</span>
|
||||
<span>{error}</span>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Certificate Provisioning Info */}
|
||||
{created > 0 && (
|
||||
<div className="bg-blue-900/20 border border-blue-800/50 rounded-lg p-4 mb-6">
|
||||
<div className="flex items-start gap-3">
|
||||
<Info className="h-4 w-4 text-blue-400 mt-0.5 flex-shrink-0" />
|
||||
<div>
|
||||
<p className="text-sm font-medium text-blue-300">Certificate Provisioning</p>
|
||||
<p className="text-xs text-gray-400 mt-1">
|
||||
SSL certificates will be automatically provisioned by Let's Encrypt.
|
||||
This typically takes 1-5 minutes per domain.
|
||||
</p>
|
||||
<p className="text-xs text-gray-400 mt-2">
|
||||
Monitor the <span className="text-blue-400">Dashboard</span> to track certificate provisioning progress.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex flex-wrap gap-3 justify-end">
|
||||
<button
|
||||
onClick={onClose}
|
||||
className="px-4 py-2 bg-gray-700 hover:bg-gray-600 text-white rounded-lg font-medium transition-colors"
|
||||
>
|
||||
Close
|
||||
</button>
|
||||
<button
|
||||
onClick={onNavigateHosts}
|
||||
className="px-4 py-2 bg-gray-800 hover:bg-gray-700 text-white rounded-lg font-medium transition-colors border border-gray-700"
|
||||
>
|
||||
View Proxy Hosts
|
||||
</button>
|
||||
<button
|
||||
onClick={onNavigateDashboard}
|
||||
className="px-4 py-2 bg-blue-active hover:bg-blue-hover text-white rounded-lg font-medium transition-colors"
|
||||
>
|
||||
Go to Dashboard
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -1,154 +0,0 @@
|
||||
import { describe, it, expect, vi } from 'vitest'
|
||||
import { render, screen, fireEvent } from '@testing-library/react'
|
||||
import ImportSuccessModal from '../ImportSuccessModal'
|
||||
|
||||
describe('ImportSuccessModal', () => {
|
||||
const defaultProps = {
|
||||
visible: true,
|
||||
onClose: vi.fn(),
|
||||
onNavigateDashboard: vi.fn(),
|
||||
onNavigateHosts: vi.fn(),
|
||||
results: {
|
||||
created: 5,
|
||||
updated: 2,
|
||||
skipped: 1,
|
||||
errors: [],
|
||||
},
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks()
|
||||
})
|
||||
|
||||
it('renders import summary correctly', () => {
|
||||
render(<ImportSuccessModal {...defaultProps} />)
|
||||
|
||||
expect(screen.getByText('Import Completed')).toBeInTheDocument()
|
||||
expect(screen.getByText('8 hosts processed')).toBeInTheDocument()
|
||||
expect(screen.getByText('5')).toBeInTheDocument()
|
||||
expect(screen.getByText(/hosts created/)).toBeInTheDocument()
|
||||
expect(screen.getByText('2')).toBeInTheDocument()
|
||||
expect(screen.getByText(/hosts updated/)).toBeInTheDocument()
|
||||
expect(screen.getByText('1')).toBeInTheDocument()
|
||||
expect(screen.getByText(/host skipped/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('displays certificate provisioning guidance when hosts are created', () => {
|
||||
render(<ImportSuccessModal {...defaultProps} />)
|
||||
|
||||
expect(screen.getByText('Certificate Provisioning')).toBeInTheDocument()
|
||||
expect(screen.getByText(/SSL certificates will be automatically provisioned/)).toBeInTheDocument()
|
||||
expect(screen.getByText(/1-5 minutes per domain/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('hides certificate provisioning guidance when no hosts are created', () => {
|
||||
const props = {
|
||||
...defaultProps,
|
||||
results: { created: 0, updated: 2, skipped: 0, errors: [] },
|
||||
}
|
||||
render(<ImportSuccessModal {...props} />)
|
||||
|
||||
expect(screen.queryByText('Certificate Provisioning')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows errors when present', () => {
|
||||
const props = {
|
||||
...defaultProps,
|
||||
results: {
|
||||
created: 0,
|
||||
updated: 0,
|
||||
skipped: 0,
|
||||
errors: ['example.com: duplicate entry', 'api.example.com: invalid config'],
|
||||
},
|
||||
}
|
||||
render(<ImportSuccessModal {...props} />)
|
||||
|
||||
expect(screen.getByText('2 errors encountered')).toBeInTheDocument()
|
||||
expect(screen.getByText('example.com: duplicate entry')).toBeInTheDocument()
|
||||
expect(screen.getByText('api.example.com: invalid config')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('calls onNavigateDashboard when clicking Dashboard button', () => {
|
||||
const onNavigateDashboard = vi.fn()
|
||||
render(<ImportSuccessModal {...defaultProps} onNavigateDashboard={onNavigateDashboard} />)
|
||||
|
||||
fireEvent.click(screen.getByText('Go to Dashboard'))
|
||||
expect(onNavigateDashboard).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('calls onNavigateHosts when clicking View Proxy Hosts button', () => {
|
||||
const onNavigateHosts = vi.fn()
|
||||
render(<ImportSuccessModal {...defaultProps} onNavigateHosts={onNavigateHosts} />)
|
||||
|
||||
fireEvent.click(screen.getByText('View Proxy Hosts'))
|
||||
expect(onNavigateHosts).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('calls onClose when clicking Close button', () => {
|
||||
const onClose = vi.fn()
|
||||
render(<ImportSuccessModal {...defaultProps} onClose={onClose} />)
|
||||
|
||||
fireEvent.click(screen.getByText('Close'))
|
||||
expect(onClose).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('calls onClose when clicking backdrop', () => {
|
||||
const onClose = vi.fn()
|
||||
const { container } = render(<ImportSuccessModal {...defaultProps} onClose={onClose} />)
|
||||
|
||||
// Click the backdrop (the overlay behind the modal)
|
||||
const backdrop = container.querySelector('.bg-black\\/60')
|
||||
if (backdrop) {
|
||||
fireEvent.click(backdrop)
|
||||
}
|
||||
expect(onClose).toHaveBeenCalledTimes(1)
|
||||
})
|
||||
|
||||
it('does not render when visible is false', () => {
|
||||
render(<ImportSuccessModal {...defaultProps} visible={false} />)
|
||||
|
||||
expect(screen.queryByText('Import Completed')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('does not render when results is null', () => {
|
||||
render(<ImportSuccessModal {...defaultProps} results={null} />)
|
||||
|
||||
expect(screen.queryByText('Import Completed')).not.toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('handles singular grammar correctly for single host', () => {
|
||||
const props = {
|
||||
...defaultProps,
|
||||
results: { created: 1, updated: 0, skipped: 0, errors: [] },
|
||||
}
|
||||
render(<ImportSuccessModal {...props} />)
|
||||
|
||||
expect(screen.getByText('1 host processed')).toBeInTheDocument()
|
||||
expect(screen.getByText(/host created/)).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('handles single error with correct grammar', () => {
|
||||
const props = {
|
||||
...defaultProps,
|
||||
results: {
|
||||
created: 0,
|
||||
updated: 0,
|
||||
skipped: 0,
|
||||
errors: ['single error'],
|
||||
},
|
||||
}
|
||||
render(<ImportSuccessModal {...props} />)
|
||||
|
||||
expect(screen.getByText('1 error encountered')).toBeInTheDocument()
|
||||
})
|
||||
|
||||
it('shows message when no hosts were processed', () => {
|
||||
const props = {
|
||||
...defaultProps,
|
||||
results: { created: 0, updated: 0, skipped: 0, errors: [] },
|
||||
}
|
||||
render(<ImportSuccessModal {...props} />)
|
||||
|
||||
expect(screen.getByText('No hosts were processed')).toBeInTheDocument()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user