Skip to content

Commit 9d4bb3b

Browse files
committed
chore(widgets): move over to bundle
1 parent f634cad commit 9d4bb3b

17 files changed

+429
-406
lines changed

Cargo.lock

+18-16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ categories = ["command-line-interface"]
2323
[dependencies]
2424
ansi-to-tui = "6.0.0"
2525
async-trait = "0.1.82"
26-
bon = "2.1.1"
26+
bon = "2.2.1"
2727
cata = { version = "0.1.1" }
2828
chrono = { version = "0.4.38", features = ["serde"] }
2929
clap = { version = "4.5.17", features = ["derive", "env"] }
@@ -45,7 +45,7 @@ itertools = "0.13.0"
4545
json_value_merge = "2.0.0"
4646
jsonwebtoken = "9.3.0"
4747
k8s-openapi = { version = "0.22.0", features = ["earliest"] }
48-
kube = { version = "0.93.1", features = ["derive", "runtime", "ws"] }
48+
kube = { version = "0.94.1", features = ["derive", "runtime", "ws"] }
4949
lazy_static = "1.5.0"
5050
local-ip-address = "0.6.2"
5151
mio = "1.0.2"
@@ -72,7 +72,7 @@ ssh-key = "0.6.6"
7272
strum = { version = "0.26.3", features = ["derive"] }
7373
strum_macros = "0.26.4"
7474
syntect = "5.2.0"
75-
syntect-tui = { git = " https://github.com/grampelberg/syntect-tui.git", branch = "ratatui-0.28.1" }
75+
syntect-tui = "3.0.4"
7676
tachyonfx = "0.6.0"
7777
tokio = { version = "1.40.0", features = ["full", "tracing"] }
7878
tokio-util = { version = "0.7.12", features = ["io-util"] }

TODO.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
11
# TODO
22

3+
- Implement multi-cluster.
4+
35
## Documentation
46

7+
- Getting started needs help, in particular:
8+
- Granting your user should probably go before the install instructions.
9+
- Say something about the error when you don't have authorization.
10+
- Make the getting started on a real cluster instructions more clear. In
11+
particular, it seems like it is a little difficult to see the install commands
12+
and realize that's what you need to use.
13+
14+
## `users grant`
15+
16+
- Allow YAML output for users who don't have a `kubeconfig`.
17+
518
## Authorization
619

720
- Groups are probably what most users are going to want to use to configure all
@@ -26,7 +39,15 @@
2639

2740
## TUI
2841

