feat: link to the forms associated with a deployment

This commit is contained in:
Aravinth Manivannan 2022-12-31 01:27:03 +05:30
parent efc8ce5a27
commit c2c139575d
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
5 changed files with 58 additions and 1 deletions

1
Cargo.lock generated
View File

@ -1479,6 +1479,7 @@ dependencies = [
"sha2",
"sqlx",
"tera",
"time",
"tokio",
"toml",
"tracing",

View File

@ -57,6 +57,7 @@ reqwest = { version = "0.11.13", features = ["json"] }
sha2 = "0.10.6"
hmac = "0.12.1"
hex= "0.4.3"
time = { version = "0.3.17", features = ["formatting"] }
[dependencies.cache-buster]
git = "https://github.com/realaravinth/cache-buster"

View File

@ -73,6 +73,7 @@ impl View {
pub struct TemplateSiteWithEvents {
pub site: Site,
pub view: String,
pub forms: String,
pub delete: String,
pub last_update: Option<TemplateSiteEvent>,
pub events: Vec<TemplateSiteEvent>,
@ -86,10 +87,12 @@ impl TemplateSiteWithEvents {
) -> Self {
let view = PAGES.dash.site.get_view(site.pub_id);
let delete = PAGES.dash.site.get_delete(site.pub_id);
let forms = PAGES.dash.site.forms.get_list_host(&site.hostname);
Self {
site,
last_update,
view,
forms,
delete,
events,
}

View File

@ -114,6 +114,44 @@ impl ForgejoWebhook {
}
}
#[derive(Serialize)]
/// Dashboard Site routes
pub struct DashSiteForms {
/// view form submission route
pub view: &'static str,
/// delete form submission route
pub delete: &'static str,
/// list forms belonging to hostname
pub list_forms: &'static str,
}
impl DashSiteForms {
/// create new instance of DashSiteForms route
pub const fn new() -> DashSiteForms {
let view = "/dash/site/forms/submission/view";
let delete = "/dash/site/forms/submission/delete";
let list_forms = "/dash/site/forms/list";
DashSiteForms {
view,
delete,
list_forms,
}
}
pub fn get_list_host(&self, host: &str) -> String {
format!("{}?host={}", self.list_forms, host)
}
pub fn get_view(&self, page: usize, host: &str, path: &str) -> String {
format!("{}?host={}&path={}&page={}", self.view, host, path, page)
}
pub fn get_delete(&self, id: usize, host: &str, path: &str) -> String {
format!("{}?host={}&path={}&id={}", self.view, host, path, id)
}
}
#[derive(Serialize)]
/// Dashboard Site routes
pub struct DashSite {
@ -123,6 +161,9 @@ pub struct DashSite {
pub view: &'static str,
/// delete site route
pub delete: &'static str,
/// forms routes
pub forms: DashSiteForms,
}
impl DashSite {
@ -131,7 +172,13 @@ impl DashSite {
let add = "/dash/site/add";
let view = "/dash/site/view/{deployment_pub_id}";
let delete = "/dash/site/delete/{deployment_pub_id}";
DashSite { add, view, delete }
let forms = DashSiteForms::new();
DashSite {
add,
view,
delete,
forms,
}
}
pub fn get_view(&self, deployment_pub_id: Uuid) -> String {

View File

@ -28,6 +28,11 @@
</td>
</tr>
<tr>
<th>Forms</th>
<td><a href="{{ payload.forms }}" >See forms</a></td>
</tr>
<tr>
<th>Branch</th>
<td>{{ payload.site.branch }}</td>