Skip to repository content

tenant.openagents/omega

No repository description is available.

OpenAgents Git authority 2026-07-28T04:42:18.693Z Public web read
NIP-34 coordinate30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omega
MaintainersHidden in public view
References2 branches · 1 tag
Read-only clonegit clone https://openagents.com/git/tenant.openagents/omega.git
Browse files

project_empty_state.rs

95 lines · 3.2 KB · rust
1use crate::{Divider, DividerColor, KeyBinding, prelude::*};
2use gpui::{ClickEvent, FocusHandle};
3
4type ClickHandler = Box<dyn Fn(&ClickEvent, &mut Window, &mut App) + 'static>;
5
6#[derive(IntoElement)]
7pub struct ProjectEmptyState {
8    label: SharedString,
9    focus_handle: FocusHandle,
10    open_project_key_binding: KeyBinding,
11    on_open_project: Option<ClickHandler>,
12    on_clone_repo: Option<ClickHandler>,
13}
14
15impl ProjectEmptyState {
16    pub fn new(
17        label: impl Into<SharedString>,
18        focus_handle: FocusHandle,
19        open_project_key_binding: KeyBinding,
20    ) -> Self {
21        Self {
22            label: label.into(),
23            focus_handle,
24            open_project_key_binding,
25            on_open_project: None,
26            on_clone_repo: None,
27        }
28    }
29
30    pub fn on_open_project(
31        mut self,
32        handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
33    ) -> Self {
34        self.on_open_project = Some(Box::new(handler));
35        self
36    }
37
38    pub fn on_clone_repo(
39        mut self,
40        handler: impl Fn(&ClickEvent, &mut Window, &mut App) + 'static,
41    ) -> Self {
42        self.on_clone_repo = Some(Box::new(handler));
43        self
44    }
45}
46
47impl RenderOnce for ProjectEmptyState {
48    fn render(self, _window: &mut Window, _cx: &mut App) -> impl IntoElement {
49        let id = format!("empty-state-{}", self.label);
50        let label = format!("Choose one of the options below to use the {}", self.label);
51
52        v_flex()
53            .id(id)
54            .p_4()
55            .size_full()
56            .items_center()
57            .justify_center()
58            .track_focus(&self.focus_handle)
59            .child(
60                v_flex()
61                    .w_48()
62                    .max_w_full()
63                    .gap_1()
64                    .child(
65                        div()
66                            .text_center()
67                            .mb_2()
68                            .child(Label::new(label).size(LabelSize::Small).color(Color::Muted)),
69                    )
70                    .child(
71                        Button::new("open_project", "Open Project")
72                            .full_width()
73                            .key_binding(self.open_project_key_binding)
74                            .when_some(self.on_open_project, |button, handler| {
75                                button.on_click(handler)
76                            }),
77                    )
78                    .child(
79                        h_flex()
80                            .gap_2()
81                            .child(Divider::horizontal().color(DividerColor::Border))
82                            .child(Label::new("or").size(LabelSize::XSmall).color(Color::Muted))
83                            .child(Divider::horizontal().color(DividerColor::Border)),
84                    )
85                    .child(
86                        Button::new("clone_repo", "Clone Repository")
87                            .full_width()
88                            .when_some(self.on_clone_repo, |button, handler| {
89                                button.on_click(handler)
90                            }),
91                    ),
92            )
93    }
94}
95
Served at tenant.openagents/omega Member data and write actions are omitted.