Merge pull request #940 from sbwalker/dev
fix ModuleCreator Invalid character use in naming fields #889
This commit is contained in:
commit
03d246340f
@ -5,73 +5,74 @@
|
|||||||
@inject IModuleService ModuleService
|
@inject IModuleService ModuleService
|
||||||
@inject ISystemService SystemService
|
@inject ISystemService SystemService
|
||||||
@inject IStringLocalizer<Index> Localizer
|
@inject IStringLocalizer<Index> Localizer
|
||||||
|
@using System.Text.RegularExpressions
|
||||||
|
|
||||||
<table class="table table-borderless">
|
<table class="table table-borderless">
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label>
|
<Label For="owner" HelpText="Enter the name of the organization who is developing this module. It should not contain spaces or punctuation." ResourceKey="OwnerName">Owner Name: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="owner" class="form-control" @bind="@_owner" />
|
<input id="owner" class="form-control" @bind="@_owner" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="module" HelpText="Enter a name for this module. It should not contain spaces or punctuation." ResourceKey="ModuleName">Module Name: </Label>
|
<Label For="module" HelpText="Enter a name for this module. It should not contain spaces or punctuation." ResourceKey="ModuleName">Module Name: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<input id="module" class="form-control" @bind="@_module" />
|
<input id="module" class="form-control" @bind="@_module" />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="description" HelpText="Enter s short description for the module" ResourceKey="Description">Description: </Label>
|
<Label For="description" HelpText="Enter s short description for the module" ResourceKey="Description">Description: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<textarea id="description" class="form-control" @bind="@_description" rows="3"></textarea>
|
<textarea id="description" class="form-control" @bind="@_description" rows="3"></textarea>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="template" HelpText="Select a module template. Internal modules are created inside of the Oqtane solution. External modules are created outside of the Oqtane solution." ResourceKey="Template">Template: </Label>
|
<Label For="template" HelpText="Select a module template. Internal modules are created inside of the Oqtane solution. External modules are created outside of the Oqtane solution." ResourceKey="Template">Template: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select id="template" class="form-control" @onchange="(e => TemplateChanged(e))">
|
<select id="template" class="form-control" @onchange="(e => TemplateChanged(e))">
|
||||||
<option value="-"><@Localizer["Select Template"]></option>
|
<option value="-"><@Localizer["Select Template"]></option>
|
||||||
<option value="internal">@Localizer["Internal"]</option>
|
<option value="internal">@Localizer["Internal"]</option>
|
||||||
<option value="external">@Localizer["External"]</option>
|
<option value="external">@Localizer["External"]</option>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<Label For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label>
|
<Label For="reference" HelpText="Select a framework reference version" ResourceKey="FrameworkReference">Framework Reference: </Label>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<select id="reference" class="form-control" @bind="@_reference">
|
<select id="reference" class="form-control" @bind="@_reference">
|
||||||
@foreach (string version in Constants.ReleaseVersions.Split(','))
|
@foreach (string version in Constants.ReleaseVersions.Split(','))
|
||||||
|
{
|
||||||
|
if (Version.Parse(version).CompareTo(Version.Parse("2.0.0")) >= 0)
|
||||||
{
|
{
|
||||||
if (Version.Parse(version).CompareTo(Version.Parse("2.0.0")) >= 0)
|
<option value="@(version)">@(version)</option>
|
||||||
{
|
|
||||||
<option value="@(version)">@(version)</option>
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
<option value="local">@Localizer["Local Version"]</option>
|
<option value="local">@Localizer["Local Version"]</option>
|
||||||
</select>
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@if (!string.IsNullOrEmpty(_location))
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<Label For="location" HelpText="Location where the module will be created" ResourceKey="Location">Location: </Label>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input id="module" class="form-control" @bind="@_location" readonly />
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@if (!string.IsNullOrEmpty(_location))
|
}
|
||||||
{
|
</table>
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<Label For="location" HelpText="Location where the module will be created" ResourceKey="Location">Location: </Label>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input id="module" class="form-control" @bind="@_location" readonly />
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</table>
|
|
||||||
|
|
||||||
<button type="button" class="btn btn-success" @onclick="CreateModule">@Localizer["Create Module"]</button>
|
<button type="button" class="btn btn-success" @onclick="CreateModule">@Localizer["Create Module"]</button>
|
||||||
|
|
||||||
@ -94,18 +95,18 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(_owner) && !string.IsNullOrEmpty(_module) && _template != "-")
|
if (IsValid(_owner) && IsValid(_module) && _template != "-")
|
||||||
{
|
{
|
||||||
ShowProgressIndicator();
|
ShowProgressIndicator();
|
||||||
var interop = new Interop(JSRuntime);
|
var interop = new Interop(JSRuntime);
|
||||||
await interop.RedirectBrowser(NavigateUrl(), 5);
|
await interop.RedirectBrowser(NavigateUrl(), 5);
|
||||||
|
|
||||||
var moduleDefinition = new ModuleDefinition { Owner = _owner.Replace(" ", ""), Name = _module.Replace(" ", ""), Description = _description, Template = _template, Version = _reference };
|
var moduleDefinition = new ModuleDefinition { Owner = _owner, Name = _module, Description = _description, Template = _template, Version = _reference };
|
||||||
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
|
await ModuleDefinitionService.CreateModuleDefinitionAsync(moduleDefinition, ModuleState.ModuleId);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
AddModuleMessage("You Must Provide An Owner, Module Name, And Template", MessageType.Warning);
|
AddModuleMessage("You Must Provide A Valid Owner Name, Module Name, And Template", MessageType.Warning);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -114,6 +115,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool IsValid(string name)
|
||||||
|
{
|
||||||
|
// must contain letters, underscores and digits and first character must be letter or underscore
|
||||||
|
return !string.IsNullOrEmpty(name) && Regex.IsMatch(name, "^[A-Za-z_][A-Za-z0-9_]*$");
|
||||||
|
}
|
||||||
|
|
||||||
private async void TemplateChanged(ChangeEventArgs e)
|
private async void TemplateChanged(ChangeEventArgs e)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
Reference in New Issue
Block a user