import { useState, type FormEvent } from 'react'; import { ApiError, request, tenantPath, type Session } from './api'; import { allowed } from './safety'; import { ErrorBox, errorText, useResource } from './resource'; import { identityNames, interpreterNames, latestRevisions, loadRevisions, parseRevision, type Identity, type Interpreter, type Revision, type Script } from './script-catalog'; import './script-workspace.css'; export function ScriptFields({ script, change, ids, interpreters }: { script: Script; change: (next: Script) => void; ids: Identity[]; interpreters?: Interpreter[]; }) { const possible = ids.filter( (id) => id === 'agent_service' || id === (script.interpreter === 'powershell' ? 'system' : 'root') ); return ( <>
Dieses Skript fordert {identityNames[script.execution_identity]}-Rechte auf den Zielgeräten an.
)} {script.interpreter === 'powershell' && /[^\x00-\x7f]/.test(script.script_utf8) && !script.script_utf8.startsWith('\ufeff') && (Windows PowerShell 5.1 benötigt für diesen Text eine UTF-8-Signatur.{' '}
)} > ); } export function ScriptLibrary({ tenantId, auth }: { tenantId: string; auth: Session }) { const read = allowed(auth, 'operations:read'); const canPublish = allowed(auth, 'operations:plan') && allowed(auth, 'scripts:execute'); const library = useResource( (signal) => (read ? loadRevisions(tenantId, signal) : Promise.resolve([])), [tenantId, read] ); const [opened, open] = useState(''); const [draft, setDraft] = useState