Skip to content

Commit

Permalink
Merge pull request #457 from sarub0b0/423-support-opening-yaml-tab-fr…
Browse files Browse the repository at this point in the history
…om-resource-list

feat: Support opening YAML popup from resource list
  • Loading branch information
sarub0b0 authored Jan 4, 2024
2 parents 055c305 + 934e6e0 commit a4fe77c
Show file tree
Hide file tree
Showing 15 changed files with 804 additions and 459 deletions.
12 changes: 11 additions & 1 deletion src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub mod view_id {
generate_id!(popup_yaml_kind);
generate_id!(popup_yaml_return);

generate_id!(popup_yaml);

generate_id!(popup_help);
}

Expand Down Expand Up @@ -440,9 +442,17 @@ pub fn update_contents(
widget.update_widget_item(Item::Array(error_lines!(e)));
}
},
Yaml(res) => {
SelectedYaml(res) => {
update_widget_item_for_vec(window, view_id::tab_yaml_widget_yaml, res);
}
DirectedYaml { kind, name, yaml } => {
let widget = window
.find_widget_mut(view_id::popup_yaml)
.widget_config_mut();
*(widget.append_title_mut()) = Some(format!(" : {}/{}", kind, name).into());

update_widget_item_for_vec(window, view_id::popup_yaml, yaml);
}
}
}

Expand Down
35 changes: 21 additions & 14 deletions src/event/kubernetes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ use self::{
pod::{LogMessage, LogWorker},
worker::{AbortWorker, PollWorker, Worker},
yaml::{
fetch_resource_list::FetchResourceList,
worker::{YamlWorker, YamlWorkerRequest},
direct::DirectedYamlWorker,
select::{resources::FetchResourceList, worker::SelectedYamlWorker},
YamlMessage, YamlRequest, YamlResponse,
},
};
Expand Down Expand Up @@ -481,23 +481,13 @@ impl Worker for MainWorker {
tx.send(YamlResponse::Resource(fetched_data).into())
.expect("Failed to send YamlResponse::Resource");
}
Yaml {
kind,
name,
namespace,
} => {
SelectedYaml(req) => {
if let Some(handler) = yaml_handler {
handler.abort();
}

let req = YamlWorkerRequest {
kind,
name,
namespace,
};

yaml_handler = Some(
YamlWorker::new(
SelectedYamlWorker::new(
is_terminated.clone(),
tx,
kube_client.clone(),
Expand All @@ -508,6 +498,23 @@ impl Worker for MainWorker {
);
task::yield_now().await;
}

DirectedYaml(req) => {
if let Some(handler) = yaml_handler {
handler.abort();
}

yaml_handler = Some(
DirectedYamlWorker::new(
is_terminated.clone(),
tx,
kube_client.clone(),
req,
)
.spawn(),
);
task::yield_now().await;
}
}
}

Expand Down
Loading

0 comments on commit a4fe77c

Please sign in to comment.