fn handle_block_events(key: Key, app: &mut App) {
  match app.get_current_route().active_block {
    ActiveBlock::Pods => {
      let _pod = handle_table_events(key, &mut app.pods);
    }
    ActiveBlock::Services => {
      let _svc = handle_table_events(key, &mut app.services);
    }
    ActiveBlock::Nodes => {
      let _node = handle_table_events(key, &mut app.nodes);
    }
    ActiveBlock::Namespaces => {
      let ns = handle_table_events(key, &mut app.namespaces);
      if let Some(v) = ns {
        app.selected_ns = Some(v.name);
        app.pop_navigation_stack();
      }
    }
    ActiveBlock::Contexts => {
      let _ctx = handle_table_events(key, &mut app.contexts);
    }
    // ActiveBlock::Dialog(_) => {
    //   dialog::handler(key, app);
    // }
    _ => {
      // do nothing
    }
  }
  if app.get_current_route().id == RouteId::Home {
    match key {
      _ if key == DEFAULT_KEYBINDING.right => {
        app.context_tabs.next();
        app.push_navigation_stack(
          RouteId::Home,
          app.context_tabs.active_block.unwrap_or(ActiveBlock::Empty),
        );
      }
      _ if key == DEFAULT_KEYBINDING.left => {
        app.context_tabs.previous();
        app.push_navigation_stack(
          RouteId::Home,
          app.context_tabs.active_block.unwrap_or(ActiveBlock::Empty),
        );
      }
      _ => {}
    };
  }
  // reset tick_count so that network requests are made faster
  if key == DEFAULT_KEYBINDING.submit {
    app.tick_count = 0;
  }
}
// Handle event for the current active block
Handle event for the current active block
Handle event for the current active block
fn handle_block_events(key: Key, app: &mut App) {
  match app.get_current_route().active_block {
    ActiveBlock::Pods => {
      let _pod = handle_table_events(key, &mut app.pods);
    }
    ActiveBlock::Services => {
      let _svc = handle_table_events(key, &mut app.services);
    }
    ActiveBlock::Nodes => {
      let _node = handle_table_events(key, &mut app.nodes);
    }
    ActiveBlock::Namespaces => {
      let ns = handle_table_events(key, &mut app.namespaces);
      if let Some(v) = ns {
        app.selected_ns = Some(v.name);
        app.pop_navigation_stack();
      }
    }
    ActiveBlock::Contexts => {
      let _ctx = handle_table_events(key, &mut app.contexts);
    }
    // ActiveBlock::Dialog(_) => {
    //   dialog::handler(key, app);
    // }
    _ => {
      // do nothing
    }
  }
  if app.get_current_route().id == RouteId::Home {
    match key {
      _ if key == DEFAULT_KEYBINDING.right => {
        app.context_tabs.next();
        app.push_navigation_stack(
          RouteId::Home,
          app.context_tabs.active_block.unwrap_or(ActiveBlock::Empty),
        );
      }
      _ if key == DEFAULT_KEYBINDING.left => {
        app.context_tabs.previous();
        app.push_navigation_stack(
          RouteId::Home,
          app.context_tabs.active_block.unwrap_or(ActiveBlock::Empty),
        );
      }
      _ => {}
    };
  }
  // reset tick_count so that network requests are made faster
  if key == DEFAULT_KEYBINDING.submit {
    app.tick_count = 0;
  }
}
fn handle_block_events ( key : Key , app : & mut App ) { match app . get_current_route ( ) . active_block { ActiveBlock :: Pods => { let _pod = handle_table_events ( key , & mut app . pods ) ; } ActiveBlock :: Services => { let _svc = handle_table_events ( key , & mut app . services ) ; } ActiveBlock :: Nodes => { let _node = handle_table_events ( key , & mut app . nodes ) ; } ActiveBlock :: Namespaces => { let ns = handle_table_events ( key , & mut app . namespaces ) ; if let Some ( v ) = ns { app . selected_ns = Some ( v . name ) ; app . pop_navigation_stack ( ) ; } } ActiveBlock :: Contexts => { let _ctx = handle_table_events ( key , & mut app . contexts ) ; } // ActiveBlock::Dialog(_) => { //   dialog::handler(key, app); // } _ => { // do nothing } } if app . get_current_route ( ) . id == RouteId :: Home { match key { _ if key == DEFAULT_KEYBINDING . right => { app . context_tabs . next ( ) ; app . push_navigation_stack ( RouteId :: Home , app . context_tabs . active_block . unwrap_or ( ActiveBlock :: Empty ) , ) ; } _ if key == DEFAULT_KEYBINDING . left => { app . context_tabs . previous ( ) ; app . push_navigation_stack ( RouteId :: Home , app . context_tabs . active_block . unwrap_or ( ActiveBlock :: Empty ) , ) ; } _ => { } } ; } // reset tick_count so that network requests are made faster if key == DEFAULT_KEYBINDING . submit { app . tick_count = 0 ; } }
Handle event for the current active block
Handle event for the current active block
key
Key
app
&mut App
key
Key
app
&mut App