Skip to content

Commit

Permalink
[issue-16267] Simplified returnUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
best-mmg committed Jun 26, 2024
1 parent 4965910 commit 771d500
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,19 @@ public async Task<IActionResult> Localize(string contentItemId, string targetCul
if (alreadyLocalizedContent != null)
{
await _notifier.WarningAsync(H["A localization already exists for '{0}'.", targetCulture]);
return RedirectToAction("Edit", "Admin", new { area = "OrchardCore.Contents", contentItemId });
return RedirectToAction("Edit", "Admin", new { area = "OrchardCore.Contents", contentItemId, returnUrl });
}

try
{
var newContent = await _contentLocalizationManager.LocalizeAsync(contentItem, targetCulture);
await _notifier.InformationAsync(H["Localized version of the content created successfully."]);

if(!string.IsNullOrEmpty(returnUrl))
{
TempData["returnUrl"] = returnUrl;
}

return RedirectToAction("Edit", "Admin", new { area = "OrchardCore.Contents", contentItemId = newContent.ContentItemId });
return RedirectToAction("Edit", "Admin", new { area = "OrchardCore.Contents", contentItemId = newContent.ContentItemId, returnUrl });
}
catch (InvalidOperationException)
{
await _notifier.WarningAsync(H["Could not create localized version of the content item."]);
return RedirectToAction("Edit", "Admin", new { area = "OrchardCore.Contents", contentItemId = contentItem.ContentItemId });
return RedirectToAction("Edit", "Admin", new { area = "OrchardCore.Contents", contentItemId = contentItem.ContentItemId, returnUrl });
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@
{
@if (!string.IsNullOrEmpty(Model.LocalizationSet))
{
var returnUrl = string.IsNullOrEmpty(Context.Request.Query["returnUrl"])
? TempData["returnUrl"] ?? string.Empty
: Context.Request.Query["returnUrl"];
var returnUrl = Context.Request.Query["returnUrl"];

<div class="list-group">
@foreach (var culture in Model.ContentItemCultures)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,11 +425,6 @@ public async Task<IActionResult> Edit(string contentItemId, string returnUrl = n

var model = await _contentItemDisplayManager.BuildEditorAsync(contentItem, this, false);

if(!string.IsNullOrEmpty(returnUrl))
{
TempData["returnUrl"] = returnUrl;
}

return View(model);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
var contentTypeDefinition = await ContentDefinitionManager.GetTypeDefinitionAsync(contentItem.ContentType);
var typeDisplayName = contentTypeDefinition?.DisplayName ?? contentItem.ContentType.CamelFriendly();

var returnUrl = string.IsNullOrEmpty(Context.Request.Query["returnUrl"])
? TempData["returnUrl"] ?? string.Empty
: Context.Request.Query["returnUrl"];
var returnUrl = Context.Request.Query["returnUrl"];
}

<zone Name="Title"><h1>@RenderTitleSegments(T["Edit {0}", typeDisplayName])</h1></zone>
Expand Down

0 comments on commit 771d500

Please sign in to comment.