Refactor navigation components and enhance return context handling
Deploy Development / deploy (push) Failing after 24s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Failing after 7s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m22s
Deploy Development / deploy (push) Failing after 24s
Test Suite / pytest-backend (push) Successful in 34s
Test Suite / lint-backend (push) Successful in 0s
Test Suite / build-frontend (push) Failing after 7s
Test Suite / k6 /health Baseline (push) Successful in 34s
Test Suite / playwright-tests (push) Successful in 1m22s
- Replaced `PageReturnLink` with `PageReturnButton` for consistent back navigation across various pages. - Updated multiple components, including `ExercisePeekModal`, `PageFormEditorChrome`, and `ExerciseDetailPage`, to utilize the new return context features. - Enhanced CSS styles for the new return button to improve visual consistency. - Improved navigation logic in `TrainingFrameworkProgramEditPage` and `TrainingModuleEditPage` to ensure seamless user experience when navigating back to previous locations.
This commit is contained in:
1 parent
6e6270b717
commit
4588ef4c7e
28 files changed
+497
-190
No files matched your search
@@ -3,12 +3,17 @@
|
||||
*/
|
||||
import {
|
||||
buildPlanningHubReturnState,
|
||||
PLANNING_HUB_PATH,
|
||||
planningHubPathFromReturnState,
|
||||
} from './planningUnitRoutes'
|
||||
|
||||
export const NAV_RETURN_STATE_KEY = 'appReturn'
|
||||
export const EXERCISES_LIST_PATH = '/exercises'
|
||||
export const TRAINING_MODULES_LIST_PATH = '/planning/training-modules'
|
||||
export const PLAN_TEMPLATES_LIST_PATH = '/planning/plan-templates'
|
||||
export const FRAMEWORK_PROGRAMS_LIST_PATH = '/planning/framework-programs'
|
||||
export const SETTINGS_PATH = '/settings'
|
||||
export const DASHBOARD_PATH = '/'
|
||||
|
||||
export function buildNavReturnContext(opts) {
|
||||
const path = String(opts?.path || '').trim()
|
||||
@@ -38,6 +43,74 @@ export function buildTrainingModulesListReturnContext() {
|
||||
})
|
||||
}
|
||||
|
||||
export function buildPlanTemplatesListReturnContext() {
|
||||
return buildNavReturnContext({
|
||||
path: PLAN_TEMPLATES_LIST_PATH,
|
||||
label: 'Zurück zu Vorlagen',
|
||||
kind: 'planTemplatesList',
|
||||
})
|
||||
}
|
||||
|
||||
export function buildFrameworkProgramsListReturnContext() {
|
||||
return buildNavReturnContext({
|
||||
path: FRAMEWORK_PROGRAMS_LIST_PATH,
|
||||
label: 'Zurück zu Rahmenprogrammen',
|
||||
kind: 'frameworkProgramsList',
|
||||
})
|
||||
}
|
||||
|
||||
export function buildSettingsReturnContext() {
|
||||
return buildNavReturnContext({
|
||||
path: SETTINGS_PATH,
|
||||
label: 'Zurück zu Einstellungen',
|
||||
kind: 'settings',
|
||||
})
|
||||
}
|
||||
|
||||
export function buildDashboardReturnContext() {
|
||||
return buildNavReturnContext({
|
||||
path: DASHBOARD_PATH,
|
||||
label: 'Zurück zur Übersicht',
|
||||
kind: 'dashboard',
|
||||
})
|
||||
}
|
||||
|
||||
export const MEDIA_LIBRARY_PATH = '/media'
|
||||
|
||||
export function buildMediaLibraryReturnContext() {
|
||||
return buildNavReturnContext({
|
||||
path: MEDIA_LIBRARY_PATH,
|
||||
label: 'Zurück zur Medienbibliothek',
|
||||
kind: 'mediaLibrary',
|
||||
})
|
||||
}
|
||||
|
||||
export function buildTrainingRunReturnContext(unitId) {
|
||||
const id = String(unitId || '').trim()
|
||||
if (!id) return null
|
||||
return buildNavReturnContext({
|
||||
path: `/planning/run/${id}`,
|
||||
label: 'Zurück zum Trainingsablauf',
|
||||
kind: 'trainingRun',
|
||||
payload: { unitId: id },
|
||||
})
|
||||
}
|
||||
|
||||
export function buildPlanningHubFallbackReturnContext() {
|
||||
return buildNavReturnContext({
|
||||
path: PLANNING_HUB_PATH,
|
||||
label: 'Zurück zur Planung',
|
||||
kind: 'planningHub',
|
||||
})
|
||||
}
|
||||
|
||||
/** Router-Link state mit appReturn (optional zusätzlicher State). */
|
||||
export function linkStateWithAppReturn(returnContext, extraState) {
|
||||
const state = { ...(extraState || {}) }
|
||||
if (returnContext) state[NAV_RETURN_STATE_KEY] = returnContext
|
||||
return Object.keys(state).length > 0 ? state : undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* Rücksprung zur aktuellen Route (z. B. Einheiten-Editor).
|
||||
*/
|
||||
|
||||
@@ -2,8 +2,10 @@ import { describe, expect, it, vi } from 'vitest'
|
||||
import {
|
||||
appReturnFromPlanningReturn,
|
||||
buildExercisesListReturnContext,
|
||||
buildMediaLibraryReturnContext,
|
||||
buildNavReturnContext,
|
||||
buildPlanningHubReturnContext,
|
||||
buildTrainingRunReturnContext,
|
||||
goNavReturn,
|
||||
readNavReturnFromLocation,
|
||||
resolveNavReturnTarget,
|
||||
@@ -82,4 +84,17 @@ describe('navReturnContext', () => {
|
||||
expect(ctx?.path).toContain('group=7')
|
||||
expect(ctx?.kind).toBe('planningHub')
|
||||
})
|
||||
|
||||
it('buildTrainingRunReturnContext', () => {
|
||||
const ctx = buildTrainingRunReturnContext(42)
|
||||
expect(ctx?.path).toBe('/planning/run/42')
|
||||
expect(ctx?.kind).toBe('trainingRun')
|
||||
expect(buildTrainingRunReturnContext('')).toBeNull()
|
||||
})
|
||||
|
||||
it('buildMediaLibraryReturnContext', () => {
|
||||
const ctx = buildMediaLibraryReturnContext()
|
||||
expect(ctx?.path).toBe('/media')
|
||||
expect(ctx?.kind).toBe('mediaLibrary')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user