Update package dependencies, enhance README for clarity, and implement new features in the admin panel and script detail pages. Added support for collections, improved script submission previews, and refactored comment handling in the script detail view.

This commit is contained in:
2025-08-15 20:29:02 +01:00
parent 5fdfe3e790
commit ef211ebe0a
27 changed files with 3457 additions and 353 deletions

View File

@ -12,6 +12,9 @@ import { Separator } from '@/components/ui/separator';
import { useAuth } from '@/contexts/AuthContext';
import { showSuccess, showError } from '@/utils/toast';
import { generateId } from '@/lib/utils';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { vscDarkPlus, vs } from 'react-syntax-highlighter/dist/esm/styles/prism';
import { useTheme } from '@/contexts/ThemeContext';
import {
Code2,
FileText,
@ -26,6 +29,7 @@ import {
export default function SubmitScript() {
const { user } = useAuth();
const navigate = useNavigate();
const { theme } = useTheme();
const [isLoading, setIsLoading] = useState(false);
const [showPreview, setShowPreview] = useState(false);
const [formData, setFormData] = useState({
@ -48,6 +52,10 @@ export default function SubmitScript() {
const operatingSystems = ['Linux', 'macOS', 'Windows', 'BSD', 'Android'];
const availableCategories = ['DevOps', 'Automation', 'System Admin', 'Development', 'Security', 'Networking', 'Data Processing', 'Web Development', 'Mobile Development', 'Game Development'];
// State for preview toggles
const [showInstallationPreview, setShowInstallationPreview] = useState(false);
const [showUsagePreview, setShowUsagePreview] = useState(false);
const licenses = ['MIT', 'Apache 2.0', 'GPL v3', 'GPL v2', 'BSD 3-Clause', 'BSD 2-Clause', 'Unlicense', 'Custom'];
const validateForm = () => {
@ -323,11 +331,24 @@ export default function SubmitScript() {
</div>
{showPreview && formData.code && (
<div className="p-4 bg-muted rounded-lg">
<h4 className="font-medium mb-2">Code Preview:</h4>
<pre className="text-sm overflow-x-auto">
<code>{formData.code}</code>
</pre>
<div className="space-y-2">
<h4 className="font-medium">Code Preview:</h4>
<div className="rounded-lg overflow-hidden border">
<SyntaxHighlighter
language="bash"
style={theme === 'dark' ? vscDarkPlus : vs}
customStyle={{
margin: 0,
borderRadius: 0,
fontSize: '14px',
lineHeight: '1.5',
}}
showLineNumbers={true}
wrapLongLines={true}
>
{formData.code}
</SyntaxHighlighter>
</div>
</div>
)}
</div>
@ -438,7 +459,18 @@ export default function SubmitScript() {
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
<div className="space-y-2">
<Label htmlFor="installation">Installation Instructions</Label>
<div className="flex items-center justify-between">
<Label htmlFor="installation">Installation Instructions</Label>
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => setShowInstallationPreview(!showInstallationPreview)}
>
<Eye className="h-4 w-4 mr-1" />
{showInstallationPreview ? 'Hide' : 'Show'} Preview
</Button>
</div>
<Textarea
id="installation"
name="installation"
@ -446,11 +478,40 @@ export default function SubmitScript() {
onChange={handleInputChange}
placeholder="How to install or set up the script..."
rows={4}
className="font-mono text-sm"
/>
{showInstallationPreview && formData.installation && (
<div className="rounded-lg overflow-hidden border">
<SyntaxHighlighter
language="bash"
style={theme === 'dark' ? vscDarkPlus : vs}
customStyle={{
margin: 0,
borderRadius: 0,
fontSize: '13px',
lineHeight: '1.4',
}}
wrapLongLines={true}
>
{formData.installation}
</SyntaxHighlighter>
</div>
)}
</div>
<div className="space-y-2">
<Label htmlFor="usage">Usage Instructions</Label>
<div className="flex items-center justify-between">
<Label htmlFor="usage">Usage Instructions</Label>
<Button
type="button"
variant="ghost"
size="sm"
onClick={() => setShowUsagePreview(!showUsagePreview)}
>
<Eye className="h-4 w-4 mr-1" />
{showUsagePreview ? 'Hide' : 'Show'} Preview
</Button>
</div>
<Textarea
id="usage"
name="usage"
@ -458,7 +519,25 @@ export default function SubmitScript() {
onChange={handleInputChange}
placeholder="How to use the script, examples, parameters..."
rows={4}
className="font-mono text-sm"
/>
{showUsagePreview && formData.usage && (
<div className="rounded-lg overflow-hidden border">
<SyntaxHighlighter
language="bash"
style={theme === 'dark' ? vscDarkPlus : vs}
customStyle={{
margin: 0,
borderRadius: 0,
fontSize: '13px',
lineHeight: '1.4',
}}
wrapLongLines={true}
>
{formData.usage}
</SyntaxHighlighter>
</div>
)}
</div>
</div>