Add DiffOps playground
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use crate::{
|
||||
api,
|
||||
api, app,
|
||||
component::text::text,
|
||||
query::{self, QueryStatus, read_query, use_query},
|
||||
};
|
||||
|
||||
@@ -7,16 +8,14 @@ pub(crate) struct PullRequestDiffView {
|
||||
selected_file_path: Option<String>,
|
||||
|
||||
pr_query: query::Entity<api::issues::FetchPullRequest>,
|
||||
old_content_query: Option<query::Entity<api::repo::FetchFileContent>>,
|
||||
new_content_query: Option<query::Entity<api::repo::FetchFileContent>>,
|
||||
content_diff_query: Option<query::Entity<api::repo::FetchFileDiff>>,
|
||||
}
|
||||
|
||||
fn new(pr_id: api::issues::Id, cx: &mut gpui::Context<PullRequestDiffView>) -> PullRequestDiffView {
|
||||
let mut view = PullRequestDiffView {
|
||||
selected_file_path: None,
|
||||
pr_query: use_query(api::issues::FetchPullRequest { id: pr_id }, cx),
|
||||
old_content_query: None,
|
||||
new_content_query: None,
|
||||
content_diff_query: None,
|
||||
};
|
||||
view.on_create(cx);
|
||||
view
|
||||
@@ -35,15 +34,15 @@ impl PullRequestDiffView {
|
||||
}
|
||||
|
||||
fn start_content_queries(&mut self, cx: &mut gpui::Context<Self>) {
|
||||
let Some((old_content_query, new_content_query)) = ({
|
||||
let Some((old_file_ref, new_file_ref)) = ({
|
||||
if let QueryStatus::Loaded(pr) = read_query(&self.pr_query, cx) {
|
||||
Some((
|
||||
api::repo::FetchFileContent {
|
||||
api::repo::FileRef {
|
||||
repo_slug: pr.base_repo_slug.clone(),
|
||||
path: pr.base_branch_name.clone(),
|
||||
reff: Some(pr.base_ref.clone()),
|
||||
},
|
||||
api::repo::FetchFileContent {
|
||||
api::repo::FileRef {
|
||||
repo_slug: pr.head_repo_slug.clone(),
|
||||
path: pr.head_branch_name.clone(),
|
||||
reff: Some(pr.head_ref.clone()),
|
||||
@@ -56,24 +55,38 @@ impl PullRequestDiffView {
|
||||
return;
|
||||
};
|
||||
|
||||
let old_content_query = use_query(old_content_query, cx);
|
||||
let new_content_query = use_query(new_content_query, cx);
|
||||
let content_diff_query = use_query(
|
||||
api::repo::FetchFileDiff {
|
||||
base: old_file_ref,
|
||||
head: new_file_ref,
|
||||
},
|
||||
cx,
|
||||
);
|
||||
|
||||
_ = cx.observe(&old_content_query, |this, _, cx| {}).detach();
|
||||
|
||||
_ = cx.observe(&new_content_query, |this, _, cx| {}).detach();
|
||||
|
||||
self.old_content_query = Some(old_content_query);
|
||||
self.new_content_query = Some(new_content_query);
|
||||
self.content_diff_query = Some(content_diff_query);
|
||||
}
|
||||
}
|
||||
|
||||
impl gpui::Render for PullRequestDiffView {
|
||||
fn render(
|
||||
&mut self,
|
||||
window: &mut gpui::Window,
|
||||
_window: &mut gpui::Window,
|
||||
cx: &mut gpui::Context<Self>,
|
||||
) -> impl gpui::IntoElement {
|
||||
todo!()
|
||||
use gpui::{ParentElement, Styled, div};
|
||||
|
||||
let theme = app::current_theme(cx);
|
||||
|
||||
div()
|
||||
.size_full()
|
||||
.bg(theme.colors.surface)
|
||||
.p_4()
|
||||
.child(
|
||||
text(
|
||||
"Pull request diff rendering is still under construction. Launch the DiffOps playground with NOVEM_DIFFOPS_PLAYGROUND=1 cargo run.",
|
||||
)
|
||||
.text_sm()
|
||||
.text_color(theme.colors.text_muted),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user