DB & Dev Tools · Tools and machines: regex, encoders, contrast, containers, pods
RegexTester tries a pattern with its flags against a sample, washes each match and lists it with its groups, zero-width ones too; a pattern that does not compile says why. Encoder turns text into Base64, URL or hex and back, says why a decode fails (Base64 pads end the text, twice at most) and copies the result, drawn through typography::literal so no ligature hides a character. ColorContrastChecker measures text on a background, translucent text as it blends, and names the WCAG levels met. ContainerList starts, stops, restarts and opens containers, each button shown when the owner handles it. PodList sorts pods by any column, ages by length through tables' new Cell::Duration, and narrows them by namespace. ResourceMonitor shows each reading's latest value beside its sparkline and, with a limit, how full it is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0cf33eea33
commit
e3f2d497f1
17 files changed
+1698
-8
No files matched your search
@@ -23,6 +23,8 @@ pub enum Cell {
|
||||
Person(SharedString),
|
||||
/// A label, and the address it opens.
|
||||
Link(SharedString, SharedString),
|
||||
/// A length of time in seconds, read in its two largest units; it sorts by length.
|
||||
Duration(u64),
|
||||
}
|
||||
|
||||
impl Cell {
|
||||
@@ -34,6 +36,9 @@ impl Cell {
|
||||
}
|
||||
Self::Number(value) => value.to_string().into(),
|
||||
Self::Progress(share) => share.to_string().into(),
|
||||
Self::Duration(seconds) => {
|
||||
format::duration(*seconds, format::DurationStyle::Compact).into()
|
||||
}
|
||||
Self::Empty | Self::Spark(_) => SharedString::default(),
|
||||
}
|
||||
}
|
||||
@@ -43,6 +48,7 @@ impl Cell {
|
||||
match self {
|
||||
Self::Number(value) => Some(*value),
|
||||
Self::Progress(share) => Some(f64::from(*share)),
|
||||
Self::Duration(seconds) => Some(*seconds as f64),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
@@ -241,6 +247,9 @@ pub(crate) fn draw(cell: &Cell, column: &Column, id: ElementId, cx: &App) -> Any
|
||||
.child(Avatar::new(id, name.clone()).size(AvatarSize::Xs))
|
||||
.child(Ellipsis::new(name.clone()))
|
||||
.into_any_element(),
|
||||
Cell::Duration(seconds) => tabular(div())
|
||||
.child(format::duration(*seconds, format::DurationStyle::Compact))
|
||||
.into_any_element(),
|
||||
Cell::Link(label, url) => {
|
||||
ExternalLink::new(id, label.clone(), url.clone()).into_any_element()
|
||||
}
|
||||
|
||||
@@ -175,6 +175,16 @@ pub fn to_csv(columns: &[Column], rows: &[Row]) -> String {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn durations_sort_by_length_not_by_their_words() {
|
||||
let rows: Vec<Row> = [("a", 600), ("b", 5_100), ("c", 90_000)]
|
||||
.into_iter()
|
||||
.map(|(key, seconds)| Row::new(key, [Cell::Duration(seconds)]))
|
||||
.collect();
|
||||
assert_eq!(sorted_by(&rows, vec![0, 1, 2], &[(0, true)]), [0, 1, 2]);
|
||||
assert_eq!(rows[1].cells[0].words(), "1h 25m");
|
||||
}
|
||||
|
||||
fn table() -> (Vec<Column>, Vec<Row>) {
|
||||
let columns = vec![
|
||||
Column::new("name", "Name"),
|
||||
|
||||
Reference in new issue
Block a user