Skip to content

Commit

Permalink
fix(Dashboard): applied label selectors when receiving resource events
Browse files Browse the repository at this point in the history
improved workflow instance details view

Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
  • Loading branch information
JBBianchi committed Jul 3, 2024
1 parent a1e40ba commit 4d8d096
Show file tree
Hide file tree
Showing 11 changed files with 134 additions and 272 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,30 @@ public virtual async Task ListResourcesAsync(ResourcesFilter? filter = null)
/// <returns>A new awaitable <see cref="Task"/></returns>
protected virtual Task OnResourceWatchEventAsync(IResourceWatchEvent<TResource> e)
{
var labelSelectors = this.Get(state => state.LabelSelectors);
if (labelSelectors != null && labelSelectors.Count > 0 && !labelSelectors.All(selector => {
if (e.Resource?.Metadata?.Labels == null || e.Resource.Metadata.Labels.Count == 0 || !e.Resource.Metadata.Labels.ContainsKey(selector.Key))
{
return false;
}
var label = e.Resource.Metadata.Labels[selector.Key];
switch (selector.Operator)
{
case LabelSelectionOperator.Equals:
return !string.IsNullOrWhiteSpace(selector.Value) && selector.Value.Equals(label);
case LabelSelectionOperator.NotEquals:
return !string.IsNullOrWhiteSpace(selector.Value) && !selector.Value.Equals(label);
case LabelSelectionOperator.Contains:
return selector.Values != null && selector.Values.Contains(label);
case LabelSelectionOperator.NotContains:
return selector.Values != null && !selector.Values.Contains(label);
default:
return false;
}
}))
{
return Task.CompletedTask;
}
switch (e.Type)
{
case ResourceWatchEventType.Created:
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
@if (WorkflowInstances != null && WorkflowInstances.Any())
{
<Virtualize Context="instance" Items="@WorkflowInstances.ToList()">
<tr @onclick="async _ => await OnShowClickedAsync(instance)" class="cursor-pointer">
<tr @onclick="async _ => await OnShowClickedAsync(instance)" class="cursor-pointer @(ActiveRow == instance.GetName() ? "table-active" : "")">
@foreach (var column in columns)
{
if (Columns.Count() == 0 || Columns.Contains(column))
Expand Down Expand Up @@ -133,6 +133,7 @@
[Parameter] public IEnumerable<WorkflowInstance>? WorkflowInstances { get; set; }
[Parameter] public IEnumerable<Workflow>? Workflows { get; set; }
[Parameter] public IEnumerable<Namespace>? Namespaces { get; set; }
[Parameter] public string? ActiveRow { get; set; }

[Parameter] public EventCallback<ChangeEventArgs> OnWorkflowChanged { get; set; }
[Parameter] public EventCallback<ChangeEventArgs> OnNamespaceChanged { get; set; }
Expand Down
10 changes: 5 additions & 5 deletions src/dashboard/Synapse.Dashboard/Pages/Workflows/Details/Store.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ IYamlSerializer yamlSerializer
}
return null;
}
return workflow.Spec.Versions.Get(version);
return workflow.Spec.Versions.Get(version)?.Clone();
}
);
).DistinctUntilChanged();

/// <summary>
/// Gets an <see cref="IObservable{T}"/> used to observe <see cref="WorkflowDetailsState.WorkflowDefinitionVersion"/> changes
Expand All @@ -137,9 +137,9 @@ IYamlSerializer yamlSerializer
{
return null;
}
return instances.FirstOrDefault(instance => instance.Metadata.Name == name);
return instances.FirstOrDefault(instance => instance.Metadata.Name == name)?.Clone();
}
);
).DistinctUntilChanged();
#endregion

