one button, and it appears when there is something to press
Two buttons was the wrong model, and it failed in the worst way: Create keyed off the SAVED names, so on a fresh screen with both fields filled it did not render at all — and the hint explaining why was behind the same condition. Two filled fields, one Save, and nothing saying what came next. Naming and creating are not separate decisions from the outside. You type two names because you want two databases. So one button that records them and creates whatever is missing, labelled with whichever of those it is about to do, and disabled only when there is genuinely nothing to press. The tick beside each field now asks pg_database about the text in the BOX rather than the text last saved. That is the question somebody typing a name has, and answering it about a different name was worse than silence. The PUT that only stored names goes with the second button. Nothing called it, and a second way to write the same two columns is a second thing that can drift. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+19
-1
@@ -141,7 +141,25 @@ export async function saveDatabases(production: string, development: string): Pr
|
||||
* a name that failed for a different reason, and reporting "created" about a database that is not
|
||||
* there is the one outcome worth engineering against.
|
||||
*/
|
||||
export async function createDatabases(): Promise<{ created: string[]; status: DatabasesStatus }> {
|
||||
export async function createDatabases(names?: {
|
||||
production?: string;
|
||||
development?: string;
|
||||
}): Promise<{ created: string[]; status: DatabasesStatus }> {
|
||||
/*
|
||||
Names may arrive with the request, and then they are SAVED before anything is created.
|
||||
|
||||
Because otherwise Create acts on stored names while the person is looking at typed ones, and the
|
||||
two can differ. Making them press Save first was the version of this that shipped, and it left a
|
||||
screen with two filled fields, no Create button and nothing explaining why — the button keyed off
|
||||
the saved names, which were still empty.
|
||||
|
||||
Recording the name you just used to create a database is not a side effect worth hiding behind a
|
||||
second click.
|
||||
*/
|
||||
if (names?.production !== undefined || names?.development !== undefined) {
|
||||
await saveDatabases(names.production ?? '', names.development ?? '');
|
||||
}
|
||||
|
||||
const status = await readDatabases();
|
||||
const wanted = [status.production.name, status.development.name].filter((name): name is string => Boolean(name));
|
||||
if (!wanted.length) throw new Error('Name the databases before creating them.');
|
||||
|
||||
Reference in New Issue
Block a user