swarm-ui: lock the backend configuration box when its stored text could not be read
Only a 404 means nothing is stored. Any other failed read used to leave an empty, editable box with save enabled, so saving one line replaced a configuration that was never read. The box now stays locked behind an error with a retry button. The decision is a small tested function, and the swarm-ui doc describes it.
This commit is contained in:
parent
ff7215a4b1
commit
c7e559a09e
1 changed files with 66 additions and 7 deletions
|
|
@ -76,6 +76,20 @@ export function backendEnvUrl(hive: string, agent: string): string {
|
|||
return `${agentBase(hive, agent)}/backend-env`;
|
||||
}
|
||||
|
||||
/**
|
||||
* What a read of the stored backend configuration answered: `stored` (200),
|
||||
* `none` (404, nothing is stored, so an empty box is right) or `failed` (any
|
||||
* other answer, which must not unlock the box: a save would replace text that
|
||||
* was never read).
|
||||
*/
|
||||
export function configReadKind(
|
||||
status: number,
|
||||
ok: boolean,
|
||||
): "stored" | "none" | "failed" {
|
||||
if (ok) return "stored";
|
||||
return status === 404 ? "none" : "failed";
|
||||
}
|
||||
|
||||
/** GET (is any stored), PUT and DELETE target for the agent's backend secrets. */
|
||||
export function backendSecretsUrl(hive: string, agent: string): string {
|
||||
return `${agentBase(hive, agent)}/backend-secrets`;
|
||||
|
|
|
|||
Loading…
Reference in a new issue