From e70e4c6abaa90e7ec3bcee5b828df6740ad9f9a4 Mon Sep 17 00:00:00 2001 From: Gordon Murray Date: Wed, 15 Apr 2026 20:59:26 +0100 Subject: [PATCH] fix(ui): pre-fill bundled-demo MinIO defaults on storage-type change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Picking MinIO from the dropdown only updated the endpoint placeholder, not the value. First-time users left the field blank, the backend defaulted to s3.amazonaws.com, and AWS rejected the demo creds with 403 — turning the click-through demo into a dead-end. Now: when MinIO is selected, fill any empty endpoint / accessKey / secretKey / tablePath with the bundled-demo defaults that mirror GET /api/demo/connection. The setIfEmpty helper guarantees we never overwrite a value the user has typed. Also fixes a pre-existing copy bug: the AWS S3 endpoint placeholder showed 's3://bucket/path/to/table' (which is a *table* path, not an endpoint). Closes #35 --- frontend/js/app.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/frontend/js/app.js b/frontend/js/app.js index 2c86baf..c93a144 100644 --- a/frontend/js/app.js +++ b/frontend/js/app.js @@ -76,19 +76,34 @@ class CloudfloeApp { updateConnectionFields(storageType) { const sessionTokenGroup = document.getElementById('sessionTokenGroup'); const endpoint = document.getElementById('endpoint'); + const accessKey = document.getElementById('accessKey'); + const secretKey = document.getElementById('secretKey'); + const tablePath = document.getElementById('tablePath'); + + // Only fill empty fields — never clobber a value the user typed. + const setIfEmpty = (el, value) => { + if (!el.value) el.value = value; + }; switch(storageType) { case 's3': sessionTokenGroup.style.display = 'block'; - endpoint.placeholder = 's3://bucket/path/to/table'; + endpoint.placeholder = 's3.amazonaws.com (leave blank for AWS default)'; break; case 'r2': sessionTokenGroup.style.display = 'none'; - endpoint.placeholder = 'https://account.r2.cloudflarestorage.com'; + endpoint.placeholder = 'account-id.r2.cloudflarestorage.com'; break; case 'minio': sessionTokenGroup.style.display = 'none'; endpoint.placeholder = 'http://localhost:9000'; + // Pre-fill the bundled-demo MinIO defaults so the first-time + // path (pick MinIO → click Test Connection) just works. + // Mirrors GET /api/demo/connection. + setIfEmpty(endpoint, 'http://localhost:9000'); + setIfEmpty(accessKey, 'cloudfloe'); + setIfEmpty(secretKey, 'cloudfloe123'); + setIfEmpty(tablePath, 's3://movies/warehouse/demo/movies'); break; } }