Skip to content

Commit

Permalink
Merge pull request #3152 from serlo/fix/redirect-back-to-exercise-fol…
Browse files Browse the repository at this point in the history
…der-upon-closing-wizard

Implement feedback of Tina to transition back to exercise folder
  • Loading branch information
Entkenntnis authored Dec 1, 2023
2 parents a3676db + 31efc5a commit ddecb74
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,16 +49,22 @@ export function LazyLoadExerciseGenerationWrapperOrNull({
closeWizard={() => {
setShowWizard(false)

const url = new URL(window.location.href)
// Delete existing query param
url.searchParams.delete('showAiWizard')
// Update URL without reloading the page
router
.replace(url.pathname + url.search, undefined, {
shallow: true,
})
.then(() => void null)
.catch(() => void null)
const referrer = router.query.referrer
if (referrer === 'exercise-folder') {
// If we come from an exercise folder, we want to transition back!
router.back()
} else {
const url = new URL(window.location.href)
// Delete existing query param
url.searchParams.delete('showAiWizard')
// Update URL without reloading the page
router
.replace(url.pathname + url.search, undefined, {
shallow: true,
})
.then(() => void null)
.catch(() => void null)
}
}}
subject={subject}
topic={topic}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,13 @@ export function AuthorTools({ tools, entityId, data }: AuthorToolsProps) {
title={
loggedInStrings.ai.exerciseGeneration.buttonTitleSingular
}
href={`/entity/create/${UuidType.Exercise}/${data.id}?showAiWizard=`}
href={`/entity/create/${UuidType.Exercise}/${data.id}?showAiWizard=&referrer=exercise-folder`}
icon={faWandSparkles}
/>
<SubItem
key="ai-group-exercise"
title={loggedInStrings.ai.exerciseGeneration.buttonTitle}
href={`/entity/create/${entityType}/${data.id}?showAiWizard=`}
href={`/entity/create/${entityType}/${data.id}?showAiWizard=&referrer=exercise-folder`}
icon={faWandMagicSparkles}
/>
</Fragment>
Expand Down

0 comments on commit ddecb74

Please sign in to comment.