forge
Explore
Log in

Don't you dare go Hollow

Settings only offered to members who can manage something (permission::can_manage_community)

Browse files at this commit

92a09380f49c7f734801bade4419587720ae8636Ahmet Kaan GümüşParent: 395f5e1
  • fix
    • Settings only offered to members who can manage something (permission::can_manage_community)
    • settings page never empty (Leave always shown)
    • builder action grid aligned again
Show full message
🐛 fix: Settings only offered to members who can manage something (permission::can_manage_community); settings page never empty (Leave always shown); builder action grid aligned again
crates/client/src/gui/builder/ui.rsmodified+1 -0
@@ -97,6 +97,7 @@ pub(super) fn action_button(
9797 ) -> Stateful<Div> {
9898 parts::press(id, palette.tokens, action)
9999 .tip(tip)
100+ .px_0()
100101 .min_w(px(size::THUMB))
101102 .text_size(text(text::CAPTION))
102103 .font_weight(FontWeight::MEDIUM)
crates/client/src/gui/community_card.rsmodified+5 -1
@@ -87,6 +87,7 @@ pub(super) fn community_popover(
8787 id,
8888 true,
8989 permission::can_leave(yumush.actor_rank()),
90+ permission::can_manage_community(yumush.actor_rank()),
9091 yumush,
9192 &entity,
9293 &popover,
@@ -99,6 +100,7 @@ pub(super) fn room_rows(
99100 id: Id,
100101 group: bool,
101102 can_leave: bool,
103+ can_manage: bool,
102104 yumush: &Yumush,
103105 entity: &Entity<Yumush>,
104106 popover: &Entity<PopoverState>,
@@ -133,7 +135,9 @@ pub(super) fn room_rows(
133135 palette.text,
134136 |yumush, id, window, cx| yumush.open_invite(id, window, cx),
135137 ))
136- .child(row(
138+ })
139+ .when(group && can_manage, |this| {
140+ this.child(row(
137141 "room_settings",
138142 words.settings,
139143 IconName::Settings,
crates/client/src/gui/community_settings.rsmodified+4 -3
@@ -199,10 +199,11 @@ impl Yumush {
199199 .into_any_element(),
200200 );
201201 }
202- if !sections.is_empty() {
203- let first = sections.remove(0);
204- sections.insert(0, with_danger(first, danger));
202+ if sections.is_empty() {
203+ sections.push(section(w().community_settings.general, palette, Vec::new()));
205204 }
205+ let first = sections.remove(0);
206+ sections.insert(0, with_danger(first, danger));
206207
207208 page(
208209 "community_settings_scroll",
crates/client/src/gui/sidebar.rsmodified+2 -0
@@ -563,6 +563,7 @@ impl Yumush {
563563 let active = self.chat.is_selected(community.id);
564564 let group = community.kind.is_group();
565565 let can_leave = group && (!active || permission::can_leave(self.actor_rank()));
566+ let can_manage = !active || permission::can_manage_community(self.actor_rank());
566567 let muted = self.chat.muted.contains(&community.id);
567568 let unread = self.chat.unread.get(&community.id);
568569 let community_id = community.id;
@@ -634,6 +635,7 @@ impl Yumush {
634635 community_id,
635636 group,
636637 can_leave,
638+ can_manage,
637639 yumush,
638640 &menu,
639641 popover,
crates/common/src/permission.rsmodified+8 -0
@@ -77,6 +77,14 @@ pub fn can_transfer_ownership(actor: Option<Rank>) -> bool {
7777 actor >= Some(Rank::Owner)
7878 }
7979
80+pub fn can_manage_community(actor: Option<Rank>) -> bool {
81+ can_rename_community(actor)
82+ || can_manage_voice(actor)
83+ || can_unban(actor)
84+ || can_read_logs(actor)
85+ || can_delete_community(actor)
86+}
87+
8088 pub fn can_leave(actor: Option<Rank>) -> bool {
8189 actor.is_some() && actor != Some(Rank::Owner)
8290 }