Skip to content

Commit 244788f

Browse files
authored
IBX-7159: Fix preview back button 500 (#1005)
1 parent 9c42a75 commit 244788f

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/bundle/Controller/ContentController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,7 @@ public function previewAction(
351351
?Location $location = null
352352
): Response {
353353
$preselectedSiteAccess = $request->query->get('preselectedSiteAccess');
354+
$referrer = $request->query->get('referrer');
354355

355356
if (null === $languageCode) {
356357
$languageCode = $content->contentInfo->mainLanguageCode;
@@ -396,6 +397,7 @@ public function previewAction(
396397
'siteaccesses' => $siteAccessesList,
397398
'version_no' => $versionNo ?? $content->getVersionInfo()->versionNo,
398399
'preselected_site_access' => $preselectedSiteAccess,
400+
'referrer' => $referrer ?? 'content_draft_edit',
399401
]);
400402
}
401403

src/bundle/Resources/views/themes/admin/content/content_preview.html.twig

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,23 @@
1212
{% block header_row %}
1313
<div class="ibexa-preview-header">
1414
<div class="ibexa-preview-header__item ibexa-preview-header__item--back">
15+
{% if referrer == 'content_draft_edit' %}
16+
{% set back_url = url('ibexa.content.draft.edit', {
17+
contentId: content.id,
18+
versionNo: version_no,
19+
language: language_code,
20+
locationId: is_published ? location.id : null,
21+
}) %}
22+
{% else %}
23+
{% set back_url = url('ibexa.content.view', {
24+
contentId: content.id,
25+
locationId: location.id,
26+
}) %}
27+
{% endif %}
28+
1529
<a
1630
class="ibexa-preview-header__link btn ibexa-btn ibexa-btn--ghost"
17-
href="{{ url('ibexa.content.draft.edit', {'contentId': content.id, 'versionNo': version_no, 'language': language_code, 'locationId': is_published ? location.id : null}) }}"
31+
href="{{ back_url }}"
1832
>
1933
<svg class="ibexa-icon ibexa-icon--small-medium">
2034
<use xlink:href="{{ ibexa_icon_path('back') }}"></use>

src/lib/Menu/ContentRightSidebarBuilder.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -496,6 +496,7 @@ private function getContentPreviewItem(
496496
'versionNo' => $content->getVersionInfo()->versionNo,
497497
'languageCode' => $languageCode,
498498
'locationId' => $location->id,
499+
'referrer' => 'content_view',
499500
],
500501
];
501502
} else {

0 commit comments

Comments
 (0)