Skip to content

Commit cdefda1

Browse files
committed
fix: multi tab sql load support
1 parent 16ce6c7 commit cdefda1

File tree

3 files changed

+50
-58
lines changed

3 files changed

+50
-58
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Welcome to the Tauri-Leptos PostgreSQL GUI, a fully Rust-based application for e
1212
- [x] **Multi-Connection Support:** Enable the GUI to handle multiple database connections simultaneously.
1313
- [x] **SQL Query Saving:** Allow users to save and manage their frequently used SQL queries.
1414
- [x] **Grid and Record View:** Provide a grid view for query results, as well as a record view for individual records.
15+
- [ ] **Multi Tab Support:** Allow users to open multiple tabs for SQL queries.
1516
- [ ] **BigQuery Support:** Add support for BigQuery databases.
1617

1718
## Key Features

src/layout.rs

Lines changed: 47 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
use leptos::{html::*, *};
2-
use thaw::{
3-
Button,
4-
Tab,
5-
//TabProps,
6-
Tabs,
7-
// TabsProps
8-
};
2+
use thaw::{Button, ButtonProps, Tab, TabProps, Tabs, TabsProps};
93

104
use crate::{footer, query_editor, query_table, sidebar, store::tabs};
115

@@ -21,56 +15,52 @@ pub fn component() -> impl IntoView {
2115
.child(
2216
main()
2317
.classes("flex-1 overflow-y-scroll")
24-
.child(
25-
view! {
26-
<Tabs value=tabs.selected_tab>
27-
<For each=move || (0..tabs.active_tabs.get()) key=|index| index.to_string() let:index>
28-
<Tab key=index.to_string() label=(index + 1).to_string()>
29-
{query_editor::component()}
30-
{query_table::component()}
31-
</Tab>
32-
</For>
33-
</Tabs>
34-
<Button on_click=move |_| {
35-
tabs.active_tabs.update(|prev| *prev += 1);
36-
tabs.selected_tab.update(|prev| *prev = (tabs.active_tabs.get() - 1).to_string());
37-
}>"+1"</Button>
38-
}),
39-
// .child(Tabs(TabsProps {
40-
// value: tabs.selected_tab,
41-
// class: MaybeSignal::Static(String::new()),
42-
// children: Children::to_children(move || {
43-
// Fragment::new(vec![
44-
// For(ForProps {
45-
// each: move || (0..tabs.active_tabs.get()),
46-
// key: |index| index.to_string(),
47-
// children: move |index| {
48-
// Tab(TabProps {
49-
// class: MaybeSignal::Static(String::new()),
50-
// key: index.to_string(),
51-
// label: (index + 1).to_string(),
52-
// children: Children::to_children(move || {
53-
// Fragment::new(vec![
54-
// query_editor::component().into_view(),
55-
// query_table::component().into_view(),
56-
// ])
57-
// }),
58-
// })
59-
// },
60-
// })
61-
// .into_view(),
62-
// button()
63-
// .on(ev::click, move |_| {
64-
// tabs.active_tabs.update(|prev| *prev += 1);
65-
// tabs
66-
// .selected_tab
67-
// .update(|prev| *prev = (tabs.active_tabs.get() - 1).to_string());
68-
// })
69-
// .child("+")
70-
// .into_view(),
71-
// ])
72-
// }),
73-
// })),
18+
.child(div().child(Tabs(TabsProps {
19+
value: tabs.selected_tab,
20+
class: MaybeSignal::default(),
21+
children: Children::to_children(move || {
22+
Fragment::new(vec![For(ForProps {
23+
each: move || (0..tabs.active_tabs.get()),
24+
key: |index| index.to_string(),
25+
children: move |index| {
26+
Fragment::new(vec![Tab(TabProps {
27+
class: MaybeSignal::default(),
28+
key: index.to_string(),
29+
label: (index + 1).to_string(),
30+
children: Children::to_children(move || {
31+
Fragment::new(vec![
32+
query_editor::component().into_view(),
33+
query_table::component().into_view(),
34+
])
35+
}),
36+
})
37+
.into_view()])
38+
},
39+
})
40+
.into_view()])
41+
}),
42+
})))
43+
.child(Button(ButtonProps {
44+
style: MaybeSignal::default(),
45+
class: MaybeSignal::Static(String::from("absolute top-2 right-2")),
46+
variant: MaybeSignal::default(),
47+
color: MaybeSignal::default(),
48+
size: MaybeSignal::default(),
49+
round: MaybeSignal::default(),
50+
circle: MaybeSignal::default(),
51+
icon: None,
52+
loading: MaybeSignal::default(),
53+
disabled: MaybeSignal::default(),
54+
on_click: Some(Callback::from(move |_| {
55+
tabs.active_tabs.update(|prev| *prev += 1);
56+
tabs
57+
.selected_tab
58+
.update(|prev| *prev = (tabs.active_tabs.get() - 1).to_string());
59+
})),
60+
children: Some(Box::new(move || {
61+
Fragment::new(vec![p().child("+").into_view()])
62+
})),
63+
})),
7464
)
7565
.child(footer::component()),
7666
)

src/store/editor.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl Default for EditorStore {
2121
impl EditorStore {
2222
pub fn new() -> Self {
2323
Self {
24-
editors: create_rw_signal(vec![create_rw_signal(ModelCell::default())]),
24+
editors: create_rw_signal(Vec::new()),
2525
}
2626
}
2727

@@ -31,6 +31,7 @@ impl EditorStore {
3131
});
3232
}
3333

34+
#[allow(dead_code)]
3435
pub fn remove_editor(&mut self, index: usize) {
3536
self.editors.update(|prev| {
3637
prev.remove(index);

0 commit comments

Comments
 (0)