Show non-admin context menu items for all channel members
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
c7c220309d
commit
7b6c0c539c
1 changed files with 43 additions and 38 deletions
|
@ -1923,47 +1923,52 @@ impl CollabPanel {
|
||||||
channel_id: u64,
|
channel_id: u64,
|
||||||
cx: &mut ViewContext<Self>,
|
cx: &mut ViewContext<Self>,
|
||||||
) {
|
) {
|
||||||
if self.channel_store.read(cx).is_user_admin(channel_id) {
|
self.context_menu_on_selected = position.is_none();
|
||||||
self.context_menu_on_selected = position.is_none();
|
|
||||||
|
|
||||||
self.context_menu.update(cx, |context_menu, cx| {
|
self.context_menu.update(cx, |context_menu, cx| {
|
||||||
context_menu.set_position_mode(if self.context_menu_on_selected {
|
context_menu.set_position_mode(if self.context_menu_on_selected {
|
||||||
OverlayPositionMode::Local
|
OverlayPositionMode::Local
|
||||||
} else {
|
} else {
|
||||||
OverlayPositionMode::Window
|
OverlayPositionMode::Window
|
||||||
});
|
|
||||||
|
|
||||||
let expand_action_name = if self.is_channel_collapsed(channel_id) {
|
|
||||||
"Expand Subchannels"
|
|
||||||
} else {
|
|
||||||
"Collapse Subchannels"
|
|
||||||
};
|
|
||||||
|
|
||||||
context_menu.show(
|
|
||||||
position.unwrap_or_default(),
|
|
||||||
if self.context_menu_on_selected {
|
|
||||||
gpui::elements::AnchorCorner::TopRight
|
|
||||||
} else {
|
|
||||||
gpui::elements::AnchorCorner::BottomLeft
|
|
||||||
},
|
|
||||||
vec![
|
|
||||||
ContextMenuItem::action(expand_action_name, ToggleCollapse { channel_id }),
|
|
||||||
ContextMenuItem::action("New Subchannel", NewChannel { channel_id }),
|
|
||||||
ContextMenuItem::action("Open Notes", OpenChannelBuffer { channel_id }),
|
|
||||||
ContextMenuItem::Separator,
|
|
||||||
ContextMenuItem::action("Invite to Channel", InviteMembers { channel_id }),
|
|
||||||
ContextMenuItem::Separator,
|
|
||||||
ContextMenuItem::action("Rename", RenameChannel { channel_id }),
|
|
||||||
ContextMenuItem::action("Manage", ManageMembers { channel_id }),
|
|
||||||
ContextMenuItem::Separator,
|
|
||||||
ContextMenuItem::action("Delete", RemoveChannel { channel_id }),
|
|
||||||
],
|
|
||||||
cx,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
cx.notify();
|
let expand_action_name = if self.is_channel_collapsed(channel_id) {
|
||||||
}
|
"Expand Subchannels"
|
||||||
|
} else {
|
||||||
|
"Collapse Subchannels"
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut items = vec![
|
||||||
|
ContextMenuItem::action(expand_action_name, ToggleCollapse { channel_id }),
|
||||||
|
ContextMenuItem::action("Open Notes", OpenChannelBuffer { channel_id }),
|
||||||
|
];
|
||||||
|
|
||||||
|
if self.channel_store.read(cx).is_user_admin(channel_id) {
|
||||||
|
items.extend([
|
||||||
|
ContextMenuItem::Separator,
|
||||||
|
ContextMenuItem::action("New Subchannel", NewChannel { channel_id }),
|
||||||
|
ContextMenuItem::action("Rename", RenameChannel { channel_id }),
|
||||||
|
ContextMenuItem::Separator,
|
||||||
|
ContextMenuItem::action("Invite Members", InviteMembers { channel_id }),
|
||||||
|
ContextMenuItem::action("Manage Members", ManageMembers { channel_id }),
|
||||||
|
ContextMenuItem::Separator,
|
||||||
|
ContextMenuItem::action("Delete", RemoveChannel { channel_id }),
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
context_menu.show(
|
||||||
|
position.unwrap_or_default(),
|
||||||
|
if self.context_menu_on_selected {
|
||||||
|
gpui::elements::AnchorCorner::TopRight
|
||||||
|
} else {
|
||||||
|
gpui::elements::AnchorCorner::BottomLeft
|
||||||
|
},
|
||||||
|
items,
|
||||||
|
cx,
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cancel(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
|
fn cancel(&mut self, _: &Cancel, cx: &mut ViewContext<Self>) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue