Enhance Exercise Progression Graph Functionality and Visibility Logic
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m16s
Deploy Development / deploy (push) Successful in 50s
Test Suite / pytest-backend (push) Successful in 44s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Successful in 14s
Test Suite / k6 /health Baseline (push) Successful in 33s
Test Suite / playwright-tests (push) Successful in 1m16s
- Introduced new functions for handling exercise visibility in progression graphs, including `library_content_visibility_for_progression_graph_sql` to manage visibility based on graph context. - Added `_supplemental_exercise_ids_from_body` to extract exercise IDs from request bodies, improving data handling in path suggestions. - Implemented visibility promotion candidate retrieval in the API, allowing for the identification of private exercises that need visibility adjustments when promoting graph visibility. - Enhanced existing SQL queries and retrieval functions to incorporate new visibility logic, ensuring accurate exercise visibility based on user roles and graph settings. - Updated frontend components to support visibility promotion workflows, including user prompts for managing private exercises during graph visibility changes. - Added tests to validate new visibility logic and ensure robustness in exercise retrieval and promotion processes.
This commit is contained in:
1 parent
7203c871fc
commit
b464047c3a
7 files changed
+447
-11
No files matched your search
@@ -13,7 +13,7 @@ import { Link, useLocation } from 'react-router-dom'
|
||||
import api from '../utils/api'
|
||||
import SkillProfilePanel from './skills/SkillProfilePanel'
|
||||
import { useAuth } from '../context/AuthContext'
|
||||
import { getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import { activeClubMemberships, getTenantClubDependencyKey } from '../utils/activeClub'
|
||||
import ProgressionGraphEditor from './ProgressionGraphEditor'
|
||||
import ProgressionGraphListCard from './ProgressionGraphListCard'
|
||||
import { EXERCISE_VISIBILITY_FIELD_LABEL } from '../constants/exerciseGovernanceLabels'
|
||||
@@ -226,6 +226,14 @@ function ExerciseProgressionGraphPanel(
|
||||
}
|
||||
}
|
||||
|
||||
const resolvePromoteClubId = () => {
|
||||
const g = graphs.find((x) => x.id === selectedGraphId)
|
||||
if (g?.club_id != null) return Number(g.club_id)
|
||||
const memberships = activeClubMemberships(user?.clubs)
|
||||
const active = memberships.find((c) => c.is_active) || memberships[0]
|
||||
return active?.club_id != null ? Number(active.club_id) : null
|
||||
}
|
||||
|
||||
const handleSaveMeta = async () => {
|
||||
if (!selectedGraphId) return
|
||||
const name = metaName.trim()
|
||||
@@ -233,8 +241,50 @@ function ExerciseProgressionGraphPanel(
|
||||
alert('Name ist Pflicht')
|
||||
return
|
||||
}
|
||||
const prevGraph = graphs.find((x) => x.id === selectedGraphId)
|
||||
const prevVis = (prevGraph?.visibility || 'private').trim().toLowerCase()
|
||||
const nextVis = (metaVisibility || 'private').trim().toLowerCase()
|
||||
|
||||
setBusy(true)
|
||||
try {
|
||||
if (prevVis === 'private' && nextVis === 'club') {
|
||||
const preview = await api.getProgressionGraphVisibilityPromotionCandidates(
|
||||
selectedGraphId,
|
||||
{ targetVisibility: 'club' },
|
||||
)
|
||||
const privateExercises = Array.isArray(preview?.exercises) ? preview.exercises : []
|
||||
if (privateExercises.length > 0) {
|
||||
const titles = privateExercises
|
||||
.slice(0, 8)
|
||||
.map((ex) => `• ${ex.title || `Übung #${ex.id}`}`)
|
||||
.join('\n')
|
||||
const more =
|
||||
privateExercises.length > 8
|
||||
? `\n… und ${privateExercises.length - 8} weitere`
|
||||
: ''
|
||||
const promote = window.confirm(
|
||||
`Der Graph wird auf „Verein“ gestellt. Im Graph sind noch ${privateExercises.length} private Übung(en):\n\n${titles}${more}\n\nDiese Übungen ebenfalls auf Vereins-Sichtbarkeit anheben?`,
|
||||
)
|
||||
if (promote) {
|
||||
const clubId = resolvePromoteClubId()
|
||||
if (!clubId) {
|
||||
alert('Kein aktiver Verein — Übungen können nicht auf Verein promoted werden.')
|
||||
} else {
|
||||
const ids = privateExercises.map((ex) => ex.id).filter((id) => id != null)
|
||||
const res = await api.bulkPatchExercisesMetadata({
|
||||
exercise_ids: ids,
|
||||
visibility: 'club',
|
||||
club_id: clubId,
|
||||
})
|
||||
if ((res?.failed || []).length) {
|
||||
const f = res.failed[0]
|
||||
throw new Error(f?.detail || 'Übungs-Promotion fehlgeschlagen')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await api.updateExerciseProgressionGraph(selectedGraphId, {
|
||||
name,
|
||||
description: metaDescription.trim() || null,
|
||||
|
||||
Reference in new issue
Block a user