Defer is_staff check for the project_diff::Deploy action (#21582)

During workspace registration, it's too early to check for the
`is_staff` flag due to no connection being established yet.
As a compromise, allow the action to appear and be registered, but do
nothing for non-staff users.

Release Notes:

- N/A
This commit is contained in:
Kirill Bulatov 2024-12-05 11:55:06 +02:00 committed by GitHub
parent 9487fffc55
commit 78fea0dd8e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -62,13 +62,15 @@ struct Changes {
}
impl ProjectDiffEditor {
fn register(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
if cx.is_staff() {
workspace.register_action(Self::deploy);
}
fn register(workspace: &mut Workspace, _: &mut ViewContext<Workspace>) {
workspace.register_action(Self::deploy);
}
fn deploy(workspace: &mut Workspace, _: &Deploy, cx: &mut ViewContext<Workspace>) {
if !cx.is_staff() {
return;
}
if let Some(existing) = workspace.item_of_type::<Self>(cx) {
workspace.activate_item(&existing, true, true, cx);
} else {