diff --git a/src/dashboard/Synapse.Dashboard/enum.cs b/src/dashboard/Synapse.Dashboard/CheckboxState.cs similarity index 100% rename from src/dashboard/Synapse.Dashboard/enum.cs rename to src/dashboard/Synapse.Dashboard/CheckboxState.cs diff --git a/src/dashboard/Synapse.Dashboard/Components/DocumentDetails/Store.cs b/src/dashboard/Synapse.Dashboard/Components/DocumentDetails/Store.cs index 7c851094d..d925c67d4 100644 --- a/src/dashboard/Synapse.Dashboard/Components/DocumentDetails/Store.cs +++ b/src/dashboard/Synapse.Dashboard/Components/DocumentDetails/Store.cs @@ -388,9 +388,23 @@ public override Task InitializeAsync() this.DocumentJson.SubscribeAsync(async (_) => { await this.SetTextEditorValueAsync(); }, cancellationToken: this.CancellationTokenSource.Token); + this.MonacoEditorHelper.PreferredThemeChanged += OnPreferedThemeChangedAsync; return base.InitializeAsync(); } + /// + /// Updates the editor theme + /// + /// + /// + protected async Task OnPreferedThemeChangedAsync(string newTheme) + { + if (this.TextEditor != null) + { + await this.TextEditor.UpdateOptions(new EditorUpdateOptions() { Theme = newTheme }); + } + } + private bool disposed; /// /// Disposes of the store @@ -412,6 +426,7 @@ protected override void Dispose(bool disposing) this.TextEditor.Dispose(); this.TextEditor = null; } + this.MonacoEditorHelper.PreferredThemeChanged -= OnPreferedThemeChangedAsync; } this.disposed = true; } diff --git a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/IMonacoEditorHelper.cs b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/IMonacoEditorHelper.cs index fbcd7d105..14fe02efa 100644 --- a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/IMonacoEditorHelper.cs +++ b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/IMonacoEditorHelper.cs @@ -19,6 +19,12 @@ namespace Synapse.Dashboard.Components; /// The new preferred language. /// A task representing the asynchronous operation of handling the event. public delegate Task PreferredLanguageChangedEventHandler(string newLanguage); +/// +/// Represents a delegate that is used to handle events related to changes in a user's preferred theme. +/// +/// The new preferred theme. +/// A task representing the asynchronous operation of handling the event. +public delegate Task PreferredThemeChangedEventHandler(string newTheme); /// /// Represents a service used to facilitate the Monaco editor configuration @@ -35,6 +41,11 @@ public interface IMonacoEditorHelper /// event PreferredLanguageChangedEventHandler? PreferredLanguageChanged; + /// + /// Emits when the editor theme changes + /// + event PreferredThemeChangedEventHandler? PreferredThemeChanged; + /// /// A function used to facilitate the construction of /// @@ -58,6 +69,13 @@ public interface IMonacoEditorHelper /// A task representing the asynchronous operation Task ChangePreferredLanguageAsync(string language); + /// + /// Changes the preferred editor theme + /// + /// The new theme to use + /// A task representing the asynchronous operation + Task ChangePreferredThemeAsync(string theme); + /// /// Returns the number of created and increases the count /// diff --git a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditorHelper.cs b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditorHelper.cs index a1d1bf337..ba6fa7903 100644 --- a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditorHelper.cs +++ b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/MonacoEditorHelper.cs @@ -18,18 +18,23 @@ public class MonacoEditorHelper : IMonacoEditorHelper { private int _modelCount = 0; + private string _preferredTheme = "vs-dark"; /// public string PreferredLanguage { get; protected set; } = "yaml"; + /// public event PreferredLanguageChangedEventHandler? PreferredLanguageChanged; + /// + public event PreferredThemeChangedEventHandler? PreferredThemeChanged; + /// public Func GetStandaloneEditorConstructionOptions(string value = "", bool readOnly = false, string language = "yaml") { return (StandaloneCodeEditor editor) => new StandaloneEditorConstructionOptions { - Theme = "vs-dark", + Theme = _preferredTheme, AutomaticLayout = true, Minimap = new EditorMinimapOptions { Enabled = false }, Language = language, @@ -63,18 +68,31 @@ public async Task ChangePreferredLanguageAsync(string language) if (!string.IsNullOrEmpty(language) && language != this.PreferredLanguage) { this.PreferredLanguage = language; - await this.OnPreferredLanguageChangeAsync(language); + if (this.PreferredLanguageChanged != null) + { + await this.PreferredLanguageChanged.Invoke(language); + } } } /// - protected async Task OnPreferredLanguageChangeAsync(string language) + public async Task ChangePreferredThemeAsync(string theme) { - if (this.PreferredLanguageChanged != null) + if (!string.IsNullOrEmpty(theme) && theme != this._preferredTheme) { - await this.PreferredLanguageChanged.Invoke(language); + if (theme == "dark") + { + theme = "vs-dark"; + } + else if (theme == "light") { + theme = "vs"; + } + this._preferredTheme = theme; + if (this.PreferredThemeChanged != null) + { + await this.PreferredThemeChanged.Invoke(theme); + } } - await Task.CompletedTask; } /// diff --git a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs index d9af967b3..ce436b721 100644 --- a/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs +++ b/src/dashboard/Synapse.Dashboard/Components/MonacoEditor/Store.cs @@ -310,9 +310,23 @@ public override Task InitializeAsync() { this.TextEditor?.UpdateOptions(new EditorUpdateOptions() { ReadOnly = isReadOnly }); }, token: this.CancellationTokenSource.Token); + this.MonacoEditorHelper.PreferredThemeChanged += OnPreferedThemeChangedAsync; return base.InitializeAsync(); } + /// + /// Updates the editor theme + /// + /// + /// + protected async Task OnPreferedThemeChangedAsync(string newTheme) + { + if (this.TextEditor != null) + { + await this.TextEditor.UpdateOptions(new EditorUpdateOptions() { Theme = newTheme }); + } + } + private bool disposed; /// /// Disposes of the store @@ -334,6 +348,7 @@ protected override void Dispose(bool disposing) this.TextEditor.Dispose(); this.TextEditor = null; } + this.MonacoEditorHelper.PreferredThemeChanged -= OnPreferedThemeChangedAsync; } this.disposed = true; } diff --git a/src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor b/src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor index f3106341f..0938c83b1 100644 --- a/src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor +++ b/src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor @@ -137,6 +137,7 @@ this.textEditorValue = textEditorValue; await this.SetTextEditorValueAsync(); }, cancellationToken: this.CancellationTokenSource.Token); + this.MonacoEditorHelper.PreferredThemeChanged += OnPreferedThemeChangedAsync; } /// @@ -155,6 +156,19 @@ return base.OnParametersSetAsync(); } + /// + /// Updates the editor theme + /// + /// + /// + protected async Task OnPreferedThemeChangedAsync(string newTheme) + { + if (this.textBasedEditor != null) + { + await this.textBasedEditor.UpdateOptions(new EditorUpdateOptions() { Theme = newTheme }); + } + } + /// /// Sets the editor as read-only when saving /// @@ -287,6 +301,7 @@ this.textBasedEditor.Dispose(); this.textBasedEditor = null; } + this.MonacoEditorHelper.PreferredThemeChanged -= OnPreferedThemeChangedAsync; } this.disposed = true; } diff --git a/src/dashboard/Synapse.Dashboard/Components/TaskInstanceDetails/TaskInstanceDetails.razor b/src/dashboard/Synapse.Dashboard/Components/TaskInstanceDetails/TaskInstanceDetails.razor index a257d0d51..f09b60421 100644 --- a/src/dashboard/Synapse.Dashboard/Components/TaskInstanceDetails/TaskInstanceDetails.razor +++ b/src/dashboard/Synapse.Dashboard/Components/TaskInstanceDetails/TaskInstanceDetails.razor @@ -31,7 +31,7 @@
Status
- @(TaskInstance.Status ?? TaskInstanceStatus.Pending) + @(TaskInstance.Status ?? TaskInstanceStatus.Pending) @if (!string.IsNullOrWhiteSpace(TaskInstance.StatusReason)) {
@TaskInstance.StatusReason
@@ -120,7 +120,7 @@ @run.StartedAt.RelativeFormat() @(run.EndedAt?.RelativeFormat() ?? "-") @(run.EndedAt.HasValue ? run.EndedAt.Value.Subtract(run.StartedAt).ToString("hh\\:mm\\:ss\\.fff") : "-") - @(run.Outcome ?? TaskInstanceStatus.Pending) + @(run.Outcome ?? TaskInstanceStatus.Pending) } diff --git a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/CorrelationContextRow.razor b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/CorrelationContextRow.razor index e7e8a44a9..34b0fb0bb 100644 --- a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/CorrelationContextRow.razor +++ b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/CorrelationContextRow.razor @@ -18,7 +18,7 @@ @Kvp.Key - @(Kvp.Value?.Status ?? CorrelationContextStatus.Inactive) + @(Kvp.Value?.Status ?? CorrelationContextStatus.Inactive) @if (isOpen) diff --git a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/TaskInstanceRow.razor b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/TaskInstanceRow.razor index f4d873ddd..8e0ba8283 100644 --- a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/TaskInstanceRow.razor +++ b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/TaskInstanceRow.razor @@ -19,7 +19,7 @@ @if (TaskInstance != null) { @TaskInstance.Reference - @(TaskInstance.Status ?? TaskInstanceStatus.Pending) + @(TaskInstance.Status ?? TaskInstanceStatus.Pending) @(TaskInstance.StartedAt?.RelativeFormat() ?? "-") @(TaskInstance.EndedAt?.RelativeFormat() ?? "-") diff --git a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor index b9934bc18..32cfaf204 100644 --- a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor +++ b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor @@ -31,7 +31,7 @@
Status
- @(workflowInstance.Status?.Phase ?? WorkflowInstanceStatusPhase.Pending) + @(workflowInstance.Status?.Phase ?? WorkflowInstanceStatusPhase.Pending)
diff --git a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.css b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.css deleted file mode 100644 index 19f8c789b..000000000 --- a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.css +++ /dev/null @@ -1,3 +0,0 @@ -.workflow-instance-details .label { - font-weight: 600; -} diff --git a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.min.css b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.min.css deleted file mode 100644 index 3ca3fce6d..000000000 --- a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.min.css +++ /dev/null @@ -1 +0,0 @@ -.workflow-instance-details .label{font-weight:600;} \ No newline at end of file diff --git a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.scss b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.scss deleted file mode 100644 index eca52e91c..000000000 --- a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceDetails/WorkflowInstanceDetails.razor.scss +++ /dev/null @@ -1,5 +0,0 @@ -.workflow-instance-details { - .label { - font-weight: 600; - } -} diff --git a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceLogs/WorkflowInstanceLogs.razor b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceLogs/WorkflowInstanceLogs.razor index bed6a85ce..638105629 100644 --- a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceLogs/WorkflowInstanceLogs.razor +++ b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstanceLogs/WorkflowInstanceLogs.razor @@ -20,7 +20,7 @@ @inherits StatefulComponent
- Logs + Logs
diff --git a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstancesList/WorkflowInstancesList.razor b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstancesList/WorkflowInstancesList.razor index 13597314d..885ce59f8 100644 --- a/src/dashboard/Synapse.Dashboard/Components/WorkflowInstancesList/WorkflowInstancesList.razor +++ b/src/dashboard/Synapse.Dashboard/Components/WorkflowInstancesList/WorkflowInstancesList.razor @@ -56,7 +56,7 @@ }