Skip to content

Commit

Permalink
fix!(attach): exec regression fixed
Browse files Browse the repository at this point in the history
- a regression had been introduced in restructure of AppContext to
  support describe
- this has now been fixed
  • Loading branch information
robertpsoane committed Jul 7, 2024
1 parent ce8651a commit ee75869
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/components/command_input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use crate::{
context::AppContext,
events::{message::MessageResponse, transition::send_transition, Key, Message, Transition},
traits::Component,
widgets::text_input::{Autocomplete, TextInput, TextInputState},
widgets::text_input::Autocomplete,
};

use super::text_input_wrapper::TextInputWrapper;
Expand Down
36 changes: 21 additions & 15 deletions src/pages/attach.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ impl Attach {
page_help: Arc::new(Mutex::new(page_help)),
}
}

async fn attach(&self, container: DockerContainer, exec: &str, cx: AppContext) -> Result<()> {
disable_raw_mode()?;
container.attach(exec).await?;

let transition = if let Some(t) = cx.next() {
t
} else {
Transition::ToContainerPage(AppContext {
docker_container: Some(container),
..Default::default()
})
};

self.tx.send(Message::Transition(transition)).await?;
self.tx
.send(Message::Transition(Transition::ToNewTerminal))
.await?;
Ok(())
}
}

#[async_trait::async_trait]
Expand All @@ -58,21 +78,7 @@ impl Page for Attach {
bail!("no docker container")
}
if let Some(container) = self.container.clone() {
disable_raw_mode()?;
container.attach(&self.config.default_exec).await?;

let transition = if let Some(t) = cx.next() {
t
} else {
Transition::ToContainerPage(AppContext {
docker_container: Some(container),
..Default::default()
})
};

self.tx.send(Message::Transition(transition)).await?;
self.tx
.send(Message::Transition(Transition::ToNewTerminal))
self.attach(container, &self.config.default_exec, cx)
.await?;
}
Ok(())
Expand Down
1 change: 1 addition & 0 deletions src/pages/containers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ impl Containers {
let cx = AppContext {
describable: Some(Box::new(container.clone())),
then,
docker_container: Some(container.clone()),
..Default::default()
};

Expand Down
5 changes: 1 addition & 4 deletions src/ui/page_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,10 +142,7 @@ impl PageManager {
}
};

self.page
.initialise(cx)
.await
.context("unable to open new page")?;
self.page.initialise(cx).await?;

Ok(())
}
Expand Down

0 comments on commit ee75869

Please sign in to comment.