Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/small-cleanups.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"seamless-glance": patch
---

Rename the misspelled API Gateway model module and render function to match the rest of the codebase, and stop the account overview from reporting a hardcoded row count. That count was never read, because the account overview free-scrolls a fixed layout and clamps its own offset while rendering, so it was a number that could only drift from the rows actually drawn.
2 changes: 1 addition & 1 deletion src/app/findings.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::BTreeSet;

use crate::aws::pricing::{LoadBalancerKind, PriceBook, PriceKey};
use crate::models::apigatway::ApiGatewayInfo;
use crate::models::apigateway::ApiGatewayInfo;
use crate::models::cloudwatch::CloudWatchAlarm;
use crate::models::ec2::Ec2InstanceInfo;
use crate::models::elb::LoadBalancerInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use crate::app::findings::{build_findings, FindingContext};
use crate::aws::clients::AwsClients;
use crate::aws::pricing::PriceBook;
use crate::cache::cost::{load_if_fresh, save, CostCache};
use crate::models::apigatway::ApiGatewayInfo;
use crate::models::apigateway::ApiGatewayInfo;
use crate::models::cloudwatch::{CloudWatchAlarm, CloudWatchSummary};
use crate::models::describable::DescribableResource;
use crate::models::ec2::Ec2InstanceInfo;
Expand Down
2 changes: 1 addition & 1 deletion src/app/refresh.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use tokio::sync::mpsc::UnboundedSender;
use crate::app::{ActiveView, App, RefreshPhase};
use crate::aws;
use crate::aws::pricing::PriceBook;
use crate::models::apigatway::ApiGatewayInfo;
use crate::models::apigateway::ApiGatewayInfo;
use crate::models::cloudwatch::{CloudWatchAlarm, CloudWatchSummary};
use crate::models::ec2::Ec2InstanceInfo;
use crate::models::elb::LoadBalancerInfo;
Expand Down
34 changes: 29 additions & 5 deletions src/app/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,6 @@ macro_rules! row_text {
};
}

/// Rows rendered by the account overview view. The view paints a fixed layout
/// rather than a list, so the count is not derived from a collection.
const ACCOUNT_OVERVIEW_ROWS: usize = 10;

pub const SERVICES: &[ServiceEntry] = &[
ServiceEntry {
view: ActiveView::Findings,
Expand All @@ -80,7 +76,10 @@ pub const SERVICES: &[ServiceEntry] = &[
},
ServiceEntry {
view: ActiveView::AccountOverview,
row_text: |_| vec![String::new(); ACCOUNT_OVERVIEW_ROWS],
// The only view with no selectable rows: it paints a fixed layout and
// free-scrolls it, clamping its own offset as it renders. A row count
// here would be a number nothing reads and everything could drift from.
row_text: |_| Vec::new(),
rows: ViewRows::Summary,
},
ServiceEntry {
Expand Down Expand Up @@ -387,6 +386,31 @@ mod tests {
assert_eq!(app.total_row_count(), 3);
}

/// The account overview free-scrolls a fixed layout and clamps its own
/// offset while rendering, so it has no selectable rows and nothing should
/// read a row count for it.
#[test]
fn the_account_overview_reports_no_selectable_rows() {
let mut app = test_app();
app.active_view = ActiveView::AccountOverview;

assert!(app.visible_indices().is_empty());
assert_eq!(app.total_row_count(), 0);
}

/// Moving the selection on a view with no rows must not underflow the
/// index or leave it somewhere a later render would index with.
#[test]
fn scrolling_a_view_with_no_rows_is_harmless() {
let mut app = test_app();
app.active_view = ActiveView::AccountOverview;

app.scroll_active_view_down(5);
app.scroll_active_view_to_bottom();

assert_eq!(app.selected_row, 0);
}

#[test]
fn every_view_is_registered_exactly_once() {
for view in ALL_VIEWS {
Expand Down
2 changes: 1 addition & 1 deletion src/aws/apigateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use crate::{
app::App,
aws::tags,
models::{
apigatway::{ApiGatewayInfo, ApiGatewaySummary},
apigateway::{ApiGatewayInfo, ApiGatewaySummary},
service_status::ServiceStatus,
},
};
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/models/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pub mod account_overview;
pub mod apigatway;
pub mod apigateway;
pub mod cloudwatch;
pub mod cost;
pub mod cost_estimate;
Expand Down
4 changes: 2 additions & 2 deletions src/ui/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use crate::ui::overlay::render::render_describe_overlay;
use crate::ui::overlay::select_profile::render_select_profile_overlay;
use crate::ui::overlay::select_ssh_key::render_select_ssh_key_overlay;
use crate::ui::views::account_overview;
use crate::ui::views::apigateway::render_apigatway;
use crate::ui::views::apigateway::render_apigateway;
use crate::ui::views::cloudwatch::render_cw;
use crate::ui::views::command::command_for_view;
use crate::ui::views::cost_overview::render_cost_overview;
Expand Down Expand Up @@ -98,7 +98,7 @@ pub fn draw(frame: &mut Frame, app: &mut App) {
render(frame, main_area, app);
}
ActiveView::Apigateway => {
render_apigatway(frame, main_area, app);
render_apigateway(frame, main_area, app);
}
ActiveView::Sqs => {
render_sqs(frame, main_area, app);
Expand Down
2 changes: 1 addition & 1 deletion src/ui/views/apigateway.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::ui::views::list_table::{
filter_query, render_list_table, visible_rows, ListSelection, ListTable, RowCells,
};

pub fn render_apigatway(frame: &mut Frame, area: ratatui::layout::Rect, app: &mut App) {
pub fn render_apigateway(frame: &mut Frame, area: ratatui::layout::Rect, app: &mut App) {
if crate::ui::views::status::render_unavailable(
frame,
area,
Expand Down
Loading