Compare commits

..

2 commits

Author SHA1 Message Date
bd6b0b2d31 WIP: feat(tui): update state model from server messages
All checks were successful
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
2024-08-22 19:55:32 +01:00
7a4f9a45a6 fix(github): register webhook with valid callback url
All checks were successful
Rust / build (push) Successful in 8m58s
ci/woodpecker/push/cron-docker-builder Pipeline was successful
ci/woodpecker/push/push-next Pipeline was successful
ci/woodpecker/push/tag-created Pipeline was successful
Release Please / Release-plz (push) Successful in 1m33s
2024-08-22 19:55:32 +01:00
6 changed files with 19 additions and 10 deletions

View file

@ -18,22 +18,26 @@ impl Handler<CloneRepo> for RepoActor {
#[instrument(name = "RepoActor::CloneRepo", skip_all, fields(repo = %self.repo_details))]
fn handle(&mut self, _msg: CloneRepo, ctx: &mut Self::Context) -> Self::Result {
logger(self.log.as_ref(), "Handler: CloneRepo: start");
self.update_tui(RepoUpdate::Cloning);
self.update_tui(RepoUpdate::Opening);
debug!("Handler: CloneRepo: start");
match git::repository::open(&*self.repository_factory, &self.repo_details) {
Ok(repository) => {
logger(self.log.as_ref(), "open okay");
debug!("open okay");
self.update_tui(RepoUpdate::Opened);
self.open_repository.replace(repository);
if self.repo_details.repo_config.is_none() {
self.update_tui(RepoUpdate::LoadingConfigFromRepo);
do_send(&ctx.address(), LoadConfigFromRepo, self.log.as_ref());
} else {
self.update_tui(RepoUpdate::RegisteringWebhook);
do_send(&ctx.address(), RegisterWebhook::new(), self.log.as_ref());
}
}
Err(err) => {
logger(self.log.as_ref(), "open failed");
warn!("Could not open repo: {err:?}");
self.alert_tui(err.to_string());
}
}
debug!("Handler: CloneRepo: finish");

View file

@ -1,7 +1,7 @@
//
use actix::prelude::*;
use tracing::{debug, Instrument as _};
use tracing::{debug, error, Instrument as _};
use crate::{
repo::{
@ -33,7 +33,7 @@ impl Handler<RegisterWebhook> for RepoActor {
async move {
match forge.register_webhook(&repo_listen_url).await {
Ok(registered_webhook) => {
debug!(?registered_webhook, "");
debug!(?registered_webhook, "webhook registered");
do_send(
&addr,
WebhookRegistered::from(registered_webhook),
@ -41,6 +41,7 @@ impl Handler<RegisterWebhook> for RepoActor {
);
}
Err(err) => {
error!(?err, "failed to register webhook");
notify_user(
notify_user_recipient.as_ref(),
UserNotification::WebhookRegistration {
@ -56,6 +57,8 @@ impl Handler<RegisterWebhook> for RepoActor {
.in_current_span()
.into_actor(self)
.wait(ctx);
} else {
self.alert_tui("already have a webhook id - cant register webhook");
}
}
}

View file

@ -73,7 +73,7 @@ pub enum RepoUpdate {
AdvancingMain {
commit: git::Commit,
},
Cloning,
Opening,
LoadingConfigFromRepo,
ReceiveCIStatus {
status: Status,
@ -88,6 +88,7 @@ pub enum RepoUpdate {
push: Push,
},
RegisteredWebhook,
Opened,
}
message!(

View file

@ -56,8 +56,11 @@ impl Handler<ServerUpdate> for Tui {
RepoUpdate::AdvancingMain { commit } => {
repo_state.update_message(format!("advancing main to {commit}"));
}
RepoUpdate::Cloning => {
repo_state.update_message("cloning...");
RepoUpdate::Opening => {
repo_state.update_message("opening...");
}
RepoUpdate::Opened => {
repo_state.update_message("opened");
}
RepoUpdate::LoadingConfigFromRepo => {
repo_state.update_message("loading config from repo...");

View file

@ -5,11 +5,9 @@ use ratatui::{
buffer::Buffer,
layout::{Constraint, Direction, Layout, Rect},
text::{Line, Text},
widgets::{Paragraph, Widget},
widgets::Widget,
};
use crate::trace_dbg;
pub struct ConfiguredRepoWidget<'a> {
pub repo_alias: &'a RepoAlias,
pub message: &'a str,

View file

@ -35,7 +35,7 @@ pub async fn register(
"active": true,
"events": ["push"],
"config": {
"url": repo_listen_url.as_ref(),
"url": repo_listen_url.to_string(),
"content_type": "json",
"secret": authorisation.to_string(),
"insecure_ssl": "0",