forge
Explore
Log in

Don't you dare go Hollow

the family's writes move behind the admin door: the Services card on the landing is read-only for everyone — cards and trio, nothing else — and the editing grows up into the admin panel as its own section beside Users, a table of key, name and address with the panel's own rows, edit disclosures, reorder arrows and confirm-guarded removals, posting to /admin/services_* behind the same require_admin as every other panel write; the landing's private gate and its /services/* routes go, and an empty family hides the card entirely, the panel being where one gets seeded

Browse files at this commit

faf28868c99c9e669da0e8765d701abb3bd75f9bAhmet Kaan GümüşParent: 0c0ea32
crates/im-core/src/services.rsmodified+1 -1
@@ -1,7 +1,7 @@
11 //! The family: the services every topbar shows as wordmarks and the
22 //! landing's services home. The list lives in the database and the admin
33 //! panel owns it — seeded once from the config's `[[services]]` on first
4-//! boot, edited from the landing (add, rename, reorder, remove), and served
4+//! boot, edited from the admin panel (add, rename, reorder, remove), and served
55 //! to the sibling apps over `GET /family`, which each mirrors into its own
66 //! database.
77
crates/im-web/src/admin.rsmodified+175 -2
@@ -1,4 +1,4 @@
1-//! The admin panel: users, mail, logs. One page, three sections, every
1+//! The admin panel: users, services, mail, settings, logs. One page, every
22 //! action a plain form post answering a 303 back to its section — the same
33 //! idiom as izlek-web's settings.rs/logs.rs, minus the client script.
44
@@ -52,6 +52,7 @@ fn escape(raw: &str) -> String {
5252 /// and holds the button that actually does it. Works with no script at all;
5353 /// the live script adds outside-click closing.
5454 fn confirm_action(
55+ field: &str,
5556 id: &str,
5657 action: &str,
5758 word: &str,
@@ -61,7 +62,7 @@ fn confirm_action(
6162 confirm: &str,
6263 ) -> String {
6364 format!(
64- r#"<details class="admin-confirm"><summary class="admin-action{extra_class}">{word}</summary><div class="admin-confirm-pop"><div class="admin-confirm-title">{title}</div><div class="muted">{cost}</div><form method="post" action="{action}"><input type="hidden" name="user" value="{id}"><button class="admin-action{extra_class}" type="submit">{confirm}</button></form></div></details>"#
65+ r#"<details class="admin-confirm"><summary class="admin-action{extra_class}">{word}</summary><div class="admin-confirm-pop"><div class="admin-confirm-title">{title}</div><div class="muted">{cost}</div><form method="post" action="{action}"><input type="hidden" name="{field}" value="{id}"><button class="admin-action{extra_class}" type="submit">{confirm}</button></form></div></details>"#
6566 )
6667 }
6768 /// The panel's live wiring moved into the shell: `layout::live_script` runs
@@ -114,6 +115,7 @@ async fn admin_page(cx: &Cx) -> Result<Response> {
114115 let nav = |current: &str| {
115116 [
116117 ("users", t(lang, Key::NavUsers)),
118+ ("services", t(lang, Key::NavServices)),
117119 ("mail", t(lang, Key::NavMail)),
118120 ("message", t(lang, Key::NavMessage)),
119121 ("settings", t(lang, Key::NavSettings)),
@@ -134,6 +136,7 @@ async fn admin_page(cx: &Cx) -> Result<Response> {
134136 "message" => message_section(cx, lang).await?,
135137 "settings" => settings_section(cx, lang).await?,
136138 "logs" => logs_section(cx, lang).await?,
139+ "services" => services_section(cx, lang).await?,
137140 "users" => users_section(cx, &me, invited.as_deref(), lang).await?,
138141 _ => users_section(cx, &me, invited.as_deref(), lang).await?,
139142 };
@@ -153,6 +156,7 @@ async fn admin_page(cx: &Cx) -> Result<Response> {
153156 "uninvited" => t(lang, Key::OkUninvited),
154157 "deleted" => t(lang, Key::OkDeleted),
155158 "settings" => t(lang, Key::OkSettingsSaved),
159+ "services" => t(lang, Key::OkServicesSaved),
156160 _ => t(lang, Key::OkDone),
157161 }
158162 )),
@@ -297,6 +301,7 @@ async fn users_section(
297301 // script adds outside-click closing on top.
298302 let toggle = if user.disabled {
299303 confirm_action(
304+ "user",
300305 &id,
301306 "/admin/enable",
302307 t(lang, Key::EnableWord),
@@ -307,6 +312,7 @@ async fn users_section(
307312 )
308313 } else {
309314 confirm_action(
315+ "user",
310316 &id,
311317 "/admin/disable",
312318 t(lang, Key::DisableWord),
@@ -317,6 +323,7 @@ async fn users_section(
317323 )
318324 };
319325 let remove = confirm_action(
326+ "user",
320327 &id,
321328 "/admin/delete",
322329 t(lang, Key::DeleteWord),
@@ -401,6 +408,172 @@ async fn users_section(
401408 ))
402409 }
403410
411+/// The family registry: the wordmarks every topbar's trio and the landing's
412+/// services home render, and `/family` serves. One table in the panel's own
413+/// skins — edit and remove as the two-step disclosures, the up/down pair as
414+/// plain row buttons — and the add line under it wearing the invite form's
415+/// skin.
416+async fn services_section(cx: &Cx, lang: i18n::Lang) -> Result<String, topcoat::Error> {
417+ let services = im_core::services::list(&app(cx).store).await?;
418+ let mut rows = String::new();
419+ for service in &services {
420+ let key = escape(&service.key);
421+ let name = escape(&service.name);
422+ let url = escape(&service.url);
423+ // The edit disclosure: the opened pop carries the name-and-address
424+ // form; the key travels hidden, like every row's write.
425+ let edit = format!(
426+ r#"<details class="admin-confirm"><summary class="admin-action">{edit_word}</summary><div class="admin-confirm-pop"><div class="admin-confirm-title">{edit_title}</div><form method="post" action="/admin/services_edit" class="admin-form"><input type="hidden" name="key" value="{key}"><label class="auth-field"><span class="auth-label">{name_label}</span><input class="auth-input auth-input-mono" type="text" name="name" value="{name}" required></label><label class="auth-field"><span class="auth-label">{url_label}</span><input class="auth-input auth-input-mono" type="text" name="url" value="{url}" required></label><button class="admin-action" type="submit">{save}</button></form></div></details>"#,
427+ edit_word = t(lang, Key::EditWord),
428+ edit_title = i18n::edit_service_title(lang, &name),
429+ key = key,
430+ name = name,
431+ url = url,
432+ name_label = t(lang, Key::NameCol),
433+ url_label = t(lang, Key::AddressLabel),
434+ save = t(lang, Key::SaveButton),
435+ );
436+ let up = format!(
437+ r#"<form method="post" action="/admin/services_move"><input type="hidden" name="key" value="{key}"><input type="hidden" name="dir" value="up"><button class="admin-action" type="submit" aria-label="{up_label}">&#8593;</button></form>"#,
438+ key = key,
439+ up_label = t(lang, Key::ServiceMoveUp),
440+ );
441+ let down = format!(
442+ r#"<form method="post" action="/admin/services_move"><input type="hidden" name="key" value="{key}"><input type="hidden" name="dir" value="down"><button class="admin-action" type="submit" aria-label="{down_label}">&#8595;</button></form>"#,
443+ key = key,
444+ down_label = t(lang, Key::ServiceMoveDown),
445+ );
446+ let remove = confirm_action(
447+ "key",
448+ &key,
449+ "/admin/services_remove",
450+ t(lang, Key::Remove),
451+ " admin-danger",
452+ &i18n::remove_service_title(lang, &name),
453+ t(lang, Key::RemoveCost),
454+ t(lang, Key::ConfirmRemove),
455+ );
456+ rows.push_str(&format!(
457+ r#"<tr><td class="mono">{key}</td><td>{name}</td><td class="mono">{url}</td><td class="actions">{edit}{up}{down}{remove}</td></tr>"#,
458+ ));
459+ }
460+ Ok(format!(
461+ r#"<div class="admin-card">
462+ <div class="auth-title">{title}</div>
463+ <div class="admin-table-wrap">
464+ <table class="admin-table">
465+ <thead><tr><th>{key_label}</th><th>{name_label}</th><th>{url_label}</th><th></th></tr></thead>
466+ <tbody>{rows}</tbody>
467+ </table>
468+ </div>
469+ <form method="post" action="/admin/services_add" class="admin-invite">
470+ <input class="auth-input auth-input-mono" type="text" name="key" placeholder="in" aria-label="{key_label}" required>
471+ <input class="auth-input" type="text" name="name" placeholder="{name_label}" aria-label="{name_label}" required>
472+ <input class="auth-input auth-input-mono" type="text" name="url" placeholder="https://in.dizey.sh" aria-label="{url_label}" required>
473+ <button class="auth-submit admin-invite-go" type="submit"><span class="auth-submit-text">{add}</span></button>
474+ </form>
475+</div>"#,
476+ title = t(lang, Key::ServicesTitle),
477+ key_label = t(lang, Key::ServiceKeyLabel),
478+ name_label = t(lang, Key::NameCol),
479+ url_label = t(lang, Key::AddressLabel),
480+ add = t(lang, Key::ServiceAdd),
481+ ))
482+}
483+
484+/// One user of the services forms: key, name, address. The add form fills
485+/// all three; the edit form carries the key in its hidden field.
486+#[derive(Deserialize)]
487+struct ServiceForm {
488+ key: String,
489+ name: String,
490+ url: String,
491+}
492+
493+#[route(POST "/admin/services_add")]
494+async fn services_add(cx: &Cx, Form(input): Form<ServiceForm>) -> Result<Response> {
495+ let me = match require_admin(cx).await {
496+ Ok(me) => me,
497+ Err(redirect) => return Ok(redirect),
498+ };
499+ let outcome = im_core::services::add(
500+ &app(cx).store,
501+ &im_core::services::Service {
502+ key: input.key,
503+ name: input.name,
504+ url: input.url,
505+ },
506+ )
507+ .await;
508+ service_outcome(cx, &me, outcome).await
509+}
510+
511+#[route(POST "/admin/services_edit")]
512+async fn services_edit(cx: &Cx, Form(input): Form<ServiceForm>) -> Result<Response> {
513+ let me = match require_admin(cx).await {
514+ Ok(me) => me,
515+ Err(redirect) => return Ok(redirect),
516+ };
517+ let outcome = im_core::services::edit(&app(cx).store, &input.key, &input.name, &input.url).await;
518+ service_outcome(cx, &me, outcome).await
519+}
520+
521+#[derive(Deserialize)]
522+struct ServiceKeyForm {
523+ key: String,
524+}
525+
526+#[route(POST "/admin/services_remove")]
527+async fn services_remove(cx: &Cx, Form(input): Form<ServiceKeyForm>) -> Result<Response> {
528+ let me = match require_admin(cx).await {
529+ Ok(me) => me,
530+ Err(redirect) => return Ok(redirect),
531+ };
532+ let outcome = im_core::services::remove(&app(cx).store, &input.key).await;
533+ service_outcome(cx, &me, outcome).await
534+}
535+
536+#[derive(Deserialize)]
537+struct ServiceMoveForm {
538+ key: String,
539+ dir: String,
540+}
541+
542+/// Up or down one slot; anything else in `dir` is the panel's refusal.
543+#[route(POST "/admin/services_move")]
544+async fn services_move(cx: &Cx, Form(input): Form<ServiceMoveForm>) -> Result<Response> {
545+ let me = match require_admin(cx).await {
546+ Ok(me) => me,
547+ Err(redirect) => return Ok(redirect),
548+ };
549+ let up = match input.dir.as_str() {
550+ "up" => true,
551+ "down" => false,
552+ _ => return back(cx, "services", "&error=bad_service"),
553+ };
554+ let outcome = im_core::services::move_service(&app(cx).store, &input.key, up).await;
555+ service_outcome(cx, &me, outcome).await
556+}
557+
558+/// The panel's answer to a services write: back to the section with the
559+/// good news, or with the section's one refusal when the store said the
560+/// value is against the rules. Anything else is a real failure and travels
561+/// as one.
562+async fn service_outcome(
563+ cx: &Cx,
564+ me: &User,
565+ outcome: im_core::store::Result<()>,
566+) -> Result<Response> {
567+ match outcome {
568+ Ok(()) => {
569+ server::log_event(cx, "services_updated", Some(&me.email), None).await;
570+ back(cx, "services", "&ok=services")
571+ }
572+ Err(im_core::store::StoreError::Invalid(_)) => back(cx, "services", "&error=bad_service"),
573+ Err(e) => Err(e.into()),
574+ }
575+}
576+
404577 /// The knobs the code shipped with, now the panel's: invite and reset link
405578 /// lifetimes, the sign-in session's days, the pending marker's minutes, and
406579 /// the sign-in failure ceiling. Same form skin as Mail.
crates/im-web/src/auth.rsmodified+0 -113
@@ -324,119 +324,6 @@ async fn logout_return(cx: &Cx) -> Redirect {
324324 see(logout_target(back.as_deref(), &services))
325325 }
326326
327-// ---------------------------------------------------------------------------
328-// The landing Services card's writes
329-// ---------------------------------------------------------------------------
330-
331-/// The admin behind this request, or `None` — the handlers below send a
332-/// non-admin to the front door, where the card carries no forms anyway.
333-/// The admin panel's `require_admin` is the same gate with the same answer.
334-async fn landing_admin(cx: &Cx) -> Option<im_core::model::User> {
335- match server::current_user(cx).await {
336- Some(user) if user.admin => Some(user),
337- _ => None,
338- }
339-}
340-
341-/// One user of the card's forms: key, name, address. The add form fills all
342-/// three; the edit form carries the key in its hidden field.
343-#[derive(Deserialize)]
344-pub struct ServiceForm {
345- key: String,
346- name: String,
347- url: String,
348-}
349-
350-/// The landing answer to a services write: back to the card with the good
351-/// news, or with the card's one refusal when the store said the value is
352-/// against the rules. Anything else is a real failure and travels as one.
353-fn service_outcome(outcome: im_core::store::Result<()>) -> Redirect {
354- match outcome {
355- Ok(()) => see("/?ok=services".to_string()),
356- Err(im_core::store::StoreError::Invalid(_)) => see("/?error=bad_service".to_string()),
357- Err(e) => Err(e.into()),
358- }
359-}
360-
361-#[route(POST "/services/add")]
362-async fn service_add(cx: &Cx, Form(input): Form<ServiceForm>) -> Redirect {
363- let Some(me) = landing_admin(cx).await else {
364- return see("/".to_string());
365- };
366- let outcome = im_core::services::add(
367- &server::app(cx).store,
368- &im_core::services::Service {
369- key: input.key,
370- name: input.name,
371- url: input.url,
372- },
373- )
374- .await;
375- if outcome.is_ok() {
376- server::log_event(cx, "services_updated", Some(&me.email), None).await;
377- }
378- service_outcome(outcome)
379-}
380-
381-#[route(POST "/services/edit")]
382-async fn service_edit(cx: &Cx, Form(input): Form<ServiceForm>) -> Redirect {
383- let Some(me) = landing_admin(cx).await else {
384- return see("/".to_string());
385- };
386- let outcome = im_core::services::edit(
387- &server::app(cx).store,
388- &input.key,
389- &input.name,
390- &input.url,
391- )
392- .await;
393- if outcome.is_ok() {
394- server::log_event(cx, "services_updated", Some(&me.email), None).await;
395- }
396- service_outcome(outcome)
397-}
398-
399-#[derive(Deserialize)]
400-struct ServiceKeyForm {
401- key: String,
402-}
403-
404-#[route(POST "/services/remove")]
405-async fn service_remove(cx: &Cx, Form(input): Form<ServiceKeyForm>) -> Redirect {
406- let Some(me) = landing_admin(cx).await else {
407- return see("/".to_string());
408- };
409- let outcome = im_core::services::remove(&server::app(cx).store, &input.key).await;
410- if outcome.is_ok() {
411- server::log_event(cx, "services_updated", Some(&me.email), None).await;
412- }
413- service_outcome(outcome)
414-}
415-
416-#[derive(Deserialize)]
417-struct ServiceMoveForm {
418- key: String,
419- dir: String,
420-}
421-
422-/// Up or down one slot; anything else in `dir` is the card's refusal.
423-#[route(POST "/services/move")]
424-async fn service_move(cx: &Cx, Form(input): Form<ServiceMoveForm>) -> Redirect {
425- let Some(me) = landing_admin(cx).await else {
426- return see("/".to_string());
427- };
428- let up = match input.dir.as_str() {
429- "up" => true,
430- "down" => false,
431- _ => return see("/?error=bad_service".to_string()),
432- };
433- let outcome = im_core::services::move_service(&server::app(cx).store, &input.key, up).await;
434- if outcome.is_ok() {
435- server::log_event(cx, "services_updated", Some(&me.email), None).await;
436- }
437- service_outcome(outcome)
438-}
439-
440327 #[derive(Deserialize)]
441328 pub struct ForgotForm {
442329 email: String,
crates/im-web/src/directory.rsmodified+34 -25
@@ -506,7 +506,7 @@ mod tests {
506506 .unwrap();
507507 let (status, location, _) = post_form(
508508 &router,
509- "/services/add",
509+ "/admin/services_add",
510510 "key=wiki&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A99",
511511 Some(&format!("{SESSION_COOKIE}={}", ben_session.expose())),
512512 )
@@ -514,21 +514,21 @@ mod tests {
514514 assert_eq!(status, StatusCode::SEE_OTHER);
515515 assert_eq!(location.as_deref(), Some("/"));
516516
517- // The admin's add lands back on the card, and /family carries the
518- // new row at the end — trailing slash stored off, like every URL.
517+ // The admin's add lands back on the section, and /family carries
518+ // the new row at the end — trailing slash stored off, like every URL.
519519 let session = im_core::sessions::create_session(&store, &ada.id, &Default::default())
520520 .await
521521 .unwrap();
522522 let cookie = format!("{SESSION_COOKIE}={}", session.expose());
523523 let (status, location, _) = post_form(
524524 &router,
525- "/services/add",
525+ "/admin/services_add",
526526 "key=wiki&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A99%2F",
527527 Some(&cookie),
528528 )
529529 .await;
530530 assert_eq!(status, StatusCode::SEE_OTHER);
531- assert_eq!(location.as_deref(), Some("/?ok=services"));
531+ assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services"));
532532 let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await;
533533 let family = serde_json::from_str::<serde_json::Value>(&body).unwrap();
534534 let family = family.as_array().unwrap();
@@ -538,33 +538,39 @@ mod tests {
538538 .collect::<Vec<_>>();
539539 assert_eq!(keys, vec!["in", "im", "iz", "wiki"], "{body}");
540540 assert_eq!(family[3]["url"], "http://127.0.0.1:99");
541+ // The forms live on the panel's Services section now.
542+ let panel = get_page(&router, "/admin?section=services", &cookie).await;
543+ assert!(panel.contains(r#"action="/admin/services_add""#));
544+ assert!(panel.contains(r#"action="/admin/services_edit""#));
545+ // The landing is the read-only directory, admins included.
541546 assert!(
542- get_page(&router, "/?section=profile", &cookie)
547+ !get_page(&router, "/?section=profile", &cookie)
543548 .await
544- .contains(r#"action="/services/add""#)
545- );
546- assert!(
547- !get_page(
548- &router,
549- "/?section=profile",
550- &format!("{SESSION_COOKIE}={}", ben_session.expose())
551- )
552- .await
553- .contains(r#"action="/services/add""#)
549+ .contains(r#"action="/admin/services_add""#)
554550 );
551+ // And a non-admin cannot open the section at all — the panel's
552+ // front-door redirect, like every admin page.
553+ let (status, location) = get_location(
554+ &router,
555+ "/admin?section=services",
556+ &format!("{SESSION_COOKIE}={}", ben_session.expose()),
557+ )
558+ .await;
559+ assert_eq!(status, StatusCode::SEE_OTHER);
560+ assert_eq!(location.as_deref(), Some("/"));
555561
556562 // Edit rewrites name and address; move up swaps with the neighbor.
557563 let (_status, location, _) = post_form(
558564 &router,
559- "/services/edit",
565+ "/admin/services_edit",
560566 "key=wiki&name=Docs&url=http%3A%2F%2F127.0.0.1%3A98",
561567 Some(&cookie),
562568 )
563569 .await;
564- assert_eq!(location.as_deref(), Some("/?ok=services"));
570+ assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services"));
565571 let (_status, location, _) =
566- post_form(&router, "/services/move", "key=wiki&dir=up", Some(&cookie)).await;
567- assert_eq!(location.as_deref(), Some("/?ok=services"));
572+ post_form(&router, "/admin/services_move", "key=wiki&dir=up", Some(&cookie)).await;
573+ assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services"));
568574 let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await;
569575 let family = serde_json::from_str::<serde_json::Value>(&body).unwrap();
570576 let family = family.as_array().unwrap();
@@ -592,8 +598,8 @@ mod tests {
592598
593599 // And once the row is gone, the same origin is refused to the door.
594600 let (_status, location, _) =
595- post_form(&router, "/services/remove", "key=wiki", Some(&cookie)).await;
596- assert_eq!(location.as_deref(), Some("/?ok=services"));
601+ post_form(&router, "/admin/services_remove", "key=wiki", Some(&cookie)).await;
602+ assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services"));
597603 let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await;
598604 let family = serde_json::from_str::<serde_json::Value>(&body).unwrap();
599605 let keys = family
@@ -614,18 +620,21 @@ mod tests {
614620 .await;
615621 assert_eq!(location.as_deref(), Some("/"));
616622
617- // A value against the rules is the card's refusal, not a write.
623+ // A value against the rules is the panel's refusal, not a write.
618624 let bad_session = im_core::sessions::create_session(&store, &ada.id, &Default::default())
619625 .await
620626 .unwrap();
621627 let (_status, location, _) = post_form(
622628 &router,
623- "/services/add",
629+ "/admin/services_add",
624630 "key=Wiki!&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A97",
625631 Some(&format!("{SESSION_COOKIE}={}", bad_session.expose())),
626632 )
627633 .await;
628- assert_eq!(location.as_deref(), Some("/?error=bad_service"));
634+ assert_eq!(
635+ location.as_deref(),
636+ Some("/admin?section=services&error=bad_service")
637+ );
629638 let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await;
630639 assert_eq!(
631640 serde_json::from_str::<serde_json::Value>(&body)
crates/im-web/src/i18n.rsmodified+35 -0
@@ -151,6 +151,7 @@ pub enum Key {
151151 NavSettings,
152152 NavLogs,
153153 NavMessage,
154+ NavServices,
154155 OkInvited,
155156 OkRevoked,
156157 OkDisabled,
@@ -160,6 +161,7 @@ pub enum Key {
160161 OkUninvited,
161162 OkDeleted,
162163 OkSettingsSaved,
164+ OkServicesSaved,
163165 OkMessageSent,
164166
165167 // Admin mail section: the composed notice.
@@ -202,12 +204,15 @@ pub enum Key {
202204 EnableWord,
203205 DisableWord,
204206 DeleteWord,
207+ EditWord,
205208 ConfirmEnable,
206209 ConfirmDisable,
207210 ConfirmDelete,
211+ ConfirmRemove,
208212 EnableCost,
209213 DisableCost,
210214 DeleteCost,
215+ RemoveCost,
211216 InvalidateButton,
212217 InviteLinkNote,
213218 PeopleTitle,
@@ -504,6 +509,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
504509 (NavLogs, Tr) => "Kayıtlar",
505510 (NavMessage, En) => "Message",
506511 (NavMessage, Tr) => "Mesaj",
512+ (NavServices, En) => "Services",
513+ (NavServices, Tr) => "Hizmetler",
507514 (OkInvited, En) => "Invite created.",
508515 (OkInvited, Tr) => "Davet oluşturuldu.",
509516 (OkRevoked, En) => "Sessions revoked — every device is signed out.",
@@ -522,6 +529,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
522529 (OkDeleted, Tr) => "Hesap silindi.",
523530 (OkSettingsSaved, En) => "Settings saved.",
524531 (OkSettingsSaved, Tr) => "Ayarlar kaydedildi.",
532+ (OkServicesSaved, En) => "Services saved.",
533+ (OkServicesSaved, Tr) => "Hizmetler kaydedildi.",
525534 (OkMessageSent, En) => "Message sent.",
526535 (OkMessageSent, Tr) => "Mesaj gönderildi.",
527536
@@ -596,12 +605,16 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
596605 (DisableWord, Tr) => "Devre dışı bırak",
597606 (DeleteWord, En) => "Delete",
598607 (DeleteWord, Tr) => "Sil",
608+ (EditWord, En) => "Edit",
609+ (EditWord, Tr) => "Düzenle",
599610 (ConfirmEnable, En) => "Confirm enable",
600611 (ConfirmEnable, Tr) => "Etkinleştirmeyi onayla",
601612 (ConfirmDisable, En) => "Confirm disable",
602613 (ConfirmDisable, Tr) => "Devre dışı bırakmayı onayla",
603614 (ConfirmDelete, En) => "Confirm delete",
604615 (ConfirmDelete, Tr) => "Silmeyi onayla",
616+ (ConfirmRemove, En) => "Confirm remove",
617+ (ConfirmRemove, Tr) => "Kaldırmayı onayla",
605618 (EnableCost, En) => "They can sign in again.",
606619 (EnableCost, Tr) => "Tekrar giriş yapabilir.",
607620 (DisableCost, En) => "They cannot sign in, and every live session ends.",
@@ -612,6 +625,12 @@ pub fn t(lang: Lang, key: Key) -> &'static str {
612625 (DeleteCost, Tr) => {
613626 "Hesap, oturumları ve tüm uygulama jetonlarıyla birlikte silinir. Adres, yeni biri olarak tekrar davet edilebilir."
614627 }
628+ (RemoveCost, En) => {
629+ "The row leaves the family list, and every sibling drops it at its next /family read."
630+ }
631+ (RemoveCost, Tr) => {
632+ "Satır aile listesinden çıkar; her kardeş uygulama bir sonraki /family okumasında düşürür."
633+ }
615634 (InvalidateButton, En) => "Invalidate",
616635 (InvalidateButton, Tr) => "Geçersiz kıl",
617636 (InviteLinkNote, En) => "The link exists once. It is shown once:",
@@ -857,6 +876,22 @@ pub fn delete_title(lang: Lang, email_html: &str) -> String {
857876 }
858877 }
859878
879+/// See [`enable_title`].
880+pub fn edit_service_title(lang: Lang, name_html: &str) -> String {
881+ match lang {
882+ Lang::En => format!("Edit {name_html}?"),
883+ Lang::Tr => format!("{name_html} düzenlensin mi?"),
884+ }
885+}
886+
887+/// See [`enable_title`].
888+pub fn remove_service_title(lang: Lang, name_html: &str) -> String {
889+ match lang {
890+ Lang::En => format!("Remove {name_html}?"),
891+ Lang::Tr => format!("{name_html} kaldırılsın mı?"),
892+ }
893+}
894+
860895 /// The mail section's lede: what the sender is for. The mono span is markup.
861896 pub fn mail_sub(lang: Lang) -> String {
862897 match lang {
crates/im-web/src/pages.rsmodified+2 -66
@@ -60,7 +60,6 @@ pub fn ok_text(code: &str, lang: Lang) -> &'static str {
6060 "photo_removed" => t(lang, Key::OkPhotoRemoved),
6161 "session_revoked" => t(lang, Key::OkSessionRevoked),
6262 "preferences" => t(lang, Key::Saved),
63- "services" => t(lang, Key::Saved),
6463 "password" => t(lang, Key::PasswordSaved),
6564 _ => t(lang, Key::OkDone),
6665 }
@@ -607,7 +606,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
607606 // the whole card the link. im's own card reads current. Above the
608607 // profile sections: im is the account center, and its landing is the
609608 // door to the rest. The list is the stored one — the rows `/family`
610- // serves — and an admin gets the handles on it right under the cards.
609+ // serves — read-only here; the admin edits it from the panel.
611610 let services = im_core::services::list(&server::app(cx).store).await?;
612611 let services_html = services
613612 .iter()
@@ -626,11 +625,6 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
626625 )
627626 })
628627 .collect::<String>();
629- let services_manage = if user.admin {
630- services_manage_html(&services, lang)
631- } else {
632- String::new()
633- };
634628 let stage = view! {
635629 cx =>
636630 <main class="auth-stage landing-stage">
@@ -638,11 +632,10 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
638632 (wordmark(cx).await?)
639633 (service_trio(cx).await?)
640634 <nav class="admin-tabs landing-nav">(topcoat::view::Unescaped::new_unchecked(nav))</nav>
641- if !services_html.is_empty() || user.admin {
635+ if !services_html.is_empty() {
642636 <div class="auth-card">
643637 <div class="auth-title">(t(lang, Key::ServicesTitle))</div>
644638 <div class="service-grid">(topcoat::view::Unescaped::new_unchecked(services_html))</div>
645- (topcoat::view::Unescaped::new_unchecked(services_manage))
646639 </div>
647640 }
648641 if let Some(code) = ok {
@@ -854,63 +847,6 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result {
854847 shell(cx, "im", Some(user), stage).await
855848 }
856849
857-/// The admin's handles under the services grid: a name-and-address edit per
858-/// row, the up/down pair, the remove, and the add form. Every action is a
859-/// plain form post answering a 303 back to this card — the landing idiom —
860-/// wearing the admin panel's quiet row-button skin, laid out by the same
861-/// flex row the panel's invite line uses.
862-fn services_manage_html(services: &[im_core::services::Service], lang: Lang) -> String {
863- let mut rows = String::new();
864- for service in services {
865- let key = escape(&service.key);
866- rows.push_str(&format!(
867- r#"<div class="admin-invite">
868- <form method="post" action="/services/edit">
869- <input type="hidden" name="key" value="{key}">
870- <input class="auth-input" type="text" name="name" value="{name}" aria-label="{name_label}" required="">
871- <input class="auth-input" type="text" name="url" value="{url}" aria-label="{url_label}" required="">
872- <button class="admin-action" type="submit">{save}</button>
873- </form>
874- <form method="post" action="/services/move">
875- <input type="hidden" name="key" value="{key}"><input type="hidden" name="dir" value="up">
876- <button class="admin-action" type="submit" aria-label="{up}">&#8593;</button>
877- </form>
878- <form method="post" action="/services/move">
879- <input type="hidden" name="key" value="{key}"><input type="hidden" name="dir" value="down">
880- <button class="admin-action" type="submit" aria-label="{down}">&#8595;</button>
881- </form>
882- <form method="post" action="/services/remove">
883- <input type="hidden" name="key" value="{key}">
884- <button class="admin-action admin-danger" type="submit">{remove}</button>
885- </form>
886-</div>"#,
887- name = escape(&service.name),
888- url = escape(&service.url),
889- name_label = t(lang, Key::NameCol),
890- url_label = t(lang, Key::AddressLabel),
891- save = t(lang, Key::SaveButton),
892- up = t(lang, Key::ServiceMoveUp),
893- down = t(lang, Key::ServiceMoveDown),
894- remove = t(lang, Key::Remove),
895- ));
896- }
897- rows.push_str(&format!(
898- r#"<div class="admin-invite">
899- <form method="post" action="/services/add">
900- <input class="auth-input" type="text" name="key" placeholder="in" aria-label="{key_label}" required="">
901- <input class="auth-input" type="text" name="name" placeholder="{name_label}" aria-label="{name_label}" required="">
902- <input class="auth-input" type="text" name="url" placeholder="https://in.dizey.sh" aria-label="{url_label}" required="">
903- <button class="admin-action" type="submit">{add}</button>
904- </form>
905-</div>"#,
906- key_label = t(lang, Key::ServiceKeyLabel),
907- name_label = t(lang, Key::NameCol),
908- url_label = t(lang, Key::AddressLabel),
909- add = t(lang, Key::ServiceAdd),
910- ));
911- rows
912-}
913-
914850 /// "Forgot it?" — the self-serve reset ask. It answers the same whether the
915851 /// address has an account: one quiet note, the same one for every address.
916852 #[page("/forgot")]