Builder row on your own card, between Settings and Log out
Browse files at this commite4dde77851652fc86abe3f13df82179713538c0aParent: f2d084f- style
- Builder row on your own card, between Settings and Log out
1 changed file +30 -4
crates/client/src/gui/profile.rsmodified+30 -4
| @@ -7,7 +7,7 @@ use std::{collections::HashMap, sync::Arc}; | |||
| 7 | 7 | ||
| 8 | use common::{ | 8 | use common::{ |
| 9 | call::{BanMember, DeleteUser, Kick, SetRank, UpdatePresence}, | 9 | call::{BanMember, DeleteUser, Kick, SetRank, UpdatePresence}, |
| 10 | - model::{Presence, Rank, User}, | 10 | + model::{Presence, Rank, Role, User}, |
| 11 | permission, | 11 | permission, |
| 12 | }; | 12 | }; |
| 13 | use gpui_kit::{ | 13 | use gpui_kit::{ |
| @@ -242,7 +242,14 @@ impl Card { | |||
| 242 | .flex() | 242 | .flex() |
| 243 | .flex_col() | 243 | .flex_col() |
| 244 | .gap(px(space::XS)) | 244 | .gap(px(space::XS)) |
| 245 | - .children(main_self_rows(entity, &popover, palette)) | 245 | + .children(main_self_rows( |
| 246 | + self.viewer | ||
| 247 | + .as_ref() | ||
| 248 | + .is_some_and(|viewer| permission::is_builder(viewer.role)), | ||
| 249 | + entity, | ||
| 250 | + &popover, | ||
| 251 | + palette, | ||
| 252 | + )) | ||
| 246 | .into_any_element() | 253 | .into_any_element() |
| 247 | } else { | 254 | } else { |
| 248 | let mut rows = self.social_rows(entity, &popover, palette); | 255 | let mut rows = self.social_rows(entity, &popover, palette); |
| @@ -585,11 +592,12 @@ impl Card { | |||
| 585 | } | 592 | } |
| 586 | 593 | ||
| 587 | fn main_self_rows( | 594 | fn main_self_rows( |
| 595 | + builder: bool, | ||
| 588 | entity: &Entity<Yumush>, | 596 | entity: &Entity<Yumush>, |
| 589 | popover: &Entity<PopoverState>, | 597 | popover: &Entity<PopoverState>, |
| 590 | palette: Palette, | 598 | palette: Palette, |
| 591 | ) -> Vec<AnyElement> { | 599 | ) -> Vec<AnyElement> { |
| 592 | - vec![ | 600 | + let mut rows = vec![ |
| 593 | menu_row( | 601 | menu_row( |
| 594 | "profile_settings", | 602 | "profile_settings", |
| 595 | w().profile.settings, | 603 | w().profile.settings, |
| @@ -601,6 +609,23 @@ fn main_self_rows( | |||
| 601 | }), | 609 | }), |
| 602 | ) | 610 | ) |
| 603 | .into_any_element(), | 611 | .into_any_element(), |
| 612 | + ]; | ||
| 613 | + if builder { | ||
| 614 | + rows.push( | ||
| 615 | + menu_row( | ||
| 616 | + "profile_builder", | ||
| 617 | + Role::Builder.label(), | ||
| 618 | + menu_icon(IconName::Shield), | ||
| 619 | + palette.text, | ||
| 620 | + palette, | ||
| 621 | + yumush_action(entity, popover, |yumush, window, cx| { | ||
| 622 | + yumush.show_view(View::Builder, window, cx) | ||
| 623 | + }), | ||
| 624 | + ) | ||
| 625 | + .into_any_element(), | ||
| 626 | + ); | ||
| 627 | + } | ||
| 628 | + rows.push( | ||
| 604 | menu_row( | 629 | menu_row( |
| 605 | "profile_logout", | 630 | "profile_logout", |
| 606 | w().profile.log_out, | 631 | w().profile.log_out, |
| @@ -612,7 +637,8 @@ fn main_self_rows( | |||
| 612 | }), | 637 | }), |
| 613 | ) | 638 | ) |
| 614 | .into_any_element(), | 639 | .into_any_element(), |
| 615 | - ] | 640 | + ); |
| 641 | + rows | ||
| 616 | } | 642 | } |
| 617 | 643 | ||
| 618 | fn accounts_rows( | 644 | fn accounts_rows( |