feat: enhance media lifecycle management and inline media integration
Deploy Development / deploy (push) Successful in 34s
Test Suite / pytest-backend (push) Successful in 23s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Successful in 24s
Deploy Development / deploy (push) Successful in 34s
Test Suite / pytest-backend (push) Successful in 23s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 6s
Test Suite / playwright-tests (push) Successful in 24s
- Implemented media lifecycle management with new API endpoints for handling asset states (trash_soft, trash_hidden, recover, purge), improving media governance. - Updated frontend components to filter and display media based on lifecycle states, enhancing user experience and visibility. - Enhanced documentation in MEDIA_ASSETS_AND_ARCHIVE_SPEC.md to include guidelines for inline media references in exercise texts, establishing a clear implementation plan. - Incremented version to 0.8.42, reflecting the latest changes in media handling and lifecycle management.
This commit is contained in:
1 parent
ece08ec1a1
commit
8ac723eafe
16 files changed
+553
-20
No files matched your search
@@ -113,6 +113,10 @@ export default function ExerciseFullContent({ exercise, loading, error, exercise
|
||||
if (!exercise) return null
|
||||
|
||||
const meta = metaParts(exercise)
|
||||
const visibleMedia = (exercise.media || []).filter((m) => {
|
||||
const lc = String(m.asset_lifecycle_state || 'active').toLowerCase()
|
||||
return lc !== 'trash_hidden'
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="exercise-coach-catalog" style={{ fontSize: '0.93rem', lineHeight: 1.5 }}>
|
||||
@@ -161,14 +165,19 @@ export default function ExerciseFullContent({ exercise, loading, error, exercise
|
||||
<HtmlBlock html={exercise.execution} />
|
||||
</section>
|
||||
)}
|
||||
{(exercise.media || []).length > 0 && (
|
||||
{visibleMedia.length > 0 && (
|
||||
<section className="card" style={{ marginTop: '10px', padding: '12px 14px' }}>
|
||||
<h3 style={{ fontSize: '0.78rem', textTransform: 'uppercase', color: 'var(--text3)', marginBottom: '8px' }}>
|
||||
Medien
|
||||
</h3>
|
||||
{exercise.media.map((m) => (
|
||||
{visibleMedia.map((m) => (
|
||||
<div key={m.id} style={{ marginBottom: '12px' }}>
|
||||
<strong style={{ fontSize: '0.9rem' }}>{m.title || m.original_filename || m.media_type}</strong>
|
||||
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_soft' && (
|
||||
<p style={{ fontSize: '0.75rem', color: 'var(--danger)', margin: '4px 0 0' }}>
|
||||
Hinweis: Dieses Medium ist im Papierkorb und steht künftig nicht mehr zur Verfügung.
|
||||
</p>
|
||||
)}
|
||||
{m.description && <p style={{ color: 'var(--text2)', fontSize: '0.82rem', marginTop: '4px' }}>{m.description}</p>}
|
||||
<MediaBlock media={m} exerciseId={exercise.id ?? exerciseId} />
|
||||
</div>
|
||||
|
||||
@@ -151,6 +151,10 @@ function ExerciseDetailPage() {
|
||||
if (!exercise) return null
|
||||
|
||||
const meta = metaParts(exercise)
|
||||
const visibleMedia = (exercise.media || []).filter((m) => {
|
||||
const lc = String(m.asset_lifecycle_state || 'active').toLowerCase()
|
||||
return lc !== 'trash_hidden'
|
||||
})
|
||||
|
||||
return (
|
||||
<div className="exercise-detail-shell" style={{ padding: '12px 12px 24px' }}>
|
||||
@@ -211,12 +215,17 @@ function ExerciseDetailPage() {
|
||||
</section>
|
||||
)}
|
||||
|
||||
{(exercise.media || []).length > 0 && (
|
||||
{visibleMedia.length > 0 && (
|
||||
<section className="card exercise-detail-section">
|
||||
<h2>Medien</h2>
|
||||
{exercise.media.map((m) => (
|
||||
{visibleMedia.map((m) => (
|
||||
<div key={m.id} style={{ marginBottom: '1.25rem' }}>
|
||||
<strong style={{ fontSize: '15px' }}>{m.title || m.original_filename || m.media_type}</strong>
|
||||
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_soft' && (
|
||||
<p style={{ fontSize: '12px', color: 'var(--danger)', margin: '6px 0 0' }}>
|
||||
Hinweis: Dieses Medium ist im Papierkorb und steht künftig nicht mehr zur Verfügung.
|
||||
</p>
|
||||
)}
|
||||
{m.description && <p style={{ color: 'var(--text2)', fontSize: '0.9rem' }}>{m.description}</p>}
|
||||
<MediaBlock media={m} exerciseId={exercise.id} />
|
||||
</div>
|
||||
|
||||
@@ -612,6 +612,16 @@ function ExerciseFormPage() {
|
||||
}
|
||||
}
|
||||
|
||||
const runMediaLifecycle = async (assetId, action) => {
|
||||
if (!assetId) return
|
||||
try {
|
||||
await api.postMediaAssetLifecycle(assetId, action)
|
||||
await refreshMedia()
|
||||
} catch (e) {
|
||||
alert(e.message || String(e))
|
||||
}
|
||||
}
|
||||
|
||||
const moveMediaRow = async (idx, dir) => {
|
||||
if (!exerciseId) return
|
||||
const j = idx + dir
|
||||
@@ -1321,6 +1331,82 @@ function ExerciseFormPage() {
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
{m.media_asset_id ? (
|
||||
<div style={{ marginTop: '8px', fontSize: '12px' }}>
|
||||
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_soft' && (
|
||||
<p style={{ color: 'var(--danger)', margin: '0 0 6px' }}>
|
||||
Papierkorb (Stufe 1): für neue Zuordnungen gesperrt.
|
||||
</p>
|
||||
)}
|
||||
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_hidden' && (
|
||||
<p style={{ color: 'var(--danger)', margin: '0 0 6px' }}>
|
||||
Ausgeblendet (Stufe 2): in der Übungsansicht nicht sichtbar.
|
||||
</p>
|
||||
)}
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '6px', alignItems: 'center' }}>
|
||||
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'active' && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px', padding: '4px 8px' }}
|
||||
onClick={() => {
|
||||
if (confirm('Medium in den Papierkorb (Stufe 1)?')) {
|
||||
runMediaLifecycle(m.media_asset_id, 'trash_soft')
|
||||
}
|
||||
}}
|
||||
>
|
||||
Papierkorb (Stufe 1)
|
||||
</button>
|
||||
)}
|
||||
{['active', 'trash_soft'].includes(String(m.asset_lifecycle_state || 'active').toLowerCase()) && (
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px', padding: '4px 8px' }}
|
||||
onClick={() => {
|
||||
if (confirm('Medium ausblenden (Stufe 2)? Lesende Nutzer sehen es nicht mehr.')) {
|
||||
runMediaLifecycle(m.media_asset_id, 'trash_hidden')
|
||||
}
|
||||
}}
|
||||
>
|
||||
Ausblenden (Stufe 2)
|
||||
</button>
|
||||
)}
|
||||
{String(m.asset_lifecycle_state || 'active').toLowerCase() === 'trash_hidden' && (
|
||||
<>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
style={{ fontSize: '11px', padding: '4px 8px' }}
|
||||
onClick={() => runMediaLifecycle(m.media_asset_id, 'recover')}
|
||||
>
|
||||
Wiederherstellen (Stufe 1)
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn"
|
||||
style={{
|
||||
fontSize: '11px',
|
||||
padding: '4px 8px',
|
||||
background: 'var(--danger)',
|
||||
color: '#fff',
|
||||
border: 'none',
|
||||
}}
|
||||
onClick={() => {
|
||||
if (
|
||||
confirm('Endgültig löschen? Entfernt Datei und Verknüpfungen dieser Medien-ID.')
|
||||
) {
|
||||
runMediaLifecycle(m.media_asset_id, 'purge')
|
||||
}
|
||||
}}
|
||||
>
|
||||
Endgültig löschen
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="form-row" style={{ marginTop: '8px', display: 'grid', gap: '8px' }}>
|
||||
<input
|
||||
type="text"
|
||||
|
||||
@@ -502,6 +502,14 @@ export async function reorderExerciseMedia(exerciseId, mediaIds) {
|
||||
})
|
||||
}
|
||||
|
||||
/** Papierkorb / Recovery — `action`: trash_soft | trash_hidden | recover | purge */
|
||||
export async function postMediaAssetLifecycle(assetId, action) {
|
||||
return request(`/api/media-assets/${assetId}/lifecycle`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ action }),
|
||||
})
|
||||
}
|
||||
|
||||
export async function getExercise(id) {
|
||||
return request(`/api/exercises/${id}`)
|
||||
}
|
||||
@@ -1203,6 +1211,7 @@ export const api = {
|
||||
updateExerciseMedia,
|
||||
deleteExerciseMedia,
|
||||
reorderExerciseMedia,
|
||||
postMediaAssetLifecycle,
|
||||
listExerciseProgressionGraphs,
|
||||
getExerciseProgressionGraph,
|
||||
createExerciseProgressionGraph,
|
||||
|
||||
Reference in new issue
Block a user