#region Setters
Expand Down Expand Up @@ -290,7 +290,7 @@ public override async Task InitializeAsync()
this.WorkflowDefinition.Where(definition => definition != null).SubscribeAsync(async (definition) =>
{
await Task.Delay(1);
var document = this.JsonSerializer.SerializeToText(definition);
var document = this.JsonSerializer.SerializeToText(definition.Clone());
this.Reduce(state => state with
{
WorkflowDefinitionJson = document
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,11 @@
<Label>Instances</Label>
<Content>
<WorkflowInstancesList Loading="Loading"
WorkflowInstances="Resources"
OnSearchInput="OnSearchInput"
Columns="columns"
OnShowDetails="OnShowInstanceDetails"
WorkflowInstances="Resources"
ActiveRow="@instanceName"
Columns="columns"
OnSearchInput="OnSearchInput"
OnShowDetails="OnShowInstanceDetails"
></WorkflowInstancesList>
<Button Outline="true" Color="ButtonColor.Primary" @onclick="_ => OnCreateInstance()" class="w-100">
<Icon Name="IconName.Plus"/>
Expand Down Expand Up @@ -69,7 +70,7 @@
<div class="d-flex flex-column h-100 mh-100">
<div class="d-flex justify-content-between mb-2">
<Button Outline="true" Color="ButtonColor.Primary" Size="Size.Small" @onclick="_ => OnCreateWorkflowVersion()">
<Icon Name="IconName.Plus" /><!-- todo: IconName.Copy not working ? -->
<Icon Name="IconName.Copy" />
</Button>
<PreferredLanguageSelector PreferedLanguageChange="Store.ToggleTextBasedEditorLanguageAsync" />
</div>
Expand Down
3 changes: 3 additions & 0 deletions src/dashboard/Synapse.Dashboard/Synapse.Dashboard.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@

<ItemGroup>
<Content Remove="wwwroot\css\horizontal-collapse.scss" />
<Content Remove="wwwroot\css\workflow-instance-details.scss" />
</ItemGroup>

<ItemGroup>
<_ContentIncludedByDefault Remove="wwwroot\css\horizontal-collapse.scss" />
<_ContentIncludedByDefault Remove="wwwroot\css\workflow-instance-details.scss" />
</ItemGroup>

<ItemGroup>
<None Include="Components\WorkflowInstanceDetails\CorrelationContextRow.razor" />
<None Include="Components\WorkflowInstanceDetails\TaskInstanceRow.razor" />
<None Include="wwwroot\css\horizontal-collapse.scss" />
<None Include="wwwroot\css\workflow-instance-details.scss" />
</ItemGroup>

<ItemGroup>
Expand Down
16 changes: 11 additions & 5 deletions src/dashboard/Synapse.Dashboard/wwwroot/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -20758,11 +20758,10 @@ textarea.form-control-lg {
background-color: var(--bs-body-bg) !important;
}

tr {
height: 61px;
max-height: 61px;
}

/*tr {
height: 61px;
max-height: 61px;
}*/
td {
vertical-align: middle;
}
Expand Down Expand Up @@ -20889,6 +20888,13 @@ tr.row-placeholder td::after {
margin-top: auto;
}

.workflow-instance-details h6, .workflow-instance-details .h6 {
font-weight: bold;
}
.workflow-instance-details .label {
font-weight: lighter;
}

html, body {
font-family: "Inconsolata", monospace;
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion src/dashboard/Synapse.Dashboard/wwwroot/css/app.min.css

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/dashboard/Synapse.Dashboard/wwwroot/css/app.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
@import "./text-editor.scss";
@import "./graph.scss";
@import "./horizontal-collapse.scss";
@import "./workflow-instance-details.scss";

html, body {
font-family: 'Inconsolata', monospace;
Expand Down
4 changes: 2 additions & 2 deletions src/dashboard/Synapse.Dashboard/wwwroot/css/table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
background-color: var(--bs-body-bg) !important;
}

tr {
/*tr {
height: 61px;
max-height: 61px;
}
}*/

td {
vertical-align: middle;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.workflow-instance-details {
h6 {
font-weight: bold;
}

.label {
font-weight: lighter;
}
}

0 comments on commit 4d8d096

Please sign in to comment.