Skip to content

Commit

Permalink
Merge pull request #4069 from oqtane/dev
Browse files Browse the repository at this point in the history
5.1.0 release
  • Loading branch information
sbwalker authored Mar 27, 2024
2 parents d938620 + ee45ed8 commit 0633b28
Show file tree
Hide file tree
Showing 224 changed files with 6,515 additions and 3,389 deletions.
91 changes: 0 additions & 91 deletions Oqtane.Client/App.razor

This file was deleted.

5 changes: 3 additions & 2 deletions Oqtane.Client/Extensions/OqtaneServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@ namespace Microsoft.Extensions.DependencyInjection
{
public static class OqtaneServiceCollectionExtensions
{
public static IServiceCollection AddOqtaneAuthorization(this IServiceCollection services)
public static IServiceCollection AddOqtaneAuthentication(this IServiceCollection services)
{
services.AddAuthorizationCore();
services.AddCascadingAuthenticationState();
services.AddScoped<IdentityAuthenticationStateProvider>();
services.AddScoped<AuthenticationStateProvider>(s => s.GetRequiredService<IdentityAuthenticationStateProvider>());

return services;
}

public static IServiceCollection AddOqtaneScopedServices(this IServiceCollection services)
public static IServiceCollection AddOqtaneClientScopedServices(this IServiceCollection services)
{
services.AddScoped<SiteState>();
services.AddScoped<IInstallationService, InstallationService>();
Expand Down
6 changes: 4 additions & 2 deletions Oqtane.Client/Installer/Installer.razor
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,10 @@
IsNewTenant = true,
SiteName = Constants.DefaultSite,
Register = _register,
SiteTemplate = _template
};
SiteTemplate = _template,
RenderMode = RenderModes.Static,
Runtime = Runtimes.Server
};

var installation = await InstallationService.Install(config);
if (installation.Success)
Expand Down
7 changes: 4 additions & 3 deletions Oqtane.Client/Modules/Admin/Dashboard/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
if (UserSecurity.IsAuthorized(PageState.User, PermissionNames.View, p.PermissionList))
{
string url = NavigateUrl(p.Path);
<p class="col-md-2 mx-auto text-center mb-3">
<div class="col-md-2 mx-auto text-center my-3">
<NavLink class="nav-link text-body" href="@url" Match="NavLinkMatch.All">
<h2><span class="@p.Icon" aria-hidden="true"></span></h2>
<p class="lead">@((MarkupString)SharedLocalizer[p.Name].ToString().Replace(" ", "<br />"))</p>
<div class="lead">@((MarkupString)SharedLocalizer[p.Name].ToString().Replace(" ", "<br />"))</div>
</NavLink>
</p>
</div>
}
}
</div>
Expand All @@ -27,6 +27,7 @@
private List<Page> _pages;

public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.View;
public override string RenderMode => RenderModes.Static;

protected override void OnInitialized()
{
Expand Down
36 changes: 9 additions & 27 deletions Oqtane.Client/Modules/Admin/Jobs/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ else

<Pager Items="@_jobs" SearchProperties="Name">
<Header>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th style="width: 1px;">&nbsp;</th>
<th>@SharedLocalizer["Name"]</th>
Expand All @@ -28,7 +27,6 @@ else
</Header>
<Row>
<td><ActionLink Action="Edit" Parameters="@($"id=" + context.JobId.ToString())" ResourceKey="EditJob" /></td>
<td><ActionDialog Header="Delete Job" Message="Are You Sure You Wish To Delete This Job?" Action="Delete" Security="SecurityAccessLevel.Host" Class="btn btn-danger" OnClick="@(async () => await DeleteJob(context))" ResourceKey="DeleteJob" /></td>
<td><ActionLink Action="Log" Class="btn btn-secondary" Parameters="@($"id=" + context.JobId.ToString())" ResourceKey="JobLog" /></td>
<td>@context.Name</td>
<td>@DisplayStatus(context.IsEnabled, context.IsExecuting)</td>
Expand All @@ -49,17 +47,17 @@ else
}

@code {
private List<Job> _jobs;
private List<Job> _jobs;

public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Host; } }

protected override async Task OnParametersSetAsync()
{
_jobs = await JobService.GetJobsAsync();
if (_jobs.Count == 0)
{
AddModuleMessage(string.Format(Localizer["Message.NoJobs"], NavigateUrl("admin/system")), MessageType.Warning);
}
protected override async Task OnInitializedAsync()
{
_jobs = await JobService.GetJobsAsync();
if (_jobs.Count == 0)
{
AddModuleMessage(string.Format(Localizer["Message.NoJobs"], NavigateUrl("admin/system")), MessageType.Warning);
}
}

private string DisplayStatus(bool isEnabled, bool isExecuting)
Expand Down Expand Up @@ -112,22 +110,6 @@ else
return result;
}

private async Task DeleteJob(Job job)
{
try
{
await JobService.DeleteJobAsync(job.JobId);
await logger.LogInformation("Job Deleted {Job}", job);
_jobs = await JobService.GetJobsAsync();
StateHasChanged();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting Job {Job} {Error}", job, ex.Message);
AddModuleMessage(Localizer["Error.Job.Delete"], MessageType.Error);
}
}

