Publish frozen exercise releases and report whether they stay offerable.
Deploy Development / deploy (push) Successful in 1m12s
Test Suite / pytest-backend (push) Failing after 30s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 16s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m42s
Deploy Development / deploy (push) Successful in 1m12s
Test Suite / pytest-backend (push) Failing after 30s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 16s
Test Suite / k6 /health Baseline (push) Successful in 35s
Test Suite / playwright-tests (push) Failing after 7m42s
Recipients can ask whether a released exercise is still offerable. Archiving or removing the source stops new offers; the frozen copy stays fetchable until withdrawal. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b537750671
commit
fe3633ba8b
21 files changed
+3862
-12
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import { TreePine, FolderTree, Download, Grid3x3, Users, Scale, Sparkles, Bot, Wand2, Activity, Building2, Shield } from 'lucide-react'
|
||||
import { TreePine, FolderTree, Download, Grid3x3, Users, Scale, Sparkles, Bot, Wand2, Activity, Building2, Shield, Share2 } from 'lucide-react'
|
||||
|
||||
/**
|
||||
* Admin-Seiten-Navigation (horizontal) — nur für Super-Admins (globaler Portal-Mandant).
|
||||
@@ -18,6 +18,7 @@ export default function AdminPageNav() {
|
||||
{ to: '/admin/ai-prompts', label: 'KI Prompts', icon: Sparkles },
|
||||
{ to: '/admin/openrouter', label: 'KI-Modell', icon: Bot },
|
||||
{ to: '/admin/exercise-enrichment', label: 'Übungs-Anreicherung', icon: Wand2 },
|
||||
{ to: '/admin/distribution', label: 'Distribution', icon: Share2 },
|
||||
]
|
||||
|
||||
return (
|
||||
|
||||
@@ -0,0 +1,262 @@
|
||||
import React, { useCallback, useEffect, useState } from 'react'
|
||||
import {
|
||||
confirmDistributionDraft,
|
||||
createDistributionDraft,
|
||||
getExerciseDistribution,
|
||||
retireDistributionRelease,
|
||||
updateDistributionDraft,
|
||||
withdrawDistributionRelease,
|
||||
} from '../../api/distribution'
|
||||
|
||||
const ACTIONS = [
|
||||
'store',
|
||||
'render',
|
||||
'stream',
|
||||
'download',
|
||||
'print',
|
||||
'course_display',
|
||||
'commercial_course_use',
|
||||
'adapt',
|
||||
'public_preview',
|
||||
'grant_customer_use',
|
||||
]
|
||||
|
||||
const REASONS = [
|
||||
['rights', 'Rechte'],
|
||||
['safety', 'Sicherheit'],
|
||||
['privacy', 'Privatsphäre'],
|
||||
['expired', 'Frist'],
|
||||
['editorial_error', 'Redaktionsfehler'],
|
||||
]
|
||||
|
||||
export default function ExerciseDistributionPanel({ exerciseId }) {
|
||||
const [overview, setOverview] = useState(null)
|
||||
const [error, setError] = useState('')
|
||||
const [publisherId, setPublisherId] = useState('')
|
||||
const [recipientId, setRecipientId] = useState('')
|
||||
const [draft, setDraft] = useState(null)
|
||||
const [evidence, setEvidence] = useState('nachweis')
|
||||
const [actions, setActions] = useState(['store', 'render'])
|
||||
const [retirePrevious, setRetirePrevious] = useState(true)
|
||||
const [reason, setReason] = useState('rights')
|
||||
const [busy, setBusy] = useState(false)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
try {
|
||||
const data = await getExerciseDistribution(exerciseId)
|
||||
setOverview(data)
|
||||
setError('')
|
||||
} catch (err) {
|
||||
setError(err.message || 'Distribution konnte nicht geladen werden.')
|
||||
}
|
||||
}, [exerciseId])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
function toggleAction(action) {
|
||||
setActions((current) =>
|
||||
current.includes(action) ? current.filter((item) => item !== action) : [...current, action]
|
||||
)
|
||||
}
|
||||
|
||||
function withRights(cut) {
|
||||
const rightsId = 'rights-main'
|
||||
const next = {
|
||||
...cut,
|
||||
editorial_rights_id: rightsId,
|
||||
rights: [
|
||||
{
|
||||
id: rightsId,
|
||||
evidence_ref: evidence.trim(),
|
||||
actions,
|
||||
territories: ['DE'],
|
||||
valid_from: new Date(Date.now() - 60000).toISOString().replace(/\.\d{3}Z$/, 'Z'),
|
||||
valid_until: null,
|
||||
note: '',
|
||||
},
|
||||
],
|
||||
parts: (cut.parts || []).map((part) => ({ ...part, rights_id: rightsId })),
|
||||
assets: (cut.assets || []).map((asset) => ({ ...asset, rights_id: rightsId })),
|
||||
}
|
||||
return next
|
||||
}
|
||||
|
||||
async function prepare() {
|
||||
setBusy(true)
|
||||
setError('')
|
||||
try {
|
||||
const created = await createDistributionDraft(exerciseId, {
|
||||
publisher_id: publisherId.trim(),
|
||||
recipient_id: recipientId.trim(),
|
||||
})
|
||||
const cut = withRights(created.cut)
|
||||
const updated = await updateDistributionDraft(exerciseId, created.draft_id, cut)
|
||||
setDraft(updated)
|
||||
} catch (err) {
|
||||
setError(err.message || 'Vorschau fehlgeschlagen.')
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function confirm() {
|
||||
if (!draft) return
|
||||
setBusy(true)
|
||||
setError('')
|
||||
try {
|
||||
const cut = withRights(draft.cut)
|
||||
await updateDistributionDraft(exerciseId, draft.draft_id, cut)
|
||||
const result = await confirmDistributionDraft(exerciseId, draft.draft_id)
|
||||
if (retirePrevious && overview?.releases?.length && !result.replayed) {
|
||||
const previous = [...overview.releases]
|
||||
.reverse()
|
||||
.find((item) => item.recipient_id === recipientId.trim() && !item.fetch_blocked)
|
||||
if (previous) {
|
||||
await retireDistributionRelease(previous.release_id)
|
||||
}
|
||||
}
|
||||
setDraft(null)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message || 'Freigabe fehlgeschlagen.')
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function withdraw(releaseId) {
|
||||
setBusy(true)
|
||||
setError('')
|
||||
try {
|
||||
await withdrawDistributionRelease(releaseId, reason)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message || 'Rückzug fehlgeschlagen.')
|
||||
} finally {
|
||||
setBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
if (!overview) {
|
||||
return <section className="card">Distribution wird geladen …</section>
|
||||
}
|
||||
|
||||
return (
|
||||
<section className="card" style={{ marginBottom: 16 }}>
|
||||
<h2 style={{ marginTop: 0 }}>Externe Freigabe</h2>
|
||||
{!overview.enabled ? (
|
||||
<p>Die Distribution ist auf dieser Instanz nicht aktiv. Bearbeitung und Planung bleiben davon unberührt.</p>
|
||||
) : (
|
||||
<>
|
||||
<p>
|
||||
Private Übungen gibt die Person frei, der sie gehören. Vereinsübungen gibt ein Vereinsadmin dieses Vereins frei.
|
||||
Globale Übungen gibt nur ein Superadmin frei.
|
||||
</p>
|
||||
{overview.release_block ? <p>{overview.release_block}</p> : null}
|
||||
<div className="form-row">
|
||||
<label className="form-label">
|
||||
Herausgeber
|
||||
<input className="form-input" value={publisherId} onChange={(event) => setPublisherId(event.target.value)} placeholder="UUID" />
|
||||
</label>
|
||||
<label className="form-label">
|
||||
Empfänger
|
||||
<input className="form-input" value={recipientId} onChange={(event) => setRecipientId(event.target.value)} placeholder="UUID" />
|
||||
</label>
|
||||
</div>
|
||||
{overview.publishers?.length ? (
|
||||
<ul>
|
||||
{overview.publishers.map((publisher) => (
|
||||
<li key={publisher.id}>
|
||||
<button type="button" className="btn btn-secondary" onClick={() => setPublisherId(publisher.id)}>
|
||||
{publisher.name} ({publisher.kind})
|
||||
</button>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
) : null}
|
||||
<fieldset>
|
||||
<legend>Nutzungsumfang</legend>
|
||||
{ACTIONS.map((action) => (
|
||||
<label key={action} style={{ display: 'inline-flex', gap: 6, marginRight: 12 }}>
|
||||
<input type="checkbox" checked={actions.includes(action)} onChange={() => toggleAction(action)} />
|
||||
{action}
|
||||
</label>
|
||||
))}
|
||||
</fieldset>
|
||||
<label className="form-label">
|
||||
Nachweisreferenz
|
||||
<input className="form-input" value={evidence} onChange={(event) => setEvidence(event.target.value)} />
|
||||
</label>
|
||||
<label style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<input type="checkbox" checked={retirePrevious} onChange={(event) => setRetirePrevious(event.target.checked)} />
|
||||
Bisherige Fassung für neue Pläne ablösen
|
||||
</label>
|
||||
<div style={{ display: 'flex', gap: 8, marginTop: 8 }}>
|
||||
<button type="button" className="btn btn-secondary" disabled={busy || !overview.may_release} onClick={prepare}>
|
||||
Vorschau
|
||||
</button>
|
||||
<button type="button" className="btn btn-primary" disabled={busy || !draft || !overview.may_release} onClick={confirm}>
|
||||
Verbindlich freigeben
|
||||
</button>
|
||||
</div>
|
||||
{draft ? (
|
||||
<div style={{ marginTop: 12 }}>
|
||||
<strong>Vorschau</strong>
|
||||
{draft.blockers?.length ? (
|
||||
<ul>
|
||||
{draft.blockers.map((item) => (
|
||||
<li key={item}>{item}</li>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p>Keine blockierenden Punkte.</p>
|
||||
)}
|
||||
<ul>
|
||||
{(draft.cut?.parts || []).map((part) => (
|
||||
<li key={part.key}>
|
||||
{part.role}: {part.text}
|
||||
</li>
|
||||
))}
|
||||
{(draft.cut?.assets || []).map((asset) => (
|
||||
<li key={asset.media_id}>
|
||||
Medium {asset.role} {asset.label || ''}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
) : null}
|
||||
</>
|
||||
)}
|
||||
{overview.releases?.length ? (
|
||||
<>
|
||||
<h3>Freigegebene Fassungen</h3>
|
||||
<label className="form-label">
|
||||
Grundklasse für Rückzug
|
||||
<select className="form-input" value={reason} onChange={(event) => setReason(event.target.value)}>
|
||||
{REASONS.map(([value, label]) => (
|
||||
<option key={value} value={value}>
|
||||
{label}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<ul>
|
||||
{overview.releases.map((release) => (
|
||||
<li key={release.release_id}>
|
||||
{release.recipient_name} · Revision {release.revision} · {release.fetch_blocked ? 'zurückgezogen' : 'abrufbar'}
|
||||
{overview.enabled && !release.fetch_blocked ? (
|
||||
<button type="button" className="btn btn-secondary" style={{ marginLeft: 8 }} disabled={busy} onClick={() => withdraw(release.release_id)}>
|
||||
Zurückziehen
|
||||
</button>
|
||||
) : null}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
) : null}
|
||||
{error ? <p role="alert">{error}</p> : null}
|
||||
</section>
|
||||
)
|
||||
}
|
||||
@@ -32,6 +32,7 @@ import { GripVertical, FileText, BookOpen, Tags, Layers, GitBranch, Image as Ima
|
||||
import UnsavedChangesPrompt from '../UnsavedChangesPrompt'
|
||||
import PageFormEditorChrome from '../PageFormEditorChrome'
|
||||
import { ExerciseFormTabBar, ExerciseFormPanel } from './ExerciseFormLayout'
|
||||
import ExerciseDistributionPanel from './ExerciseDistributionPanel'
|
||||
import { useNavReturn } from '../../hooks/useNavReturn'
|
||||
import {
|
||||
EXERCISES_LIST_PATH,
|
||||
@@ -1611,6 +1612,8 @@ function ExerciseFormPageRoot() {
|
||||
</p>
|
||||
) : null}
|
||||
|
||||
{isEdit && exerciseId ? <ExerciseDistributionPanel exerciseId={exerciseId} /> : null}
|
||||
|
||||
<div className="card exercise-form-edit">
|
||||
<form id="exercise-form" onSubmit={handleSubmit}>
|
||||
<ExerciseFormTabBar
|
||||
|
||||
Reference in new issue
Block a user