+
}
-else if (workflowDefinition != null)
+else
{
-
-
+
-
-}
-else if(!string.IsNullOrWhiteSpace(ns))
-{
-
+
+ @if (problemDetails != null)
+ {
+
+ @problemDetails.Detail
+
+ @if (problemDetails.Errors != null && problemDetails.Errors.Any())
+ {
+ foreach (KeyValuePair
errorContainer in problemDetails.Errors)
+ {
+
+
+ @foreach (string error in errorContainer.Value)
+ {
+ - @error
+ }
+
+
+ }
+ }
+ }
+
+
}
@code {
- StandaloneCodeEditor? textBasedEditor;
- string textEditorValue = string.Empty;
string? ns;
string? name;
- Workflow? workflow;
- WorkflowDefinition? workflowDefinition;
- bool initialized;
bool loading;
bool saving;
- StandaloneCodeEditor? TextBasedEditor
- {
- get => this.textBasedEditor;
- set => this.Store.SetTextEditor(value);
- }
+ private ProblemDetails? problemDetails = null;
[Parameter] public string? Namespace { get; set; }
[Parameter] public string? Name { get; set; }
+ ///
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
- this.Store.Loading.Subscribe(value => this.OnStateChanged(_ => loading = value), token: this.CancellationTokenSource.Token);
- this.Store.Saving.Subscribe(value => this.OnStateChanged(_ => saving = value), token: this.CancellationTokenSource.Token);
- this.Store.WorkflowDefinition.Subscribe(value => this.OnStateChanged(_ => workflowDefinition = value), token: this.CancellationTokenSource.Token);
+ BreadcrumbManager.Use(Breadcrumbs.Workflows);
+ BreadcrumbManager.Add(new($"New", $"/workflows/new"));
+ Store.Namespace.Subscribe(value => OnStateChanged(_ => ns = value), token: CancellationTokenSource.Token);
+ Store.Name.Subscribe(value => OnStateChanged(_ => name = value), token: CancellationTokenSource.Token);
+ Store.Loading.Subscribe(value => OnStateChanged(_ => loading = value), token: CancellationTokenSource.Token);
+ Store.Saving.Subscribe(value => OnStateChanged(_ => saving = value), token: CancellationTokenSource.Token);
+ Store.ProblemDetails.Subscribe(problemDetails => OnStateChanged(cmp => cmp.problemDetails = problemDetails), token: CancellationTokenSource.Token);
}
- protected override async Task OnParametersSetAsync()
+ ///
+ protected override void OnParametersSet()
{
- var updated = false;
if (Namespace != ns)
{
- ns = Namespace;
- updated = true;
+ Store.SetNamespace(Namespace);
}
if (Name != name)
{
- name = Name;
- updated = true;
- }
- if (updated || !initialized)
- {
- if (string.IsNullOrWhiteSpace(ns) || string.IsNullOrWhiteSpace(name)) await this.Store.CreateWorkflowDefinitionAsync();
- else await this.Store.CreateWorkflowDefinitionAsync(ns, name);
- BreadcrumbManager.Use(Breadcrumbs.Workflows);
- BreadcrumbManager.Add(new($"New", $"/workflows/new"));
- initialized = true;
- StateHasChanged();
+ Store.SetName(Name);
}
}
diff --git a/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/State.cs b/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/State.cs
index ae23e691a..e878de587 100644
--- a/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/State.cs
+++ b/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/State.cs
@@ -28,12 +28,12 @@ public record WorkflowDetailsState
public Workflow? Workflow { get; set; }
///
- /// The displayed 's name
+ /// Gets/sets the displayed 's name
///
public string? WorkflowDefinitionName { get; set; }
///
- /// The displayed 's version
+ /// Gets/sets the displayed 's version
///
public string? WorkflowDefinitionVersion { get; set; }
@@ -45,6 +45,6 @@ public record WorkflowDetailsState
///
/// Gets/sets the parsed
///
- public string JsonWorkflowDefinition { get; set; } = string.Empty;
+ public string WorkflowDefinitionJson { get; set; } = string.Empty;
}
diff --git a/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/Store.cs b/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/Store.cs
index 53289442f..dc6e89157 100644
--- a/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/Store.cs
+++ b/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/Store.cs
@@ -22,7 +22,7 @@ namespace Synapse.Dashboard.Pages.Workflows.Details;
///
///
The service used to interact with the Synapse API
///
The hub used to watch resource events
-///
The service used from JS interop
+///
The service used for JS interop
///
The service used ease Monaco Editor interactions
///
The service used to serialize and deserialize JSON
///
The service used to serialize and deserialize YAML
@@ -38,6 +38,7 @@ IYamlSerializer yamlSerializer
{
private TextModel? _textModel = null;
+ private bool _disposed;
///
/// The provider function
@@ -96,9 +97,9 @@ IYamlSerializer yamlSerializer
public IObservable?> Workflows => this.Select(state => state.Workflows).DistinctUntilChanged();
///
- /// Gets an used to observe changes
+ /// Gets an used to observe changes
///
- public IObservable Document => this.Select(state => state.JsonWorkflowDefinition).DistinctUntilChanged();
+ public IObservable Document => this.Select(state => state.WorkflowDefinitionJson).DistinctUntilChanged();
#endregion
#region Setters
@@ -113,8 +114,8 @@ public void SetWorkflowDefinitionName(string? workflowDefinitionName)
Workflow = null,
WorkflowDefinitionName = workflowDefinitionName
});
- var ns = this.Get(state => state.Namespace);
}
+
///
/// Sets the state's
///
@@ -210,7 +211,7 @@ public async Task SetTextBasedEditorLanguageAsync()
///
async Task SetTextEditorValueAsync()
{
- var document = this.Get(state => state.JsonWorkflowDefinition);
+ var document = this.Get(state => state.WorkflowDefinitionJson);
var language = monacoEditorHelper.PreferredLanguage;
if (this.TextEditor != null && !string.IsNullOrWhiteSpace(document))
{
@@ -240,7 +241,7 @@ public override async Task InitializeAsync()
var document = jsonSerializer.SerializeToText(definition);
this.Reduce(state => state with
{
- JsonWorkflowDefinition = document
+ WorkflowDefinitionJson = document
});
await this.SetTextEditorValueAsync();
if (monacoEditorHelper.PreferredLanguage != PreferredLanguage.YAML)
@@ -266,14 +267,13 @@ public override async Task InitializeAsync()
await base.InitializeAsync();
}
- private bool disposed;
///
/// Disposes of the store
///
/// A boolean indicating whether or not the dispose of the store
protected override void Dispose(bool disposing)
{
- if (!this.disposed)
+ if (!this._disposed)
{
if (disposing)
{
@@ -288,7 +288,7 @@ protected override void Dispose(bool disposing)
this.TextEditor = null;
}
}
- this.disposed = true;
+ this._disposed = true;
}
}
}
diff --git a/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/View.razor b/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/View.razor
index 8e1c147fa..a5b9606a6 100644
--- a/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/View.razor
+++ b/src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/View.razor
@@ -14,16 +14,12 @@
limitations under the License.
*@
-@page "/workflows/{namespace}/{name}/latest"
-@page "/workflows/{namespace}/{name}/{version}"
+@page "/workflows/details/{namespace}/{name}/latest"
+@page "/workflows/details/{namespace}/{name}/{version}"
@using ServerlessWorkflow.Sdk.Models
@using Synapse.Api.Client.Services
@inherits NamespacedResourceManagementComponent
-@inject ISynapseApiClient Api
@inject IBreadcrumbManager BreadcrumbManager
-@inject IJSRuntime JSRuntime
-@inject IMonacoEditorHelper MonacoEditorHelper
-@inject IYamlSerializer YamlSerializer
Workflow @($"{name}.{ns}:{version}")
@@ -33,7 +29,6 @@
@@ -66,11 +61,16 @@
}
else
{
-
-
+
+
}
@@ -86,10 +86,10 @@
WorkflowDefinition workflowDefinition = null!;
readonly IEnumerable
columns = [
"Name",
- "Namespace",
- "Status",
- "Started At",
- "Ended At"
+ "Namespace",
+ "Status",
+ "Started At",
+ "Ended At"
];
[Parameter] public new string? Namespace { get; set; }
@@ -100,50 +100,63 @@
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync().ConfigureAwait(false);
- this.Store.Namespace.Where(newNamespace => !string.IsNullOrWhiteSpace(newNamespace)).Subscribe(newNamespace => this.OnStateChanged(cmp => cmp.ns = newNamespace!), token: this.CancellationTokenSource.Token);
- this.Store.WorkflowDefinitionName.Where(newName => !string.IsNullOrWhiteSpace(newName)).Subscribe(newName => this.OnStateChanged(cmp => cmp.name = newName!), token: this.CancellationTokenSource.Token);
- this.Store.WorkflowDefinitionVersion.Where(newVersion => !string.IsNullOrWhiteSpace(newVersion)).Subscribe(newVersion => this.OnStateChanged(cmp => cmp.version = newVersion!), token: this.CancellationTokenSource.Token);
- this.Store.Workflow.Where(newWorkflow => newWorkflow != null).Subscribe(newWorkflow => this.OnStateChanged(cmp => cmp.workflow = newWorkflow!), token: this.CancellationTokenSource.Token);
- this.Store.WorkflowDefinition.Where(newWorkflowDefinition => newWorkflowDefinition != null).Subscribe(newWorkflowDefinition =>
+ UpdateBreadcrumb();
+ Store.Namespace.Where(value => !string.IsNullOrWhiteSpace(value)).Subscribe(value => OnStateChanged(_ => ns = value!), token: CancellationTokenSource.Token);
+ Store.WorkflowDefinitionName.Where(value => !string.IsNullOrWhiteSpace(value)).Subscribe(value => OnStateChanged(_ => name = value!), token: CancellationTokenSource.Token);
+ Store.WorkflowDefinitionVersion.Where(value => !string.IsNullOrWhiteSpace(value)).Subscribe(value => OnStateChanged(_ => version = value!), token: CancellationTokenSource.Token);
+ Store.WorkflowDefinition.Where(value => value != null).Subscribe(value => OnStateChanged(_ => workflowDefinition = value!), token: CancellationTokenSource.Token);
+ Store.Workflow.Where(value => value != null).Subscribe(value =>
{
- this.OnStateChanged(cmp => cmp.workflowDefinition = newWorkflowDefinition!);
- BreadcrumbManager.Use(Breadcrumbs.Workflows);
- BreadcrumbManager.Add(new($"{newWorkflowDefinition!.Document.Name}.{newWorkflowDefinition!.Document.Namespace}", $"/workflows/{newWorkflowDefinition!.Document.Namespace}/{newWorkflowDefinition!.Document.Name}/latest"));
-
- }, token: this.CancellationTokenSource.Token);
+ OnStateChanged(_ => workflow = value!);
+ UpdateBreadcrumb();
+ }, token: CancellationTokenSource.Token);
}
+ ///
protected override void OnParametersSet()
{
- if (this.Namespace != this.ns)
+ if (Namespace != ns)
+ {
+ Store.SetNamespace(Namespace);
+ }
+ if (Name != name)
{
- this.Store.SetNamespace(this.Namespace);
+ Store.SetWorkflowDefinitionName(Name);
}
- if (this.Name != this.name)
+ if (Version != version)
{
- this.Store.SetWorkflowDefinitionName(this.Name);
+ Store.SetWorkflowDefinitionVersion(Version);
}
- if (this.Version != this.version)
+ }
+
+ ///
+ /// Updates the breadcrumb
+ ///
+ protected void UpdateBreadcrumb()
+ {
+ BreadcrumbManager.Use(Breadcrumbs.Workflows);
+ BreadcrumbManager.Add(new($"{Name}.{Namespace}", $"/workflows/{Namespace}/{Name}/latest"));
+ if (workflow != null)
{
- this.Store.SetWorkflowDefinitionVersion(this.Version);
+ BreadcrumbManager.Add(new(VersionSelector()));
}
}
- RenderFragment Title() => __builder =>
+ ///
+ /// Renders the workflows instances table's title
+ ///
+ ///
+ protected RenderFragment VersionSelector() => __builder =>
{
-
-
- /
-
+ }
+
};
}
diff --git a/src/dashboard/Synapse.Dashboard/Pages/Workflows/List/View.razor b/src/dashboard/Synapse.Dashboard/Pages/Workflows/List/View.razor
index c4cef5f1a..884799bd4 100644
--- a/src/dashboard/Synapse.Dashboard/Pages/Workflows/List/View.razor
+++ b/src/dashboard/Synapse.Dashboard/Pages/Workflows/List/View.razor
@@ -124,10 +124,13 @@
else throw new NotSupportedException("The specified schedule type is not supported");
}
- void OnViewWorkflow(Workflow workflow) => this.NavigationManager.NavigateTo($"workflows/{workflow.GetNamespace()}/{workflow.GetName()}/{workflow.Spec.Versions.GetLatest().Document.Version}");
+ void OnViewWorkflow(Workflow workflow) => this.NavigationManager.NavigateTo($"workflows/details/{workflow.GetNamespace()}/{workflow.GetName()}/{workflow.Spec.Versions.GetLatest().Document.Version}");
void OnCreateNewWorkflow() => this.NavigationManager.NavigateTo("/workflows/new");
- void OnCreateNewWorkflowVersion(string ns, string name) => this.NavigationManager.NavigateTo($"/workflows/{ns}/{name}/new");
+ void OnCreateNewWorkflowVersion(string ns, string name) => this.NavigationManager.NavigateTo($"/workflows/new/{ns}/{name}");
+
+ //void OnNavigateToVersion(string ns, string name, string version) => NavigationManager.NavigateTo($"/workflows/details/{ns}/{name}/{version}");
+
}
\ No newline at end of file