Render overlay after remote project becomes read-only

Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
Antonio Scandurra 2022-03-04 17:28:18 +01:00
parent dc5a09b3f7
commit b21d91db22
7 changed files with 73 additions and 17 deletions

View file

@ -1297,6 +1297,24 @@ impl Workspace {
None
}
}
fn render_disconnected_overlay(&self, cx: &AppContext) -> Option<ElementBox> {
if self.project.read(cx).is_read_only() {
let theme = &self.settings.borrow().theme;
Some(
Label::new(
"Your connection to the remote project has been lost.".to_string(),
theme.workspace.disconnected_overlay.text.clone(),
)
.aligned()
.contained()
.with_style(theme.workspace.disconnected_overlay.container)
.boxed(),
)
} else {
None
}
}
}
impl Entity for Workspace {
@ -1339,6 +1357,7 @@ impl View for Workspace {
content.boxed()
})
.with_children(self.modal.as_ref().map(|m| ChildView::new(m).boxed()))
.with_children(self.render_disconnected_overlay(cx))
.flexible(1.0, true)
.boxed(),
)