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 commitfaf28868c99c9e669da0e8765d701abb3bd75f9bParent: 0c0ea326 changed files +247 -207
- crates/im-core/src/services.rs +1 -1
- crates/im-web/src/admin.rs +175 -2
- crates/im-web/src/auth.rs +0 -113
- crates/im-web/src/directory.rs +34 -25
- crates/im-web/src/i18n.rs +35 -0
- crates/im-web/src/pages.rs +2 -66
crates/im-core/src/services.rsmodified+1 -1
| @@ -1,7 +1,7 @@ | |||
| 1 | //! The family: the services every topbar shows as wordmarks and the | 1 | //! The family: the services every topbar shows as wordmarks and the |
| 2 | //! landing's services home. The list lives in the database and the admin | 2 | //! landing's services home. The list lives in the database and the admin |
| 3 | //! panel owns it — seeded once from the config's `[[services]]` on first | 3 | //! 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 |
| 5 | //! to the sibling apps over `GET /family`, which each mirrors into its own | 5 | //! to the sibling apps over `GET /family`, which each mirrors into its own |
| 6 | //! database. | 6 | //! database. |
| 7 | 7 | ||
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 |
| 2 | //! action a plain form post answering a 303 back to its section — the same | 2 | //! action a plain form post answering a 303 back to its section — the same |
| 3 | //! idiom as izlek-web's settings.rs/logs.rs, minus the client script. | 3 | //! idiom as izlek-web's settings.rs/logs.rs, minus the client script. |
| 4 | 4 | ||
| @@ -52,6 +52,7 @@ fn escape(raw: &str) -> String { | |||
| 52 | /// and holds the button that actually does it. Works with no script at all; | 52 | /// and holds the button that actually does it. Works with no script at all; |
| 53 | /// the live script adds outside-click closing. | 53 | /// the live script adds outside-click closing. |
| 54 | fn confirm_action( | 54 | fn confirm_action( |
| 55 | + field: &str, | ||
| 55 | id: &str, | 56 | id: &str, |
| 56 | action: &str, | 57 | action: &str, |
| 57 | word: &str, | 58 | word: &str, |
| @@ -61,7 +62,7 @@ fn confirm_action( | |||
| 61 | confirm: &str, | 62 | confirm: &str, |
| 62 | ) -> String { | 63 | ) -> String { |
| 63 | format!( | 64 | 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>"# |
| 65 | ) | 66 | ) |
| 66 | } | 67 | } |
| 67 | /// The panel's live wiring moved into the shell: `layout::live_script` runs | 68 | /// 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> { | |||
| 114 | let nav = |current: &str| { | 115 | let nav = |current: &str| { |
| 115 | [ | 116 | [ |
| 116 | ("users", t(lang, Key::NavUsers)), | 117 | ("users", t(lang, Key::NavUsers)), |
| 118 | + ("services", t(lang, Key::NavServices)), | ||
| 117 | ("mail", t(lang, Key::NavMail)), | 119 | ("mail", t(lang, Key::NavMail)), |
| 118 | ("message", t(lang, Key::NavMessage)), | 120 | ("message", t(lang, Key::NavMessage)), |
| 119 | ("settings", t(lang, Key::NavSettings)), | 121 | ("settings", t(lang, Key::NavSettings)), |
| @@ -134,6 +136,7 @@ async fn admin_page(cx: &Cx) -> Result<Response> { | |||
| 134 | "message" => message_section(cx, lang).await?, | 136 | "message" => message_section(cx, lang).await?, |
| 135 | "settings" => settings_section(cx, lang).await?, | 137 | "settings" => settings_section(cx, lang).await?, |
| 136 | "logs" => logs_section(cx, lang).await?, | 138 | "logs" => logs_section(cx, lang).await?, |
| 139 | + "services" => services_section(cx, lang).await?, | ||
| 137 | "users" => users_section(cx, &me, invited.as_deref(), lang).await?, | 140 | "users" => users_section(cx, &me, invited.as_deref(), lang).await?, |
| 138 | _ => users_section(cx, &me, invited.as_deref(), lang).await?, | 141 | _ => users_section(cx, &me, invited.as_deref(), lang).await?, |
| 139 | }; | 142 | }; |
| @@ -153,6 +156,7 @@ async fn admin_page(cx: &Cx) -> Result<Response> { | |||
| 153 | "uninvited" => t(lang, Key::OkUninvited), | 156 | "uninvited" => t(lang, Key::OkUninvited), |
| 154 | "deleted" => t(lang, Key::OkDeleted), | 157 | "deleted" => t(lang, Key::OkDeleted), |
| 155 | "settings" => t(lang, Key::OkSettingsSaved), | 158 | "settings" => t(lang, Key::OkSettingsSaved), |
| 159 | + "services" => t(lang, Key::OkServicesSaved), | ||
| 156 | _ => t(lang, Key::OkDone), | 160 | _ => t(lang, Key::OkDone), |
| 157 | } | 161 | } |
| 158 | )), | 162 | )), |
| @@ -297,6 +301,7 @@ async fn users_section( | |||
| 297 | // script adds outside-click closing on top. | 301 | // script adds outside-click closing on top. |
| 298 | let toggle = if user.disabled { | 302 | let toggle = if user.disabled { |
| 299 | confirm_action( | 303 | confirm_action( |
| 304 | + "user", | ||
| 300 | &id, | 305 | &id, |
| 301 | "/admin/enable", | 306 | "/admin/enable", |
| 302 | t(lang, Key::EnableWord), | 307 | t(lang, Key::EnableWord), |
| @@ -307,6 +312,7 @@ async fn users_section( | |||
| 307 | ) | 312 | ) |
| 308 | } else { | 313 | } else { |
| 309 | confirm_action( | 314 | confirm_action( |
| 315 | + "user", | ||
| 310 | &id, | 316 | &id, |
| 311 | "/admin/disable", | 317 | "/admin/disable", |
| 312 | t(lang, Key::DisableWord), | 318 | t(lang, Key::DisableWord), |
| @@ -317,6 +323,7 @@ async fn users_section( | |||
| 317 | ) | 323 | ) |
| 318 | }; | 324 | }; |
| 319 | let remove = confirm_action( | 325 | let remove = confirm_action( |
| 326 | + "user", | ||
| 320 | &id, | 327 | &id, |
| 321 | "/admin/delete", | 328 | "/admin/delete", |
| 322 | t(lang, Key::DeleteWord), | 329 | t(lang, Key::DeleteWord), |
| @@ -401,6 +408,172 @@ async fn users_section( | |||
| 401 | )) | 408 | )) |
| 402 | } | 409 | } |
| 403 | 410 | ||
| 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}">↑</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}">↓</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 | + | ||
| 404 | /// The knobs the code shipped with, now the panel's: invite and reset link | 577 | /// The knobs the code shipped with, now the panel's: invite and reset link |
| 405 | /// lifetimes, the sign-in session's days, the pending marker's minutes, and | 578 | /// lifetimes, the sign-in session's days, the pending marker's minutes, and |
| 406 | /// the sign-in failure ceiling. Same form skin as Mail. | 579 | /// 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 { | |||
| 324 | see(logout_target(back.as_deref(), &services)) | 324 | see(logout_target(back.as_deref(), &services)) |
| 325 | } | 325 | } |
| 326 | 326 | ||
| 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 | - | ||
| 440 | #[derive(Deserialize)] | 327 | #[derive(Deserialize)] |
| 441 | pub struct ForgotForm { | 328 | pub struct ForgotForm { |
| 442 | email: String, | 329 | email: String, |
crates/im-web/src/directory.rsmodified+34 -25
| @@ -506,7 +506,7 @@ mod tests { | |||
| 506 | .unwrap(); | 506 | .unwrap(); |
| 507 | let (status, location, _) = post_form( | 507 | let (status, location, _) = post_form( |
| 508 | &router, | 508 | &router, |
| 509 | - "/services/add", | 509 | + "/admin/services_add", |
| 510 | "key=wiki&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A99", | 510 | "key=wiki&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A99", |
| 511 | Some(&format!("{SESSION_COOKIE}={}", ben_session.expose())), | 511 | Some(&format!("{SESSION_COOKIE}={}", ben_session.expose())), |
| 512 | ) | 512 | ) |
| @@ -514,21 +514,21 @@ mod tests { | |||
| 514 | assert_eq!(status, StatusCode::SEE_OTHER); | 514 | assert_eq!(status, StatusCode::SEE_OTHER); |
| 515 | assert_eq!(location.as_deref(), Some("/")); | 515 | assert_eq!(location.as_deref(), Some("/")); |
| 516 | 516 | ||
| 517 | - // The admin's add lands back on the card, and /family carries the | 517 | + // The admin's add lands back on the section, and /family carries |
| 518 | - // new row at the end — trailing slash stored off, like every URL. | 518 | + // the new row at the end — trailing slash stored off, like every URL. |
| 519 | let session = im_core::sessions::create_session(&store, &ada.id, &Default::default()) | 519 | let session = im_core::sessions::create_session(&store, &ada.id, &Default::default()) |
| 520 | .await | 520 | .await |
| 521 | .unwrap(); | 521 | .unwrap(); |
| 522 | let cookie = format!("{SESSION_COOKIE}={}", session.expose()); | 522 | let cookie = format!("{SESSION_COOKIE}={}", session.expose()); |
| 523 | let (status, location, _) = post_form( | 523 | let (status, location, _) = post_form( |
| 524 | &router, | 524 | &router, |
| 525 | - "/services/add", | 525 | + "/admin/services_add", |
| 526 | "key=wiki&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A99%2F", | 526 | "key=wiki&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A99%2F", |
| 527 | Some(&cookie), | 527 | Some(&cookie), |
| 528 | ) | 528 | ) |
| 529 | .await; | 529 | .await; |
| 530 | assert_eq!(status, StatusCode::SEE_OTHER); | 530 | 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")); |
| 532 | let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; | 532 | let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; |
| 533 | let family = serde_json::from_str::<serde_json::Value>(&body).unwrap(); | 533 | let family = serde_json::from_str::<serde_json::Value>(&body).unwrap(); |
| 534 | let family = family.as_array().unwrap(); | 534 | let family = family.as_array().unwrap(); |
| @@ -538,33 +538,39 @@ mod tests { | |||
| 538 | .collect::<Vec<_>>(); | 538 | .collect::<Vec<_>>(); |
| 539 | assert_eq!(keys, vec!["in", "im", "iz", "wiki"], "{body}"); | 539 | assert_eq!(keys, vec!["in", "im", "iz", "wiki"], "{body}"); |
| 540 | assert_eq!(family[3]["url"], "http://127.0.0.1:99"); | 540 | 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. | ||
| 541 | assert!( | 546 | assert!( |
| 542 | - get_page(&router, "/?section=profile", &cookie) | 547 | + !get_page(&router, "/?section=profile", &cookie) |
| 543 | .await | 548 | .await |
| 544 | - .contains(r#"action="/services/add""#) | 549 | + .contains(r#"action="/admin/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""#) | ||
| 554 | ); | 550 | ); |
| 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("/")); | ||
| 555 | 561 | ||
| 556 | // Edit rewrites name and address; move up swaps with the neighbor. | 562 | // Edit rewrites name and address; move up swaps with the neighbor. |
| 557 | let (_status, location, _) = post_form( | 563 | let (_status, location, _) = post_form( |
| 558 | &router, | 564 | &router, |
| 559 | - "/services/edit", | 565 | + "/admin/services_edit", |
| 560 | "key=wiki&name=Docs&url=http%3A%2F%2F127.0.0.1%3A98", | 566 | "key=wiki&name=Docs&url=http%3A%2F%2F127.0.0.1%3A98", |
| 561 | Some(&cookie), | 567 | Some(&cookie), |
| 562 | ) | 568 | ) |
| 563 | .await; | 569 | .await; |
| 564 | - assert_eq!(location.as_deref(), Some("/?ok=services")); | 570 | + assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services")); |
| 565 | let (_status, location, _) = | 571 | let (_status, location, _) = |
| 566 | - post_form(&router, "/services/move", "key=wiki&dir=up", Some(&cookie)).await; | 572 | + post_form(&router, "/admin/services_move", "key=wiki&dir=up", Some(&cookie)).await; |
| 567 | - assert_eq!(location.as_deref(), Some("/?ok=services")); | 573 | + assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services")); |
| 568 | let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; | 574 | let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; |
| 569 | let family = serde_json::from_str::<serde_json::Value>(&body).unwrap(); | 575 | let family = serde_json::from_str::<serde_json::Value>(&body).unwrap(); |
| 570 | let family = family.as_array().unwrap(); | 576 | let family = family.as_array().unwrap(); |
| @@ -592,8 +598,8 @@ mod tests { | |||
| 592 | 598 | ||
| 593 | // And once the row is gone, the same origin is refused to the door. | 599 | // And once the row is gone, the same origin is refused to the door. |
| 594 | let (_status, location, _) = | 600 | let (_status, location, _) = |
| 595 | - post_form(&router, "/services/remove", "key=wiki", Some(&cookie)).await; | 601 | + post_form(&router, "/admin/services_remove", "key=wiki", Some(&cookie)).await; |
| 596 | - assert_eq!(location.as_deref(), Some("/?ok=services")); | 602 | + assert_eq!(location.as_deref(), Some("/admin?section=services&ok=services")); |
| 597 | let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; | 603 | let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; |
| 598 | let family = serde_json::from_str::<serde_json::Value>(&body).unwrap(); | 604 | let family = serde_json::from_str::<serde_json::Value>(&body).unwrap(); |
| 599 | let keys = family | 605 | let keys = family |
| @@ -614,18 +620,21 @@ mod tests { | |||
| 614 | .await; | 620 | .await; |
| 615 | assert_eq!(location.as_deref(), Some("/")); | 621 | assert_eq!(location.as_deref(), Some("/")); |
| 616 | 622 | ||
| 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. |
| 618 | let bad_session = im_core::sessions::create_session(&store, &ada.id, &Default::default()) | 624 | let bad_session = im_core::sessions::create_session(&store, &ada.id, &Default::default()) |
| 619 | .await | 625 | .await |
| 620 | .unwrap(); | 626 | .unwrap(); |
| 621 | let (_status, location, _) = post_form( | 627 | let (_status, location, _) = post_form( |
| 622 | &router, | 628 | &router, |
| 623 | - "/services/add", | 629 | + "/admin/services_add", |
| 624 | "key=Wiki!&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A97", | 630 | "key=Wiki!&name=Wiki&url=http%3A%2F%2F127.0.0.1%3A97", |
| 625 | Some(&format!("{SESSION_COOKIE}={}", bad_session.expose())), | 631 | Some(&format!("{SESSION_COOKIE}={}", bad_session.expose())), |
| 626 | ) | 632 | ) |
| 627 | .await; | 633 | .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 | + ); | ||
| 629 | let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; | 638 | let (_, body) = get_family(&router, Some(basic(&client_id, &secret))).await; |
| 630 | assert_eq!( | 639 | assert_eq!( |
| 631 | serde_json::from_str::<serde_json::Value>(&body) | 640 | serde_json::from_str::<serde_json::Value>(&body) |
crates/im-web/src/i18n.rsmodified+35 -0
| @@ -151,6 +151,7 @@ pub enum Key { | |||
| 151 | NavSettings, | 151 | NavSettings, |
| 152 | NavLogs, | 152 | NavLogs, |
| 153 | NavMessage, | 153 | NavMessage, |
| 154 | + NavServices, | ||
| 154 | OkInvited, | 155 | OkInvited, |
| 155 | OkRevoked, | 156 | OkRevoked, |
| 156 | OkDisabled, | 157 | OkDisabled, |
| @@ -160,6 +161,7 @@ pub enum Key { | |||
| 160 | OkUninvited, | 161 | OkUninvited, |
| 161 | OkDeleted, | 162 | OkDeleted, |
| 162 | OkSettingsSaved, | 163 | OkSettingsSaved, |
| 164 | + OkServicesSaved, | ||
| 163 | OkMessageSent, | 165 | OkMessageSent, |
| 164 | 166 | ||
| 165 | // Admin mail section: the composed notice. | 167 | // Admin mail section: the composed notice. |
| @@ -202,12 +204,15 @@ pub enum Key { | |||
| 202 | EnableWord, | 204 | EnableWord, |
| 203 | DisableWord, | 205 | DisableWord, |
| 204 | DeleteWord, | 206 | DeleteWord, |
| 207 | + EditWord, | ||
| 205 | ConfirmEnable, | 208 | ConfirmEnable, |
| 206 | ConfirmDisable, | 209 | ConfirmDisable, |
| 207 | ConfirmDelete, | 210 | ConfirmDelete, |
| 211 | + ConfirmRemove, | ||
| 208 | EnableCost, | 212 | EnableCost, |
| 209 | DisableCost, | 213 | DisableCost, |
| 210 | DeleteCost, | 214 | DeleteCost, |
| 215 | + RemoveCost, | ||
| 211 | InvalidateButton, | 216 | InvalidateButton, |
| 212 | InviteLinkNote, | 217 | InviteLinkNote, |
| 213 | PeopleTitle, | 218 | PeopleTitle, |
| @@ -504,6 +509,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 504 | (NavLogs, Tr) => "Kayıtlar", | 509 | (NavLogs, Tr) => "Kayıtlar", |
| 505 | (NavMessage, En) => "Message", | 510 | (NavMessage, En) => "Message", |
| 506 | (NavMessage, Tr) => "Mesaj", | 511 | (NavMessage, Tr) => "Mesaj", |
| 512 | + (NavServices, En) => "Services", | ||
| 513 | + (NavServices, Tr) => "Hizmetler", | ||
| 507 | (OkInvited, En) => "Invite created.", | 514 | (OkInvited, En) => "Invite created.", |
| 508 | (OkInvited, Tr) => "Davet oluşturuldu.", | 515 | (OkInvited, Tr) => "Davet oluşturuldu.", |
| 509 | (OkRevoked, En) => "Sessions revoked — every device is signed out.", | 516 | (OkRevoked, En) => "Sessions revoked — every device is signed out.", |
| @@ -522,6 +529,8 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 522 | (OkDeleted, Tr) => "Hesap silindi.", | 529 | (OkDeleted, Tr) => "Hesap silindi.", |
| 523 | (OkSettingsSaved, En) => "Settings saved.", | 530 | (OkSettingsSaved, En) => "Settings saved.", |
| 524 | (OkSettingsSaved, Tr) => "Ayarlar kaydedildi.", | 531 | (OkSettingsSaved, Tr) => "Ayarlar kaydedildi.", |
| 532 | + (OkServicesSaved, En) => "Services saved.", | ||
| 533 | + (OkServicesSaved, Tr) => "Hizmetler kaydedildi.", | ||
| 525 | (OkMessageSent, En) => "Message sent.", | 534 | (OkMessageSent, En) => "Message sent.", |
| 526 | (OkMessageSent, Tr) => "Mesaj gönderildi.", | 535 | (OkMessageSent, Tr) => "Mesaj gönderildi.", |
| 527 | 536 | ||
| @@ -596,12 +605,16 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 596 | (DisableWord, Tr) => "Devre dışı bırak", | 605 | (DisableWord, Tr) => "Devre dışı bırak", |
| 597 | (DeleteWord, En) => "Delete", | 606 | (DeleteWord, En) => "Delete", |
| 598 | (DeleteWord, Tr) => "Sil", | 607 | (DeleteWord, Tr) => "Sil", |
| 608 | + (EditWord, En) => "Edit", | ||
| 609 | + (EditWord, Tr) => "Düzenle", | ||
| 599 | (ConfirmEnable, En) => "Confirm enable", | 610 | (ConfirmEnable, En) => "Confirm enable", |
| 600 | (ConfirmEnable, Tr) => "Etkinleştirmeyi onayla", | 611 | (ConfirmEnable, Tr) => "Etkinleştirmeyi onayla", |
| 601 | (ConfirmDisable, En) => "Confirm disable", | 612 | (ConfirmDisable, En) => "Confirm disable", |
| 602 | (ConfirmDisable, Tr) => "Devre dışı bırakmayı onayla", | 613 | (ConfirmDisable, Tr) => "Devre dışı bırakmayı onayla", |
| 603 | (ConfirmDelete, En) => "Confirm delete", | 614 | (ConfirmDelete, En) => "Confirm delete", |
| 604 | (ConfirmDelete, Tr) => "Silmeyi onayla", | 615 | (ConfirmDelete, Tr) => "Silmeyi onayla", |
| 616 | + (ConfirmRemove, En) => "Confirm remove", | ||
| 617 | + (ConfirmRemove, Tr) => "Kaldırmayı onayla", | ||
| 605 | (EnableCost, En) => "They can sign in again.", | 618 | (EnableCost, En) => "They can sign in again.", |
| 606 | (EnableCost, Tr) => "Tekrar giriş yapabilir.", | 619 | (EnableCost, Tr) => "Tekrar giriş yapabilir.", |
| 607 | (DisableCost, En) => "They cannot sign in, and every live session ends.", | 620 | (DisableCost, En) => "They cannot sign in, and every live session ends.", |
| @@ -612,6 +625,12 @@ pub fn t(lang: Lang, key: Key) -> &'static str { | |||
| 612 | (DeleteCost, Tr) => { | 625 | (DeleteCost, Tr) => { |
| 613 | "Hesap, oturumları ve tüm uygulama jetonlarıyla birlikte silinir. Adres, yeni biri olarak tekrar davet edilebilir." | 626 | "Hesap, oturumları ve tüm uygulama jetonlarıyla birlikte silinir. Adres, yeni biri olarak tekrar davet edilebilir." |
| 614 | } | 627 | } |
| 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 | + } | ||
| 615 | (InvalidateButton, En) => "Invalidate", | 634 | (InvalidateButton, En) => "Invalidate", |
| 616 | (InvalidateButton, Tr) => "Geçersiz kıl", | 635 | (InvalidateButton, Tr) => "Geçersiz kıl", |
| 617 | (InviteLinkNote, En) => "The link exists once. It is shown once:", | 636 | (InviteLinkNote, En) => "The link exists once. It is shown once:", |
| @@ -857,6 +876,22 @@ pub fn delete_title(lang: Lang, email_html: &str) -> String { | |||
| 857 | } | 876 | } |
| 858 | } | 877 | } |
| 859 | 878 | ||
| 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 | + | ||
| 860 | /// The mail section's lede: what the sender is for. The mono span is markup. | 895 | /// The mail section's lede: what the sender is for. The mono span is markup. |
| 861 | pub fn mail_sub(lang: Lang) -> String { | 896 | pub fn mail_sub(lang: Lang) -> String { |
| 862 | match lang { | 897 | match lang { |
crates/im-web/src/pages.rsmodified+2 -66
| @@ -60,7 +60,6 @@ pub fn ok_text(code: &str, lang: Lang) -> &'static str { | |||
| 60 | "photo_removed" => t(lang, Key::OkPhotoRemoved), | 60 | "photo_removed" => t(lang, Key::OkPhotoRemoved), |
| 61 | "session_revoked" => t(lang, Key::OkSessionRevoked), | 61 | "session_revoked" => t(lang, Key::OkSessionRevoked), |
| 62 | "preferences" => t(lang, Key::Saved), | 62 | "preferences" => t(lang, Key::Saved), |
| 63 | - "services" => t(lang, Key::Saved), | ||
| 64 | "password" => t(lang, Key::PasswordSaved), | 63 | "password" => t(lang, Key::PasswordSaved), |
| 65 | _ => t(lang, Key::OkDone), | 64 | _ => t(lang, Key::OkDone), |
| 66 | } | 65 | } |
| @@ -607,7 +606,7 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { | |||
| 607 | // the whole card the link. im's own card reads current. Above the | 606 | // the whole card the link. im's own card reads current. Above the |
| 608 | // profile sections: im is the account center, and its landing is the | 607 | // profile sections: im is the account center, and its landing is the |
| 609 | // door to the rest. The list is the stored one — the rows `/family` | 608 | // 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. |
| 611 | let services = im_core::services::list(&server::app(cx).store).await?; | 610 | let services = im_core::services::list(&server::app(cx).store).await?; |
| 612 | let services_html = services | 611 | let services_html = services |
| 613 | .iter() | 612 | .iter() |
| @@ -626,11 +625,6 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { | |||
| 626 | ) | 625 | ) |
| 627 | }) | 626 | }) |
| 628 | .collect::<String>(); | 627 | .collect::<String>(); |
| 629 | - let services_manage = if user.admin { | ||
| 630 | - services_manage_html(&services, lang) | ||
| 631 | - } else { | ||
| 632 | - String::new() | ||
| 633 | - }; | ||
| 634 | let stage = view! { | 628 | let stage = view! { |
| 635 | cx => | 629 | cx => |
| 636 | <main class="auth-stage landing-stage"> | 630 | <main class="auth-stage landing-stage"> |
| @@ -638,11 +632,10 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { | |||
| 638 | (wordmark(cx).await?) | 632 | (wordmark(cx).await?) |
| 639 | (service_trio(cx).await?) | 633 | (service_trio(cx).await?) |
| 640 | <nav class="admin-tabs landing-nav">(topcoat::view::Unescaped::new_unchecked(nav))</nav> | 634 | <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() { |
| 642 | <div class="auth-card"> | 636 | <div class="auth-card"> |
| 643 | <div class="auth-title">(t(lang, Key::ServicesTitle))</div> | 637 | <div class="auth-title">(t(lang, Key::ServicesTitle))</div> |
| 644 | <div class="service-grid">(topcoat::view::Unescaped::new_unchecked(services_html))</div> | 638 | <div class="service-grid">(topcoat::view::Unescaped::new_unchecked(services_html))</div> |
| 645 | - (topcoat::view::Unescaped::new_unchecked(services_manage)) | ||
| 646 | </div> | 639 | </div> |
| 647 | } | 640 | } |
| 648 | if let Some(code) = ok { | 641 | if let Some(code) = ok { |
| @@ -854,63 +847,6 @@ async fn signed_in(cx: &Cx, user: &im_core::model::User) -> Result { | |||
| 854 | shell(cx, "im", Some(user), stage).await | 847 | shell(cx, "im", Some(user), stage).await |
| 855 | } | 848 | } |
| 856 | 849 | ||
| 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}">↑</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}">↓</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 | - | ||
| 914 | /// "Forgot it?" — the self-serve reset ask. It answers the same whether the | 850 | /// "Forgot it?" — the self-serve reset ask. It answers the same whether the |
| 915 | /// address has an account: one quiet note, the same one for every address. | 851 | /// address has an account: one quiet note, the same one for every address. |
| 916 | #[page("/forgot")] | 852 | #[page("/forgot")] |