29-
- Allow wrapping around with the tabs (so left from 0 goes to the end).
42+
- Implement vim [key bindings](https://vim.rtorr.com).
43+
44+
- Move navigation dispatch (up, down) into common code.
45+
46+
- Add routing back in.
47+
48+
- It feels like it'd be nice to just try to run the default command and if it
49+
errors give the user the option to change. That way, going to the shell tab
50+
will ~immediately jump into the pod.
3051

3152
- Dashboard as a struct doesn't really make sense anymore, it should likely be
3253
converted over to a simple function.
@@ -82,8 +103,15 @@
82103

83104
## Build
84105

106+
- Figure out why `git cliff` goes `0.2.0` -> `0.2.1` -> `0.3.0` instead of
107+
`0.2.2`.
85108
- Move client_id and config_url to a build-time concern.
86109

110+
## Deployment
111+
112+
- Add `kustomize` to allow for an easier getting started.
113+
- Make `helm install` work if someone's checked the repo out.
114+
87115
## Misc
88116

89117
- Move to [bon](https://docs.rs/bon/latest/bon/) instead of `derive_builder`.

src/events.rs

+5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@ pub enum Broadcast {
1111
Consumed,
1212
Ignored,
1313
Exited,
14+
// Switch to raw mode - where input is passed directly to a single widget.
1415
Raw(Box<dyn Raw>),
16+
// Allows a child component to communicate to a parent that there was a selection event which
17+
// occurred in it. The parent is expected to handle this as part of propagating the dispatch
18+
// back to the apex.
19+
Selected(usize),
1520
}
1621

1722
#[derive(Debug, Clone)]

src/resources/container.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use ratatui::{
1414
};
1515

1616
use super::{age::Age, Compare};
17-
use crate::widget::{table::RowStyle, TableRow};
17+
use crate::widget::table;
1818

1919
#[allow(clippy::module_name_repetitions)]
2020
pub trait ContainerExt {
@@ -196,8 +196,8 @@ impl ContainerExt for Container {
196196
}
197197
}
198198

199-
impl<'a> TableRow<'a> for Container {
200-
fn header() -> Option<Row<'a>> {
199+
impl table::Row for Container {
200+
fn header<'a>() -> Option<Row<'a>> {
201201
Some(Row::new(vec![
202202
Cell::from("Name"),
203203
Cell::from("Image"),
@@ -219,7 +219,7 @@ impl<'a> TableRow<'a> for Container {
219219
]
220220
}
221221

222-
fn row(&self, style: &RowStyle) -> Row {
222+
fn row(&self, style: &table::RowStyle) -> Row {
223223
Row::new(vec![
224224
Cell::from(self.name_any()),
225225
Cell::from(self.image()),

src/resources/pod.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ use super::{
1919
container::{Container, ContainerExt},
2020
Compare, Filter,
2121
};
22-
use crate::widget::{
23-
table::{Content, RowStyle},
24-
TableRow,
25-
};
22+
use crate::widget::table;
2623

2724
pub enum Phase {
2825
Pending,
@@ -227,8 +224,8 @@ impl PodExt for Pod {
227224
}
228225
}
229226

230-
impl<'a> TableRow<'a> for Arc<Pod> {
231-
fn header() -> Option<Row<'a>> {
227+
impl table::Row for Arc<Pod> {
228+
fn header<'a>() -> Option<Row<'a>> {
232229
Some(Row::new(vec![
233230
Cell::from("Namespace"),
234231
Cell::from("Name"),
@@ -250,7 +247,7 @@ impl<'a> TableRow<'a> for Arc<Pod> {
250247
]
251248
}
252249

253-
fn row(&self, style: &RowStyle) -> Row {
250+
fn row(&self, style: &table::RowStyle) -> Row {
254251
Row::new(vec![
255252
self.namespace().unwrap_or_default(),
256253
self.name_any(),
@@ -288,8 +285,10 @@ impl Compare for Arc<Pod> {
288285
}
289286
}
290287

291-
impl<'a> Content<'a, Container> for Arc<Pod> {
292-
fn items(&self, filter: Option<String>) -> Vec<impl TableRow<'a>> {
288+
impl table::Items for Arc<Pod> {
289+
type Item = Container;
290+
291+
fn items(&self, filter: Option<String>) -> Vec<Self::Item> {
293292
self.containers(filter)
294293
}
295294
}

src/resources/store.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use serde::de::DeserializeOwned;
1515
use tokio::task::JoinHandle;
1616

1717
use super::{Compare, Filter};
18-
use crate::widget::{table, TableRow};
18+
use crate::widget::table;
1919

2020
async fn is_ready<K>(reader: reflector::Store<K>) -> Result<(), WriterDropped>
2121
where
@@ -124,7 +124,7 @@ where
124124
}
125125
}
126126

127-
impl<'a, K> table::Content<'a, Arc<K>> for Arc<Store<K>>
127+
impl<K> table::Items for Arc<Store<K>>
128128
where
129129
K: Filter
130130
+ kube::Resource<DynamicType = ()>
@@ -134,9 +134,11 @@ where
134134
+ Sync
135135
+ DeserializeOwned
136136
+ 'static,
137-
Arc<K>: TableRow<'a> + Compare,
137+
Arc<K>: table::Row + Compare,
138138
{
139-
fn items(&self, filter: Option<String>) -> Vec<impl TableRow<'a>> {
139+
type Item = Arc<K>;
140+
141+
fn items(&self, filter: Option<String>) -> Vec<Self::Item> {
140142
Store::items(self, filter)
141143
}
142144
}

src/resources/tunnel.rs

+15-3
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use prometheus_static_metric::make_static_metric;
1717
use ratatui::{layout::Constraint, widgets::Row};
1818
use tokio::io::{AsyncRead, AsyncWrite};
1919

20-
use crate::widget::{table::RowStyle, TableRow};
20+
use crate::widget::table;
2121

2222
make_static_metric! {
2323
pub struct ResourceVec: IntCounter {
@@ -141,7 +141,19 @@ impl PartialEq for Tunnel {
141141

142142
impl Eq for Tunnel {}
143143

144-
impl<'a> TableRow<'a> for Tunnel {
144+
impl PartialOrd for Tunnel {
145+
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
146+
Some(self.cmp(other))
147+
}
148+
}
149+
150+
impl Ord for Tunnel {
151+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
152+
self.addr().cmp(&other.addr())
153+
}
154+
}
155+
156+
impl table::Row for Tunnel {
145157
fn constraints() -> Vec<Constraint> {
146158
vec![
147159
Constraint::Length(10),
@@ -150,7 +162,7 @@ impl<'a> TableRow<'a> for Tunnel {
150162
]
151163
}
152164

153-
fn row(&self, style: &RowStyle) -> Row {
165+
fn row(&self, style: &table::RowStyle) -> Row {
154166
Row::new(vec![
155167
self.kind.to_string().to_lowercase(),
156168
format!("{}:{}", self.host, self.port),

0 commit comments

Comments
 (0)