From faf28868c99c9e669da0e8765d701abb3bd75f9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Kaan=20G=C3=BCm=C3=BC=C5=9F?= Date: Tue, 8 Sep 2026 03:07:03 +0300 Subject: [PATCH] =?UTF-8?q?the=20family's=20writes=20move=20behind=20the?= =?UTF-8?q?=20admin=20door:=20the=20Services=20card=20on=20the=20landing?= =?UTF-8?q?=20is=20read-only=20for=20everyone=20=E2=80=94=20cards=20and=20?= =?UTF-8?q?trio,=20nothing=20else=20=E2=80=94=20and=20the=20editing=20grow?= =?UTF-8?q?s=20up=20into=20the=20admin=20panel=20as=20its=20own=20section?= =?UTF-8?q?=20beside=20Users,=20a=20table=20of=20key,=20name=20and=20addre?= =?UTF-8?q?ss=20with=20the=20panel's=20own=20rows,=20edit=20disclosures,?= =?UTF-8?q?=20reorder=20arrows=20and=20confirm-guarded=20removals,=20posti?= =?UTF-8?q?ng=20to=20/admin/services=5F*=20behind=20the=20same=20require?= =?UTF-8?q?=5Fadmin=20as=20every=20other=20panel=20write;=20the=20landing'?= =?UTF-8?q?s=20private=20gate=20and=20its=20/services/*=20routes=20go,=20a?= =?UTF-8?q?nd=20an=20empty=20family=20hides=20the=20card=20entirely,=20the?= =?UTF-8?q?=20panel=20being=20where=20one=20gets=20seeded?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/im-core/src/services.rs | 2 +- crates/im-web/src/admin.rs | 177 ++++++++++++++++++++++++++++++++- crates/im-web/src/auth.rs | 113 --------------------- crates/im-web/src/directory.rs | 59 ++++++----- crates/im-web/src/i18n.rs | 35 +++++++ crates/im-web/src/pages.rs | 68 +------------ 6 files changed, 247 insertions(+), 207 deletions(-) diff --git a/crates/im-core/src/services.rs b/crates/im-core/src/services.rs index b3d3f15..8d5245d 100644 --- a/crates/im-core/src/services.rs +++ b/crates/im-core/src/services.rs @@ -1,7 +1,7 @@ //! The family: the services every topbar shows as wordmarks and the //! landing's services home. The list lives in the database and the admin //! panel owns it — seeded once from the config's `[[services]]` on first -//! boot, edited from the landing (add, rename, reorder, remove), and served +//! boot, edited from the admin panel (add, rename, reorder, remove), and served //! to the sibling apps over `GET /family`, which each mirrors into its own //! database. diff --git a/crates/im-web/src/admin.rs b/crates/im-web/src/admin.rs index 95ebb79..ba6de32 100644 --- a/crates/im-web/src/admin.rs +++ b/crates/im-web/src/admin.rs @@ -1,4 +1,4 @@ -//! The admin panel: users, mail, logs. One page, three sections, every +//! The admin panel: users, services, mail, settings, logs. One page, every //! action a plain form post answering a 303 back to its section — the same //! idiom as izlek-web's settings.rs/logs.rs, minus the client script. @@ -52,6 +52,7 @@ fn escape(raw: &str) -> String { /// and holds the button that actually does it. Works with no script at all; /// the live script adds outside-click closing. fn confirm_action( + field: &str, id: &str, action: &str, word: &str, @@ -61,7 +62,7 @@ fn confirm_action( confirm: &str, ) -> String { format!( - r#"
{word}
{title}
{cost}
"# + r#"
{word}
{title}
{cost}
"# ) } /// The panel's live wiring moved into the shell: `layout::live_script` runs @@ -114,6 +115,7 @@ async fn admin_page(cx: &Cx) -> Result { let nav = |current: &str| { [ ("users", t(lang, Key::NavUsers)), + ("services", t(lang, Key::NavServices)), ("mail", t(lang, Key::NavMail)), ("message", t(lang, Key::NavMessage)), ("settings", t(lang, Key::NavSettings)), @@ -134,6 +136,7 @@ async fn admin_page(cx: &Cx) -> Result { "message" => message_section(cx, lang).await?, "settings" => settings_section(cx, lang).await?, "logs" => logs_section(cx, lang).await?, + "services" => services_section(cx, lang).await?, "users" => users_section(cx, &me, invited.as_deref(), lang).await?, _ => users_section(cx, &me, invited.as_deref(), lang).await?, }; @@ -153,6 +156,7 @@ async fn admin_page(cx: &Cx) -> Result { "uninvited" => t(lang, Key::OkUninvited), "deleted" => t(lang, Key::OkDeleted), "settings" => t(lang, Key::OkSettingsSaved), + "services" => t(lang, Key::OkServicesSaved), _ => t(lang, Key::OkDone), } )), @@ -297,6 +301,7 @@ async fn users_section( // script adds outside-click closing on top. let toggle = if user.disabled { confirm_action( + "user", &id, "/admin/enable", t(lang, Key::EnableWord), @@ -307,6 +312,7 @@ async fn users_section( ) } else { confirm_action( + "user", &id, "/admin/disable", t(lang, Key::DisableWord), @@ -317,6 +323,7 @@ async fn users_section( ) }; let remove = confirm_action( + "user", &id, "/admin/delete", t(lang, Key::DeleteWord), @@ -401,6 +408,172 @@ async fn users_section( )) } +/// The family registry: the wordmarks every topbar's trio and the landing's +/// services home render, and `/family` serves. One table in the panel's own +/// skins — edit and remove as the two-step disclosures, the up/down pair as +/// plain row buttons — and the add line under it wearing the invite form's +/// skin. +async fn services_section(cx: &Cx, lang: i18n::Lang) -> Result { + let services = im_core::services::list(&app(cx).store).await?; + let mut rows = String::new(); + for service in &services { + let key = escape(&service.key); + let name = escape(&service.name); + let url = escape(&service.url); + // The edit disclosure: the opened pop carries the name-and-address + // form; the key travels hidden, like every row's write. + let edit = format!( + r#"
{edit_word}
{edit_title}
"#, + edit_word = t(lang, Key::EditWord), + edit_title = i18n::edit_service_title(lang, &name), + key = key, + name = name, + url = url, + name_label = t(lang, Key::NameCol), + url_label = t(lang, Key::AddressLabel), + save = t(lang, Key::SaveButton), + ); + let up = format!( + r#"
"#, + key = key, + up_label = t(lang, Key::ServiceMoveUp), + ); + let down = format!( + r#"
"#, + key = key, + down_label = t(lang, Key::ServiceMoveDown), + ); + let remove = confirm_action( + "key", + &key, + "/admin/services_remove", + t(lang, Key::Remove), + " admin-danger", + &i18n::remove_service_title(lang, &name), + t(lang, Key::RemoveCost), + t(lang, Key::ConfirmRemove), + ); + rows.push_str(&format!( + r#"{key}{name}{url}{edit}{up}{down}{remove}"#, + )); + } + Ok(format!( + r#"
+
{title}
+
+ + + {rows} +
{key_label}{name_label}{url_label}
+
+
+ + + + +
+
"#, + title = t(lang, Key::ServicesTitle), + key_label = t(lang, Key::ServiceKeyLabel), + name_label = t(lang, Key::NameCol), + url_label = t(lang, Key::AddressLabel), + add = t(lang, Key::ServiceAdd), + )) +} + +/// One user of the services forms: key, name, address. The add form fills +/// all three; the edit form carries the key in its hidden field. +#[derive(Deserialize)] +struct ServiceForm { + key: String, + name: String, + url: String, +} + +#[route(POST "/admin/services_add")] +async fn services_add(cx: &Cx, Form(input): Form) -> Result { + let me = match require_admin(cx).await { + Ok(me) => me, + Err(redirect) => return Ok(redirect), + }; + let outcome = im_core::services::add( + &app(cx).store, + &im_core::services::Service { + key: input.key, + name: input.name, + url: input.url, + }, + ) + .await; + service_outcome(cx, &me, outcome).await +} + +#[route(POST "/admin/services_edit")] +async fn services_edit(cx: &Cx, Form(input): Form) -> Result { + let me = match require_admin(cx).await { + Ok(me) => me, + Err(redirect) => return Ok(redirect), + }; + let outcome = im_core::services::edit(&app(cx).store, &input.key, &input.name, &input.url).await; + service_outcome(cx, &me, outcome).await +} + +#[derive(Deserialize)] +struct ServiceKeyForm { + key: String, +} + +#[route(POST "/admin/services_remove")] +async fn services_remove(cx: &Cx, Form(input): Form) -> Result { + let me = match require_admin(cx).await { + Ok(me) => me, + Err(redirect) => return Ok(redirect), + }; + let outcome = im_core::services::remove(&app(cx).store, &input.key).await; + service_outcome(cx, &me, outcome).await +} + +#[derive(Deserialize)] +struct ServiceMoveForm { + key: String, + dir: String, +} + +/// Up or down one slot; anything else in `dir` is the panel's refusal. +#[route(POST "/admin/services_move")] +async fn services_move(cx: &Cx, Form(input): Form) -> Result { + let me = match require_admin(cx).await { + Ok(me) => me, + Err(redirect) => return Ok(redirect), + }; + let up = match input.dir.as_str() { + "up" => true, + "down" => false, + _ => return back(cx, "services", "&error=bad_service"), + }; + let outcome = im_core::services::move_service(&app(cx).store, &input.key, up).await; + service_outcome(cx, &me, outcome).await +} + +/// The panel's answer to a services write: back to the section with the +/// good news, or with the section's one refusal when the store said the +/// value is against the rules. Anything else is a real failure and travels +/// as one. +async fn service_outcome( + cx: &Cx, + me: &User, + outcome: im_core::store::Result<()>, +) -> Result { + match outcome { + Ok(()) => { + server::log_event(cx, "services_updated", Some(&me.email), None).await; + back(cx, "services", "&ok=services") + } + Err(im_core::store::StoreError::Invalid(_)) => back(cx, "services", "&error=bad_service"), + Err(e) => Err(e.into()), + } +} + /// The knobs the code shipped with, now the panel's: invite and reset link /// lifetimes, the sign-in session's days, the pending marker's minutes, and /// the sign-in failure ceiling. Same form skin as Mail. diff --git a/crates/im-web/src/auth.rs b/crates/im-web/src/auth.rs index 56fc56e..0064fdb 100644 --- a/crates/im-web/src/auth.rs +++ b/crates/im-web/src/auth.rs @@ -324,119 +324,6 @@ async fn logout_return(cx: &Cx) -> Redirect { see(logout_target(back.as_deref(), &services)) } -// --------------------------------------------------------------------------- -// The landing Services card's writes -// --------------------------------------------------------------------------- - -/// The admin behind this request, or `None` — the handlers below send a -/// non-admin to the front door, where the card carries no forms anyway. -/// The admin panel's `require_admin` is the same gate with the same answer. -async fn landing_admin(cx: &Cx) -> Option { - match server::current_user(cx).await { - Some(user) if user.admin => Some(user), - _ => None, - } -} - -/// One user of the card's forms: key, name, address. The add form fills all -/// three; the edit form carries the key in its hidden field. -#[derive(Deserialize)] -pub struct ServiceForm { - key: String, - name: String, - url: String, -} - -/// The landing answer to a services write: back to the card with the good -/// news, or with the card's one refusal when the store said the value is -/// against the rules. Anything else is a real failure and travels as one. -fn service_outcome(outcome: im_core::store::Result<()>) -> Redirect { - match outcome { - Ok(()) => see("/?ok=services".to_string()), - Err(im_core::store::StoreError::Invalid(_)) => see("/?error=bad_service".to_string()), - Err(e) => Err(e.into()), - } -} - -#[route(POST "/services/add")] -async fn service_add(cx: &Cx, Form(input): Form) -> Redirect { - let Some(me) = landing_admin(cx).await else { - return see("/".to_string()); - }; - let outcome = im_core::services::add( - &server::app(cx).store, - &im_core::services::Service { - key: input.key, - name: input.name, - url: input.url, - }, - ) - .await; - if outcome.is_ok() { - server::log_event(cx, "services_updated", Some(&me.email), None).await; - } - service_outcome(outcome) -} - -#[route(POST "/services/edit")] -async fn service_edit(cx: &Cx, Form(input): Form) -> Redirect { - let Some(me) = landing_admin(cx).await else { - return see("/".to_string()); - }; - let outcome = im_core::services::edit( - &server::app(cx).store, - &input.key, - &input.name, - &input.url, - ) - .await; - if outcome.is_ok() { - server::log_event(cx, "services_updated", Some(&me.email), None).await; - } - service_outcome(outcome) -} - -#[derive(Deserialize)] -struct ServiceKeyForm { - key: String, -} - -#[route(POST "/services/remove")] -async fn service_remove(cx: &Cx, Form(input): Form) -> Redirect { - let Some(me) = landing_admin(cx).await else { - return see("/".to_string()); - }; - let outcome = im_core::services::remove(&server::app(cx).store, &input.key).await; - if outcome.is_ok() { - server::log_event(cx, "services_updated", Some(&me.email), None).await; - } - service_outcome(outcome) -} - -#[derive(Deserialize)] -struct ServiceMoveForm { - key: String, - dir: String, -} - -/// Up or down one slot; anything else in `dir` is the card's refusal. -#[route(POST "/services/move")] -async fn service_move(cx: &Cx, Form(input): Form) -> Redirect { - let Some(me) = landing_admin(cx).await else { - return see("/".to_string()); - }; - let up = match input.dir.as_str() { - "up" => true, - "down" => false, - _ => return see("/?error=bad_service".to_string()), - }; - let outcome = im_core::services::move_service(&server::app(cx).store, &input.key, up).await; - if outcome.is_ok() { - server::log_event(cx, "services_updated", Some(&me.email), None).await; - } - service_outcome(outcome) -} - #[derive(Deserialize)] pub struct ForgotForm { email: String, diff --git a/crates/im-web/src/directory.rs b/crates/im-web/src/directory.rs index 78d3415..e818a06 100644 --- a/crates/im-web/src/directory.rs +++ b/crates/im-web/src/directory.rs @@ -506,7 +506,7 @@ mod tests { .unwrap(); let (status, location, _) = post_form( &router, - "/services/add", + "/admin/services_add", "key=wiki&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A99", Some(&format!("{SESSION_COOKIE}={}", ben_session.expose())), ) @@ -514,21 +514,21 @@ mod tests { assert_eq!(status, StatusCode::SEE_OTHER); assert_eq!(location.as_deref(), Some("/")); - // The admin's add lands back on the card, and /family carries the - // new row at the end — trailing slash stored off, like every URL. + // The admin's add lands back on the section, and /family carries + // the new row at the end — trailing slash stored off, like every URL. let session = im_core::sessions::create_session(&store, &ada.id, &Default::default()) .await .unwrap(); let cookie = format!("{SESSION_COOKIE}={}", session.expose()); let (status, location, _) = post_form( &router, - "/services/add", + "/admin/services_add", "key=wiki&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A99%2F", Some(&cookie), ) .await; assert_eq!(status, StatusCode::SEE_OTHER); - assert_eq!(location.as_deref(), Some("/?ok=services")); + assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services")); let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; let family = serde_json::from_str::(&body).unwrap(); let family = family.as_array().unwrap(); @@ -538,33 +538,39 @@ mod tests { .collect::>(); assert_eq!(keys, vec!["in", "im", "iz", "wiki"], "{body}"); assert_eq!(family[3]["url"], "http://127.0.0.1:99"); + // The forms live on the panel's Services section now. + let panel = get_page(&router, "/admin?section=services", &cookie).await; + assert!(panel.contains(r#"action="/admin/services_add""#)); + assert!(panel.contains(r#"action="/admin/services_edit""#)); + // The landing is the read-only directory, admins included. assert!( - get_page(&router, "/?section=profile", &cookie) + !get_page(&router, "/?section=profile", &cookie) .await - .contains(r#"action="/services/add""#) - ); - assert!( - !get_page( - &router, - "/?section=profile", - &format!("{SESSION_COOKIE}={}", ben_session.expose()) - ) - .await - .contains(r#"action="/services/add""#) + .contains(r#"action="/admin/services_add""#) ); + // And a non-admin cannot open the section at all — the panel's + // front-door redirect, like every admin page. + let (status, location) = get_location( + &router, + "/admin?section=services", + &format!("{SESSION_COOKIE}={}", ben_session.expose()), + ) + .await; + assert_eq!(status, StatusCode::SEE_OTHER); + assert_eq!(location.as_deref(), Some("/")); // Edit rewrites name and address; move up swaps with the neighbor. let (_status, location, _) = post_form( &router, - "/services/edit", + "/admin/services_edit", "key=wiki&name=Docs&url=http%3A%2F%2F127.0.0.1%3A98", Some(&cookie), ) .await; - assert_eq!(location.as_deref(), Some("/?ok=services")); + assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services")); let (_status, location, _) = - post_form(&router, "/services/move", "key=wiki&dir=up", Some(&cookie)).await; - assert_eq!(location.as_deref(), Some("/?ok=services")); + post_form(&router, "/admin/services_move", "key=wiki&dir=up", Some(&cookie)).await; + assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services")); let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; let family = serde_json::from_str::(&body).unwrap(); let family = family.as_array().unwrap(); @@ -592,8 +598,8 @@ mod tests { // And once the row is gone, the same origin is refused to the door. let (_status, location, _) = - post_form(&router, "/services/remove", "key=wiki", Some(&cookie)).await; - assert_eq!(location.as_deref(), Some("/?ok=services")); + post_form(&router, "/admin/services_remove", "key=wiki", Some(&cookie)).await; + assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services")); let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; let family = serde_json::from_str::(&body).unwrap(); let keys = family @@ -614,18 +620,21 @@ mod tests { .await; assert_eq!(location.as_deref(), Some("/")); - // A value against the rules is the card's refusal, not a write. + // A value against the rules is the panel's refusal, not a write. let bad_session = im_core::sessions::create_session(&store, &ada.id, &Default::default()) .await .unwrap(); let (_status, location, _) = post_form( &router, - "/services/add", + "/admin/services_add", "key=Wiki!&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A97", Some(&format!("{SESSION_COOKIE}={}", bad_session.expose())), ) .await; - assert_eq!(location.as_deref(), Some("/?error=bad_service")); + assert_eq!( + location.as_deref(), + Some("/admin?section=services&error=bad_service") + ); let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; assert_eq!( serde_json::from_str::(&body) diff --git a/crates/im-web/src/i18n.rs b/crates/im-web/src/i18n.rs index fdffc37..53ed129 100644 --- a/crates/im-web/src/i18n.rs +++ b/crates/im-web/src/i18n.rs @@ -151,6 +151,7 @@ pub enum Key { NavSettings, NavLogs, NavMessage, + NavServices, OkInvited, OkRevoked, OkDisabled, @@ -160,6 +161,7 @@ pub enum Key { OkUninvited, OkDeleted, OkSettingsSaved, + OkServicesSaved, OkMessageSent, // Admin mail section: the composed notice. @@ -202,12 +204,15 @@ pub enum Key { EnableWord, DisableWord, DeleteWord, + EditWord, ConfirmEnable, ConfirmDisable, ConfirmDelete, + ConfirmRemove, EnableCost, DisableCost, DeleteCost, + RemoveCost, InvalidateButton, InviteLinkNote, PeopleTitle, @@ -504,6 +509,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (NavLogs, Tr) => "Kayıtlar", (NavMessage, En) => "Message", (NavMessage, Tr) => "Mesaj", + (NavServices, En) => "Services", + (NavServices, Tr) => "Hizmetler", (OkInvited, En) => "Invite created.", (OkInvited, Tr) => "Davet oluşturuldu.", (OkRevoked, En) => "Sessions revoked — every device is signed out.", @@ -522,6 +529,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (OkDeleted, Tr) => "Hesap silindi.", (OkSettingsSaved, En) => "Settings saved.", (OkSettingsSaved, Tr) => "Ayarlar kaydedildi.", + (OkServicesSaved, En) => "Services saved.", + (OkServicesSaved, Tr) => "Hizmetler kaydedildi.", (OkMessageSent, En) => "Message sent.", (OkMessageSent, Tr) => "Mesaj gönderildi.", @@ -596,12 +605,16 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (DisableWord, Tr) => "Devre dışı bırak", (DeleteWord, En) => "Delete", (DeleteWord, Tr) => "Sil", + (EditWord, En) => "Edit", + (EditWord, Tr) => "Düzenle", (ConfirmEnable, En) => "Confirm enable", (ConfirmEnable, Tr) => "Etkinleştirmeyi onayla", (ConfirmDisable, En) => "Confirm disable", (ConfirmDisable, Tr) => "Devre dışı bırakmayı onayla", (ConfirmDelete, En) => "Confirm delete", (ConfirmDelete, Tr) => "Silmeyi onayla", + (ConfirmRemove, En) => "Confirm remove", + (ConfirmRemove, Tr) => "Kaldırmayı onayla", (EnableCost, En) => "They can sign in again.", (EnableCost, Tr) => "Tekrar giriş yapabilir.", (DisableCost, En) => "They cannot sign in, and every live session ends.", @@ -612,6 +625,12 @@ pub fn t(lang: Lang, key: Key) -> &'static str { (DeleteCost, Tr) => { "Hesap, oturumları ve tüm uygulama jetonlarıyla birlikte silinir. Adres, yeni biri olarak tekrar davet edilebilir." } + (RemoveCost, En) => { + "The row leaves the family list, and every sibling drops it at its next /family read." + } + (RemoveCost, Tr) => { + "Satır aile listesinden çıkar; her kardeş uygulama bir sonraki /family okumasında düşürür." + } (InvalidateButton, En) => "Invalidate", (InvalidateButton, Tr) => "Geçersiz kıl", (InviteLinkNote, En) => "The link exists once. It is shown once:", @@ -857,6 +876,22 @@ pub fn delete_title(lang: Lang, email_html: &str) -> String { } } +/// See [`enable_title`]. +pub fn edit_service_title(lang: Lang, name_html: &str) -> String { + match lang { + Lang::En => format!("Edit {name_html}?"), + Lang::Tr => format!("{name_html} düzenlensin mi?"), + } +} + +/// See [`enable_title`]. +pub fn remove_service_title(lang: Lang, name_html: &str) -> String { + match lang { + Lang::En => format!("Remove {name_html}?"), + Lang::Tr => format!("{name_html} kaldırılsın mı?"), + } +} + /// The mail section's lede: what the sender is for. The mono span is markup. pub fn mail_sub(lang: Lang) -> String { match lang { diff --git a/crates/im-web/src/pages.rs b/crates/im-web/src/pages.rs index c650e29..3938086 100644 --- a/crates/im-web/src/pages.rs +++ b/crates/im-web/src/pages.rs @@ -60,7 +60,6 @@ pub fn ok_text(code: &str, lang: Lang) -> &'static str { "photo_removed" => t(lang, Key::OkPhotoRemoved), "session_revoked" => t(lang, Key::OkSessionRevoked), "preferences" => t(lang, Key::Saved), - "services" => t(lang, Key::Saved), "password" => t(lang, Key::PasswordSaved), _ => t(lang, Key::OkDone), } @@ -607,7 +606,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { // the whole card the link. im's own card reads current. Above the // profile sections: im is the account center, and its landing is the // door to the rest. The list is the stored one — the rows `/family` - // serves — and an admin gets the handles on it right under the cards. + // serves — read-only here; the admin edits it from the panel. let services = im_core::services::list(&server::app(cx).store).await?; let services_html = services .iter() @@ -626,11 +625,6 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { ) }) .collect::(); - let services_manage = if user.admin { - services_manage_html(&services, lang) - } else { - String::new() - }; let stage = view! { cx =>
@@ -638,11 +632,10 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { (wordmark(cx).await?) (service_trio(cx).await?) - if !services_html.is_empty() || user.admin { + if !services_html.is_empty() {
(t(lang, Key::ServicesTitle))
(topcoat::view::Unescaped::new_unchecked(services_html))
- (topcoat::view::Unescaped::new_unchecked(services_manage))
} if let Some(code) = ok { @@ -854,63 +847,6 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { shell(cx, "im", Some(user), stage).await } -/// The admin's handles under the services grid: a name-and-address edit per -/// row, the up/down pair, the remove, and the add form. Every action is a -/// plain form post answering a 303 back to this card — the landing idiom — -/// wearing the admin panel's quiet row-button skin, laid out by the same -/// flex row the panel's invite line uses. -fn services_manage_html(services: &[im_core::services::Service], lang: Lang) -> String { - let mut rows = String::new(); - for service in services { - let key = escape(&service.key); - rows.push_str(&format!( - r#"
-
- - - - -
-
- - -
-
- - -
-
- - -
-
"#, - name = escape(&service.name), - url = escape(&service.url), - name_label = t(lang, Key::NameCol), - url_label = t(lang, Key::AddressLabel), - save = t(lang, Key::SaveButton), - up = t(lang, Key::ServiceMoveUp), - down = t(lang, Key::ServiceMoveDown), - remove = t(lang, Key::Remove), - )); - } - rows.push_str(&format!( - r#"
-
- - - - -
-
"#, - key_label = t(lang, Key::ServiceKeyLabel), - name_label = t(lang, Key::NameCol), - url_label = t(lang, Key::AddressLabel), - add = t(lang, Key::ServiceAdd), - )); - rows -} - /// "Forgot it?" — the self-serve reset ask. It answers the same whether the /// address has an account: one quiet note, the same one for every address. #[page("/forgot")]