Merge branch 'feature/plugins' into 'dev'

Resolve "Plugin support"

Closes #29

See merge request leon.hoppe/hopframe!30
This commit was merged in pull request #68.
This commit is contained in:
2025-02-05 16:56:59 +00:00
27 changed files with 540 additions and 85 deletions

View File

@@ -11,15 +11,11 @@
<option name="autoReloadType" value="SELECTIVE" /> <option name="autoReloadType" value="SELECTIVE" />
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="0648788e-7696-4e60-bf12-5d5601f33d8c" name="Changes" comment=""> <list default="true" id="0648788e-7696-4e60-bf12-5d5601f33d8c" name="Changes" comment="Added plugin buttons">
<change afterPath="$PROJECT_DIR$/src/HopFrame.Web/Components/HopFrameCard.razor" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Components/Pages/HopFrameTablePage.razor" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Components/Pages/HopFrameTablePage.razor" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/HopFrame.Web/HopFrameConfiguratorExtensions.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/PageInitializedEvent.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Events/TableInitializedEvent.cs" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/HopFrame.Web/Models/CustomView.cs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/IPluginOrchestrator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/IPluginOrchestrator.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/.idea.HopFrame/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.HopFrame/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Internal/PluginOrchestrator.cs" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Plugins/Internal/PluginOrchestrator.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Components/Layout/HopFrameLayout.razor" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Components/Layout/HopFrameLayout.razor" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/HopFrame.Web/Components/Layout/HopFrameSideMenu.razor" beforeDir="false" afterPath="$PROJECT_DIR$/src/HopFrame.Web/Components/Layout/HopFrameSideMenu.razor" afterDir="false" />
<change beforePath="$PROJECT_DIR$/testing/HopFrame.Testing/Components/Pages/Counter.razor" beforeDir="false" afterPath="$PROJECT_DIR$/testing/HopFrame.Testing/Components/Pages/Counter.razor" afterDir="false" />
<change beforePath="$PROJECT_DIR$/testing/HopFrame.Testing/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/testing/HopFrame.Testing/Program.cs" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@@ -63,18 +59,23 @@
<component name="HighlightingSettingsPerFile"> <component name="HighlightingSettingsPerFile">
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/02/6ae7626a/IList.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/02/6ae7626a/IList.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/5b/a350be00/IEnumerable.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/5b/a350be00/IEnumerable.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/62/1fb63ed0/IDisposable.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/8b/db8582a3/IList`1.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/8b/db8582a3/IList`1.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/ad/ba9a50e7/ICollection.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/ad/ba9a50e7/ICollection.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/fc/6f7933d2/ICollection`1.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/DecompilerCache/decompiler/c73b3c6c598640c592fd3c6fa226c286e90908/fc/6f7933d2/ICollection`1.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/10c66a9a1e137111895f7182a2ae246eabe06a261578c3fa495a45f6f177d35/IconVariant.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/10c66a9a1e137111895f7182a2ae246eabe06a261578c3fa495a45f6f177d35/IconVariant.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/1b81cb3be224213a6a73519b6e340a628d9a1fb8629c351a186a26f6376669/List.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/1b81cb3be224213a6a73519b6e340a628d9a1fb8629c351a186a26f6376669/List.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/24dd1164ba47541cb1d3eb011e638e16953dbea3ae3f4dc208c3bbf3e96298a/ServiceCollectionServiceExtensions.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/26c9a2fb5243863babc926e4be763daf4128d4f97c4a769cdce1e2e3e5c532/FluentButton.razor.cs" root0="SKIP_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/26c9a2fb5243863babc926e4be763daf4128d4f97c4a769cdce1e2e3e5c532/FluentButton.razor.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/2751d5afefca5424bfc4b21347f581372f7a739c0ae4df661ea557fcb97ef20/EnumExtensions.cs" root0="SKIP_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/2751d5afefca5424bfc4b21347f581372f7a739c0ae4df661ea557fcb97ef20/EnumExtensions.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/439c4ee753b23e743cc14119593bc889751f9eb0b38997577d8e4c47c4fed/ToCollection.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/439c4ee753b23e743cc14119593bc889751f9eb0b38997577d8e4c47c4fed/ToCollection.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/4c41a7d338749915157d56585365d1693fbad6be8231d3d583b1cf10d16896d9/FluentIcon.razor.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/4ee221fd7e91e9a4c14ff82aae2ee938edecde35a934133e991aba56aa9499/Icon.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/4ee221fd7e91e9a4c14ff82aae2ee938edecde35a934133e991aba56aa9499/Icon.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/558c1d46e1e21d2e78ee2ab67a674f6927bf95355b2f245f35d74bb5ec0f92/CancellationTokenSource.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/5a69b82eed595b731b82667db08722b69b82482e275cf32dfb219190e3dc49/CollectionEntry.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/5a69b82eed595b731b82667db08722b69b82482e275cf32dfb219190e3dc49/CollectionEntry.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/60e7b22380df80ef6fefe43138047f49ec6eff4b25c12b42ce3d6ed5aac/MethodInvokerCommon.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/60e7b22380df80ef6fefe43138047f49ec6eff4b25c12b42ce3d6ed5aac/MethodInvokerCommon.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/642391624bd5c30b3411a11434588aba4906207335166b784bf3a4325f6c7/NavigationEntry.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/642391624bd5c30b3411a11434588aba4906207335166b784bf3a4325f6c7/NavigationEntry.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/6d1d64f05e7045295fa180276a8c2aef0302c9e96eb53b3431ab13db4579/FluentAppBarItem.razor.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/6fe785cceb29ca2d1da78e157315815a7c4372b582a20a71c28b210f9d56e/IconsExtensions.cs" root0="SKIP_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/6fe785cceb29ca2d1da78e157315815a7c4372b582a20a71c28b210f9d56e/IconsExtensions.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/7ad7d2d0ae865063993eb8a03427815ea3bdb6a774e0a2f95512e9f669a4f489/MemberEntry.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/7ad7d2d0ae865063993eb8a03427815ea3bdb6a774e0a2f95512e9f669a4f489/MemberEntry.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/87c584767b46b5fd42769be76547105558e6690f785614efddca134b2d682/Type.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/87c584767b46b5fd42769be76547105558e6690f785614efddca134b2d682/Type.cs" root0="FORCE_HIGHLIGHTING" />
@@ -86,11 +87,13 @@
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/d04a416cac8afac0341a8be0e859b230f2eae64924298eef48c317ba35916/RenderTreeBuilder.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/d04a416cac8afac0341a8be0e859b230f2eae64924298eef48c317ba35916/RenderTreeBuilder.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/d39923abb31e6a6e7a9e8173e217da584c54925ce63e568126a2b89b9ab/DefaultRazorComponentsServiceOptionsConfiguration.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/d39923abb31e6a6e7a9e8173e217da584c54925ce63e568126a2b89b9ab/DefaultRazorComponentsServiceOptionsConfiguration.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/d858ddb35a8e36df5573b7612542f9ad50f426b8ab43818587d1ac65fab14829/DatabaseGeneratedAttribute.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/d858ddb35a8e36df5573b7612542f9ad50f426b8ab43818587d1ac65fab14829/DatabaseGeneratedAttribute.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/dac3553c90d47a746e7e7f02faecb1a5e581090/Components_AppBar_FluentAppBarItem_razor.g.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/e26a4f2df232f16e374b9719f883c1b2419f6341838d94b7581db9c7d2de17/IconInfo.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/e26a4f2df232f16e374b9719f883c1b2419f6341838d94b7581db9c7d2de17/IconInfo.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/eab2d6b892f743a27cb49a139ba782855897baf1233febd2dfd2092f3/EntityEntry.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/eab2d6b892f743a27cb49a139ba782855897baf1233febd2dfd2092f3/EntityEntry.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/ece8533187fe96ce67b3ef1c9cc3502ef8da5510aadb132a9b21c5605d7c2119/PropertyColumn.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/ece8533187fe96ce67b3ef1c9cc3502ef8da5510aadb132a9b21c5605d7c2119/PropertyColumn.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/ee4d234452e240d83e3de396c2e85cbf9ac9fb9add618b955eea196c81aaf8/IDialogContentComponent.cs" root0="SKIP_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/ee4d234452e240d83e3de396c2e85cbf9ac9fb9add618b955eea196c81aaf8/IDialogContentComponent.cs" root0="SKIP_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/fc2027f7e776fc105cddb56b1a25eeb3895b3ae6f3aac854d786e63bd01f75e2/CallSiteFactory.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/fc2027f7e776fc105cddb56b1a25eeb3895b3ae6f3aac854d786e63bd01f75e2/CallSiteFactory.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/fd57398b7dc3a8ce7da2786f2c67289c3d974658a9e90d0c1e84db3d965fbf1/Console.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/ff37d54b3bf4d2756237fb789635831532603376e940f63d634b869d26d74c/Regular16.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$APPLICATION_CONFIG_DIR$/resharper-host/SourcesCache/ff37d54b3bf4d2756237fb789635831532603376e940f63d634b869d26d74c/Regular16.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/src/HopFrame.Core/Config/DbContextConfig.cs" root0="FORCE_HIGHLIGHTING" /> <setting file="file://$PROJECT_DIR$/src/HopFrame.Core/Config/DbContextConfig.cs" root0="FORCE_HIGHLIGHTING" />
</component> </component>
@@ -122,7 +125,7 @@
&quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;, &quot;RunOnceActivity.git.unshallow&quot;: &quot;true&quot;,
&quot;b5f11219-dfc4-47a1-b02c-90ab603034fb.executor&quot;: &quot;Debug&quot;, &quot;b5f11219-dfc4-47a1-b02c-90ab603034fb.executor&quot;: &quot;Debug&quot;,
&quot;dcdf1689-dc07-47e4-8824-2e60a4fbf301.executor&quot;: &quot;Debug&quot;, &quot;dcdf1689-dc07-47e4-8824-2e60a4fbf301.executor&quot;: &quot;Debug&quot;,
&quot;git-widget-placeholder&quot;: &quot;!29 on feature/custom-views&quot;, &quot;git-widget-placeholder&quot;: &quot;!30 on feature/plugins&quot;,
&quot;list.type.of.created.stylesheet&quot;: &quot;CSS&quot;, &quot;list.type.of.created.stylesheet&quot;: &quot;CSS&quot;,
&quot;node.js.detected.package.eslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.eslint&quot;: &quot;true&quot;,
&quot;node.js.detected.package.tslint&quot;: &quot;true&quot;, &quot;node.js.detected.package.tslint&quot;: &quot;true&quot;,
@@ -233,6 +236,10 @@
<workItem from="1738335286481" duration="2039000" /> <workItem from="1738335286481" duration="2039000" />
<workItem from="1738403493974" duration="4231000" /> <workItem from="1738403493974" duration="4231000" />
<workItem from="1738418482606" duration="2795000" /> <workItem from="1738418482606" duration="2795000" />
<workItem from="1738421294144" duration="1651000" />
<workItem from="1738422949337" duration="141000" />
<workItem from="1738512801911" duration="6776000" />
<workItem from="1738769458367" duration="4838000" />
</task> </task>
<task id="LOCAL-00001" summary="Added basic configuration"> <task id="LOCAL-00001" summary="Added basic configuration">
<option name="closed" value="true" /> <option name="closed" value="true" />
@@ -514,7 +521,39 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1738407710507</updated> <updated>1738407710507</updated>
</task> </task>
<option name="localTasksCounter" value="36" /> <task id="LOCAL-00036" summary="Added custom views">
<option name="closed" value="true" />
<created>1738422931038</created>
<option name="number" value="00036" />
<option name="presentableId" value="LOCAL-00036" />
<option name="project" value="LOCAL" />
<updated>1738422931038</updated>
</task>
<task id="LOCAL-00037" summary="Added plugin events">
<option name="closed" value="true" />
<created>1738519603597</created>
<option name="number" value="00037" />
<option name="presentableId" value="LOCAL-00037" />
<option name="project" value="LOCAL" />
<updated>1738519603597</updated>
</task>
<task id="LOCAL-00038" summary="Passed cancellation tokens to event handlers if needed">
<option name="closed" value="true" />
<created>1738770468949</created>
<option name="number" value="00038" />
<option name="presentableId" value="LOCAL-00038" />
<option name="project" value="LOCAL" />
<updated>1738770468949</updated>
</task>
<task id="LOCAL-00039" summary="Added plugin buttons">
<option name="closed" value="true" />
<created>1738773315593</created>
<option name="number" value="00039" />
<option name="presentableId" value="LOCAL-00039" />
<option name="project" value="LOCAL" />
<updated>1738773315593</updated>
</task>
<option name="localTasksCounter" value="40" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
@@ -565,10 +604,6 @@
<component name="UnityProjectConfiguration" hasMinimizedUI="false" /> <component name="UnityProjectConfiguration" hasMinimizedUI="false" />
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" /> <option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="true" />
<MESSAGE value="Removed Template" />
<MESSAGE value="Added policy validation, ordering and virtual listing properties" />
<MESSAGE value="Added n -&gt; m relation support" />
<MESSAGE value="Added text area support and DI support for modifier functions" />
<MESSAGE value="Addressed all build warnings" /> <MESSAGE value="Addressed all build warnings" />
<MESSAGE value="Added documentation for the configurators and service extensions methods" /> <MESSAGE value="Added documentation for the configurators and service extensions methods" />
<MESSAGE value="Created tests for the core module" /> <MESSAGE value="Created tests for the core module" />
@@ -590,6 +625,10 @@
<MESSAGE value="Added missing installation instructions" /> <MESSAGE value="Added missing installation instructions" />
<MESSAGE value="Added modular event system" /> <MESSAGE value="Added modular event system" />
<MESSAGE value="Fixed event emitter service scope" /> <MESSAGE value="Fixed event emitter service scope" />
<option name="LAST_COMMIT_MESSAGE" value="Fixed event emitter service scope" /> <MESSAGE value="Added custom views" />
<MESSAGE value="Added plugin events" />
<MESSAGE value="Passed cancellation tokens to event handlers if needed" />
<MESSAGE value="Added plugin buttons" />
<option name="LAST_COMMIT_MESSAGE" value="Added plugin buttons" />
</component> </component>
</project> </project>