private async Task StartJob(int jobId)
{
try
Expand Down
34 changes: 19 additions & 15 deletions Oqtane.Client/Modules/Admin/Login/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
<Authorizing>
<text>...</text>
</Authorizing>
<Authorized>
<ModuleMessage Message="@Localizer["Info.SignedIn"]" Type="MessageType.Info" />
</Authorized>
<NotAuthorized>
@if (!twofactor)
{
Expand Down Expand Up @@ -47,8 +50,13 @@
<button type="button" class="btn btn-primary" @onclick="Login">@SharedLocalizer["Login"]</button>
<button type="button" class="btn btn-secondary" @onclick="Cancel">@SharedLocalizer["Cancel"]</button>
<br /><br />
<button type="button" class="btn btn-secondary" @onclick="Forgot">@Localizer["ForgotPassword"]</button>
}
<button type="button" class="btn btn-secondary" @onclick="Forgot">@Localizer["ForgotPassword"]</button>
@if (PageState.Site.AllowRegistration)
{
<br /><br />
<NavLink href="@NavigateUrl("register")">@Localizer["Register"]</NavLink>
}
}
</div>
</form>
}
Expand Down Expand Up @@ -84,8 +92,6 @@
private bool _alwaysremember = false;
private string _code = string.Empty;

private string _returnUrl = string.Empty;

public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Anonymous;

public override List<Resource> Resources => new List<Resource>()
Expand All @@ -103,11 +109,6 @@

_togglepassword = SharedLocalizer["ShowPassword"];

if (PageState.QueryString.ContainsKey("returnurl"))
{
_returnUrl = PageState.QueryString["returnurl"];
}

if (PageState.QueryString.ContainsKey("name"))
{
_username = PageState.QueryString["name"];
Expand Down Expand Up @@ -168,11 +169,14 @@
{
if (firstRender && PageState.User == null && _allowsitelogin)
{
await username.FocusAsync();
if (!string.IsNullOrEmpty(username.Id)) // ensure username is visible in UI
{
await username.FocusAsync();
}
}

// redirect logged in user to specified page
if (PageState.User != null)
if (PageState.User != null && !UserSecurity.IsAuthorized(PageState.User, RoleNames.Admin))
{
NavigationManager.NavigateTo(PageState.ReturnUrl);
}
Expand Down Expand Up @@ -208,12 +212,12 @@
// hybrid apps utilize an interactive login
var authstateprovider = (IdentityAuthenticationStateProvider)ServiceProvider.GetService(typeof(IdentityAuthenticationStateProvider));
authstateprovider.NotifyAuthenticationChanged();
NavigationManager.NavigateTo(NavigateUrl(WebUtility.UrlDecode(_returnUrl), true));
NavigationManager.NavigateTo(NavigateUrl(PageState.ReturnUrl, true));
}
else
{
// post back to the Login page so that the cookies are set correctly
var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, username = _username, password = _password, remember = _remember, returnurl = _returnUrl };
var fields = new { __RequestVerificationToken = SiteState.AntiForgeryToken, username = _username, password = _password, remember = _remember, returnurl = WebUtility.UrlEncode(PageState.ReturnUrl) };
string url = Utilities.TenantUrl(PageState.Alias, "/pages/login/");
await interop.SubmitForm(url, fields);
}
Expand Down Expand Up @@ -255,7 +259,7 @@

private void Cancel()
{
NavigationManager.NavigateTo(_returnUrl);
NavigationManager.NavigateTo(PageState.ReturnUrl);
}

private async Task Forgot()
Expand Down Expand Up @@ -323,7 +327,7 @@

private void ExternalLogin()
{
NavigationManager.NavigateTo(Utilities.TenantUrl(PageState.Alias, "/pages/external?returnurl=" + _returnUrl), true);
NavigationManager.NavigateTo(Utilities.TenantUrl(PageState.Alias, "/pages/external?returnurl=" + WebUtility.UrlEncode(PageState.ReturnUrl)), true);
}

}
11 changes: 7 additions & 4 deletions Oqtane.Client/Modules/Admin/Modules/Settings.razor
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
</TabStrip>
<br />
<button type="button" class="btn btn-success" @onclick="SaveModule">@SharedLocalizer["Save"]</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">@SharedLocalizer["Cancel"]</NavLink>
<NavLink class="btn btn-secondary" href="@PageState.ReturnUrl">@SharedLocalizer["Cancel"]</NavLink>
<br />
<br />
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon"></AuditInfo>
Expand Down Expand Up @@ -155,6 +155,7 @@
private DateTime modifiedon;
private DateTime? _effectivedate = null;
private DateTime? _expirydate = null;

protected override void OnInitialized()
{
_module = ModuleState.ModuleDefinition.Name;
Expand Down Expand Up @@ -197,7 +198,8 @@
ModuleSettingsComponent = builder =>
{
builder.OpenComponent(0, _moduleSettingsType);
builder.AddComponentReferenceCapture(1, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); });
builder.AddAttribute(1, "RenderModeBoundary", RenderModeBoundary);
builder.AddComponentReferenceCapture(2, inst => { _moduleSettings = Convert.ChangeType(inst, _moduleSettingsType); });
builder.CloseComponent();
};
}
Expand All @@ -216,7 +218,8 @@
ContainerSettingsComponent = builder =>
{
builder.OpenComponent(0, _containerSettingsType);
builder.AddComponentReferenceCapture(1, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); });
builder.AddAttribute(1, "RenderModeBoundary", RenderModeBoundary);
builder.AddComponentReferenceCapture(2, inst => { _containerSettings = Convert.ChangeType(inst, _containerSettingsType); });
builder.CloseComponent();
};
}
Expand Down Expand Up @@ -280,7 +283,7 @@
await containerSettingsControl.UpdateSettings();
}

NavigationManager.NavigateTo(NavigateUrl());
NavigationManager.NavigateTo(PageState.ReturnUrl);
}
else
{
Expand Down
Loading

0 comments on commit 0633b28

Please sign in to comment.