Skip to content

Commit

Permalink
Merge pull request #3788 from sbwalker/dev
Browse files Browse the repository at this point in the history
force ModuleActions to interactive render mode
  • Loading branch information
sbwalker authored Feb 14, 2024
2 parents 921f552 + 872ec90 commit e33fc1a
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 43 deletions.
48 changes: 9 additions & 39 deletions Oqtane.Client/Themes/Controls/Container/ModuleActions.razor
Original file line number Diff line number Diff line change
@@ -1,45 +1,15 @@
@namespace Oqtane.Themes.Controls
@inherits ModuleActionsBase
@inherits ContainerBase
@attribute [OqtaneIgnore]

@if (PageState.EditMode && UserSecurity.IsAuthorized(PageState.User, PermissionNames.Edit, PageState.Page.PermissionList) && PageState.Action == Constants.DefaultAction)
{
<div class="app-moduleactions py-2 px-3">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"></a>
<ul class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 37px, 0px);" role="button">
@foreach (var action in Actions.Where(item => !item.Name.Contains("Pane")))
{
if (string.IsNullOrEmpty(action.Name))
{
<li class="dropdown-divider"></li>
}
else
{
<li>
<a class="dropdown-item" @onclick="(async () => await ModuleAction(action))">
<span class="@action.Icon" aria-hidden="true"></span>&nbsp;@action.Name
</a>
</li>
}
}
@if (Actions.Where(item => item.Name.Contains("Pane")).Any())
{
<li class="dropdown-submenu">
<a class="dropdown-item" onclick="return subMenu(this)">
<span class="@Icons.AccountLogin" aria-hidden="true"></span>&nbsp;Move To &gt;
</a>
<ul class="dropdown-menu">
@foreach (var action in Actions.Where(item => item.Name.Contains("Pane")))
{
<li>
<a class="dropdown-item" @onclick="(async () => await ModuleAction(action))">
<span class="@action.Icon" aria-hidden="true"></span>&nbsp;@action.Name
</a>
</li>
}
</ul>
</li>
}
</ul>
</div>
@if (PageState.Site.RenderMode == RenderModes.Interactive)
{
<ModuleActionsInteractive PageState="@PageState" ModuleState="@ModuleState" />
}
else
{
<ModuleActionsInteractive PageState="@PageState" ModuleState="@ModuleState" @rendermode="@InteractiveRenderMode.GetInteractiveRenderMode(PageState.Site.Runtime, PageState.Site.Prerender)" />
}
}
12 changes: 8 additions & 4 deletions Oqtane.Client/Themes/Controls/Container/ModuleActionsBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,22 @@
using Oqtane.Security;
using Oqtane.Services;
using Oqtane.Shared;
using Oqtane.UI;

// ReSharper disable UnassignedGetOnlyAutoProperty
// ReSharper disable MemberCanBePrivate.Global

namespace Oqtane.Themes.Controls
{
public class ModuleActionsBase : ContainerBase
public class ModuleActionsBase : ComponentBase
{
[Inject] public NavigationManager NavigationManager { get; set; }
[Inject] public IPageModuleService PageModuleService { get; set; }
[Inject] public IModuleService ModuleService { get; set; }

[Parameter] public PageState PageState { get; set; }
[Parameter] public Module ModuleState { get; set; }

public List<ActionViewModel> Actions;

protected override void OnParametersSet()
Expand Down Expand Up @@ -88,7 +92,7 @@ protected virtual List<ActionViewModel> GetActions()
private async Task<string> EditUrlAsync(string url, int moduleId, string import)
{
await Task.Yield();
return EditUrl(moduleId, import);
return Utilities.EditUrl(PageState.Alias.Path, PageState.Page.Path, moduleId, import, "");
}

protected async Task ModuleAction(ActionViewModel action)
Expand All @@ -97,7 +101,7 @@ protected async Task ModuleAction(ActionViewModel action)
{
PageModule pagemodule = await PageModuleService.GetPageModuleAsync(ModuleState.PageModuleId);

string url = NavigateUrl(true);
string url = Utilities.NavigateUrl(PageState.Alias.Path, PageState.Page.Path, "refresh");

if (action.Action != null)
{
Expand Down Expand Up @@ -130,7 +134,7 @@ private async Task<string> DeleteModule(string url, PageModule pagemodule)
private async Task<string> Settings(string url, PageModule pagemodule)
{
await Task.Yield();
url = EditUrl(pagemodule.ModuleId, "Settings");
url = Utilities.EditUrl(PageState.Alias.Path, PageState.Page.Path, pagemodule.ModuleId, "Settings", "");
return url;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@namespace Oqtane.Themes.Controls
@inherits ModuleActionsBase
@attribute [OqtaneIgnore]

<div class="app-moduleactions py-2 px-3">
<a class="nav-link dropdown-toggle" data-bs-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"></a>
<ul class="dropdown-menu" x-placement="bottom-start" style="position: absolute; will-change: transform; top: 0px; left: 0px; transform: translate3d(0px, 37px, 0px);" role="button">
@foreach (var action in Actions.Where(item => !item.Name.Contains("Pane")))
{
if (string.IsNullOrEmpty(action.Name))
{
<li class="dropdown-divider"></li>
}
else
{
<li>
<a class="dropdown-item" @onclick="(async () => await ModuleAction(action))">
<span class="@action.Icon" aria-hidden="true"></span>&nbsp;@action.Name
</a>
</li>
}
}
@if (Actions.Where(item => item.Name.Contains("Pane")).Any())
{
<li class="dropdown-submenu">
<a class="dropdown-item" onclick="return subMenu(this)">
<span class="@Icons.AccountLogin" aria-hidden="true"></span>&nbsp;Move To &gt;
</a>
<ul class="dropdown-menu">
@foreach (var action in Actions.Where(item => item.Name.Contains("Pane")))
{
<li>
<a class="dropdown-item" @onclick="(async () => await ModuleAction(action))">
<span class="@action.Icon" aria-hidden="true"></span>&nbsp;@action.Name
</a>
</li>
}
</ul>
</li>
}
</ul>
</div>

0 comments on commit e33fc1a

Please sign in to comment.