View File

@@ -1,8 +1,8 @@
using HopFrame.Core.Config; using HopFrame.Core.Config;
namespace HopFrame.Core.Events; namespace HopFrame.Core.Callbacks;
public static class EventTypes { public static class CallbackTypes {
private const string Prefix = "HopFrame."; private const string Prefix = "HopFrame.";
private const string CreateEntryPrefix = Prefix + "Entry.Create."; private const string CreateEntryPrefix = Prefix + "Entry.Create.";
@@ -13,18 +13,18 @@ public static class EventTypes {
public static string UpdateEntry(TableConfig config) => UpdateEntryPrefix + config.PropertyName; public static string UpdateEntry(TableConfig config) => UpdateEntryPrefix + config.PropertyName;
public static string DeleteEntry(TableConfig config) => DeleteEntryPrefix + config.PropertyName; public static string DeleteEntry(TableConfig config) => DeleteEntryPrefix + config.PropertyName;
public static string ConstructEventName(EventType type, TableConfig config) { public static string ConstructCallbackName(CallbackType type, TableConfig config) {
return type switch { return type switch {
EventType.CreateEntry => CreateEntry(config), CallbackType.CreateEntry => CreateEntry(config),
EventType.UpdateEntry => UpdateEntry(config), CallbackType.UpdateEntry => UpdateEntry(config),
EventType.DeleteEntry => DeleteEntry(config), CallbackType.DeleteEntry => DeleteEntry(config),
_ => Prefix _ => Prefix
}; };
} }
} }
public enum EventType { public enum CallbackType {
CreateEntry = 0, CreateEntry = 0,
UpdateEntry = 1, UpdateEntry = 1,
DeleteEntry = 2 DeleteEntry = 2

View File

@@ -1,6 +1,6 @@
namespace HopFrame.Core.Events; namespace HopFrame.Core.Callbacks;
public readonly struct HopEventHandler(string eventType, Func<object, IServiceProvider, Task> handler) { public readonly struct HopCallbackHandler(string eventType, Func<object, IServiceProvider, Task> handler) {
public Guid Id { get; } = Guid.CreateVersion7(); public Guid Id { get; } = Guid.CreateVersion7();
public Func<object, IServiceProvider, Task> Handler { get; } = handler; public Func<object, IServiceProvider, Task> Handler { get; } = handler;
public string EventType { get; } = eventType; public string EventType { get; } = eventType;

View File

@@ -0,0 +1,14 @@
namespace HopFrame.Core.Callbacks;
public interface ICallbackEmitter {
Guid RegisterCallbackHandler(string @event, Func<object, IServiceProvider, Task> handler);
bool RemoveCallbackHandler(Guid id);
Task DispatchCallback(string @event, object argument = null!);
void RemoveAllCallbackHandlers(string @event);
void RemoveAllCallbackHandlers();
}

View File

@@ -1,5 +1,4 @@
using HopFrame.Core.Events; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore;
namespace HopFrame.Core.Config; namespace HopFrame.Core.Config;

View File

@@ -1,5 +1,6 @@
using HopFrame.Core.Events; using HopFrame.Core.Callbacks;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
namespace HopFrame.Core.Config; namespace HopFrame.Core.Config;
@@ -8,19 +9,21 @@ public class HopFrameConfig {
public bool DisplayUserInfo { get; set; } = true; public bool DisplayUserInfo { get; set; } = true;
public string? BasePolicy { get; set; } public string? BasePolicy { get; set; }
public string? LoginPageRewrite { get; set; } public string? LoginPageRewrite { get; set; }
public List<HopEventHandler> Handlers { get; } = new(); public List<HopCallbackHandler> Handlers { get; } = new();
} }
/// <summary> /// <summary>
/// A helper class for editing the <see cref="HopFrameConfig"/> /// A helper class for editing the <see cref="HopFrameConfig"/>
/// </summary> /// </summary>
public class HopFrameConfigurator(HopFrameConfig config) { public class HopFrameConfigurator(HopFrameConfig config, IServiceCollection collection = null!) {
/// <summary> /// <summary>
/// The Internal HopFrame configuration that's modified by the helper functions /// The Internal HopFrame configuration that's modified by the helper functions
/// </summary> /// </summary>
public HopFrameConfig InnerConfig { get; } = config; public HopFrameConfig InnerConfig { get; } = config;
public IServiceCollection ServiceCollection { get; } = collection;
/// <summary> /// <summary>
/// Adds all tables defined in the DbContext to the HopFrame ui and configures it using the provided configurator /// Adds all tables defined in the DbContext to the HopFrame ui and configures it using the provided configurator
/// </summary> /// </summary>
@@ -45,6 +48,18 @@ public class HopFrameConfigurator(HopFrameConfig config) {
return new DbContextConfigurator<TDbContext>(context); return new DbContextConfigurator<TDbContext>(context);
} }
public bool HasDbContext<TDbContext>() where TDbContext : DbContext {
return InnerConfig.Contexts.Any(context => context.ContextType == typeof(TDbContext));
}
public DbContextConfigurator<TDbContext>? GetDbContext<TDbContext>() where TDbContext : DbContext {
var config = InnerConfig.Contexts
.SingleOrDefault(context => context.ContextType == typeof(TDbContext));
if (config is null) return null;
return new DbContextConfigurator<TDbContext>(config);
}
/// <summary> /// <summary>
/// Determines if the name of the currently logged-in user should be displayed in the top right corner of the admin ui /// Determines if the name of the currently logged-in user should be displayed in the top right corner of the admin ui
/// </summary> /// </summary>

View File

@@ -2,7 +2,7 @@
using System.ComponentModel.DataAnnotations.Schema; using System.ComponentModel.DataAnnotations.Schema;
using System.Linq.Expressions; using System.Linq.Expressions;
using System.Reflection; using System.Reflection;
using HopFrame.Core.Events; using HopFrame.Core.Callbacks;
namespace HopFrame.Core.Config; namespace HopFrame.Core.Config;
@@ -191,26 +191,26 @@ public class TableConfigurator<TModel>(TableConfig config) {
} }
/// <summary> /// <summary>
/// Adds an event handler of the provided type /// Adds a callback handler of the provided type
/// </summary> /// </summary>
/// <param name="type">The type of event that triggers the handler</param> /// <param name="type">The type of callback that triggers the handler</param>
/// <param name="handler">The handler delegate</param> /// <param name="handler">The handler delegate</param>
public TableConfigurator<TModel> AddEventHandler(EventType type, Func<TModel, IServiceProvider, Task> handler) { public TableConfigurator<TModel> AddCallbackHandler(CallbackType type, Func<TModel, IServiceProvider, Task> handler) {
var eventName = EventTypes.ConstructEventName(type, InnerConfig); var eventName = CallbackTypes.ConstructCallbackName(type, InnerConfig);
var handlerStore = new HopEventHandler(eventName, (o, provider) => handler.Invoke((TModel)o, provider)); var handlerStore = new HopCallbackHandler(eventName, (o, provider) => handler.Invoke((TModel)o, provider));
InnerConfig.ContextConfig.ParentConfig.Handlers.Add(handlerStore); InnerConfig.ContextConfig.ParentConfig.Handlers.Add(handlerStore);
return this; return this;
} }
/// <summary> /// <summary>
/// Adds an event handler of the provided type /// Adds a callback handler of the provided type
/// </summary> /// </summary>
/// <param name="type">The type of event that triggers the handler</param> /// <param name="type">The type of callback that triggers the handler</param>
/// <param name="handler">The handler delegate</param> /// <param name="handler">The handler delegate</param>
public TableConfigurator<TModel> AddEventHandler(EventType type, Action<TModel, IServiceProvider> handler) { public TableConfigurator<TModel> AddCallbackHandler(CallbackType type, Action<TModel, IServiceProvider> handler) {
var eventName = EventTypes.ConstructEventName(type, InnerConfig); var eventName = CallbackTypes.ConstructCallbackName(type, InnerConfig);
var handlerStore = new HopEventHandler(eventName, (o, provider) => { var handlerStore = new HopCallbackHandler(eventName, (o, provider) => {
handler.Invoke((TModel)o, provider); handler.Invoke((TModel)o, provider);
return Task.CompletedTask; return Task.CompletedTask;
}); });

View File

@@ -1,14 +0,0 @@
namespace HopFrame.Core.Events;
public interface IEventEmitter {
Guid RegisterEventHandler(string @event, Func<object, IServiceProvider, Task> handler);
bool RemoveEventHandler(Guid id);
Task DispatchEvent(string @event, object argument = null!);
void RemoveAllEventHandlers(string @event);
void RemoveAllEventHandlers();
}

View File

@@ -1,4 +1,4 @@
using HopFrame.Core.Events; using HopFrame.Core.Callbacks;
using HopFrame.Core.Services; using HopFrame.Core.Services;
using HopFrame.Core.Services.Implementations; using HopFrame.Core.Services.Implementations;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@@ -16,7 +16,7 @@ public static class ServiceCollectionExtensions {
public static IServiceCollection AddHopFrameServices(this IServiceCollection services) { public static IServiceCollection AddHopFrameServices(this IServiceCollection services) {
services.AddScoped<IContextExplorer, ContextExplorer>(); services.AddScoped<IContextExplorer, ContextExplorer>();
services.TryAddScoped<IHopFrameAuthHandler, DefaultAuthHandler>(); services.TryAddScoped<IHopFrameAuthHandler, DefaultAuthHandler>();
services.TryAddScoped<IEventEmitter, EventEmitter>(); services.TryAddScoped<ICallbackEmitter, CallbackEmitter>();
return services; return services;
} }

View File

@@ -1,22 +1,22 @@
using HopFrame.Core.Config; using HopFrame.Core.Config;
using HopFrame.Core.Events; using HopFrame.Core.Callbacks;
namespace HopFrame.Core.Services.Implementations; namespace HopFrame.Core.Services.Implementations;
internal sealed class EventEmitter(IServiceProvider provider, HopFrameConfig config) : IEventEmitter { internal sealed class CallbackEmitter(IServiceProvider provider, HopFrameConfig config) : ICallbackEmitter {
public Guid RegisterEventHandler(string @event, Func<object, IServiceProvider, Task> handler) { public Guid RegisterCallbackHandler(string @event, Func<object, IServiceProvider, Task> handler) {
var handlerStore = new HopEventHandler(@event, handler); var handlerStore = new HopCallbackHandler(@event, handler);
config.Handlers.Add(handlerStore); config.Handlers.Add(handlerStore);
return handlerStore.Id; return handlerStore.Id;
} }
public bool RemoveEventHandler(Guid id) { public bool RemoveCallbackHandler(Guid id) {
var count = config.Handlers.RemoveAll(handler => handler.Id == id); var count = config.Handlers.RemoveAll(handler => handler.Id == id);
return count > 0; return count > 0;
} }
public async Task DispatchEvent(string @event, object argument = null!) { public async Task DispatchCallback(string @event, object argument = null!) {
var handlers = config.Handlers.Where(handler => handler.EventType == @event); var handlers = config.Handlers.Where(handler => handler.EventType == @event);
var tasks = new List<Task>(); var tasks = new List<Task>();
@@ -28,11 +28,11 @@ internal sealed class EventEmitter(IServiceProvider provider, HopFrameConfig con
await Task.WhenAll(tasks); await Task.WhenAll(tasks);
} }
public void RemoveAllEventHandlers(string @event) { public void RemoveAllCallbackHandlers(string @event) {
config.Handlers.RemoveAll(handler => handler.EventType == @event); config.Handlers.RemoveAll(handler => handler.EventType == @event);
} }
public void RemoveAllEventHandlers() { public void RemoveAllCallbackHandlers() {
config.Handlers.Clear(); config.Handlers.Clear();
} }

View File

@@ -1,11 +1,14 @@
@rendermode InteractiveServer @rendermode InteractiveServer
@implements IDialogContentComponent<EditorDialogData> @implements IDialogContentComponent<EditorDialogData>
@implements IDisposable
@using System.Collections @using System.Collections
@using HopFrame.Core.Config @using HopFrame.Core.Config
@using HopFrame.Core.Services @using HopFrame.Core.Services
@using HopFrame.Web.Models @using HopFrame.Web.Models
@using HopFrame.Web.Helpers @using HopFrame.Web.Helpers
@using HopFrame.Web.Plugins
@using HopFrame.Web.Plugins.Events
<FluentDialogBody> <FluentDialogBody>
@foreach (var property in Content.Config.Properties.Where(prop => !prop.IsListingProperty).OrderBy(prop => prop.Order)) { @foreach (var property in Content.Config.Properties.Where(prop => !prop.IsListingProperty).OrderBy(prop => prop.Order)) {
@@ -169,6 +172,7 @@
@inject IHopFrameAuthHandler Handler @inject IHopFrameAuthHandler Handler
@inject IToastService Toasts @inject IToastService Toasts
@inject IServiceProvider Provider @inject IServiceProvider Provider
@inject IPluginOrchestrator PluginOrchestrator
@code { @code {
[Parameter] [Parameter]
@@ -181,6 +185,7 @@
private ITableManager? _manager; private ITableManager? _manager;
private readonly Dictionary<string, List<string>> _validationErrors = new(); private readonly Dictionary<string, List<string>> _validationErrors = new();
private readonly List<PropertyChange> _changes = new(); private readonly List<PropertyChange> _changes = new();
private readonly CancellationTokenSource _tokenSource = new();
protected override void OnInitialized() { protected override void OnInitialized() {
_currentlyEditing = Content.CurrentObject is not null; _currentlyEditing = Content.CurrentObject is not null;
@@ -374,6 +379,14 @@
if (value is null && property.IsRequired) if (value is null && property.IsRequired)
errorList.Add($"{property.Name} is required"); errorList.Add($"{property.Name} is required");
var eventResult = await PluginOrchestrator.DispatchEvent(new ValidationEvent(this) {
Errors = errorList,
Property = property,
Table = Content.Config
}, _tokenSource.Token);
if (eventResult.IsCanceled) return false;
} }
StateHasChanged(); StateHasChanged();
@@ -390,6 +403,10 @@
return true; return true;
} }
public void Dispose() {
_tokenSource.Dispose();
}
private enum InputType { private enum InputType {
Number, Number,
Switch, Switch,

View File

@@ -4,9 +4,11 @@
@implements IDisposable @implements IDisposable
@using HopFrame.Core.Config @using HopFrame.Core.Config
@using HopFrame.Core.Events @using HopFrame.Core.Callbacks
@using HopFrame.Core.Services @using HopFrame.Core.Services
@using HopFrame.Web.Models @using HopFrame.Web.Models
@using HopFrame.Web.Plugins
@using HopFrame.Web.Plugins.Events
@using Microsoft.JSInterop @using Microsoft.JSInterop
@using Microsoft.EntityFrameworkCore @using Microsoft.EntityFrameworkCore
@@ -19,7 +21,7 @@
<div style="display: flex; flex-direction: column; height: 100%"> <div style="display: flex; flex-direction: column; height: 100%">
<FluentToolbar Class="hopframe-toolbar"> <FluentToolbar Class="hopframe-toolbar">
<h3>@_config?.DisplayName</h3> <h3>@_config?.DisplayName</h3>
@if (!DisplaySelection) { @if (!DisplaySelection && _buttonToggles.ShowRefreshButton) {
<FluentButton <FluentButton
IconStart="@(new Icons.Regular.Size16.ArrowClockwise())" IconStart="@(new Icons.Regular.Size16.ArrowClockwise())"
OnClick="Reload" OnClick="Reload"
@@ -29,18 +31,34 @@
</FluentButton> </FluentButton>
} }
@foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.TopLeft)) {
<FluentButton
IconStart="@(button.Icon?.GetInstance())"
OnClick="() => button.Handler.Invoke(null!, _config!)">
@button.Title
</FluentButton>
}
<FluentSpacer /> <FluentSpacer />
<FluentSearch @oninput="OnSearch" @onchange="OnSearch" Style="width: 350px" /> <FluentSearch @oninput="OnSearch" @onchange="OnSearch" Style="width: 350px" />
@if (_hasCreatePolicy && DisplayActions) { @if (_hasCreatePolicy && DisplayActions && _buttonToggles.ShowAddEntityButton) {
<FluentButton OnClick="async () => { await CreateOrEdit(null); }">Add Entry</FluentButton> <FluentButton OnClick="async () => { await CreateOrEdit(null); }">Add Entity</FluentButton>
}
@foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.TopRight)) {
<FluentButton
IconStart="@(button.Icon?.GetInstance())"
OnClick="() => button.Handler.Invoke(null!, _config!)">
@button.Title
</FluentButton>
} }
</FluentToolbar> </FluentToolbar>
<FluentProgress Visible="_loading" Width="100%" /> <FluentProgress Visible="_loading" Width="100%" />
<div style="display: flex; overflow-y: auto; flex-grow: 1"> <div style="display: flex; overflow-y: auto; flex-grow: 1">
<div style="flex-grow: 1"> <div style="flex-grow: 1">
<FluentDataGrid Items="_currentlyDisplayedModels.AsQueryable()"> <FluentDataGrid Items="CurrentlyDisplayedModels.AsQueryable()">
@if (DisplaySelection) { @if (DisplaySelection) {
<SelectColumn <SelectColumn
TGridItem="object" TGridItem="object"
@@ -61,13 +79,19 @@
@if (DisplayActions && (_hasDeletePolicy || _hasUpdatePolicy)) { @if (DisplayActions && (_hasDeletePolicy || _hasUpdatePolicy)) {
<TemplateColumn Title="Actions" Align="@Align.End" Style="min-height: 44px; min-width: max-content"> <TemplateColumn Title="Actions" Align="@Align.End" Style="min-height: 44px; min-width: max-content">
@if (_hasUpdatePolicy) { @foreach (var button in _pluginButtons.Where(pb => pb.IsForTable(_config)).Where(pb => pb.Position == PluginButtonPosition.OnEntry)) {
<FluentButton OnClick="() => button.Handler.Invoke(context, _config!)">
<FluentIcon Value="@(button.Icon!.GetInstance())" />
</FluentButton>
}
@if (_hasUpdatePolicy && _buttonToggles.ShowEditButton) {
<FluentButton aria-label="Edit entry" OnClick="async () => { await CreateOrEdit(context); }"> <FluentButton aria-label="Edit entry" OnClick="async () => { await CreateOrEdit(context); }">
<FluentIcon Value="@(new Icons.Regular.Size16.Edit())"/> <FluentIcon Value="@(new Icons.Regular.Size16.Edit())"/>
</FluentButton> </FluentButton>
} }
@if (_hasDeletePolicy) { @if (_hasDeletePolicy && _buttonToggles.ShowDeleteButton) {
<FluentButton aria-label="Delete entry" OnClick="async () => { await DeleteEntry(context); }"> <FluentButton aria-label="Delete entry" OnClick="async () => { await DeleteEntry(context); }">
<FluentIcon Value="@(new Icons.Regular.Size16.Delete())" Color="Color.Warning"/> <FluentIcon Value="@(new Icons.Regular.Size16.Delete())" Color="Color.Warning"/>
</FluentButton> </FluentButton>
@@ -118,7 +142,8 @@
@inject IJSRuntime Js @inject IJSRuntime Js
@inject IDialogService Dialogs @inject IDialogService Dialogs
@inject IHopFrameAuthHandler Handler @inject IHopFrameAuthHandler Handler
@inject IEventEmitter Emitter @inject ICallbackEmitter Emitter
@inject IPluginOrchestrator PluginOrchestrator
@code { @code {
@@ -143,7 +168,7 @@
private TableConfig? _config; private TableConfig? _config;
private ITableManager? _manager; private ITableManager? _manager;
private object[] _currentlyDisplayedModels = []; public object[] CurrentlyDisplayedModels = [];
private int _currentPage; private int _currentPage;
private int _totalPages; private int _totalPages;
private string? _searchTerm; private string? _searchTerm;
@@ -155,6 +180,10 @@
private bool _allSelected; private bool _allSelected;
private readonly CancellationTokenSource _tokenSource = new();
private List<PluginButton> _pluginButtons = new();
private DefaultButtonToggles _buttonToggles = new();
protected override void OnInitialized() { protected override void OnInitialized() {
_config ??= Explorer.GetTable(TableDisplayName); _config ??= Explorer.GetTable(TableDisplayName);
@@ -169,12 +198,19 @@
return; return;
} }
var eventResult = await PluginOrchestrator.DispatchEvent(new TableInitializedEvent(this) {
Table = _config!
});
if (eventResult.IsCanceled) return;
_pluginButtons = eventResult.PluginButtons;
_buttonToggles = eventResult.DefaultButtons;
_hasUpdatePolicy = await Handler.IsAuthenticatedAsync(_config?.UpdatePolicy); _hasUpdatePolicy = await Handler.IsAuthenticatedAsync(_config?.UpdatePolicy);
_hasDeletePolicy = await Handler.IsAuthenticatedAsync(_config?.DeletePolicy); _hasDeletePolicy = await Handler.IsAuthenticatedAsync(_config?.DeletePolicy);
_hasCreatePolicy = await Handler.IsAuthenticatedAsync(_config?.CreatePolicy); _hasCreatePolicy = await Handler.IsAuthenticatedAsync(_config?.CreatePolicy);
_manager ??= Explorer.GetTableManager(_config!.PropertyName); _manager ??= Explorer.GetTableManager(_config!.PropertyName);
_currentlyDisplayedModels = await _manager!.LoadPage(_currentPage, PerPage).ToArrayAsync(); CurrentlyDisplayedModels = await _manager!.LoadPage(_currentPage, PerPage).ToArrayAsync();
_totalPages = await _manager.TotalPages(PerPage); _totalPages = await _manager.TotalPages(PerPage);
} }
@@ -189,6 +225,7 @@
public void Dispose() { public void Dispose() {
_searchCancel.Dispose(); _searchCancel.Dispose();
_tokenSource.Dispose();
} }
private CancellationTokenSource _searchCancel = new(); private CancellationTokenSource _searchCancel = new();
@@ -199,14 +236,31 @@
_searchCancel = new(); _searchCancel = new();
await Task.Delay(500, _searchCancel.Token); await Task.Delay(500, _searchCancel.Token);
var eventResult = await PluginOrchestrator.DispatchEvent(new SearchEvent(this) {
SearchTerm = _searchTerm,
Table = _config!
}, _tokenSource.Token);
if (eventResult.IsCanceled) return;
_searchTerm = eventResult.SearchTerm;
await Reload(); await Reload();
} }
private async Task Reload() { private async Task Reload() {
_loading = true; _loading = true;
var eventResult = await PluginOrchestrator.DispatchEvent(new ReloadEvent(this) {
Table = _config!
}, _tokenSource.Token);
if (eventResult.IsCanceled) {
_loading = false;
return;
}
if (!string.IsNullOrEmpty(_searchTerm)) { if (!string.IsNullOrEmpty(_searchTerm)) {
(var query, _totalPages) = await _manager!.Search(_searchTerm, 0, PerPage); (var query, _totalPages) = await _manager!.Search(_searchTerm, 0, PerPage);
_currentlyDisplayedModels = query.ToArray(); CurrentlyDisplayedModels = query.ToArray();
} }
else { else {
await OnInitializedAsync(); await OnInitializedAsync();
@@ -215,6 +269,15 @@
} }
private async Task ChangePage(int page) { private async Task ChangePage(int page) {
var eventResult = await PluginOrchestrator.DispatchEvent(new PageChangeEvent(this) {
CurrentPage = _currentPage,
NewPage = page,
TotalPages = _totalPages,
Table = _config!
}, _tokenSource.Token);
if (eventResult.IsCanceled) return;
page = eventResult.NewPage;
if (page < 0 || page > _totalPages - 1) return; if (page < 0 || page > _totalPages - 1) return;
_currentPage = page; _currentPage = page;
await Reload(); await Reload();
@@ -226,12 +289,18 @@
return; return;
} }
var eventResult = await PluginOrchestrator.DispatchEvent(new DeleteEntryEvent(this) {
Entity = element,
Table = _config!
}, _tokenSource.Token);
if (eventResult.IsCanceled) return;
var dialog = await Dialogs.ShowConfirmationAsync("Do you really want to delete this entry?"); var dialog = await Dialogs.ShowConfirmationAsync("Do you really want to delete this entry?");
var result = await dialog.Result; var result = await dialog.Result;
if (result.Cancelled) return; if (result.Cancelled) return;
await _manager!.DeleteItem(element); await _manager!.DeleteItem(element);
await Emitter.DispatchEvent(EventTypes.DeleteEntry(_config!), element); await Emitter.DispatchCallback(CallbackTypes.DeleteEntry(_config!), element);
await Reload(); await Reload();
} }
@@ -241,6 +310,22 @@
return; return;
} }
HopFrameTablePageEventArgs eventArgs;
if (element is null) {
eventArgs = new CreateEntryEvent(this) {
Table = _config!
};
}
else {
eventArgs = new UpdateEntryEvent(this) {
Table = _config!,
Entity = element
};
}
var eventResult = await PluginOrchestrator.DispatchEvent(eventArgs, _tokenSource.Token);
if (eventResult.IsCanceled) return;
var panel = await Dialogs.ShowPanelAsync<HopFrameEditor>(new EditorDialogData(_config!, element), new DialogParameters { var panel = await Dialogs.ShowPanelAsync<HopFrameEditor>(new EditorDialogData(_config!, element), new DialogParameters {
TrapFocus = false TrapFocus = false
}); });
@@ -251,25 +336,33 @@
if (element is null) { if (element is null) {
await _manager!.AddItem(data!.CurrentObject!); await _manager!.AddItem(data!.CurrentObject!);
await Emitter.DispatchEvent(EventTypes.CreateEntry(_config!), data.CurrentObject!); await Emitter.DispatchCallback(CallbackTypes.CreateEntry(_config!), data.CurrentObject!);
} }
else { else {
await _manager!.EditItem(data!.CurrentObject!); await _manager!.EditItem(data!.CurrentObject!);
await Emitter.DispatchEvent(EventTypes.UpdateEntry(_config!), data.CurrentObject!); await Emitter.DispatchCallback(CallbackTypes.UpdateEntry(_config!), data.CurrentObject!);
} }
await Reload(); await Reload();
} }
private void SelectItem(object item, bool selected) { private void SelectItem(object item, bool selected) {
var eventResult = PluginOrchestrator.DispatchEvent(new SelectEntryEvent(this) {
Entity = item,
Selected = selected,
Table = _config!
}, _tokenSource.Token).Result;
if (eventResult.IsCanceled) return;
selected = eventResult.Selected;
if (!selected) if (!selected)
DialogData!.SelectedObjects.Remove(item); DialogData!.SelectedObjects.Remove(item);
else DialogData!.SelectedObjects.Add(item); else DialogData!.SelectedObjects.Add(item);
} }
private void SelectAll() { private void SelectAll() {
var selected = _currentlyDisplayedModels.All(DialogData!.SelectedObjects.Contains); var selected = CurrentlyDisplayedModels.All(DialogData!.SelectedObjects.Contains);
foreach (var displayedModel in _currentlyDisplayedModels) { foreach (var displayedModel in CurrentlyDisplayedModels) {
SelectItem(displayedModel, !selected); SelectItem(displayedModel, !selected);
} }
_allSelected = selected; _allSelected = selected;

View File

@@ -1,6 +1,10 @@
using HopFrame.Core.Config; using System.Reflection;
using HopFrame.Core.Config;
using HopFrame.Web.Components.Layout; using HopFrame.Web.Components.Layout;
using HopFrame.Web.Models; using HopFrame.Web.Models;
using HopFrame.Web.Plugins;
using HopFrame.Web.Plugins.Annotations;
using HopFrame.Web.Plugins.Internal;
namespace HopFrame.Web; namespace HopFrame.Web;
@@ -29,4 +33,22 @@ public static class HopFrameConfiguratorExtensions {
return configurator; return configurator;
} }
public static HopFrameConfigurator AddPlugin<TPlugin>(this HopFrameConfigurator configurator) where TPlugin : HopFramePlugin {
PluginOrchestrator.RegisterPlugin(configurator.ServiceCollection, typeof(TPlugin));
var methods = typeof(TPlugin).GetMethods()
.Where(method => method.IsStatic)
.Where(method => method.GetCustomAttributes(true)
.Any(attr => attr is PluginConfiguratorAttribute))
.Where(method => method.GetParameters().Length < 2);
foreach (var method in methods) {
if (method.GetParameters().Length > 0)
method.Invoke(null, [configurator]);
else method.Invoke(null, []);
}
return configurator;
}
} }

View File

@@ -0,0 +1,4 @@
namespace HopFrame.Web.Plugins.Annotations;
[AttributeUsage(AttributeTargets.Method)]
public class EventHandlerAttribute : Attribute;

View File

@@ -0,0 +1,8 @@
namespace HopFrame.Web.Plugins.Annotations;
/// <summary>
/// Configures the method as a plugin configurator, so the method gets called, when the plugin is registered.
/// Only works on static methods
/// </summary>
[AttributeUsage(AttributeTargets.Method)]
public class PluginConfiguratorAttribute : Attribute;

View File

@@ -0,0 +1,18 @@
using HopFrame.Web.Components.Pages;
namespace HopFrame.Web.Plugins.Events;
public sealed class DeleteEntryEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
public required object Entity { get; init; }
}
public sealed class CreateEntryEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender);
public sealed class UpdateEntryEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
public required object Entity { get; init; }
}
public sealed class SelectEntryEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
public required object Entity { get; init; }
public required bool Selected { get; set; }
}

View File

@@ -0,0 +1,27 @@
using HopFrame.Core.Config;
using HopFrame.Web.Components.Dialogs;
using HopFrame.Web.Components.Pages;
namespace HopFrame.Web.Plugins.Events;
public abstract class HopFrameEventArgs(object internalSender) {
internal object InternalSender { get; } = internalSender;
public bool IsCanceled { get; protected set; }
public void SetCancelled(bool canceled) => IsCanceled = canceled;
}
public abstract class HopFrameEventArgs<TSender>(TSender sender) : HopFrameEventArgs(sender) where TSender : class {
public TSender Sender => (TSender)InternalSender;
}
public abstract class HopFrameTablePageEventArgs(HopFrameTablePage sender)
: HopFrameEventArgs<HopFrameTablePage>(sender) {
public required TableConfig Table { get; init; }
}
public abstract class HopFrameEditorEventArgs(HopFrameEditor sender)
: HopFrameEventArgs<HopFrameEditor>(sender) {
public required TableConfig Table { get; init; }
}

View File

@@ -0,0 +1,9 @@
using HopFrame.Web.Components.Pages;
namespace HopFrame.Web.Plugins.Events;
public sealed class PageChangeEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
public required int CurrentPage { get; init; }
public required int TotalPages { get; init; }
public required int NewPage { get; set; }
}

View File

@@ -0,0 +1,9 @@
using System.Reflection;
namespace HopFrame.Web.Plugins.Events;
internal sealed class PluginEventContainer {
public required MethodInfo Handler { get; init; }
public required Type EventType { get; init; }
public required bool IsAwaitable { get; init; }
}

View File

@@ -0,0 +1,7 @@
using HopFrame.Web.Components.Pages;
namespace HopFrame.Web.Plugins.Events;
public sealed class ReloadEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
}

View File

@@ -0,0 +1,7 @@
using HopFrame.Web.Components.Pages;
namespace HopFrame.Web.Plugins.Events;
public sealed class SearchEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
public required string SearchTerm { get; set; }
}

View File

@@ -0,0 +1,101 @@
using HopFrame.Core.Config;
using HopFrame.Web.Components.Pages;
using Microsoft.FluentUI.AspNetCore.Components;
namespace HopFrame.Web.Plugins.Events;
public class TableInitializedEvent(HopFrameTablePage sender) : HopFrameTablePageEventArgs(sender) {
public List<PluginButton> PluginButtons { get; } = new();
public DefaultButtonToggles DefaultButtons { get; set; } = new();
public void AddPageButton(string title, Func<Task> callback, bool pushRight = false, IconInfo? icon = null) {
PluginButtons.Add(new() {
Title = title,
Icon = icon,
Position = pushRight ? PluginButtonPosition.TopRight : PluginButtonPosition.TopLeft,
Handler = (_, _) => callback.Invoke()
});
}
public void AddPageButton(string title, Action callback, bool pushRight = false, IconInfo? icon = null) {
AddPageButton(title, () => {
callback.Invoke();
return Task.CompletedTask;
}, pushRight, icon);
}
public void AddEntityButton(IconInfo icon, Func<object, TableConfig, Task> callback) {
PluginButtons.Add(new() {
Icon = icon,
Position = PluginButtonPosition.OnEntry,
Handler = callback
});
}
public void AddEntityButton(IconInfo icon, Action<object, TableConfig> callback) {
AddEntityButton(icon, (obj, cfg) => {
callback.Invoke(obj, cfg);
return Task.CompletedTask;
});
}
public void AddEntityButton<TEntity>(IconInfo icon, Func<TEntity, TableConfig, Task> callback) {
PluginButtons.Add(new() {
Icon = icon,
Position = PluginButtonPosition.OnEntry,
Handler = (obj, cfg) => callback.Invoke((TEntity)obj, cfg),
TableFilter = typeof(TEntity)
});
}
public void AddEntityButton<TEntity>(IconInfo icon, Action<TEntity, TableConfig> callback) {
AddEntityButton<TEntity>(icon, (obj, cfg) => {
callback.Invoke(obj, cfg);
return Task.CompletedTask;
});
}
public void AddPageButton<TEntity>(string title, Func<Task> callback, bool pushRight = false, IconInfo? icon = null) {
PluginButtons.Add(new() {
Title = title,
Icon = icon,
Position = pushRight ? PluginButtonPosition.TopRight : PluginButtonPosition.TopLeft,
Handler = (_, _) => callback.Invoke(),
TableFilter = typeof(TEntity)
});
}
public void AddPageButton<TEntity>(string title, Action callback, bool pushRight = false, IconInfo? icon = null) {
AddPageButton<TEntity>(title, () => {
callback.Invoke();
return Task.CompletedTask;
}, pushRight, icon);
}
}
public struct PluginButton {
public PluginButtonPosition Position { get; set; }
public Func<object, TableConfig, Task> Handler { get; set; }
public string? Title { get; set; }
public IconInfo? Icon { get; set; }
public Type? TableFilter { get; set; }
internal bool IsForTable(TableConfig? config) {
if (config is null) return false;
if (TableFilter is null) return true;
return config.TableType == TableFilter;
}
}
public enum PluginButtonPosition {
TopLeft = 0,
TopRight = 1,
OnEntry = 2
}
public struct DefaultButtonToggles() {
public bool ShowRefreshButton { get; set; } = true;
public bool ShowAddEntityButton { get; set; } = true;
public bool ShowDeleteButton { get; set; } = true;
public bool ShowEditButton { get; set; } = true;
}

View File

@@ -0,0 +1,9 @@
using HopFrame.Core.Config;
using HopFrame.Web.Components.Dialogs;
namespace HopFrame.Web.Plugins.Events;
public sealed class ValidationEvent(HopFrameEditor sender) : HopFrameEditorEventArgs(sender) {
public required IList<string> Errors { get; init; }
public required PropertyConfig Property { get; init; }
}

View File

@@ -0,0 +1,3 @@
namespace HopFrame.Web.Plugins;
public abstract class HopFramePlugin;

View File

@@ -0,0 +1,7 @@
using HopFrame.Web.Plugins.Events;
namespace HopFrame.Web.Plugins;
public interface IPluginOrchestrator {
public Task<TEvent> DispatchEvent<TEvent>(TEvent @event, CancellationToken ct = new()) where TEvent : HopFrameEventArgs;
}

View File

@@ -0,0 +1,57 @@
using HopFrame.Web.Plugins.Annotations;
using HopFrame.Web.Plugins.Events;
using Microsoft.Extensions.DependencyInjection;
namespace HopFrame.Web.Plugins.Internal;
internal sealed class PluginOrchestrator(IServiceProvider services) : IPluginOrchestrator {
public static void RegisterPlugin(IServiceCollection collection, Type plugin) {
var methods = plugin.GetMethods()
.Where(method => method.GetCustomAttributes(true)
.Any(attr => attr is EventHandlerAttribute));
foreach (var method in methods) {
var awaitable = method.ReturnType.IsAssignableFrom(typeof(Task));
var eventType = method
.GetParameters()
.FirstOrDefault(param => param.ParameterType.IsAssignableTo(typeof(HopFrameEventArgs)))?.ParameterType;
if (eventType is null) continue;
var container = new PluginEventContainer {
EventType = eventType,
IsAwaitable = awaitable,
Handler = method
};
collection.AddSingleton(container);
collection.AddScoped(plugin);
}
}
public async Task<TEvent> DispatchEvent<TEvent>(TEvent @event, CancellationToken ct = new()) where TEvent : HopFrameEventArgs {
var eventContainers = services.GetRequiredService<IEnumerable<PluginEventContainer>>()
.Where(container => container.EventType == typeof(TEvent));
var eventType = typeof(TEvent);
var tokenType = typeof(CancellationToken);
foreach (var container in eventContainers) {
var plugin = services.GetRequiredService(container.Handler.DeclaringType!);
var parameters = new List<object?>();
foreach (var parameter in container.Handler.GetParameters()) {
if (parameter.ParameterType == eventType)
parameters.Add(@event);
else if (parameter.ParameterType == tokenType)
parameters.Add(ct);
else parameters.Add(null);
}
var result = container.Handler.Invoke(plugin, parameters.ToArray());
if (container.IsAwaitable)
await (Task)result!;
}
return @event;
}
}

View File

@@ -1,8 +1,10 @@
using HopFrame.Core; using HopFrame.Core;
using HopFrame.Core.Config; using HopFrame.Core.Config;
using HopFrame.Core.Events; using HopFrame.Core.Callbacks;
using HopFrame.Web.Components; using HopFrame.Web.Components;
using HopFrame.Web.Components.Pages; using HopFrame.Web.Components.Pages;
using HopFrame.Web.Plugins;
using HopFrame.Web.Plugins.Internal;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.FluentUI.AspNetCore.Components; using Microsoft.FluentUI.AspNetCore.Components;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
@@ -21,7 +23,7 @@ public static class ServiceCollectionExtensions {
/// <returns>The same service collection that is passed in</returns> /// <returns>The same service collection that is passed in</returns>
public static IServiceCollection AddHopFrame(this IServiceCollection services, Action<HopFrameConfigurator> configurator, LibraryConfiguration? fluentUiLibraryConfiguration = null, bool addRazorComponents = true) { public static IServiceCollection AddHopFrame(this IServiceCollection services, Action<HopFrameConfigurator> configurator, LibraryConfiguration? fluentUiLibraryConfiguration = null, bool addRazorComponents = true) {
var config = new HopFrameConfig(); var config = new HopFrameConfig();
configurator.Invoke(new HopFrameConfigurator(config)); configurator.Invoke(new HopFrameConfigurator(config, services));
return AddHopFrame(services, config, fluentUiLibraryConfiguration, addRazorComponents); return AddHopFrame(services, config, fluentUiLibraryConfiguration, addRazorComponents);
} }
@@ -38,6 +40,8 @@ public static class ServiceCollectionExtensions {
services.AddHopFrameServices(); services.AddHopFrameServices();
services.AddFluentUIComponents(fluentUiLibraryConfiguration); services.AddFluentUIComponents(fluentUiLibraryConfiguration);
services.AddScoped<IPluginOrchestrator, PluginOrchestrator>();
if (addRazorComponents) { if (addRazorComponents) {
services.AddRazorComponents() services.AddRazorComponents()
.AddInteractiveServerComponents(); .AddInteractiveServerComponents();