43 lines
932 B
Rust
43 lines
932 B
Rust
use askama::Template;
|
|
use askama_axum::IntoResponse;
|
|
use axum::{
|
|
extract::{Path, State},
|
|
response::Redirect,
|
|
};
|
|
|
|
use crate::{
|
|
http::error::Result,
|
|
stack::{self, operation},
|
|
AppState,
|
|
};
|
|
|
|
#[derive(Template)]
|
|
#[template(path = "stack/delete-one.html")]
|
|
struct ConfirmDeleteTemplate {
|
|
stack_name: String,
|
|
}
|
|
|
|
pub(super) async fn confirm_deletion_page(
|
|
Path(stack_name): Path<String>,
|
|
State(state): State<AppState>,
|
|
) -> Result<impl IntoResponse> {
|
|
let project_id = stack::list::stack_name(&state.stack_dir, &stack_name).await?;
|
|
|
|
Ok(ConfirmDeleteTemplate {
|
|
stack_name: project_id,
|
|
})
|
|
}
|
|
|
|
pub(super) async fn delete_stack(
|
|
Path(stack_name): Path<String>,
|
|
State(state): State<AppState>,
|
|
) -> Result<Redirect> {
|
|
operation::remove(
|
|
&state.stack_dir,
|
|
&state.arion_bin,
|
|
state.repository,
|
|
&stack_name,
|
|
)
|
|
.await?;
|
|
Ok(Redirect::to("/"))
|
|
}
|