diff --git a/Oqtane.Client/Resources/UI/ModuleInstance.resx b/Oqtane.Client/Resources/UI/ModuleInstance.resx
index 3ce75ee0..a10f61d6 100644
--- a/Oqtane.Client/Resources/UI/ModuleInstance.resx
+++ b/Oqtane.Client/Resources/UI/ModuleInstance.resx
@@ -123,4 +123,7 @@
Module Type Is Invalid For {0}
+
+ Program error in module {0}
+
\ No newline at end of file
diff --git a/Oqtane.Client/UI/ModuleInstance.razor b/Oqtane.Client/UI/ModuleInstance.razor
index 41e7f12e..f2bff75d 100644
--- a/Oqtane.Client/UI/ModuleInstance.razor
+++ b/Oqtane.Client/UI/ModuleInstance.razor
@@ -1,17 +1,30 @@
@namespace Oqtane.UI
@inject IStringLocalizer Localizer
-
-@DynamicComponent
-@if (_progressindicator)
-{
-
-}
+
+
+
+
+
+
+ @if (ModuleType != null)
+ {
+
+ @if (_progressIndicator)
+ {
+
+ }
+ }
+
+
@code {
private string _message;
- private MessageType _messagetype;
- private bool _progressindicator = false;
+ private MessageType _messageType;
+ private bool _progressIndicator = false;
+
+ private Type ModuleType { get; set; }
+ private IDictionary ModuleParameters { get; set; }
[CascadingParameter]
protected PageState PageState { get; set; }
@@ -26,53 +39,54 @@
protected override void OnParametersSet()
{
_message = "";
-
- DynamicComponent = builder =>
+ if (!string.IsNullOrEmpty(ModuleState.ModuleType))
{
- Type moduleType = null;
- if (!string.IsNullOrEmpty(ModuleState.ModuleType))
+ ModuleType = Type.GetType(ModuleState.ModuleType);
+ if (ModuleType != null)
{
- moduleType = Type.GetType(ModuleState.ModuleType);
-
- if (moduleType != null)
- {
- builder.OpenComponent(0, moduleType);
- builder.AddAttribute(1, "ModuleInstance", this);
- builder.CloseComponent();
- }
- else
- {
- // module does not exist with typename specified
- _message = string.Format(Localizer["Error.Module.InvalidName"], Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0));
- _messagetype = MessageType.Error;
- }
+ ModuleParameters = new Dictionary { { "ModuleInstance", this } };
+ return;
}
- else
- {
- _message = string.Format(Localizer["Error.Module.InvalidType"], ModuleState.ModuleDefinitionName);
- _messagetype = MessageType.Error;
- }
-
- };
+ // module does not exist with typename specified
+ _message = string.Format(Localizer["Error.Module.InvalidName"], Utilities.GetTypeNameLastSegment(ModuleState.ModuleType, 0));
+ _messageType = MessageType.Error;
+ }
+ else
+ {
+ _message = string.Format(Localizer["Error.Module.InvalidType"], ModuleState.ModuleDefinitionName);
+ _messageType = MessageType.Error;
+ }
}
public void AddModuleMessage(string message, MessageType type)
{
_message = message;
- _messagetype = type;
- _progressindicator = false;
+ _messageType = type;
+ _progressIndicator = false;
StateHasChanged();
}
public void ShowProgressIndicator()
{
- _progressindicator = true;
+ _progressIndicator = true;
StateHasChanged();
}
public void HideProgressIndicator()
{
- _progressindicator = false;
+ _progressIndicator = false;
StateHasChanged();
}
+
+
+ private string ErrorMessage(Exception context)
+ {
+ var message = string.Format(Localizer["Error.Module.Exception"], ModuleState.ModuleDefinitionName);
+ if (UserSecurity.IsAuthorized(PageState.User, RoleNames.Host))
+ {
+ return $"{message}
{context}";
+ }
+ return message;
+ }
+
}