mirror of
https://github.com/zed-industries/zed.git
synced 2024-10-23 23:09:42 +00:00
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,
|
||||
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| {
|
||||
context_menu.set_position_mode(if self.context_menu_on_selected {
|
||||
OverlayPositionMode::Local
|
||||
} else {
|
||||
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,
|
||||
);
|
||||
self.context_menu.update(cx, |context_menu, cx| {
|
||||
context_menu.set_position_mode(if self.context_menu_on_selected {
|
||||
OverlayPositionMode::Local
|
||||
} else {
|
||||
OverlayPositionMode::Window
|
||||
});
|
||||
|
||||
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>) {
|
||||
|
|
Loading…
Reference in a new issue