pub struct Tabs<M = ()>(/* private fields */);Expand description
tabs: a tab strip.
Implementations§
Source§impl<M> Tabs<M>
impl<M> Tabs<M>
Sourcepub fn key(self, key: impl Into<NodeKey>) -> Self
pub fn key(self, key: impl Into<NodeKey>) -> Self
Identity among siblings: keeps the node’s id (and Tern’s view state) across reorders. A string, or an integer.
Examples found in repository?
765 fn nav(&self) -> ui::Tabs<Msg> {
766 let count = |n: usize| ui::span(n.to_string()).style("muted");
767 let open = self
768 .incidents
769 .iter()
770 .filter(|i| i.phase != Phase::Resolved)
771 .count();
772 ui::tabs()
773 .key("nav")
774 .active(self.page.id())
775 .tab("services", spans!["Services ", count(self.services.len())])
776 .tab("deploys", spans!["Deploys ", count(self.deploys.len())])
777 .tab("incidents", spans!["Incidents ", count(open)])
778 .on_select(|id| Msg::Page(id.to_owned()))
779 }
780
781 /// The active view: its table beside the selected row's detail card
782 /// (under it when `plain`).
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }
834
835 /// A selectable table of `page` with its handlers and selection.
836 fn table(&self, page: Page, empty: &str) -> ui::Table<Msg> {
837 let mut table = ui::table()
838 .key("table")
839 .selectable(true)
840 .empty(empty)
841 .on_select(move |id| Msg::Select(page, id.to_owned()))
842 .on_activate(move |id| Msg::Open(page, id.to_owned()));
843 if let Some(id) = self.selected[page.index()] {
844 table = table.selected(id);
845 }
846 table
847 }
848
849 /// The services table.
850 fn services_table(&self) -> ui::Table<Msg> {
851 let mut table = self
852 .table(Page::Services, "No services yet")
853 .col(Column::new("name", "Service").grow(1.0).priority(6.0))
854 .col(Column::new("region", "Region").priority(3.0))
855 .col(Column::new("version", "Version").mono(true).priority(2.0))
856 .col(Column::new("traffic", "Traffic").priority(1.0))
857 .col(
858 Column::new("rps", "req/s")
859 .align(TextAlign::End)
860 .mono(true)
861 .priority(4.0),
862 )
863 .col(
864 Column::new("p95", "p95")
865 .align(TextAlign::End)
866 .mono(true)
867 .priority(4.0),
868 )
869 .col(
870 Column::new("errors", "Errors")
871 .align(TextAlign::End)
872 .mono(true)
873 .priority(4.0),
874 )
875 .col(Column::new("health", "Health").priority(5.0));
876 for s in &self.services {
877 let (label, tone) = s.health.look();
878 let mut errors = TextCell::new(format!("{:.1}%", s.errors));
879 if s.errors >= 1.0 {
880 errors = errors.tone(Tone::Error);
881 }
882 table = table.row(
883 TableRow::new(s.id)
884 .cell("name", TextCell::new(s.id).dot(tone.clone()))
885 .cell("region", s.region)
886 .cell("version", s.version)
887 .cell("traffic", SparkCell::new(s.rps.clone()))
888 .cell("rps", format!("{:.0}", s.rps.last().copied().unwrap_or_default()))
889 .cell("p95", format!("{:.0} ms", s.p95))
890 .cell("errors", errors)
891 .cell("health", BadgeSpec::new(label).tone(tone)),
892 );
893 }
894 table
895 }
896
897 /// The deploys toolbar: a muted description and the filter.
898 fn deploys_bar(&self) -> ui::Row<Msg> {
899 let attention = self
900 .deploys
901 .iter()
902 .filter(|d| matches!(d.state, State::Waiting | State::Failed))
903 .count();
904 ui::row()
905 .key("bar")
906 .justify("between")
907 .align("center")
908 .child(
909 ui::text(ui::span("Rollouts to production, newest first").style("muted")).key("about"),
910 )
911 .child(
912 ui::tabs()
913 .key("filter")
914 .variant("segmented")
915 .active(self.filter.clone())
916 .tab("all", "All")
917 .tab("attention", spans![
918 "Needs you ",
919 ui::span(attention.to_string()).style("muted")
920 ])
921 .on_select(|id| Msg::Filter(id.to_owned())),
922 )
923 }Sourcepub fn role(self, role: impl Into<String>) -> Self
pub fn role(self, role: impl Into<String>) -> Self
A name of yours, exposed to CSS as data-role.
Keeps the node mounted but not laid out.
Sourcepub fn mark(self, mark: impl Into<Mark>) -> Self
pub fn mark(self, mark: impl Into<Mark>) -> Self
A transient selection mark drawn over the node.
Sourcepub fn aria(self, aria: impl Into<String>) -> Self
pub fn aria(self, aria: impl Into<String>) -> Self
The accessible name of a node that shows no text.
Sourcepub fn hovercard<N>(self, card: impl Into<Node<N>>) -> Self
pub fn hovercard<N>(self, card: impl Into<Node<N>>) -> Self
A floating card of card’s tree shown while the pointer rests on
the node, in place of title. Sent id-less (ids, keys and handlers
inside are ignored); an older Tern ignores it.
Sourcepub fn href(self, href: impl Into<String>) -> Self
pub fn href(self, href: impl Into<String>) -> Self
A link: ⌘-click opens it; copy and open use it.
Sourcepub fn basis(self, basis: impl Into<Basis>) -> Self
pub fn basis(self, basis: impl Into<Basis>) -> Self
Flex basis: a fraction of the parent, or the content’s size.
Sourcepub fn prop(self, name: &str, value: impl Serialize) -> Self
pub fn prop(self, name: &str, value: impl Serialize) -> Self
Sets any prop untyped; null removes it.
Sourcepub fn on_click(self, msg: M) -> Self
pub fn on_click(self, msg: M) -> Self
Sends msg on a click (sets actions.click to "click" unless
the node names its click action itself).
Sourcepub fn on_dblclick(self, msg: M) -> Self
pub fn on_dblclick(self, msg: M) -> Self
Sends msg on a double click (sets actions.dblclick to
"dblclick" unless the node names it).
Adds act to the context menu and sends msg when it is picked.
Sourcepub fn on_action(self, act: impl Into<String>, msg: M) -> Self
pub fn on_action(self, act: impl Into<String>, msg: M) -> Self
Sends msg on action events whose action is act (name or
name=value).
Sourcepub fn on_action_with(
self,
act: impl Into<String>,
f: impl Fn(&Action) -> M + Send + Sync + 'static,
) -> Self
pub fn on_action_with( self, act: impl Into<String>, f: impl Fn(&Action) -> M + Send + Sync + 'static, ) -> Self
Maps action events whose action is act to a message.
Sourcepub fn on_toggle(self, f: impl Fn(bool) -> M + Send + Sync + 'static) -> Self
pub fn on_toggle(self, f: impl Fn(bool) -> M + Send + Sync + 'static) -> Self
Maps toggle events (the new collapsed; a menu, select or trace
line that opened is not collapsed) to a message.
Sourcepub fn on_select(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
pub fn on_select(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
Maps select events (the item) to a message. On a list’s item the
item’s own handler runs first.
Examples found in repository?
765 fn nav(&self) -> ui::Tabs<Msg> {
766 let count = |n: usize| ui::span(n.to_string()).style("muted");
767 let open = self
768 .incidents
769 .iter()
770 .filter(|i| i.phase != Phase::Resolved)
771 .count();
772 ui::tabs()
773 .key("nav")
774 .active(self.page.id())
775 .tab("services", spans!["Services ", count(self.services.len())])
776 .tab("deploys", spans!["Deploys ", count(self.deploys.len())])
777 .tab("incidents", spans!["Incidents ", count(open)])
778 .on_select(|id| Msg::Page(id.to_owned()))
779 }
780
781 /// The active view: its table beside the selected row's detail card
782 /// (under it when `plain`).
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }
834
835 /// A selectable table of `page` with its handlers and selection.
836 fn table(&self, page: Page, empty: &str) -> ui::Table<Msg> {
837 let mut table = ui::table()
838 .key("table")
839 .selectable(true)
840 .empty(empty)
841 .on_select(move |id| Msg::Select(page, id.to_owned()))
842 .on_activate(move |id| Msg::Open(page, id.to_owned()));
843 if let Some(id) = self.selected[page.index()] {
844 table = table.selected(id);
845 }
846 table
847 }
848
849 /// The services table.
850 fn services_table(&self) -> ui::Table<Msg> {
851 let mut table = self
852 .table(Page::Services, "No services yet")
853 .col(Column::new("name", "Service").grow(1.0).priority(6.0))
854 .col(Column::new("region", "Region").priority(3.0))
855 .col(Column::new("version", "Version").mono(true).priority(2.0))
856 .col(Column::new("traffic", "Traffic").priority(1.0))
857 .col(
858 Column::new("rps", "req/s")
859 .align(TextAlign::End)
860 .mono(true)
861 .priority(4.0),
862 )
863 .col(
864 Column::new("p95", "p95")
865 .align(TextAlign::End)
866 .mono(true)
867 .priority(4.0),
868 )
869 .col(
870 Column::new("errors", "Errors")
871 .align(TextAlign::End)
872 .mono(true)
873 .priority(4.0),
874 )
875 .col(Column::new("health", "Health").priority(5.0));
876 for s in &self.services {
877 let (label, tone) = s.health.look();
878 let mut errors = TextCell::new(format!("{:.1}%", s.errors));
879 if s.errors >= 1.0 {
880 errors = errors.tone(Tone::Error);
881 }
882 table = table.row(
883 TableRow::new(s.id)
884 .cell("name", TextCell::new(s.id).dot(tone.clone()))
885 .cell("region", s.region)
886 .cell("version", s.version)
887 .cell("traffic", SparkCell::new(s.rps.clone()))
888 .cell("rps", format!("{:.0}", s.rps.last().copied().unwrap_or_default()))
889 .cell("p95", format!("{:.0} ms", s.p95))
890 .cell("errors", errors)
891 .cell("health", BadgeSpec::new(label).tone(tone)),
892 );
893 }
894 table
895 }
896
897 /// The deploys toolbar: a muted description and the filter.
898 fn deploys_bar(&self) -> ui::Row<Msg> {
899 let attention = self
900 .deploys
901 .iter()
902 .filter(|d| matches!(d.state, State::Waiting | State::Failed))
903 .count();
904 ui::row()
905 .key("bar")
906 .justify("between")
907 .align("center")
908 .child(
909 ui::text(ui::span("Rollouts to production, newest first").style("muted")).key("about"),
910 )
911 .child(
912 ui::tabs()
913 .key("filter")
914 .variant("segmented")
915 .active(self.filter.clone())
916 .tab("all", "All")
917 .tab("attention", spans![
918 "Needs you ",
919 ui::span(attention.to_string()).style("muted")
920 ])
921 .on_select(|id| Msg::Filter(id.to_owned())),
922 )
923 }Sourcepub fn on_activate(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
pub fn on_activate(self, f: impl Fn(&str) -> M + Send + Sync + 'static) -> Self
Maps activate events (the item) to a message.
Sourcepub fn on_change(self, f: impl Fn(&Change) -> M + Send + Sync + 'static) -> Self
pub fn on_change(self, f: impl Fn(&Change) -> M + Send + Sync + 'static) -> Self
Maps change events to a message.
Sourcepub fn on_edit(self, f: impl Fn(&Edit) -> M + Send + Sync + 'static) -> Self
pub fn on_edit(self, f: impl Fn(&Edit) -> M + Send + Sync + 'static) -> Self
Maps edit events (native editing) to a message.
Source§impl<M> Tabs<M>
impl<M> Tabs<M>
Sourcepub fn active(self, value: impl Into<String>) -> Self
pub fn active(self, value: impl Into<String>) -> Self
The active tab’s id.
Examples found in repository?
765 fn nav(&self) -> ui::Tabs<Msg> {
766 let count = |n: usize| ui::span(n.to_string()).style("muted");
767 let open = self
768 .incidents
769 .iter()
770 .filter(|i| i.phase != Phase::Resolved)
771 .count();
772 ui::tabs()
773 .key("nav")
774 .active(self.page.id())
775 .tab("services", spans!["Services ", count(self.services.len())])
776 .tab("deploys", spans!["Deploys ", count(self.deploys.len())])
777 .tab("incidents", spans!["Incidents ", count(open)])
778 .on_select(|id| Msg::Page(id.to_owned()))
779 }
780
781 /// The active view: its table beside the selected row's detail card
782 /// (under it when `plain`).
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }
834
835 /// A selectable table of `page` with its handlers and selection.
836 fn table(&self, page: Page, empty: &str) -> ui::Table<Msg> {
837 let mut table = ui::table()
838 .key("table")
839 .selectable(true)
840 .empty(empty)
841 .on_select(move |id| Msg::Select(page, id.to_owned()))
842 .on_activate(move |id| Msg::Open(page, id.to_owned()));
843 if let Some(id) = self.selected[page.index()] {
844 table = table.selected(id);
845 }
846 table
847 }
848
849 /// The services table.
850 fn services_table(&self) -> ui::Table<Msg> {
851 let mut table = self
852 .table(Page::Services, "No services yet")
853 .col(Column::new("name", "Service").grow(1.0).priority(6.0))
854 .col(Column::new("region", "Region").priority(3.0))
855 .col(Column::new("version", "Version").mono(true).priority(2.0))
856 .col(Column::new("traffic", "Traffic").priority(1.0))
857 .col(
858 Column::new("rps", "req/s")
859 .align(TextAlign::End)
860 .mono(true)
861 .priority(4.0),
862 )
863 .col(
864 Column::new("p95", "p95")
865 .align(TextAlign::End)
866 .mono(true)
867 .priority(4.0),
868 )
869 .col(
870 Column::new("errors", "Errors")
871 .align(TextAlign::End)
872 .mono(true)
873 .priority(4.0),
874 )
875 .col(Column::new("health", "Health").priority(5.0));
876 for s in &self.services {
877 let (label, tone) = s.health.look();
878 let mut errors = TextCell::new(format!("{:.1}%", s.errors));
879 if s.errors >= 1.0 {
880 errors = errors.tone(Tone::Error);
881 }
882 table = table.row(
883 TableRow::new(s.id)
884 .cell("name", TextCell::new(s.id).dot(tone.clone()))
885 .cell("region", s.region)
886 .cell("version", s.version)
887 .cell("traffic", SparkCell::new(s.rps.clone()))
888 .cell("rps", format!("{:.0}", s.rps.last().copied().unwrap_or_default()))
889 .cell("p95", format!("{:.0} ms", s.p95))
890 .cell("errors", errors)
891 .cell("health", BadgeSpec::new(label).tone(tone)),
892 );
893 }
894 table
895 }
896
897 /// The deploys toolbar: a muted description and the filter.
898 fn deploys_bar(&self) -> ui::Row<Msg> {
899 let attention = self
900 .deploys
901 .iter()
902 .filter(|d| matches!(d.state, State::Waiting | State::Failed))
903 .count();
904 ui::row()
905 .key("bar")
906 .justify("between")
907 .align("center")
908 .child(
909 ui::text(ui::span("Rollouts to production, newest first").style("muted")).key("about"),
910 )
911 .child(
912 ui::tabs()
913 .key("filter")
914 .variant("segmented")
915 .active(self.filter.clone())
916 .tab("all", "All")
917 .tab("attention", spans![
918 "Needs you ",
919 ui::span(attention.to_string()).style("muted")
920 ])
921 .on_select(|id| Msg::Filter(id.to_owned())),
922 )
923 }Sourcepub fn variant(self, value: impl Into<TabsVariant>) -> Self
pub fn variant(self, value: impl Into<TabsVariant>) -> Self
Underline (default) or a segmented well.
Examples found in repository?
898 fn deploys_bar(&self) -> ui::Row<Msg> {
899 let attention = self
900 .deploys
901 .iter()
902 .filter(|d| matches!(d.state, State::Waiting | State::Failed))
903 .count();
904 ui::row()
905 .key("bar")
906 .justify("between")
907 .align("center")
908 .child(
909 ui::text(ui::span("Rollouts to production, newest first").style("muted")).key("about"),
910 )
911 .child(
912 ui::tabs()
913 .key("filter")
914 .variant("segmented")
915 .active(self.filter.clone())
916 .tab("all", "All")
917 .tab("attention", spans![
918 "Needs you ",
919 ui::span(attention.to_string()).style("muted")
920 ])
921 .on_select(|id| Msg::Filter(id.to_owned())),
922 )
923 }Sourcepub fn tab(self, id: impl Into<String>, label: impl Into<Text>) -> Self
pub fn tab(self, id: impl Into<String>, label: impl Into<Text>) -> Self
Adds a tab.
Examples found in repository?
765 fn nav(&self) -> ui::Tabs<Msg> {
766 let count = |n: usize| ui::span(n.to_string()).style("muted");
767 let open = self
768 .incidents
769 .iter()
770 .filter(|i| i.phase != Phase::Resolved)
771 .count();
772 ui::tabs()
773 .key("nav")
774 .active(self.page.id())
775 .tab("services", spans!["Services ", count(self.services.len())])
776 .tab("deploys", spans!["Deploys ", count(self.deploys.len())])
777 .tab("incidents", spans!["Incidents ", count(open)])
778 .on_select(|id| Msg::Page(id.to_owned()))
779 }
780
781 /// The active view: its table beside the selected row's detail card
782 /// (under it when `plain`).
783 fn body(&self, plain: bool) -> Node<Msg> {
784 let page = self.page;
785 let selected = self.selected[page.index()];
786 let (list, detail) = match page {
787 Page::Services => (
788 nodes![self.services_table()],
789 selected
790 .and_then(|id| self.services.iter().find(|s| s.id == id))
791 .map(service_card),
792 ),
793 Page::Deploys => (
794 nodes![self.deploys_bar(), self.deploys_table()],
795 selected
796 .and_then(|id| self.deploys.iter().find(|d| d.id == id))
797 .map(deploy_card),
798 ),
799 Page::Incidents => (
800 nodes![self.incidents_table()],
801 selected
802 .and_then(|id| self.incidents.iter().find(|i| i.id == id))
803 .map(incident_card),
804 ),
805 };
806 let mut parts: Vec<Node<Msg>> = nodes![
807 ui::col()
808 .key("list")
809 .gap("sm")
810 .grow(1.0)
811 .basis(0.0)
812 .children(list)
813 ];
814 if let Some(card) = detail {
815 parts.push(
816 card
817 .key("detail")
818 .min(Bound::w(Extent::Ch(44.0)))
819 .max(Bound::w(Extent::Ch(56.0)))
820 .into(),
821 );
822 }
823 if plain {
824 ui::col().key(page.id()).gap("md").children(parts).into()
825 } else {
826 ui::row()
827 .key(page.id())
828 .align("stretch")
829 .gap("lg")
830 .children(parts)
831 .into()
832 }
833 }
834
835 /// A selectable table of `page` with its handlers and selection.
836 fn table(&self, page: Page, empty: &str) -> ui::Table<Msg> {
837 let mut table = ui::table()
838 .key("table")
839 .selectable(true)
840 .empty(empty)
841 .on_select(move |id| Msg::Select(page, id.to_owned()))
842 .on_activate(move |id| Msg::Open(page, id.to_owned()));
843 if let Some(id) = self.selected[page.index()] {
844 table = table.selected(id);
845 }
846 table
847 }
848
849 /// The services table.
850 fn services_table(&self) -> ui::Table<Msg> {
851 let mut table = self
852 .table(Page::Services, "No services yet")
853 .col(Column::new("name", "Service").grow(1.0).priority(6.0))
854 .col(Column::new("region", "Region").priority(3.0))
855 .col(Column::new("version", "Version").mono(true).priority(2.0))
856 .col(Column::new("traffic", "Traffic").priority(1.0))
857 .col(
858 Column::new("rps", "req/s")
859 .align(TextAlign::End)
860 .mono(true)
861 .priority(4.0),
862 )
863 .col(
864 Column::new("p95", "p95")
865 .align(TextAlign::End)
866 .mono(true)
867 .priority(4.0),
868 )
869 .col(
870 Column::new("errors", "Errors")
871 .align(TextAlign::End)
872 .mono(true)
873 .priority(4.0),
874 )
875 .col(Column::new("health", "Health").priority(5.0));
876 for s in &self.services {
877 let (label, tone) = s.health.look();
878 let mut errors = TextCell::new(format!("{:.1}%", s.errors));
879 if s.errors >= 1.0 {
880 errors = errors.tone(Tone::Error);
881 }
882 table = table.row(
883 TableRow::new(s.id)
884 .cell("name", TextCell::new(s.id).dot(tone.clone()))
885 .cell("region", s.region)
886 .cell("version", s.version)
887 .cell("traffic", SparkCell::new(s.rps.clone()))
888 .cell("rps", format!("{:.0}", s.rps.last().copied().unwrap_or_default()))
889 .cell("p95", format!("{:.0} ms", s.p95))
890 .cell("errors", errors)
891 .cell("health", BadgeSpec::new(label).tone(tone)),
892 );
893 }
894 table
895 }
896
897 /// The deploys toolbar: a muted description and the filter.
898 fn deploys_bar(&self) -> ui::Row<Msg> {
899 let attention = self
900 .deploys
901 .iter()
902 .filter(|d| matches!(d.state, State::Waiting | State::Failed))
903 .count();
904 ui::row()
905 .key("bar")
906 .justify("between")
907 .align("center")
908 .child(
909 ui::text(ui::span("Rollouts to production, newest first").style("muted")).key("about"),
910 )
911 .child(
912 ui::tabs()
913 .key("filter")
914 .variant("segmented")
915 .active(self.filter.clone())
916 .tab("all", "All")
917 .tab("attention", spans![
918 "Needs you ",
919 ui::span(attention.to_string()).style("muted")
920 ])
921 .on_select(|id| Msg::Filter(id.to_owned())),
922 )
923 }