yumush
Clone
https://git.tahinli.com/Tahinli/yumush.git
0 watching·0 forks·Rust·AGPL-3.0·7.2 MiB·4b67e80·Tahinli·1 hour ago·400 commits
| 1 | use common::model::Id; |
| 2 | use std::{future::Future, time::Duration}; |
| 3 | |
| 4 | use common::{ |
| 5 | call::{ |
| 6 | BanUser, ClearProfile, CreateUser, DeleteUser, FollowStats, ListSessions, |
| 7 | ListUpdateClients, PurgeUser, RenameUser, ResetPassword, RevokeSession, RevokeSessions, |
| 8 | SuspendUser, TimeoutUser, |
| 9 | }, |
| 10 | model::{Account, BanScope, Role, SessionInfo, UpdateClient, UpdateState, User}, |
| 11 | permission, |
| 12 | stats::Stats, |
| 13 | time::{DAY_MILLIS, HOUR_MILLIS, MINUTE_MILLIS, now_ms}, |
| 14 | }; |
| 15 | use gpui_kit::{ |
| 16 | Anchor, AnyElement, App, Context, Div, Entity, FontWeight, InteractiveElement as _, |
| 17 | IntoElement, ParentElement, StatefulInteractiveElement as _, Styled, Window, |
| 18 | assets::IconName, |
| 19 | component::{Icon, popover::Popover}, |
| 20 | div, |
| 21 | prelude::FluentBuilder as _, |
| 22 | px, |
| 23 | }; |
| 24 | |
| 25 | use super::BuilderTab; |
| 26 | use super::releases::{caption_text, meter}; |
| 27 | use super::ui::{action_button, action_group, card, confirm_button, confirmed, pill}; |
| 28 | use crate::lang::w; |
| 29 | use crate::{ |
| 30 | gui::{ |
| 31 | Palette, Tooltip as _, Yumush, avatar, |
| 32 | chat::View, |
| 33 | clickable, entity_action, millis_time, notify_error, |
| 34 | parts::{self, Press}, |
| 35 | profile::user_link, |
| 36 | style::{radius, size, space, text}, |
| 37 | text, |
| 38 | widget::{field, search_text}, |
| 39 | }, |
| 40 | net::{Fail, NetworkHandle}, |
| 41 | }; |
| 42 | |
| 43 | const FRIENDS_MAX_H: f32 = 200.; |
| 44 | const CLIENTS_TICK: Duration = Duration::from_secs(1); |
| 45 | const MINUTES_PER_HOUR: u64 = HOUR_MILLIS / MINUTE_MILLIS; |
| 46 | const MINUTES_PER_DAY: u64 = DAY_MILLIS / MINUTE_MILLIS; |
| 47 | |
| 48 | fn seen_text(last_seen: Option<u64>) -> String { |
| 49 | let Some(last_seen) = last_seen else { |
| 50 | return w().builder_users.seen_never.to_string(); |
| 51 | }; |
| 52 | let minutes = now_ms().saturating_sub(last_seen) / MINUTE_MILLIS; |
| 53 | |
| 54 | match minutes { |
| 55 | 0 => w().builder_users.seen_now.to_string(), |
| 56 | 1..MINUTES_PER_HOUR => w().builder_users.seen_minutes(minutes), |
| 57 | MINUTES_PER_HOUR..MINUTES_PER_DAY => { |
| 58 | w().builder_users.seen_hours(minutes / MINUTES_PER_HOUR) |
| 59 | } |
| 60 | _ => millis_time(last_seen, crate::lang::w().common.day), |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | fn status(label: &str, color: gpui_kit::Hsla, palette: Palette) -> Div { |
| 65 | div().flex_shrink_0().child(pill(label, color, palette)) |
| 66 | } |
| 67 | |
| 68 | impl Yumush { |
| 69 | pub(super) fn submit_new_user(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 70 | let username = self.chat.new_username.read(cx).text().to_string(); |
| 71 | let password = self.chat.new_password.read(cx).text().to_string(); |
| 72 | self.chat |
| 73 | .new_password |
| 74 | .update(cx, |input, cx| input.set_value("", window, cx)); |
| 75 | let network = self.network.clone(); |
| 76 | |
| 77 | cx.spawn_in(window, async move |this, cx| { |
| 78 | match network.call(CreateUser { username, password }).await { |
| 79 | Ok(_) => { |
| 80 | let _ = this.update_in(cx, |yumush, window, cx| { |
| 81 | yumush |
| 82 | .chat |
| 83 | .new_username |
| 84 | .update(cx, |input, cx| input.set_value("", window, cx)); |
| 85 | yumush.load_users(window, cx); |
| 86 | }); |
| 87 | } |
| 88 | Err(error) => notify_error(&this, cx, error), |
| 89 | } |
| 90 | }) |
| 91 | .detach(); |
| 92 | } |
| 93 | |
| 94 | pub(super) fn delete_builder_user( |
| 95 | &mut self, |
| 96 | user_id: Id, |
| 97 | window: &mut Window, |
| 98 | cx: &mut Context<Self>, |
| 99 | ) { |
| 100 | if !confirmed(&mut self.chat.pending_builder_delete, user_id) { |
| 101 | cx.notify(); |
| 102 | return; |
| 103 | } |
| 104 | let network = self.network.clone(); |
| 105 | |
| 106 | cx.spawn_in(window, async move |this, cx| { |
| 107 | match network.call(DeleteUser { user_id }).await { |
| 108 | Ok(()) => { |
| 109 | let _ = this.update(cx, |yumush, cx| { |
| 110 | yumush |
| 111 | .chat |
| 112 | .builder_users |
| 113 | .retain(|account| account.user.id != user_id); |
| 114 | cx.notify(); |
| 115 | }); |
| 116 | } |
| 117 | Err(error) => notify_error(&this, cx, error), |
| 118 | } |
| 119 | }) |
| 120 | .detach(); |
| 121 | } |
| 122 | |
| 123 | pub(super) fn builder_user_action<Fut>( |
| 124 | &mut self, |
| 125 | window: &mut Window, |
| 126 | cx: &mut Context<Self>, |
| 127 | action: impl FnOnce(NetworkHandle) -> Fut + 'static, |
| 128 | ) where |
| 129 | Fut: Future<Output = Result<(), Fail>> + 'static, |
| 130 | { |
| 131 | let network = self.network.clone(); |
| 132 | |
| 133 | cx.spawn_in(window, async move |this, cx| match action(network).await { |
| 134 | Ok(()) => { |
| 135 | let _ = this.update_in(cx, |yumush, window, cx| yumush.load_users(window, cx)); |
| 136 | } |
| 137 | Err(error) => notify_error(&this, cx, error), |
| 138 | }) |
| 139 | .detach(); |
| 140 | } |
| 141 | |
| 142 | pub(super) fn suspend_builder_user( |
| 143 | &mut self, |
| 144 | user_id: Id, |
| 145 | suspended: bool, |
| 146 | window: &mut Window, |
| 147 | cx: &mut Context<Self>, |
| 148 | ) { |
| 149 | self.builder_user_action(window, cx, move |network| async move { |
| 150 | network.call(SuspendUser { user_id, suspended }).await |
| 151 | }); |
| 152 | } |
| 153 | |
| 154 | pub(super) fn revoke_builder_sessions( |
| 155 | &mut self, |
| 156 | user_id: Id, |
| 157 | window: &mut Window, |
| 158 | cx: &mut Context<Self>, |
| 159 | ) { |
| 160 | self.builder_user_action(window, cx, move |network| async move { |
| 161 | network.call(RevokeSessions { user_id }).await |
| 162 | }); |
| 163 | } |
| 164 | |
| 165 | pub(super) fn clear_builder_profile( |
| 166 | &mut self, |
| 167 | user_id: Id, |
| 168 | window: &mut Window, |
| 169 | cx: &mut Context<Self>, |
| 170 | ) { |
| 171 | self.builder_user_action(window, cx, move |network| async move { |
| 172 | network.call(ClearProfile { user_id }).await.map(|_| ()) |
| 173 | }); |
| 174 | } |
| 175 | |
| 176 | pub(super) fn toggle_builder_stats(&mut self, user_id: Id, cx: &mut Context<Self>) { |
| 177 | let target = match self.chat.followed { |
| 178 | Some((id, _)) if id == user_id => None, |
| 179 | _ => Some(user_id), |
| 180 | }; |
| 181 | self.chat.followed = target.map(|id| (id, Stats::default())); |
| 182 | let network = self.network.clone(); |
| 183 | cx.spawn(async move |this, cx| { |
| 184 | let latest = network.call(FollowStats { user_id: target }).await; |
| 185 | let _ = this.update(cx, |yumush, cx| { |
| 186 | if let (Ok(Some(stats)), Some(followed)) = (latest, yumush.chat.followed.as_mut()) |
| 187 | && Some(followed.0) == target |
| 188 | { |
| 189 | followed.1 = stats; |
| 190 | } |
| 191 | cx.notify(); |
| 192 | }); |
| 193 | }) |
| 194 | .detach(); |
| 195 | cx.notify(); |
| 196 | } |
| 197 | |
| 198 | pub(super) fn toggle_builder_password(&mut self, user_id: Id, cx: &mut Context<Self>) { |
| 199 | if self.chat.pending_builder_password == Some(user_id) { |
| 200 | self.chat.pending_builder_password = None; |
| 201 | } else { |
| 202 | self.chat.pending_builder_password = Some(user_id); |
| 203 | } |
| 204 | cx.notify(); |
| 205 | } |
| 206 | |
| 207 | pub(super) fn reset_builder_password(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 208 | let Some(user_id) = self.chat.pending_builder_password.take() else { |
| 209 | return; |
| 210 | }; |
| 211 | let password = self.chat.builder_password.read(cx).text().to_string(); |
| 212 | self.chat |
| 213 | .builder_password |
| 214 | .update(cx, |input, cx| input.set_value("", window, cx)); |
| 215 | self.builder_user_action(window, cx, move |network| async move { |
| 216 | network.call(ResetPassword { user_id, password }).await |
| 217 | }); |
| 218 | } |
| 219 | |
| 220 | pub(super) fn load_sessions(&self, user_id: Id, window: &mut Window, cx: &mut Context<Self>) { |
| 221 | let network = self.network.clone(); |
| 222 | |
| 223 | cx.spawn_in(window, async move |this, cx| { |
| 224 | let friends = network |
| 225 | .call(common::call::ListUserFriends { user_id }) |
| 226 | .await |
| 227 | .unwrap_or_default(); |
| 228 | match network.call(ListSessions { user_id }).await { |
| 229 | Ok(sessions) => { |
| 230 | let _ = this.update(cx, |yumush, cx| { |
| 231 | yumush.chat.builder_sessions = Some((user_id, sessions)); |
| 232 | yumush.chat.builder_friends = friends; |
| 233 | cx.notify(); |
| 234 | }); |
| 235 | } |
| 236 | Err(error) => notify_error(&this, cx, error), |
| 237 | } |
| 238 | }) |
| 239 | .detach(); |
| 240 | } |
| 241 | |
| 242 | pub(super) fn toggle_builder_sessions( |
| 243 | &mut self, |
| 244 | user_id: Id, |
| 245 | window: &mut Window, |
| 246 | cx: &mut Context<Self>, |
| 247 | ) { |
| 248 | if let Some((followed, _)) = self.chat.followed { |
| 249 | self.toggle_builder_stats(followed, cx); |
| 250 | } |
| 251 | if self |
| 252 | .chat |
| 253 | .builder_sessions |
| 254 | .as_ref() |
| 255 | .is_some_and(|(open, _)| *open == user_id) |
| 256 | { |
| 257 | self.chat.builder_sessions = None; |
| 258 | self.chat.builder_clients.clear(); |
| 259 | self.chat.builder_clients_task = None; |
| 260 | cx.notify(); |
| 261 | return; |
| 262 | } |
| 263 | self.load_sessions(user_id, window, cx); |
| 264 | self.chat.builder_clients.clear(); |
| 265 | self.watch_builder_clients(user_id, cx); |
| 266 | } |
| 267 | |
| 268 | fn watch_builder_clients(&mut self, user_id: Id, cx: &mut Context<Self>) { |
| 269 | let network = self.network.clone(); |
| 270 | self.chat.builder_clients_task = Some(cx.spawn(async move |this, cx| { |
| 271 | loop { |
| 272 | let Ok(visible) = this.update(cx, |yumush, _| { |
| 273 | yumush.chat.view == View::Builder |
| 274 | && yumush.chat.builder_tab == BuilderTab::Users |
| 275 | }) else { |
| 276 | break; |
| 277 | }; |
| 278 | if visible && let Ok(clients) = network.call(ListUpdateClients { user_id }).await { |
| 279 | let _ = this.update(cx, |yumush, cx| { |
| 280 | yumush.chat.builder_clients = clients; |
| 281 | cx.notify(); |
| 282 | }); |
| 283 | } |
| 284 | cx.background_executor().timer(CLIENTS_TICK).await; |
| 285 | } |
| 286 | })); |
| 287 | } |
| 288 | |
| 289 | pub(super) fn revoke_builder_session( |
| 290 | &mut self, |
| 291 | user_id: Id, |
| 292 | session_id: Id, |
| 293 | window: &mut Window, |
| 294 | cx: &mut Context<Self>, |
| 295 | ) { |
| 296 | let network = self.network.clone(); |
| 297 | |
| 298 | cx.spawn_in(window, async move |this, cx| { |
| 299 | match network |
| 300 | .call(RevokeSession { |
| 301 | user_id, |
| 302 | session_id, |
| 303 | }) |
| 304 | .await |
| 305 | { |
| 306 | Ok(()) => { |
| 307 | let _ = this.update_in(cx, |yumush, window, cx| { |
| 308 | yumush.load_sessions(user_id, window, cx) |
| 309 | }); |
| 310 | } |
| 311 | Err(error) => notify_error(&this, cx, error), |
| 312 | } |
| 313 | }) |
| 314 | .detach(); |
| 315 | } |
| 316 | |
| 317 | pub(super) fn toggle_builder_rename(&mut self, user_id: Id, cx: &mut Context<Self>) { |
| 318 | if self.chat.pending_builder_rename == Some(user_id) { |
| 319 | self.chat.pending_builder_rename = None; |
| 320 | } else { |
| 321 | self.chat.pending_builder_rename = Some(user_id); |
| 322 | } |
| 323 | cx.notify(); |
| 324 | } |
| 325 | |
| 326 | pub(super) fn rename_builder_user(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 327 | let Some(user_id) = self.chat.pending_builder_rename.take() else { |
| 328 | return; |
| 329 | }; |
| 330 | let username = self.chat.builder_rename.read(cx).text().to_string(); |
| 331 | self.chat |
| 332 | .builder_rename |
| 333 | .update(cx, |input, cx| input.set_value("", window, cx)); |
| 334 | self.builder_user_action(window, cx, move |network| async move { |
| 335 | network |
| 336 | .call(RenameUser { user_id, username }) |
| 337 | .await |
| 338 | .map(|_| ()) |
| 339 | }); |
| 340 | } |
| 341 | |
| 342 | pub(super) fn toggle_builder_timeout(&mut self, user_id: Id, cx: &mut Context<Self>) { |
| 343 | if self.chat.pending_builder_timeout == Some(user_id) { |
| 344 | self.chat.pending_builder_timeout = None; |
| 345 | } else { |
| 346 | self.chat.pending_builder_timeout = Some(user_id); |
| 347 | } |
| 348 | cx.notify(); |
| 349 | } |
| 350 | |
| 351 | pub(super) fn confirm_builder_timeout(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 352 | let Some(user_id) = self.chat.pending_builder_timeout else { |
| 353 | return; |
| 354 | }; |
| 355 | let minutes = self.chat.builder_timeout.read(cx).text().to_string(); |
| 356 | let Ok(minutes) = minutes.trim().parse::<u32>() else { |
| 357 | return; |
| 358 | }; |
| 359 | self.chat.pending_builder_timeout = None; |
| 360 | self.chat |
| 361 | .builder_timeout |
| 362 | .update(cx, |input, cx| input.set_value("", window, cx)); |
| 363 | self.builder_user_action(window, cx, move |network| async move { |
| 364 | network.call(TimeoutUser { user_id, minutes }).await |
| 365 | }); |
| 366 | } |
| 367 | |
| 368 | pub(super) fn toggle_builder_ban(&mut self, user_id: Id, cx: &mut Context<Self>) { |
| 369 | if self.chat.pending_builder_ban == Some(user_id) { |
| 370 | self.chat.pending_builder_ban = None; |
| 371 | } else { |
| 372 | self.chat.pending_builder_ban = Some(user_id); |
| 373 | } |
| 374 | cx.notify(); |
| 375 | } |
| 376 | |
| 377 | pub(super) fn toggle_builder_ban_ip(&mut self, cx: &mut Context<Self>) { |
| 378 | self.chat.builder_ban_scope = match self.chat.builder_ban_scope { |
| 379 | BanScope::Account => BanScope::AccountAndIp, |
| 380 | BanScope::AccountAndIp => BanScope::Account, |
| 381 | }; |
| 382 | cx.notify(); |
| 383 | } |
| 384 | |
| 385 | pub(super) fn confirm_builder_ban(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 386 | let Some(user_id) = self.chat.pending_builder_ban.take() else { |
| 387 | return; |
| 388 | }; |
| 389 | let reason = self.chat.builder_ban_reason.read(cx).text().to_string(); |
| 390 | let reason = reason.trim().to_string(); |
| 391 | let reason = (!reason.is_empty()).then_some(reason); |
| 392 | let scope = self.chat.builder_ban_scope; |
| 393 | self.chat |
| 394 | .builder_ban_reason |
| 395 | .update(cx, |input, cx| input.set_value("", window, cx)); |
| 396 | self.builder_user_action(window, cx, move |network| async move { |
| 397 | network |
| 398 | .call(BanUser { |
| 399 | user_id, |
| 400 | reason, |
| 401 | scope, |
| 402 | }) |
| 403 | .await |
| 404 | }); |
| 405 | } |
| 406 | |
| 407 | pub(super) fn purge_builder_user( |
| 408 | &mut self, |
| 409 | user_id: Id, |
| 410 | window: &mut Window, |
| 411 | cx: &mut Context<Self>, |
| 412 | ) { |
| 413 | if !confirmed(&mut self.chat.pending_builder_purge, user_id) { |
| 414 | cx.notify(); |
| 415 | return; |
| 416 | } |
| 417 | let network = self.network.clone(); |
| 418 | |
| 419 | cx.spawn_in(window, async move |this, cx| { |
| 420 | match network.call(PurgeUser { user_id }).await { |
| 421 | Ok(()) => { |
| 422 | let _ = this.update_in(cx, |yumush, window, cx| { |
| 423 | yumush |
| 424 | .chat |
| 425 | .builder_messages |
| 426 | .retain(|hit| hit.message.user_id != user_id); |
| 427 | yumush.load_users(window, cx); |
| 428 | }); |
| 429 | } |
| 430 | Err(error) => notify_error(&this, cx, error), |
| 431 | } |
| 432 | }) |
| 433 | .detach(); |
| 434 | } |
| 435 | |
| 436 | pub(super) fn users_body( |
| 437 | &self, |
| 438 | entity: &Entity<Self>, |
| 439 | palette: Palette, |
| 440 | cx: &App, |
| 441 | ) -> Vec<AnyElement> { |
| 442 | let query = search_text(&self.chat.builder_search, cx); |
| 443 | let rows: Vec<Div> = match self.user.as_ref() { |
| 444 | Some(me) => self |
| 445 | .chat |
| 446 | .builder_users |
| 447 | .iter() |
| 448 | .filter(|account| { |
| 449 | account |
| 450 | .user |
| 451 | .username |
| 452 | .to_lowercase() |
| 453 | .contains(query.as_str()) |
| 454 | }) |
| 455 | .map(|account| self.builder_row(account, me, entity, palette, cx)) |
| 456 | .collect(), |
| 457 | None => Vec::new(), |
| 458 | }; |
| 459 | |
| 460 | let toolbar = div() |
| 461 | .pb(px(space::SM)) |
| 462 | .flex() |
| 463 | .flex_wrap() |
| 464 | .items_center() |
| 465 | .gap(px(space::SM)) |
| 466 | .child( |
| 467 | div() |
| 468 | .flex_1() |
| 469 | .min_w(px(size::THUMB)) |
| 470 | .child(crate::gui::sidebar::input_box( |
| 471 | &self.chat.builder_search, |
| 472 | palette, |
| 473 | )), |
| 474 | ) |
| 475 | .child( |
| 476 | div() |
| 477 | .flex_1() |
| 478 | .min_w(px(size::THUMB)) |
| 479 | .child(field(palette, &self.chat.new_username)), |
| 480 | ) |
| 481 | .child( |
| 482 | div() |
| 483 | .flex_1() |
| 484 | .min_w(px(size::THUMB)) |
| 485 | .child(field(palette, &self.chat.new_password)), |
| 486 | ) |
| 487 | .child(crate::gui::parts::button( |
| 488 | "create_user", |
| 489 | w().builder_users.create, |
| 490 | crate::gui::parts::Press::Plain, |
| 491 | palette.tokens, |
| 492 | entity_action(entity, |yumush, window, cx| { |
| 493 | yumush.submit_new_user(window, cx) |
| 494 | }), |
| 495 | )); |
| 496 | |
| 497 | let body = if rows.is_empty() { |
| 498 | crate::gui::parts::empty(w().common.no_users, palette.tokens) |
| 499 | } else { |
| 500 | div().flex().flex_col().children(rows) |
| 501 | }; |
| 502 | |
| 503 | vec![card(palette).child(toolbar).child(body).into_any_element()] |
| 504 | } |
| 505 | |
| 506 | pub(super) fn builder_timeout_row( |
| 507 | &self, |
| 508 | user_id: Id, |
| 509 | entity: &Entity<Self>, |
| 510 | palette: Palette, |
| 511 | ) -> Div { |
| 512 | div() |
| 513 | .h(px(size::ROW)) |
| 514 | .px(px(space::MD)) |
| 515 | .flex() |
| 516 | .items_center() |
| 517 | .gap(px(space::SM)) |
| 518 | .child( |
| 519 | div() |
| 520 | .flex_1() |
| 521 | .min_w_0() |
| 522 | .child(field(palette, &self.chat.builder_timeout)), |
| 523 | ) |
| 524 | .child(parts::button( |
| 525 | format!("confirm_timeout_{user_id}"), |
| 526 | w().builder_users.confirm, |
| 527 | Press::Plain, |
| 528 | palette.tokens, |
| 529 | entity_action(entity, |yumush, window, cx| { |
| 530 | yumush.confirm_builder_timeout(window, cx) |
| 531 | }), |
| 532 | )) |
| 533 | } |
| 534 | |
| 535 | pub(super) fn builder_ban_row( |
| 536 | &self, |
| 537 | user_id: Id, |
| 538 | entity: &Entity<Self>, |
| 539 | palette: Palette, |
| 540 | ) -> Div { |
| 541 | let ip_label = if self.chat.builder_ban_scope == BanScope::AccountAndIp { |
| 542 | w().builder_users.ip_on |
| 543 | } else { |
| 544 | w().builder_users.ip_off |
| 545 | }; |
| 546 | |
| 547 | div() |
| 548 | .h(px(size::ROW)) |
| 549 | .px(px(space::MD)) |
| 550 | .flex() |
| 551 | .items_center() |
| 552 | .gap(px(space::SM)) |
| 553 | .child( |
| 554 | div() |
| 555 | .flex_1() |
| 556 | .min_w_0() |
| 557 | .child(field(palette, &self.chat.builder_ban_reason)), |
| 558 | ) |
| 559 | .child(parts::button( |
| 560 | format!("ban_ip_{user_id}"), |
| 561 | ip_label, |
| 562 | Press::Plain, |
| 563 | palette.tokens, |
| 564 | entity_action(entity, |yumush, _, cx| yumush.toggle_builder_ban_ip(cx)), |
| 565 | )) |
| 566 | .child(parts::button( |
| 567 | format!("confirm_ban_{user_id}"), |
| 568 | w().builder_users.confirm, |
| 569 | Press::Plain, |
| 570 | palette.tokens, |
| 571 | entity_action(entity, |yumush, window, cx| { |
| 572 | yumush.confirm_builder_ban(window, cx) |
| 573 | }), |
| 574 | )) |
| 575 | } |
| 576 | |
| 577 | fn builder_friend_list(&self, palette: Palette) -> Vec<AnyElement> { |
| 578 | let friends = self.chat.builder_friends.clone(); |
| 579 | let search = self.chat.builder_friend_search.clone(); |
| 580 | let avatars = self.chat.avatars.clone(); |
| 581 | let label = w().builder_users.friends_count(friends.len()); |
| 582 | |
| 583 | vec![ |
| 584 | Popover::new("builder_friends") |
| 585 | .anchor(Anchor::TopLeft) |
| 586 | .appearance(false) |
| 587 | .trigger(crate::gui::Trigger::new( |
| 588 | clickable("builder_friends_trigger", palette, |_, _| {}) |
| 589 | .h(px(size::CONTROL_SM)) |
| 590 | .flex() |
| 591 | .items_center() |
| 592 | .gap(px(space::SM)) |
| 593 | .rounded(px(radius::MD)) |
| 594 | .text_size(text(text::CAPTION)) |
| 595 | .font_weight(FontWeight::MEDIUM) |
| 596 | .text_color(palette.text) |
| 597 | .child(crate::gui::parts::small_icon(IconName::Users)) |
| 598 | .child(label) |
| 599 | .child(crate::gui::parts::small_icon(IconName::ChevronDown)), |
| 600 | )) |
| 601 | .content(move |_, _, cx| { |
| 602 | let query = crate::gui::widget::search_text(&search, cx); |
| 603 | crate::gui::parts::popover(palette.tokens) |
| 604 | .w(px(size::POPOVER)) |
| 605 | .p(px(space::SM)) |
| 606 | .gap(px(space::XS)) |
| 607 | .child(crate::gui::sidebar::input_box(&search, palette)) |
| 608 | .child( |
| 609 | div() |
| 610 | .id("builder_friends_list") |
| 611 | .max_h(px(FRIENDS_MAX_H)) |
| 612 | .overflow_y_scroll() |
| 613 | .flex() |
| 614 | .flex_col() |
| 615 | .when(friends.is_empty(), |list| { |
| 616 | list.child( |
| 617 | div() |
| 618 | .text_size(text(text::CAPTION)) |
| 619 | .text_color(palette.muted) |
| 620 | .child(w().builder_users.no_friends), |
| 621 | ) |
| 622 | }) |
| 623 | .children( |
| 624 | friends |
| 625 | .iter() |
| 626 | .filter(|friend| { |
| 627 | friend.username.to_lowercase().contains(&query) |
| 628 | }) |
| 629 | .map(|friend| { |
| 630 | div() |
| 631 | .h(px(size::CONTROL_SM)) |
| 632 | .flex() |
| 633 | .items_center() |
| 634 | .gap(px(space::SM)) |
| 635 | .child(crate::gui::avatar( |
| 636 | palette, |
| 637 | friend, |
| 638 | px(size::ICON), |
| 639 | text(text::CAPTION), |
| 640 | &avatars, |
| 641 | )) |
| 642 | .child( |
| 643 | div() |
| 644 | .text_size(text(text::CAPTION)) |
| 645 | .child(friend.username.clone()), |
| 646 | ) |
| 647 | }), |
| 648 | ), |
| 649 | ) |
| 650 | }) |
| 651 | .into_any_element(), |
| 652 | ] |
| 653 | } |
| 654 | |
| 655 | pub(super) fn builder_session_row( |
| 656 | &self, |
| 657 | user_id: Id, |
| 658 | session: &SessionInfo, |
| 659 | entity: &Entity<Self>, |
| 660 | palette: Palette, |
| 661 | ) -> Div { |
| 662 | let revoke_user_id = user_id; |
| 663 | let session_id = session.id; |
| 664 | let revoke_button = action_button( |
| 665 | format!("revoke_session_{}", session.id), |
| 666 | IconName::LogOut, |
| 667 | w().builder_users.revoke, |
| 668 | w().builder_users.end_session, |
| 669 | palette.muted, |
| 670 | palette, |
| 671 | entity_action(entity, move |yumush, window, cx| { |
| 672 | yumush.revoke_builder_session(revoke_user_id, session_id, window, cx) |
| 673 | }), |
| 674 | ); |
| 675 | let device = if session.device.is_empty() { |
| 676 | w().builder_users.unknown_device |
| 677 | } else { |
| 678 | session.device.as_str() |
| 679 | }; |
| 680 | |
| 681 | div() |
| 682 | .w_full() |
| 683 | .h(px(size::CONTROL_SM)) |
| 684 | .flex() |
| 685 | .items_center() |
| 686 | .gap(px(space::SM)) |
| 687 | .child(crate::gui::parts::small_icon(IconName::Monitor).text_color(palette.muted)) |
| 688 | .child( |
| 689 | div() |
| 690 | .flex_1() |
| 691 | .text_size(text(text::CAPTION)) |
| 692 | .min_w_0() |
| 693 | .truncate() |
| 694 | .child(device.to_string()), |
| 695 | ) |
| 696 | .child( |
| 697 | div() |
| 698 | .flex_shrink_0() |
| 699 | .text_size(text(text::CAPTION)) |
| 700 | .text_color(palette.muted) |
| 701 | .child(seen_text(session.last_seen)), |
| 702 | ) |
| 703 | .child(revoke_button) |
| 704 | } |
| 705 | |
| 706 | fn builder_client_row(&self, client: &UpdateClient, palette: Palette) -> Div { |
| 707 | let release = match (client.release, client.target.as_deref()) { |
| 708 | (Some(seq), Some(target)) => format!("#{seq} · {target}"), |
| 709 | _ => w().builder_users.unknown.to_string(), |
| 710 | }; |
| 711 | let state = match client.state { |
| 712 | UpdateState::Unknown => caption_text(w().builder_users.dev, palette.muted), |
| 713 | UpdateState::Latest => caption_text(w().builder_users.latest, palette.ok), |
| 714 | UpdateState::Available { required, .. } => caption_text( |
| 715 | if required { |
| 716 | format!( |
| 717 | "{} · {}", |
| 718 | w().builder_users.available, |
| 719 | w().builder_users.required |
| 720 | ) |
| 721 | } else { |
| 722 | w().builder_users.available.to_string() |
| 723 | }, |
| 724 | palette.muted, |
| 725 | ), |
| 726 | UpdateState::Downloading { percent, .. } => { |
| 727 | meter(f32::from(percent) / 100., format!("{percent}%"), palette) |
| 728 | } |
| 729 | UpdateState::Installing { .. } => { |
| 730 | caption_text(w().builder_users.installing, palette.muted) |
| 731 | } |
| 732 | UpdateState::Ready { .. } => caption_text(w().builder_users.ready, palette.ok), |
| 733 | UpdateState::Failed { .. } => caption_text(w().builder_users.failed, palette.danger), |
| 734 | }; |
| 735 | let dot = div() |
| 736 | .size(px(space::SM)) |
| 737 | .flex_shrink_0() |
| 738 | .rounded_full() |
| 739 | .bg(if client.online { |
| 740 | palette.ok |
| 741 | } else { |
| 742 | palette.muted |
| 743 | }); |
| 744 | let seen = |
| 745 | (!client.online).then(|| caption_text(seen_text(Some(client.seen_ms)), palette.muted)); |
| 746 | |
| 747 | div() |
| 748 | .w_full() |
| 749 | .h(px(size::CONTROL_SM)) |
| 750 | .flex() |
| 751 | .items_center() |
| 752 | .gap(px(space::SM)) |
| 753 | .child(crate::gui::parts::small_icon(IconName::Monitor).text_color(palette.muted)) |
| 754 | .child( |
| 755 | div() |
| 756 | .flex_1() |
| 757 | .text_size(text(text::CAPTION)) |
| 758 | .min_w_0() |
| 759 | .truncate() |
| 760 | .child(client.device.clone()), |
| 761 | ) |
| 762 | .child(caption_text(release, palette.muted)) |
| 763 | .child(state) |
| 764 | .child(dot) |
| 765 | .children(seen) |
| 766 | } |
| 767 | |
| 768 | pub(super) fn builder_rename_row( |
| 769 | &self, |
| 770 | user_id: Id, |
| 771 | entity: &Entity<Self>, |
| 772 | palette: Palette, |
| 773 | cx: &App, |
| 774 | ) -> Div { |
| 775 | let value = self.chat.builder_rename.read(cx).text().to_string(); |
| 776 | let current = self |
| 777 | .chat |
| 778 | .builder_users |
| 779 | .iter() |
| 780 | .find(|account| account.user.id == user_id) |
| 781 | .map_or("", |account| account.user.username.as_str()); |
| 782 | let ready = !value.is_empty() && value != current; |
| 783 | div() |
| 784 | .h(px(size::ROW)) |
| 785 | .px(px(space::MD)) |
| 786 | .flex() |
| 787 | .items_center() |
| 788 | .gap(px(space::SM)) |
| 789 | .child( |
| 790 | div() |
| 791 | .flex_1() |
| 792 | .min_w_0() |
| 793 | .child(field(palette, &self.chat.builder_rename)), |
| 794 | ) |
| 795 | .when(ready, |row| { |
| 796 | row.child(parts::button( |
| 797 | format!("confirm_rename_{user_id}"), |
| 798 | w().builder_users.confirm, |
| 799 | Press::Plain, |
| 800 | palette.tokens, |
| 801 | entity_action(entity, |yumush, window, cx| { |
| 802 | yumush.rename_builder_user(window, cx) |
| 803 | }), |
| 804 | )) |
| 805 | }) |
| 806 | } |
| 807 | |
| 808 | pub(super) fn builder_password_row( |
| 809 | &self, |
| 810 | user_id: Id, |
| 811 | entity: &Entity<Self>, |
| 812 | palette: Palette, |
| 813 | cx: &App, |
| 814 | ) -> Div { |
| 815 | let value = self.chat.builder_password.read(cx).text().to_string(); |
| 816 | let ready = !value.is_empty(); |
| 817 | div() |
| 818 | .h(px(size::ROW)) |
| 819 | .px(px(space::MD)) |
| 820 | .flex() |
| 821 | .items_center() |
| 822 | .gap(px(space::SM)) |
| 823 | .child( |
| 824 | div() |
| 825 | .flex_1() |
| 826 | .min_w_0() |
| 827 | .child(field(palette, &self.chat.builder_password)), |
| 828 | ) |
| 829 | .when(ready, |row| { |
| 830 | row.child(parts::button( |
| 831 | format!("confirm_password_{user_id}"), |
| 832 | w().builder_users.confirm, |
| 833 | Press::Plain, |
| 834 | palette.tokens, |
| 835 | entity_action(entity, |yumush, window, cx| { |
| 836 | yumush.reset_builder_password(window, cx) |
| 837 | }), |
| 838 | )) |
| 839 | }) |
| 840 | } |
| 841 | |
| 842 | pub(super) fn builder_row( |
| 843 | &self, |
| 844 | account: &Account, |
| 845 | me: &User, |
| 846 | entity: &Entity<Self>, |
| 847 | palette: Palette, |
| 848 | cx: &App, |
| 849 | ) -> Div { |
| 850 | let user = &account.user; |
| 851 | let is_self = user.id == me.id; |
| 852 | let manage = permission::can_manage_user(me.role, is_self, user.role); |
| 853 | let can_delete = !is_self && permission::can_delete_user(me.role, is_self, user.role); |
| 854 | let has_actions = manage || can_delete; |
| 855 | let suspended = account.suspended; |
| 856 | let timed_out = account |
| 857 | .suspended_until |
| 858 | .is_some_and(|until| until > now_ms()); |
| 859 | let expanded_sessions = self |
| 860 | .chat |
| 861 | .builder_sessions |
| 862 | .as_ref() |
| 863 | .filter(|(open, _)| *open == user.id) |
| 864 | .map(|(_, sessions)| sessions); |
| 865 | let expanded = expanded_sessions.is_some(); |
| 866 | let pending_delete = self.chat.pending_builder_delete == Some(user.id); |
| 867 | let pending_purge = self.chat.pending_builder_purge == Some(user.id); |
| 868 | let delete_id = user.id; |
| 869 | let suspend_id = user.id; |
| 870 | let sessions_id = user.id; |
| 871 | let password_id = user.id; |
| 872 | let profile_id = user.id; |
| 873 | let sessions_list_id = user.id; |
| 874 | let rename_id = user.id; |
| 875 | let timeout_id = user.id; |
| 876 | let ban_id = user.id; |
| 877 | let purge_id = user.id; |
| 878 | let joined = millis_time(user.created_at, crate::lang::w().common.date); |
| 879 | let seen = seen_text(account.last_seen); |
| 880 | |
| 881 | let tone = palette.text; |
| 882 | let suspend_button = action_button( |
| 883 | format!("suspend_user_{}_{suspended}", user.id), |
| 884 | IconName::CirclePause, |
| 885 | if suspended { |
| 886 | w().builder_users.unsuspend |
| 887 | } else { |
| 888 | w().builder_users.suspend |
| 889 | }, |
| 890 | if suspended { |
| 891 | w().builder_users.allow_sign_in |
| 892 | } else { |
| 893 | w().builder_users.block_until_lifted |
| 894 | }, |
| 895 | tone, |
| 896 | palette, |
| 897 | entity_action(entity, move |yumush, window, cx| { |
| 898 | yumush.suspend_builder_user(suspend_id, !suspended, window, cx) |
| 899 | }), |
| 900 | ); |
| 901 | |
| 902 | let sessions_button = action_button( |
| 903 | format!("sessions_user_{}", user.id), |
| 904 | IconName::LogOut, |
| 905 | w().builder_users.sign_out, |
| 906 | w().builder_users.end_all_sessions, |
| 907 | tone, |
| 908 | palette, |
| 909 | entity_action(entity, move |yumush, window, cx| { |
| 910 | yumush.revoke_builder_sessions(sessions_id, window, cx) |
| 911 | }), |
| 912 | ); |
| 913 | |
| 914 | let stats_id = user.id; |
| 915 | let stats_open = self |
| 916 | .chat |
| 917 | .followed |
| 918 | .as_ref() |
| 919 | .filter(|(id, _)| *id == user.id) |
| 920 | .map(|(_, stats)| stats); |
| 921 | let stats_button = action_button( |
| 922 | format!("stats_user_{}", user.id), |
| 923 | IconName::Activity, |
| 924 | w().builder_users.stats, |
| 925 | w().builder_users.stats_tip, |
| 926 | if stats_open.is_some() { |
| 927 | palette.text |
| 928 | } else { |
| 929 | tone |
| 930 | }, |
| 931 | palette, |
| 932 | entity_action(entity, move |yumush, _, cx| { |
| 933 | yumush.toggle_builder_stats(stats_id, cx) |
| 934 | }), |
| 935 | ); |
| 936 | |
| 937 | let password_button = action_button( |
| 938 | format!("password_user_{}", user.id), |
| 939 | IconName::KeyRound, |
| 940 | w().builder_users.password, |
| 941 | w().builder_users.password_tip, |
| 942 | tone, |
| 943 | palette, |
| 944 | entity_action(entity, move |yumush, _, cx| { |
| 945 | yumush.toggle_builder_password(password_id, cx) |
| 946 | }), |
| 947 | ); |
| 948 | |
| 949 | let toggle_button = clickable( |
| 950 | format!("sessions_list_user_{}", user.id), |
| 951 | palette, |
| 952 | entity_action(entity, move |yumush, window, cx| { |
| 953 | yumush.toggle_builder_sessions(sessions_list_id, window, cx) |
| 954 | }), |
| 955 | ) |
| 956 | .tip(w().builder_users.manage) |
| 957 | .size(px(size::CONTROL_SM)) |
| 958 | .flex_shrink_0() |
| 959 | .flex() |
| 960 | .items_center() |
| 961 | .justify_center() |
| 962 | .rounded(px(radius::MD)) |
| 963 | .text_color(palette.muted) |
| 964 | .when(expanded, |this| this.bg(palette.hover)) |
| 965 | .child(Icon::new(IconName::Ellipsis).size(px(size::ICON))); |
| 966 | |
| 967 | let rename_button = action_button( |
| 968 | format!("rename_user_{}", user.id), |
| 969 | IconName::Pencil, |
| 970 | w().builder_users.rename, |
| 971 | w().builder_users.rename_tip, |
| 972 | tone, |
| 973 | palette, |
| 974 | entity_action(entity, move |yumush, _, cx| { |
| 975 | yumush.toggle_builder_rename(rename_id, cx) |
| 976 | }), |
| 977 | ); |
| 978 | |
| 979 | let timeout_button = action_button( |
| 980 | format!("timeout_user_{}", user.id), |
| 981 | IconName::Timer, |
| 982 | w().builder_users.timeout, |
| 983 | w().builder_users.timeout_tip, |
| 984 | tone, |
| 985 | palette, |
| 986 | entity_action(entity, move |yumush, _, cx| { |
| 987 | yumush.toggle_builder_timeout(timeout_id, cx) |
| 988 | }), |
| 989 | ); |
| 990 | |
| 991 | let ban_button = action_button( |
| 992 | format!("ban_user_{}", user.id), |
| 993 | IconName::Ban, |
| 994 | w().builder_users.ban, |
| 995 | w().builder_users.ban_tip, |
| 996 | tone, |
| 997 | palette, |
| 998 | entity_action(entity, move |yumush, _, cx| { |
| 999 | yumush.toggle_builder_ban(ban_id, cx) |
| 1000 | }), |
| 1001 | ); |
| 1002 | |
| 1003 | let profile_button = action_button( |
| 1004 | format!("profile_user_{}", user.id), |
| 1005 | IconName::Eraser, |
| 1006 | w().builder_users.clear_profile, |
| 1007 | w().builder_users.clear_profile_tip, |
| 1008 | palette.danger, |
| 1009 | palette, |
| 1010 | entity_action(entity, move |yumush, window, cx| { |
| 1011 | yumush.clear_builder_profile(profile_id, window, cx) |
| 1012 | }), |
| 1013 | ); |
| 1014 | |
| 1015 | let purge_button = confirm_button( |
| 1016 | format!("purge_user_{}", user.id), |
| 1017 | IconName::MessageSquareX, |
| 1018 | w().builder_users.purge, |
| 1019 | w().builder_users.purge_tip, |
| 1020 | pending_purge, |
| 1021 | palette, |
| 1022 | entity_action(entity, move |yumush, window, cx| { |
| 1023 | yumush.purge_builder_user(purge_id, window, cx) |
| 1024 | }), |
| 1025 | ); |
| 1026 | |
| 1027 | let delete_button = confirm_button( |
| 1028 | format!("delete_user_{}", user.id), |
| 1029 | IconName::UserX, |
| 1030 | w().builder_users.delete, |
| 1031 | w().builder_users.delete_tip, |
| 1032 | pending_delete, |
| 1033 | palette, |
| 1034 | entity_action(entity, move |yumush, window, cx| { |
| 1035 | yumush.delete_builder_user(delete_id, window, cx) |
| 1036 | }), |
| 1037 | ); |
| 1038 | |
| 1039 | let row = div() |
| 1040 | .px(px(space::LG)) |
| 1041 | .py(px(space::MD)) |
| 1042 | .flex() |
| 1043 | .items_center() |
| 1044 | .gap(px(space::MD)) |
| 1045 | .child(user_link( |
| 1046 | format!("builder_user_avatar_{}", user.id), |
| 1047 | Some(user), |
| 1048 | entity, |
| 1049 | avatar( |
| 1050 | palette, |
| 1051 | user, |
| 1052 | px(size::AVATAR), |
| 1053 | text(text::CAPTION), |
| 1054 | &self.chat.avatars, |
| 1055 | ), |
| 1056 | )) |
| 1057 | .child( |
| 1058 | div() |
| 1059 | .flex_1() |
| 1060 | .min_w_0() |
| 1061 | .flex() |
| 1062 | .flex_col() |
| 1063 | .gap(px(space::XXS)) |
| 1064 | .child( |
| 1065 | div() |
| 1066 | .min_w_0() |
| 1067 | .flex() |
| 1068 | .items_center() |
| 1069 | .gap(px(space::SM)) |
| 1070 | .child(user_link( |
| 1071 | format!("builder_user_name_{}", user.id), |
| 1072 | Some(user), |
| 1073 | entity, |
| 1074 | div() |
| 1075 | .truncate() |
| 1076 | .text_size(text(text::LABEL)) |
| 1077 | .font_weight(FontWeight::MEDIUM) |
| 1078 | .text_color(palette.text) |
| 1079 | .child(user.username.clone()), |
| 1080 | )) |
| 1081 | .when(user.role == Role::Builder, |this| { |
| 1082 | this.child(status( |
| 1083 | w().builder_users.tag_builder, |
| 1084 | palette.accent, |
| 1085 | palette, |
| 1086 | )) |
| 1087 | }) |
| 1088 | .when(suspended, |this| { |
| 1089 | this.child(status( |
| 1090 | w().builder_users.tag_suspended, |
| 1091 | palette.danger, |
| 1092 | palette, |
| 1093 | )) |
| 1094 | }) |
| 1095 | .when(timed_out, |this| { |
| 1096 | this.child(status( |
| 1097 | w().builder_users.tag_timed_out, |
| 1098 | palette.danger, |
| 1099 | palette, |
| 1100 | )) |
| 1101 | }) |
| 1102 | .when(account.ghost, |this| { |
| 1103 | this.child(status( |
| 1104 | w().builder_users.tag_ghost, |
| 1105 | palette.muted, |
| 1106 | palette, |
| 1107 | )) |
| 1108 | }), |
| 1109 | ) |
| 1110 | .child( |
| 1111 | div() |
| 1112 | .min_w_0() |
| 1113 | .truncate() |
| 1114 | .text_size(text(text::CAPTION)) |
| 1115 | .text_color(palette.muted) |
| 1116 | .child(w().builder_users.joined_seen(joined, seen)), |
| 1117 | ), |
| 1118 | ) |
| 1119 | .children(has_actions.then_some(toggle_button)); |
| 1120 | |
| 1121 | let panel = expanded_sessions.map(|sessions| { |
| 1122 | let open_id = user.id; |
| 1123 | let password_open = self.chat.pending_builder_password == Some(open_id); |
| 1124 | let rename_open = self.chat.pending_builder_rename == Some(open_id); |
| 1125 | let timeout_open = self.chat.pending_builder_timeout == Some(open_id); |
| 1126 | let ban_open = self.chat.pending_builder_ban == Some(open_id); |
| 1127 | |
| 1128 | let account_actions = [ |
| 1129 | manage.then(|| rename_button.into_any_element()), |
| 1130 | manage.then(|| password_button.into_any_element()), |
| 1131 | Some(stats_button.into_any_element()), |
| 1132 | ]; |
| 1133 | let moderation_actions = [ |
| 1134 | manage.then(|| timeout_button.into_any_element()), |
| 1135 | manage.then(|| suspend_button.into_any_element()), |
| 1136 | manage.then(|| ban_button.into_any_element()), |
| 1137 | manage.then(|| sessions_button.into_any_element()), |
| 1138 | ]; |
| 1139 | let danger_actions = [ |
| 1140 | manage.then(|| profile_button.into_any_element()), |
| 1141 | manage.then(|| purge_button.into_any_element()), |
| 1142 | can_delete.then(|| delete_button.into_any_element()), |
| 1143 | ]; |
| 1144 | let sessions: Vec<AnyElement> = sessions |
| 1145 | .iter() |
| 1146 | .map(|session| { |
| 1147 | self.builder_session_row(user.id, session, entity, palette) |
| 1148 | .into_any_element() |
| 1149 | }) |
| 1150 | .collect(); |
| 1151 | let clients: Vec<AnyElement> = if self.chat.builder_clients.is_empty() { |
| 1152 | vec![caption_text(w().builder_users.no_clients, palette.muted).into_any_element()] |
| 1153 | } else { |
| 1154 | self.chat |
| 1155 | .builder_clients |
| 1156 | .iter() |
| 1157 | .map(|client| self.builder_client_row(client, palette).into_any_element()) |
| 1158 | .collect() |
| 1159 | }; |
| 1160 | |
| 1161 | div() |
| 1162 | .flex() |
| 1163 | .flex_col() |
| 1164 | .gap(px(space::SM)) |
| 1165 | .ml(px(space::MD)) |
| 1166 | .mb(px(space::MD)) |
| 1167 | .pl(px(space::XL)) |
| 1168 | .py(px(space::SM)) |
| 1169 | .border_l(px(crate::gui::style::stroke::LINE)) |
| 1170 | .border_color(palette.tokens.person(user.id)) |
| 1171 | .children(action_group( |
| 1172 | w().builder_users.group_account, |
| 1173 | palette, |
| 1174 | account_actions.into_iter().flatten().collect(), |
| 1175 | )) |
| 1176 | .children( |
| 1177 | password_open.then(|| self.builder_password_row(user.id, entity, palette, cx)), |
| 1178 | ) |
| 1179 | .children( |
| 1180 | rename_open.then(|| self.builder_rename_row(user.id, entity, palette, cx)), |
| 1181 | ) |
| 1182 | .children(action_group( |
| 1183 | w().builder_users.group_moderation, |
| 1184 | palette, |
| 1185 | moderation_actions.into_iter().flatten().collect(), |
| 1186 | )) |
| 1187 | .children(timeout_open.then(|| self.builder_timeout_row(user.id, entity, palette))) |
| 1188 | .children(ban_open.then(|| self.builder_ban_row(user.id, entity, palette))) |
| 1189 | .children(action_group( |
| 1190 | w().builder_users.group_danger, |
| 1191 | palette, |
| 1192 | danger_actions.into_iter().flatten().collect(), |
| 1193 | )) |
| 1194 | .children(action_group( |
| 1195 | w().builder_users.group_sessions, |
| 1196 | palette, |
| 1197 | sessions, |
| 1198 | )) |
| 1199 | .children(action_group( |
| 1200 | w().builder_users.group_clients, |
| 1201 | palette, |
| 1202 | clients, |
| 1203 | )) |
| 1204 | .children(action_group( |
| 1205 | w().builder_users.group_friends, |
| 1206 | palette, |
| 1207 | self.builder_friend_list(palette), |
| 1208 | )) |
| 1209 | .children(stats_open.map(|stats| { |
| 1210 | super::super::voice_stats::stats_panel( |
| 1211 | stats, |
| 1212 | &|id| self.chat.name_of(id), |
| 1213 | super::super::voice_stats::Detail::Full, |
| 1214 | palette, |
| 1215 | ) |
| 1216 | .pt(px(space::MD)) |
| 1217 | })) |
| 1218 | }); |
| 1219 | |
| 1220 | div().flex().flex_col().child(row).children(panel) |
| 1221 | } |
| 1222 | } |