diff --git a/src/dashboard/Synapse.Dashboard/Components/DocumentDetails/DocumentDetails.razor b/src/dashboard/Synapse.Dashboard/Components/DocumentDetails/DocumentDetails.razor index 5ed749c34..207451705 100644 --- a/src/dashboard/Synapse.Dashboard/Components/DocumentDetails/DocumentDetails.razor +++ b/src/dashboard/Synapse.Dashboard/Components/DocumentDetails/DocumentDetails.razor @@ -43,7 +43,12 @@ } else { -
+
+
+ +
The service used ease Monaco Editor interactions /// The service used to serialize and deserialize JSON /// The service used to serialize and deserialize YAML +/// The service used display toast messages public class DocumentDetailsStore( ILogger logger, ISynapseApiClient apiClient, IJSRuntime jsRuntime, IMonacoEditorHelper monacoEditorHelper, IJsonSerializer jsonSerializer, - IYamlSerializer yamlSerializer + IYamlSerializer yamlSerializer, + ToastService toastService ) : ComponentStore(new()) { @@ -69,6 +71,11 @@ IYamlSerializer yamlSerializer /// protected IYamlSerializer YamlSerializer { get; } = yamlSerializer; + /// + /// Gets the service used display toast messages + /// + protected ToastService ToastService { get; } = toastService; + /// /// The provider function /// @@ -352,6 +359,27 @@ async Task SetTextEditorValueAsync() } } } + + /// + /// Copies to content of the Monaco editor to the clipboard + /// + /// A awaitable task + public async Task OnCopyToClipboard() + { + if (this.TextEditor == null) return; + var text = await this.TextEditor.GetValue(); + if (string.IsNullOrWhiteSpace(text)) return; + try + { + await this.JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text); + this.ToastService.Notify(new(ToastType.Success, "Definition copied to the clipboard!")); + } + catch (Exception ex) + { + this.ToastService.Notify(new(ToastType.Danger, "Failed to copy the definition to the clipboard.")); + this.Logger.LogError("Unable to copy to clipboard: {exception}", ex.ToString()); + } + } #endregion /// diff --git a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditor.razor b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditor.razor index 25a2af9cf..1139cf937 100644 --- a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditor.razor +++ b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditor.razor @@ -18,7 +18,12 @@ @using Synapse.Dashboard.Components.MonacoEditorStateManagement @inherits StatefulComponent -
+
+
+ +
GetStanda ReadOnly = readOnly, Value = value, TabSize = 2, + FormatOnPaste = true, + FormatOnType = true, QuickSuggestions = new QuickSuggestionsOptions { Other = "true", - Strings = "true" + Strings = "true", + Comments = "fasle" } }; } diff --git a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs index 5dba75a3d..306c234cf 100644 --- a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs +++ b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs @@ -25,7 +25,8 @@ namespace Synapse.Dashboard.Components.MonacoEditorStateManagement; /// The service used ease Monaco Editor interactions /// The service used to serialize and deserialize JSON /// The service used to serialize and deserialize YAML -public class MonacoEditorStore(ILogger logger, ISynapseApiClient apiClient, IJSRuntime jsRuntime, IMonacoEditorHelper monacoEditorHelper, IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer) +/// The service used display toast messages +public class MonacoEditorStore(ILogger logger, ISynapseApiClient apiClient, IJSRuntime jsRuntime, IMonacoEditorHelper monacoEditorHelper, IJsonSerializer jsonSerializer, IYamlSerializer yamlSerializer, ToastService toastService) : ComponentStore(new()) { @@ -62,6 +63,11 @@ public class MonacoEditorStore(ILogger logger, ISynapseApiCli /// protected IYamlSerializer YamlSerializer { get; } = yamlSerializer; + /// + /// Gets the service used display toast messages + /// + protected ToastService ToastService { get; } = toastService; + /// /// The provider function /// @@ -271,6 +277,27 @@ async Task SetTextEditorValueAsync() await this.TextEditor.SetValue(document); } } + + /// + /// Copies to content of the Monaco editor to the clipboard + /// + /// A awaitable task + public async Task OnCopyToClipboard() + { + if (this.TextEditor == null) return; + var text = await this.TextEditor.GetValue(); + if (string.IsNullOrWhiteSpace(text)) return; + try + { + await this.JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text); + this.ToastService.Notify(new(ToastType.Success, "Definition copied to the clipboard!")); + } + catch (Exception ex) + { + this.ToastService.Notify(new(ToastType.Danger, "Failed to copy the definition to the clipboard.")); + this.Logger.LogError("Unable to copy to clipboard: {exception}", ex.ToString()); + } + } #endregion /// diff --git a/src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor b/src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor index 0d11be9d6..b2b5566c6 100644 --- a/src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor +++ b/src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor @@ -20,10 +20,16 @@ @inherits StatefulComponent, ResourceEditorStore, ResourceEditorState> @inject IMonacoEditorHelper MonacoEditorHelper @inject IJSRuntime JSRuntime +@inject ToastService ToastService
-
+
+
+ +
+ /// Copies to content of the Monaco editor to the clipboard + /// + /// A awaitable task + public async Task OnCopyToClipboard() + { + if (this.textBasedEditor == null) return; + var text = await this.textBasedEditor.GetValue(); + if (string.IsNullOrWhiteSpace(text)) return; + try + { + await this.JSRuntime.InvokeVoidAsync("navigator.clipboard.writeText", text); + this.ToastService.Notify(new(ToastType.Success, "Definition copied to the clipboard!")); + } + catch (Exception ex) + { + this.ToastService.Notify(new(ToastType.Danger, "Failed to copy the definition to the clipboard.")); + } + } + private bool disposed; /// /// Disposes of the component diff --git a/src/dashboard/Synapse.Dashboard/Pages/Functions/Create/View.razor b/src/dashboard/Synapse.Dashboard/Pages/Functions/Create/View.razor index 424d25ed8..04cae6189 100644 --- a/src/dashboard/Synapse.Dashboard/Pages/Functions/Create/View.razor +++ b/src/dashboard/Synapse.Dashboard/Pages/Functions/Create/View.razor @@ -91,7 +91,6 @@ else string? version; string? chosenName; string? nameInputValue; - string? namespaceSelectValue; bool loading; bool saving; ProblemDetails? problemDetails = null; diff --git a/src/dashboard/Synapse.Dashboard/Pages/Workflows/Create/State.cs b/src/dashboard/Synapse.Dashboard/Pages/Workflows/Create/State.cs index 5aa82de20..38aeae13b 100644 --- a/src/dashboard/Synapse.Dashboard/Pages/Workflows/Create/State.cs +++ b/src/dashboard/Synapse.Dashboard/Pages/Workflows/Create/State.cs @@ -44,7 +44,7 @@ public record CreateWorkflowViewState { Document = new() { - Dsl = "1.0.0-alpha3", + Dsl = "1.0.0-alpha5", Namespace = Neuroglia.Data.Infrastructure.ResourceOriented.Namespace.DefaultNamespaceName, Name = "new-workflow", Version = "0.1.0"