forge
Explore
Log in

Don't you dare go Hollow

Per-user instrument/ledger density, rebuilt settings page

Browse files at this commit

d3811f16ab8925f6cb3e0e37f1f9fdc84ef1605dAhmet Kaan GümüşParent: 29f6365
  • feat
    • per-user instrument/ledger density, rebuilt settings page
Show full message
feat(ui): per-user instrument/ledger density, rebuilt settings page

The settings page put bare sections straight into the shell's flex row
and panels without panel-head, so labels overlapped values and three
panels crammed into one line (user screenshot). Rebuilt on iz's
skeleton: settings-shell > settings-stage, panel-head/panel-body,
field/field-label rows, member-table for the admin list.

Density follows iz's preference model: user.ui column (0002, default
ledger), set_user_ui validates the offered values, root_layout emits
data-ui from the signed-in user, and a house dropdown on the settings
page saves it through POST /api/settings/ui (BadUi refusal otherwise).
Instrument's fixed 40px filterbar becomes a floor so the drive's
create-folder form fits; the form itself goes inline in the bar.
crates/in-core/migrations/0002_ui.sqladded+6 -0
@@ -0,0 +1,6 @@
1+-- The person's UI density: 'ledger' or 'instrument', read by `root_layout`
2+-- into `data-ui`. The DEFAULT is the backfill: SQLite fills every existing
3+-- row with it as the column is added. Databases already carrying the column
4+-- never see this file applied piecemeal — they reach the declared shape
5+-- through `in reconcile`, whose copy map backfills the same value.
6+ALTER TABLE user ADD COLUMN ui TEXT NOT NULL DEFAULT 'ledger';
crates/in-core/src/store/mod.rsmodified+9 -0
@@ -93,6 +93,9 @@ pub struct User {
9393 /// file that can be restored still costs. Recomputed from the rows after
9494 /// every mutation, never blindly incremented.
9595 pub used_bytes: u64,
96+ /// Display-only, the way `quota_bytes` is data: 'ledger' or 'instrument',
97+ /// read by `root_layout` into `data-ui`. Nothing stored depends on it.
98+ pub ui: String,
9699 pub created_at: OffsetDateTime,
97100 pub last_seen_at: Option<OffsetDateTime>,
98101 }
@@ -358,6 +361,12 @@ pub trait Store: 'static + Send + Sync {
358361 /// layer reads this and treats the person as signed out.
359362 async fn set_user_disabled(&self, user_id: &str, disabled: bool) -> Result<()>;
360363
364+ /// Writes the person's UI density: `ledger` or `instrument`, read by
365+ /// `root_layout` into `data-ui`. Anything else is refused with
366+ /// [`StoreError::Corrupt`] — the same refusal a bad enum read from the
367+ /// row gets, because a bad enum written is a corrupt row.
368+ async fn set_user_ui(&self, id: &str, ui: &str) -> Result<()>;
369+
361370 // -- folders -----------------------------------------------------------
362371
363372 /// Creates a folder. A parent of another owner is [`StoreError::CrossOwner`],
crates/in-core/src/store/reconcile.rsmodified+32 -25
@@ -202,26 +202,34 @@ struct TableMap {
202202 columns: Vec<(&'static str, String)>,
203203 }
204204
205-/// Builds the explicit column map. Every table maps every column to its old
206-/// self: In's first schema is the declared one, so a database old enough to
207-/// be reconciled carries the same columns, and the map is the receipt that
208-/// says nothing was dropped, renamed or defaulted on the way across.
209-fn build_maps() -> Vec<TableMap> {
205+/// Builds the explicit column map. Unchanged tables map every column to its
206+/// old self; the user table carries the migration-specific expression for
207+/// `ui`: a database old enough to predate the column starts on the schema's
208+/// own default rather than on an empty string, which no writer would ever
209+/// store and no reader would ever honour.
210+fn build_maps(old_has_ui: bool) -> Vec<TableMap> {
210211 vec![
211212 TableMap {
212213 name: "user",
213- columns: old_cols(&[
214- "id",
215- "oidc_sub",
216- "email",
217- "display_name",
218- "admin",
219- "disabled",
220- "quota_bytes",
221- "used_bytes",
222- "created_at",
223- "last_seen_at",
224- ]),
214+ columns: {
215+ let mut columns = old_cols(&[
216+ "id",
217+ "oidc_sub",
218+ "email",
219+ "display_name",
220+ "admin",
221+ "disabled",
222+ "quota_bytes",
223+ "used_bytes",
224+ ]);
225+ columns.push(if old_has_ui {
226+ ("ui", "old.ui".into())
227+ } else {
228+ ("ui", "'ledger'".into())
229+ });
230+ columns.extend(old_cols(&["created_at", "last_seen_at"]));
231+ columns
232+ },
225233 },
226234 TableMap {
227235 name: "folder",
@@ -363,14 +371,15 @@ async fn validate_maps(conn: &Connection, maps: &[TableMap]) -> Result<()> {
363371 /// main schema, in foreign-key-safe order: owners before folders, folders
364372 /// before the files and sessions that name them, everything before the
365373 /// shares that name all of it.
366-async fn copy_data(_old_conn: &Connection, new_conn: &Connection, path: &str) -> Result<()> {
374+async fn copy_data(old_conn: &Connection, new_conn: &Connection, path: &str) -> Result<()> {
367375 let escaped = path.replace('\'', "''");
368376 new_conn
369377 .execute(&format!("ATTACH DATABASE '{}' AS old", escaped), ())
370378 .await
371379 .map_err(|e| StoreError::Backend(e.to_string()))?;
372380
373- let maps = build_maps();
381+ let old_has_ui = old_has_column(old_conn, "user", "ui").await?;
382+ let maps = build_maps(old_has_ui);
374383 validate_maps(new_conn, &maps).await?;
375384
376385 // Foreign keys stay off during the copy and are checked by `verify`
@@ -555,12 +564,10 @@ fn backup_name(path: &str) -> Result<String> {
555564 }
556565 }
557566
558-/// A probe the copy plan can ask: whether the old database already carries
559-/// `column` on `table`. Unused while the declared schema is the first one —
560-/// every database old enough to be reconciled predates every column it
561-/// would probe — and kept because the second migration will need exactly
562-/// this question on its first day.
563-#[allow(dead_code)]
567+/// A probe the copy plan asks: whether the old database already carries
568+/// `column` on `table`. A column the second migration added is absent on a
569+/// database old enough to predate it, and the map backfills the default
570+/// instead of reading a column that is not there.
564571 async fn old_has_column(conn: &Connection, table: &str, column: &str) -> Result<bool> {
565572 let mut rows = conn
566573 .query(&format!("PRAGMA table_info({table})"), ())
crates/in-core/src/store/schema.rsmodified+6 -2
@@ -11,8 +11,12 @@ use turso::Connection;
1111
1212 /// The declared migrations, in order. An empty database is built by applying
1313 /// them one after another; each one applies cleanly to what the ones before
14-/// it built, so their concatenation is itself a valid whole-schema script.
15-pub(crate) const MIGRATIONS: &[&str] = &[include_str!("../../migrations/0001_init.sql")];
14+/// it built (`0002` is `ALTER`s), so their concatenation is itself a valid
15+/// whole-schema script.
16+pub(crate) const MIGRATIONS: &[&str] = &[
17+ include_str!("../../migrations/0001_init.sql"),
18+ include_str!("../../migrations/0002_ui.sql"),
19+];
1620
1721 /// The whole declared schema — every migration applied in order — as one
1822 /// batch of SQL.
crates/in-core/src/store/turso_store.rsmodified+21 -3
@@ -36,7 +36,7 @@ const UPLOADS_DIR: &str = "uploads";
3636 const THUMB_SOURCE_CAP: u64 = 64 * 1024 * 1024;
3737
3838 const USER_COLUMNS: &str =
39- "id, oidc_sub, email, display_name, admin, disabled, quota_bytes, used_bytes, created_at, last_seen_at";
39+ "id, oidc_sub, email, display_name, admin, disabled, quota_bytes, used_bytes, ui, created_at, last_seen_at";
4040 const FOLDER_COLUMNS: &str = "id, owner_id, parent_id, name, created_at, deleted_at";
4141 const FILE_COLUMNS: &str =
4242 "id, owner_id, folder_id, name, mime, size_bytes, thumb_state, created_at, updated_at, deleted_at";
@@ -713,8 +713,9 @@ fn user_from(row: &Row) -> Result<User> {
713713 disabled: row.get::<i64>(5).map_err(backend)? != 0,
714714 quota_bytes: row.get::<i64>(6).map_err(backend)?.max(0) as u64,
715715 used_bytes: row.get::<i64>(7).map_err(backend)?.max(0) as u64,
716- created_at: parse_stamp(&text(row, 8)?)?,
717- last_seen_at: opt_stamp(row, 9)?,
716+ ui: text(row, 8)?,
717+ created_at: parse_stamp(&text(row, 9)?)?,
718+ last_seen_at: opt_stamp(row, 10)?,
718719 })
719720 }
720721
@@ -946,6 +947,23 @@ impl Store for TursoStore {
946947 Ok(())
947948 }
948949
950+ async fn set_user_ui(&self, id: &str, ui: &str) -> Result<()> {
951+ if ui != "ledger" && ui != "instrument" {
952+ return Err(StoreError::Corrupt(format!("ui {ui:?}")));
953+ }
954+ let conn = self.conn.lock().await;
955+ let n = conn
956+ .execute("UPDATE user SET ui = ?1 WHERE id = ?2", params![ui, id])
957+ .await
958+ .map_err(backend)?;
959+ if n == 0 {
960+ return Err(StoreError::NotFound);
961+ }
962+ drop(conn);
963+ self.announce([Topic::Admin(id.to_string())]);
964+ Ok(())
965+ }
966+
949967 async fn create_folder(
950968 &self,
951969 owner_id: &str,
crates/in-core/tests/store.rsmodified+65 -0
@@ -1120,3 +1120,68 @@ async fn add_share_user_needs_the_owner() {
11201120 scratch.store.add_share_user(&user.id, ShareKind::File, &file.id, &stranger.id, true).await.unwrap();
11211121 assert!(scratch.store.can_see(ShareKind::File, &file.id, &stranger.id).await.unwrap());
11221122 }
1123+
1124+#[tokio::test]
1125+async fn a_provisioned_user_wears_the_ledger_ui() {
1126+ let scratch = Scratch::open().await;
1127+ let user = alice(&scratch.store).await;
1128+ assert_eq!(user.ui, "ledger");
1129+}
1130+
1131+#[tokio::test]
1132+async fn the_ui_round_trips_and_refuses_what_is_not_offered() {
1133+ let scratch = Scratch::open().await;
1134+ let user = alice(&scratch.store).await;
1135+ scratch.store.set_user_ui(&user.id, "instrument").await.unwrap();
1136+ let back = scratch.store.user(&user.id).await.unwrap().unwrap();
1137+ assert_eq!(back.ui, "instrument");
1138+ // A value no settings screen offers is refused, and the row keeps what
1139+ // the last good write left — the same Corrupt the store answers a bad
1140+ // enum it reads.
1141+ assert!(matches!(
1142+ scratch.store.set_user_ui(&user.id, "dense").await,
1143+ Err(StoreError::Corrupt(_))
1144+ ));
1145+ let kept = scratch.store.user(&user.id).await.unwrap().unwrap();
1146+ assert_eq!(kept.ui, "instrument");
1147+ assert!(matches!(
1148+ scratch.store.set_user_ui("no-such-user", "ledger").await,
1149+ Err(StoreError::NotFound)
1150+ ));
1151+}
1152+
1153+#[tokio::test]
1154+async fn a_first_migration_database_gains_the_ui_column_on_open() {
1155+ // A database built from 0001 alone — the shape In was deployed with —
1156+ // carries no `ui` column. Opening it with the current code reconciles it
1157+ // onto the declared schema, and its people arrive wearing the default.
1158+ let dir = std::env::temp_dir().join(format!("in-test-{}", Ulid::new()));
1159+ std::fs::create_dir_all(&dir).unwrap();
1160+ let path = dir.join("in.db").to_string_lossy().into_owned();
1161+ {
1162+ let db = turso::Builder::new_local(&path).build().await.unwrap();
1163+ let conn = db.connect().unwrap();
1164+ conn.execute_batch(include_str!("../migrations/0001_init.sql"))
1165+ .await
1166+ .unwrap();
1167+ conn.execute(
1168+ "INSERT INTO user (id, oidc_sub, email, display_name, admin, disabled, \
1169+ quota_bytes, used_bytes, created_at, last_seen_at) \
1170+ VALUES ('u-old', 'sub-old', 'old@example.com', 'Old', 1, 0, 100, 0, \
1171+ '2026-08-01T00:00:00Z', '2026-08-01T00:00:00Z')",
1172+ (),
1173+ )
1174+ .await
1175+ .unwrap();
1176+ }
1177+ let storage = dir.join("storage");
1178+ let store = TursoStore::open(&path, Some(&storage)).await.unwrap();
1179+ let user = store.user_by_oidc_sub("sub-old").await.unwrap().unwrap();
1180+ assert_eq!(user.ui, "ledger");
1181+ // And the carried row takes a new preference like any other.
1182+ store.set_user_ui(&user.id, "instrument").await.unwrap();
1183+ let back = store.user(&user.id).await.unwrap().unwrap();
1184+ assert_eq!(back.ui, "instrument");
1185+ drop(store);
1186+ let _ = std::fs::remove_dir_all(&dir);
1187+}
crates/in-web/src/i18n.rsmodified+3 -0
@@ -161,6 +161,7 @@ pub enum Key {
161161 ViewOnly,
162162 NoLinks,
163163 ManageLinks,
164+ UiLabel,
164165 }
165166
166167 pub fn t(lang: Lang, key: Key) -> &'static str {
@@ -259,6 +260,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
259260 ViewOnly => "View only — preview, no downloads",
260261 NoLinks => "No share links yet.",
261262 ManageLinks => "Share links",
263+ UiLabel => "Interface",
262264 },
263265 Lang::Tr => match key {
264266 Cancel => "Vazgeç",
@@ -353,6 +355,7 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
353355 ViewOnly => "Yalnızca görüntüleme — önizleme, indirme yok",
354356 NoLinks => "Henüz paylaşım bağlantısı yok.",
355357 ManageLinks => "Paylaşım bağlantıları",
358+ UiLabel => "Arayüz",
356359 },
357360 }
358361 }
crates/in-web/src/layout.rsmodified+8 -6
@@ -850,12 +850,14 @@ const STYLE: Asset = asset!("assets/main.css");
850850
851851 #[layout("/")]
852852 async fn root_layout(cx: &Cx, slot: Result) -> Result {
853- // v1 has no per-user theme or language: every page renders light, and
854- // the language comes off the request's Accept-Language header.
855- let asking = match current_user(cx).await {
856- Ok(user) => user.is_some(),
857- Err(_) => false,
853+ // The one per-user chrome knob: the UI density, read off the request's
854+ // own user. Signed-out (or unreadable) renders ledger, the default.
855+ let me = match current_user(cx).await {
856+ Ok(user) => user.as_ref(),
857+ Err(_) => None,
858858 };
859+ let asking = me.is_some();
860+ let ui = me.as_ref().map_or("ledger", |user| user.ui.as_str());
859861 let lang = crate::i18n::lang(cx);
860862
861863 let content = match slot {
@@ -878,7 +880,7 @@ async fn root_layout(cx: &Cx, slot: Result) -> Result {
878880 let build = STYLE.id().as_u64().to_string();
879881 view! {
880882 <!DOCTYPE html>
881- <html lang=(lang.code()) data-ui="ledger" data-build=(build)>
883+ <html lang=(lang.code()) data-ui=(ui) data-build=(build)>
882884 <head>
883885 <meta charset="utf-8">
884886 <meta name="viewport" content="width=device-width, initial-scale=1">
crates/in-web/src/server.rsmodified+7 -1
@@ -212,6 +212,8 @@ pub enum Refusal {
212212 AncestorTrashed,
213213 /// The store failed to say. Never a sign-in prompt — see `require_user`.
214214 Unavailable,
215+ /// The ui field was not one of the values the form offers.
216+ BadUi,
215217 }
216218
217219 impl Refusal {
@@ -232,6 +234,7 @@ impl Refusal {
232234 Refusal::BadChunk => "That piece arrived damaged — send it again.".to_string(),
233235 Refusal::AncestorTrashed => "Restore the folder it is in first.".to_string(),
234236 Refusal::Unavailable => "Something went wrong.".to_string(),
237+ Refusal::BadUi => "That interface choice is not offered.".to_string(),
235238 }
236239 }
237240
@@ -252,8 +255,9 @@ impl Refusal {
252255 Refusal::ShareRevoked => "Bu bağlantı artık çalışmıyor.".to_string(),
253256 Refusal::UploadExpired => "Bu yüklemenin süresi doldu — yeniden başlat.".to_string(),
254257 Refusal::BadChunk => "Bu parça bozuk geldi — yeniden gönder.".to_string(),
255- Refusal::AncestorTrashed => "Önce içinde olduğu klasörü geri yükle.".to_string(),
256258 Refusal::Unavailable => "Bir şeyler ters gitti.".to_string(),
259+ Refusal::AncestorTrashed => "Önce içinde olduğu klasörü geri yükle.".to_string(),
260+ Refusal::BadUi => "Bu arayüz seçeneği sunulmuyor.".to_string(),
257261 }
258262 }
259263
@@ -274,6 +278,7 @@ impl Refusal {
274278 "bad-chunk" => Refusal::BadChunk,
275279 "ancestor-trashed" => Refusal::AncestorTrashed,
276280 "unavailable" => Refusal::Unavailable,
281+ "bad-ui" => Refusal::BadUi,
277282 _ => return None,
278283 })
279284 }
@@ -298,6 +303,7 @@ impl Refusal {
298303 Refusal::BadChunk => "bad-chunk",
299304 Refusal::AncestorTrashed => "ancestor-trashed",
300305 Refusal::Unavailable => "unavailable",
306+ Refusal::BadUi => "bad-ui",
301307 }
302308 }
303309 }
crates/in-web/src/settings.rsmodified+148 -78
@@ -117,6 +117,29 @@ async fn set_disabled(cx: &Cx, Form(input): Form<DisableForm>) -> Redirect {
117117 }
118118 }
119119
120+#[derive(Deserialize)]
121+struct UiForm {
122+ ui: String,
123+}
124+
125+/// Switches the reader's own interface between the ledger and the
126+/// instrument. Anything else is refused — the form only ever offers the
127+/// two, so another value is a hand-built post, not a typo.
128+#[route(POST "/api/settings/ui")]
129+async fn set_ui(cx: &Cx, Form(input): Form<UiForm>) -> Redirect {
130+ let user = match require_user(cx).await {
131+ Ok(user) => user,
132+ Err(refusal) => return redirect_back(cx, "ui", Some(refusal)),
133+ };
134+ if input.ui != "ledger" && input.ui != "instrument" {
135+ return redirect_back(cx, "ui", Some(Refusal::BadUi));
136+ }
137+ match app(cx).store.set_user_ui(&user.id, &input.ui).await {
138+ Ok(()) => redirect_back(cx, "ui", None),
139+ Err(error) => redirect_back(cx, "ui", Some(refusal_of(error))),
140+ }
141+}
142+
120143 /// The reader's profile and quota, their live share links, and — for an
121144 /// admin — every account with its quota and kill switch.
122145 #[page("/settings")]
@@ -157,92 +180,139 @@ async fn settings(cx: &Cx) -> Result {
157180 let origin = app(cx).config.listen_url();
158181 view! {
159182 cx =>
160- <main class="settings-shell">
161- (topbar(cx, NavPage::Settings, &fresh, language).await?)
162- <h1 class="settings-title">(t(language, Key::Settings))</h1>
163- (refusal_banner(cx, language, &["create", "revoke", "add", "remove", "quota", "disable"]).await?)
164- if let Some(token) = created {
183+ (topbar(cx, NavPage::Settings, &fresh, language).await?)
184+ <div class="settings-shell">
185+ <main class="settings-stage">
186+ <h1 class="settings-title">(t(language, Key::Settings))</h1>
187+ (refusal_banner(cx, language, &["create", "revoke", "add", "remove", "quota", "disable", "ui"]).await?)
188+ if let Some(token) = created {
189+ <section class="panel">
190+ <div class="panel-head">
191+ <h2 class="panel-title">(t(language, Key::LinkCreated))</h2>
192+ </div>
193+ <div class="panel-body">
194+ <p class="field-note">(t(language, Key::CopyLinkOnce))</p>
195+ <p class="member-link-value">(format!("{origin}/s/{token}"))</p>
196+ </div>
197+ </section>
198+ }
165199 <section class="panel">
166- <h2 class="panel-title">(t(language, Key::LinkCreated))</h2>
200+ <div class="panel-head">
201+ <h2 class="panel-title">(t(language, Key::Profile))</h2>
202+ </div>
167203 <div class="panel-body">
168- <p class="field-note">(t(language, Key::CopyLinkOnce))</p>
169- <p class="member-link-value">(format!("{origin}/s/{token}"))</p>
204+ <label class="field">
205+ <span class="field-label">(t(language, Key::DisplayName))</span>
206+ <span class="field-static">(fresh.display_name.clone())</span>
207+ </label>
208+ <label class="field">
209+ <span class="field-label">(t(language, Key::EmailAddress))</span>
210+ <span class="field-static">(fresh.email.clone())</span>
211+ </label>
212+ <div class="field">
213+ <span class="field-label">(t(language, Key::QuotaUsage))</span>
214+ <span class="field-static">(format!("{} {} {}", human_bytes(fresh.used_bytes), t(language, Key::QuotaOf), human_bytes(fresh.quota_bytes)))</span>
215+ <div class="quota-bar" role="progressbar" aria-valuenow=(quota_percent(&fresh).to_string()) aria-valuemin="0" aria-valuemax="100">
216+ <div class="quota-fill" style=(format!("width: {}%", quota_percent(&fresh)))></div>
217+ </div>
218+ </div>
219+ <form class="field" method="post" action="/api/settings/ui">
220+ <label class="field">
221+ <span class="field-label">(t(language, Key::UiLabel))</span>
222+ <select class="field-input" name="ui">
223+ <option value="instrument" selected=(fresh.ui == "instrument")>"Instrument"</option>
224+ <option value="ledger" selected=(fresh.ui == "ledger")>"Ledger"</option>
225+ </select>
226+ </label>
227+ <div class="panel-foot">
228+ <button class="primary" type="submit">(t(language, Key::Save))</button>
229+ </div>
230+ </form>
170231 </div>
171232 </section>
172- }
173- <section class="panel">
174- <h2 class="panel-title">(t(language, Key::Profile))</h2>
175- <div class="panel-body">
176- <p><span class="field-label">(t(language, Key::DisplayName))</span> (fresh.display_name.clone())</p>
177- <p><span class="field-label">(t(language, Key::EmailAddress))</span> (fresh.email.clone())</p>
178- <p>
179- <span class="field-label">(t(language, Key::QuotaUsage))</span>
180- (format!("{} {} {}", human_bytes(fresh.used_bytes), t(language, Key::QuotaOf), human_bytes(fresh.quota_bytes)))
181- </p>
182- <div class="quota-bar" role="progressbar" aria-valuenow=(quota_percent(&fresh).to_string()) aria-valuemin="0" aria-valuemax="100">
183- <div class="quota-fill" style=(format!("width: {}%", quota_percent(&fresh)))></div>
184- </div>
185- </div>
186- </section>
187- <section class="panel">
188- <h2 class="panel-title">(t(language, Key::ManageLinks))</h2>
189- <div class="panel-body">
190- if live_links.is_empty() {
191- <p class="field-note">(t(language, Key::NoLinks))</p>
192- }
193- for link in live_links {
194- <div class="member-row">
195- <span class="member-name">(format!("{} · {}", link.kind.as_str(), link.target_id.clone()))</span>
196- <span class="field-note">(expiry_line(language, link.expires_at))</span>
197- <span class="field-note">(if link.can_download { t(language, Key::CanDownload) } else { t(language, Key::ViewOnly) })</span>
198- <form class="pop-row-form" method="post" action="/api/share/link/revoke">
199- <input type="hidden" name="id" value=(link.id.clone())>
200- <button type="submit">(t(language, Key::RevokeLink))</button>
201- </form>
202- </div>
203- }
204- </div>
205- </section>
206- if fresh.admin {
207233 <section class="panel">
208- <h2 class="panel-title">(t(language, Key::AdminPanel))</h2>
234+ <div class="panel-head">
235+ <h2 class="panel-title">(t(language, Key::ManageLinks))</h2>
236+ </div>
209237 <div class="panel-body">
210- <div class="member-table">
211- for listed in &users {
212- <div class="member-row">
213- <span class="member-name">(listed.display_name.clone())</span>
214- <span class="member-address">(listed.email.clone())</span>
215- <span class="field-note">(format!("{} {} {}", human_bytes(listed.used_bytes), t(language, Key::QuotaOf), human_bytes(listed.quota_bytes)))</span>
216- if listed.admin {
217- <span class="chip chip-admin">(t(language, Key::AdminBadge))</span>
218- }
219- if listed.disabled {
220- <span class="chip chip-off">(t(language, Key::DisabledBadge))</span>
221- }
222- <form class="pop-row-form" method="post" action="/api/settings/quota">
223- <input type="hidden" name="user_id" value=(listed.id.clone())>
224- <input class="field-input" type="number" name="quota_bytes" min="0" value=(listed.quota_bytes.to_string()) aria-label=(t(language, Key::QuotaBytes))>
225- <button type="submit">(t(language, Key::SetQuota))</button>
226- </form>
227- if listed.id != fresh.id {
228- <form class="pop-row-form" method="post" action="/api/settings/disable">
229- <input type="hidden" name="user_id" value=(listed.id.clone())>
230- if listed.disabled {
231- <input type="hidden" name="disabled" value="0">
232- <button type="submit">(t(language, Key::EnableUser))</button>
233- } else {
234- <input type="hidden" name="disabled" value="1">
235- <button class="quiet-danger" type="submit">(t(language, Key::DisableUser))</button>
236- }
237- </form>
238- }
239- </div>
240- }
241- </div>
238+ if live_links.is_empty() {
239+ <p class="field-note">(t(language, Key::NoLinks))</p>
240+ }
241+ for link in live_links {
242+ <div class="member-row">
243+ <span class="member-name">(format!("{} · {}", link.kind.as_str(), link.target_id.clone()))</span>
244+ <span class="field-note">(expiry_line(language, link.expires_at))</span>
245+ <span class="field-note">(if link.can_download { t(language, Key::CanDownload) } else { t(language, Key::ViewOnly) })</span>
246+ <form class="pop-row-form" method="post" action="/api/share/link/revoke">
247+ <input type="hidden" name="id" value=(link.id.clone())>
248+ <button type="submit">(t(language, Key::RevokeLink))</button>
249+ </form>
250+ </div>
251+ }
242252 </div>
243253 </section>
244- }
245- </main>
254+ if fresh.admin {
255+ <section class="panel">
256+ <div class="panel-head">
257+ <h2 class="panel-title">(t(language, Key::AdminPanel))</h2>
258+ </div>
259+ <div class="panel-body">
260+ <div class="table-pan">
261+ <table class="member-table">
262+ <thead>
263+ <tr>
264+ <th class="member-col-name" scope="col">(t(language, Key::NameColumn))</th>
265+ <th class="member-col-address" scope="col">(t(language, Key::EmailAddress))</th>
266+ <th class="member-col-account" scope="col">(t(language, Key::QuotaUsage))</th>
267+ <th class="member-col-role" scope="col"></th>
268+ </tr>
269+ </thead>
270+ <tbody>
271+ for listed in &users {
272+ <tr class="member-row">
273+ <td class="member-col-name member-name">
274+ <span class="member-name-row">
275+ (listed.display_name.clone())
276+ if listed.admin {
277+ <span class="chip chip-admin">(t(language, Key::AdminBadge))</span>
278+ }
279+ if listed.disabled {
280+ <span class="chip chip-off">(t(language, Key::DisabledBadge))</span>
281+ }
282+ </span>
283+ </td>
284+ <td class="member-col-address member-address">(listed.email.clone())</td>
285+ <td class="member-col-account member-account">(format!("{} {} {}", human_bytes(listed.used_bytes), t(language, Key::QuotaOf), human_bytes(listed.quota_bytes)))</td>
286+ <td class="member-col-role">
287+ <form class="pop-row-form" method="post" action="/api/settings/quota">
288+ <input type="hidden" name="user_id" value=(listed.id.clone())>
289+ <input class="field-input" type="number" name="quota_bytes" min="0" value=(listed.quota_bytes.to_string()) aria-label=(t(language, Key::QuotaBytes))>
290+ <button type="submit">(t(language, Key::SetQuota))</button>
291+ </form>
292+ if listed.id != fresh.id {
293+ <form class="pop-row-form" method="post" action="/api/settings/disable">
294+ <input type="hidden" name="user_id" value=(listed.id.clone())>
295+ if listed.disabled {
296+ <input type="hidden" name="disabled" value="0">
297+ <button type="submit">(t(language, Key::EnableUser))</button>
298+ } else {
299+ <input type="hidden" name="disabled" value="1">
300+ <button class="quiet-danger" type="submit">(t(language, Key::DisableUser))</button>
301+ }
302+ </form>
303+ }
304+ </td>
305+ </tr>
306+ }
307+ </tbody>
308+ </table>
309+ </div>
310+ </div>
311+ </section>
312+ }
313+ </main>
314+ </div>
315+ (crate::dropdown::dropdown_script(cx).await?)
246316 }
247317 }
248318
crates/in-web/tests/http.rsmodified+89 -0
@@ -1896,3 +1896,92 @@ async fn a_refused_upload_carries_a_well_formed_query() {
18961896 assert_eq!(page.status, StatusCode::OK, "{}", page.text());
18971897 assert!(page.text().contains("already taken"), "{}", page.text());
18981898 }
1899+
1900+// -- settings ui picker --------------------------------------------------------
1901+
1902+#[tokio::test]
1903+async fn settings_ui_picker_round_trips() {
1904+ let app = TestApp::build().await;
1905+ let cookie = app.sign_in("sub-ui", "ui@in.test", "Ui").await;
1906+ let me = owner_of(&app, "sub-ui").await;
1907+
1908+ // The ledger is the default, worn on `<html>` from the first render.
1909+ assert_eq!(app.store.user(&me).await.unwrap().unwrap().ui, "ledger");
1910+ let page = app.get("/settings", Some(&cookie)).await;
1911+ assert_eq!(page.status, StatusCode::OK, "{}", page.text());
1912+ assert!(page.text().contains("data-ui=\"ledger\""), "{}", page.text());
1913+
1914+ // Picking the instrument writes the row and re-renders the chrome.
1915+ let answer = app
1916+ .post("/api/settings/ui", Some(&cookie), &[("ui", "instrument")])
1917+ .await;
1918+ assert!(answer.accepted(), "ui refused: {:?}", answer.location);
1919+ assert_eq!(
1920+ app.store.user(&me).await.unwrap().unwrap().ui,
1921+ "instrument"
1922+ );
1923+ let page = app.get("/settings", Some(&cookie)).await;
1924+ assert_eq!(page.status, StatusCode::OK, "{}", page.text());
1925+ assert!(
1926+ page.text().contains("data-ui=\"instrument\""),
1927+ "{}",
1928+ page.text()
1929+ );
1930+ assert!(page.text().contains("name=\"ui\""), "{}", page.text());
1931+
1932+ // And back again.
1933+ let answer = app
1934+ .post("/api/settings/ui", Some(&cookie), &[("ui", "ledger")])
1935+ .await;
1936+ assert!(answer.accepted(), "ui refused: {:?}", answer.location);
1937+ assert_eq!(app.store.user(&me).await.unwrap().unwrap().ui, "ledger");
1938+}
1939+
1940+#[tokio::test]
1941+async fn settings_ui_rejects_unknown_values() {
1942+ let app = TestApp::build().await;
1943+ let cookie = app.sign_in("sub-ui-bad", "uibad@in.test", "UiBad").await;
1944+ let me = owner_of(&app, "sub-ui-bad").await;
1945+
1946+ let answer = app
1947+ .post("/api/settings/ui", Some(&cookie), &[("ui", "mosaic")])
1948+ .await;
1949+ assert!(answer.refused("bad-ui", "ui"), "{:?}", answer.location);
1950+ assert_eq!(app.store.user(&me).await.unwrap().unwrap().ui, "ledger");
1951+
1952+ // The carried refusal renders under the picker form.
1953+ let page = app
1954+ .get(answer.location.as_deref().unwrap(), Some(&cookie))
1955+ .await;
1956+ assert_eq!(page.status, StatusCode::OK, "{}", page.text());
1957+ assert!(
1958+ page.text().contains("That interface choice is not offered."),
1959+ "{}",
1960+ page.text()
1961+ );
1962+
1963+ // Signed out, the same post asks to sign in first.
1964+ let answer = app
1965+ .post("/api/settings/ui", None, &[("ui", "instrument")])
1966+ .await;
1967+ assert!(answer.refused("sign-in-first", "ui"), "{:?}", answer.location);
1968+}
1969+
1970+#[tokio::test]
1971+async fn settings_panels_nest_inside_the_stage() {
1972+ let app = TestApp::build().await;
1973+ let admin = app.sign_in("sub-stage", "stage@in.test", "Stage").await;
1974+ let page = app.get("/settings", Some(&admin)).await;
1975+ assert_eq!(page.status, StatusCode::OK, "{}", page.text());
1976+ let body = page.text();
1977+ let stage = body
1978+ .find("<main class=\"settings-stage\">")
1979+ .expect("no settings-stage");
1980+ let close = body.find("</main>").expect("no main close");
1981+ for marker in ["panel-head", "member-table", "name=\"ui\""] {
1982+ let at = body.find(marker).unwrap_or_else(|| panic!("no {marker}"));
1983+ assert!(stage < at && at < close, "{marker} escapes the stage");
1984+ }
1985+ // The admin register is a table now: one named column per fact.
1986+ assert!(body.contains("<th class=\"member-col-name\""), "{body}");
1987+}
style/_instrument.scssmodified+5 -1
@@ -16,8 +16,12 @@
1616 height: 44px;
1717 }
1818
19+ // In's drive filterbar carries a full create-folder form (iz's only holds
20+ // chips), so the skin's fixed 40px clips it: 40px is the floor, not the
21+ // ceiling.
1922 .filterbar {
20- height: 40px;
23+ min-height: 40px;
24+ height: auto;
2125 }
2226
2327 // Active nav underlines in accent, not ink.
style/main.scssmodified+20 -0
@@ -732,6 +732,18 @@ a {
732732 padding: 8px 24px;
733733 }
734734
735+// The drive page's create-folder form sits inside the filterbar, where the
736+// column form's stacking (gap, padding, top rule) would blow the 40px
737+// instrument bar apart and float oddly centred in ledger too: inline here,
738+// so the row fits the bar in both skins.
739+.filterbar .tag-form {
740+ flex-direction: row;
741+ align-items: center;
742+ gap: 10px;
743+ padding: 0;
744+ border-top: none;
745+}
746+
735747 .segmented {
736748 display: flex;
737749 align-items: center;
@@ -3129,6 +3141,14 @@ img.avatar {
31293141 color: var(--muted-soft);
31303142 }
31313143
3144+// A read-only value under a field label — the profile's name, address and
3145+// quota line. Same type size as a field input, without the box: the label
3146+// above it is the structure, not a border.
3147+.field-static {
3148+ font-size: 13px;
3149+ color: var(--ink);
3150+}
3151+
31323152 .auth-input,
31333153 .field-input {
31343154 height: 40px;