Skip to content

Revert "Allow to inject arbitrary components into the <head>" #1504

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 1 addition & 21 deletions pgml-dashboard/src/components/layouts/head/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use pgml_components::{component, Component};
use pgml_components::component;
use sailfish::TemplateOnce;

#[derive(TemplateOnce, Default, Clone)]
Expand All @@ -10,7 +10,6 @@ pub struct Head {
pub preloads: Vec<String>,
pub context: Option<String>,
pub canonical: Option<String>,
pub additional_components: Vec<Component>,
}

impl Head {
Expand Down Expand Up @@ -59,25 +58,6 @@ impl Head {
self.context = context.to_owned();
self
}

/// Add a component to `<head>`.
///
/// This can be anything, e.g. a `<script>` tag or a `<meta>` or just some HTML or text.
///
/// # Example
///
/// ```
/// use pgml_components::Component;
/// use pgml_components::layouts::Head;
///
/// let head = Head::new()
/// .add_component(Component::from("<script>console.log('hello');</script>"));
/// ```
///
pub fn add_component(mut self, component: Component) -> Self {
self.additional_components.push(component);
self
}
}

component!(Head);
Expand Down
4 changes: 0 additions & 4 deletions pgml-dashboard/src/components/layouts/head/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,4 @@
};
</script>
<% } %>

<% for component in additional_components { %>
<%+ component %>
<% } %>
</head>
11 changes: 1 addition & 10 deletions pgml-dashboard/src/components/layouts/marketing/base/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::components::notifications::marketing::AlertBanner;
use crate::guards::Cluster;
use crate::models::User;
use crate::Notification;
use pgml_components::{component, Component};
use pgml_components::component;
use sailfish::TemplateOnce;
use std::fmt;

Expand Down Expand Up @@ -72,15 +72,6 @@ impl Base {
rsp
}

/// Add a component to the `<head>`.
///
/// See [`Head::add_component`](crate::components::layouts::Head::add_component) for more information.
///
pub fn add_head_component(mut self, component: Component) -> Self {
self.head = self.head.add_component(component);
self
}

pub fn footer(mut self, footer: String) -> Self {
self.footer = Some(footer);
self
Expand Down
11 changes: 0 additions & 11 deletions pgml-dashboard/src/templates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,6 @@ impl<'a> WebAppBase<'a> {
self
}

/// Add a component to head (`<head>`).
///
/// # Arguments
///
/// * `component` - The component to add to the head.
///
pub fn add_head_component(&mut self, component: Component) -> &mut Self {
self.head = self.head.clone().add_component(component);
self
}

pub fn render<T>(&mut self, template: T) -> String
where
T: sailfish::TemplateOnce,
Expand Down