Skip to content

Commit

Permalink
Merge pull request #3271 from sbwalker/dev
Browse files Browse the repository at this point in the history
fix #3231 - validate module description
  • Loading branch information
sbwalker authored Sep 20, 2023
2 parents 6967a5c + a6ca843 commit e88c8ee
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 186 deletions.
28 changes: 22 additions & 6 deletions Oqtane.Client/Modules/Admin/ModuleDefinitions/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,10 @@

protected override void OnInitialized()
{
AddModuleMessage(Localizer["Info.Module.Development"], MessageType.Info);
if (!NavigationManager.BaseUri.Contains("localhost:"))
{
AddModuleMessage(Localizer["Info.Module.Development"], MessageType.Info);
}
}

protected override async Task OnParametersSetAsync()
Expand All @@ -115,11 +118,18 @@
{
if (IsValid(_owner) && IsValid(_module) && _owner != _module && _template != "-")
{
var template = _templates.FirstOrDefault(item => item.Name == _template);
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference, ModuleDefinitionName = template.Namespace };
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
GetLocation();
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
if (IsValidXML(_description))
{
var template = _templates.FirstOrDefault(item => item.Name == _template);
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference, ModuleDefinitionName = template.Namespace };
moduleDefinition = await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition);
GetLocation();
AddModuleMessage(string.Format(Localizer["Success.Module.Create"], NavigateUrl("admin/system")), MessageType.Success);
}
else
{
AddModuleMessage(Localizer["Message.Require.ValidDescription"], MessageType.Warning);
}
}
else
{
Expand All @@ -143,6 +153,12 @@
return !string.IsNullOrEmpty(name) && name.ToLower() != "module" && !name.ToLower().Contains("oqtane") && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
}

private bool IsValidXML(string description)
{
// must contain letters, digits, or spaces
return Regex.IsMatch(description, "^[A-Za-z0-9 ]+$");
}

private void TemplateChanged(ChangeEventArgs e)
{
_template = (string)e.Value;
Expand Down
5 changes: 4 additions & 1 deletion Oqtane.Client/Modules/Admin/Themes/Create.razor
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,10 @@

protected override void OnInitialized()
{
AddModuleMessage(Localizer["Info.Theme.CreatorIntent"], MessageType.Info);
if (!NavigationManager.BaseUri.Contains("localhost:"))
{
AddModuleMessage(Localizer["Info.Theme.CreatorIntent"], MessageType.Info);
}
}

protected override async Task OnParametersSetAsync()
Expand Down
177 changes: 0 additions & 177 deletions Oqtane.Client/Resources/Modules/Admin/ModuleCreator/Index.resx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,9 @@
<data name="Message.Require.ValidName" xml:space="preserve">
<value>You Must Provide A Valid Owner Name And Module Name ( ie. No Punctuation Or Spaces And The Values Cannot Be The Same ) And Choose A Template</value>
</data>
<data name="Message.Require.ValidDescription" xml:space="preserve">
<value>You Must Provide A Valid Description (ie. No Punctuation)</value>
</data>
<data name="OwnerName.HelpText" xml:space="preserve">
<value>Enter the name of the organization who is developing this module. It should not contain spaces or punctuation.</value>
</data>
Expand Down
2 changes: 0 additions & 2 deletions Oqtane.Client/Themes/Controls/Theme/LoginBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public class LoginBase : ThemeControlBase
[Inject] public IJSRuntime jsRuntime { get; set; }
[Inject] public IServiceProvider ServiceProvider { get; set; }

private bool _allowsitelogin = true;

protected void LoginUser()
{
Route route = new Route(PageState.Uri.AbsoluteUri, PageState.Alias.Path);
Expand Down

0 comments on commit e88c8ee

Please sign in to comment.