feat(centralui): Create saves bindings (upsert) and lands on Configure with a created/bound/bindError notice
Claude-Session: https://claude.ai/code/session_01G2GHPnbbKGvyyfbr2XBRVH
This commit is contained in:
+40
-6
@@ -293,26 +293,60 @@
|
||||
return;
|
||||
}
|
||||
|
||||
string user;
|
||||
int id;
|
||||
try
|
||||
{
|
||||
var user = await GetCurrentUserAsync();
|
||||
user = await GetCurrentUserAsync();
|
||||
var result = await InstanceService.CreateInstanceAsync(
|
||||
_createName.Trim(), _createTemplateId, _createSiteId, _createAreaId == 0 ? null : _createAreaId, user);
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
NavigationManager.NavigateTo("/deployment/topology");
|
||||
}
|
||||
else
|
||||
if (result.IsFailure)
|
||||
{
|
||||
_formError = result.Error;
|
||||
return;
|
||||
}
|
||||
id = result.Value.Id;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_formError = $"Create failed: {ex.Message}";
|
||||
return;
|
||||
}
|
||||
|
||||
// From here the instance EXISTS. Whatever the binding save does, land on
|
||||
// Configure rather than leaving the operator on a stale create form —
|
||||
// carrying any binding error in the query so it is visible there.
|
||||
var bindings = _skipBindings || _previewError is not null
|
||||
? (IReadOnlyList<ConnectionBinding>)Array.Empty<ConnectionBinding>()
|
||||
: CreateBindingPlanner.BuildBindings(_groups, _inputs);
|
||||
|
||||
if (bindings.Count == 0)
|
||||
{
|
||||
NavigationManager.NavigateTo($"/deployment/instances/{id}/configure?created=1");
|
||||
return;
|
||||
}
|
||||
|
||||
string? bindError = null;
|
||||
try
|
||||
{
|
||||
var bind = await InstanceService.SetConnectionBindingsAsync(id, bindings, user);
|
||||
if (bind.IsFailure) bindError = bind.Error;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Network / actor timeout AFTER the instance was created.
|
||||
bindError = ex.Message;
|
||||
}
|
||||
|
||||
var query = bindError is null
|
||||
? $"created=1&bound={bindings.Count}"
|
||||
: $"created=1&bindError={Uri.EscapeDataString(Truncate(bindError, 300))}";
|
||||
NavigationManager.NavigateTo($"/deployment/instances/{id}/configure?{query}");
|
||||
}
|
||||
|
||||
/// <summary>Keeps a failure message short enough to ride in the query string.</summary>
|
||||
private static string Truncate(string s, int n) => s.Length <= n ? s : s[..n] + "…";
|
||||
|
||||
private void GoBack() => NavigationManager.NavigateTo("/deployment/topology");
|
||||
|
||||
// CentralUI-024: delegates to the shared helper so the claim type stays
|
||||
|
||||
Reference in New Issue
Block a user