Skip to content

Commit a27e584

Browse files
committed
fix(Dashboard): ensure resource editor reflects latest resource state
Closes #523 Signed-off-by: Jean-Baptiste Bianchi <[email protected]>
1 parent 4787c0b commit a27e584

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/dashboard/Synapse.Dashboard/Components/ResourceEditor/ResourceEditor.razor

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,9 @@
125125
protected override async Task OnInitializedAsync()
126126
{
127127
await base.OnInitializedAsync().ConfigureAwait(false);
128+
this.Store.IsSaving.Subscribe(saving => this.OnStateChanged(cmp => this.OnSavingChanged(saving)), token: this.CancellationTokenSource.Token);
128129
this.Store.Resource.Subscribe(resource => this.OnStateChanged(cmp => cmp.resource = resource), token: this.CancellationTokenSource.Token);
129130
this.Store.IsUpdating.Subscribe(updating => this.OnStateChanged(cmp => cmp.isUpdating = updating), token: this.CancellationTokenSource.Token);
130-
this.Store.IsSaving.Subscribe(OnSavingChanged, token: this.CancellationTokenSource.Token);
131131
this.Store.ProblemDetails.Subscribe(problemDetails => this.OnStateChanged(cmp => cmp.problemDetails = problemDetails), token: this.CancellationTokenSource.Token);
132132
this.textEditorInput
133133
.Throttle(TimeSpan.FromMilliseconds(300))
@@ -148,6 +148,7 @@
148148
{
149149
this.resource = this.Resource; // should happen in this.Store.Resource.Subscribe but prevents possible race when multiple params are set
150150
this.Store.SetResource(this.Resource);
151+
this.Store.SetProblemDetails(null);
151152
}
152153
if (this.isCluster != this.IsCluster)
153154
{
@@ -178,7 +179,6 @@
178179
{
179180
this.isSaving = saving;
180181
if (this.textBasedEditor != null) this.textBasedEditor.UpdateOptions(new EditorUpdateOptions() { ReadOnly = saving });
181-
this.StateHasChanged();
182182
}
183183

184184
/// <summary>
@@ -199,7 +199,7 @@
199199
await this.SetTextEditorValueAsync();
200200
await this.SetTextBasedEditorLanguageAsync();
201201
}
202-
this.StateHasChanged();
202+
this.OnStateChanged();
203203
}
204204

205205
/// <summary>

src/dashboard/Synapse.Dashboard/StatefulComponent.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ protected override async Task OnInitializedAsync()
6161
/// Patches the component fields after a change
6262
/// </summary>
6363
/// <param name="patch">The patch to apply</param>
64-
protected void OnStateChanged(Action<TComponent> patch)
64+
protected void OnStateChanged(Action<TComponent>? patch = null)
6565
{
66-
patch((TComponent)this);
66+
if (patch != null) patch((TComponent)this);
6767
this.shouldRender = true;
6868
this.StateHasChanged();
6969
}

0 commit comments

Comments
 (0)