use maud::{Markup, Render, html};

/// The public/private radio fieldset for repository visibility.
pub(super) struct VisibilityRadios<'a> {
    pub(super) current: &'a str,
}

impl Render for VisibilityRadios<'_> {
    fn render(&self) -> Markup {
        html! {
            label {
                input type="radio" name="visibility" value="public"
                    checked[self.current == "public"];
                "Public"
            }
            label {
                input type="radio" name="visibility" value="private"
                    checked[self.current == "private"];
                "Private"
            }
        }
    }
}

/// The merge policy select dropdown for repository settings and patch edit.
pub(super) struct MergePolicySelect<'a> {
    pub(super) name: &'a str,
    pub(super) current: &'a str,
}

impl Render for MergePolicySelect<'_> {
    fn render(&self) -> Markup {
        html! {
            select name=(self.name) {
                option value="prefer-fast-forward"
                    selected[self.current == "prefer-fast-forward"] {
                    "Prefer fast-forward"
                }
                option value="fast-forward-only"
                    selected[self.current == "fast-forward-only"] {
                    "Fast-forward only"
                }
                option value="merge-commit-only"
                    selected[self.current == "merge-commit-only"] {
                    "Merge commit only"
                }
                option value="rebase-then-fast-forward"
                    selected[self.current == "rebase-then-fast-forward"] {
                    "Rebase then fast-forward"
                }
            }
        }
    }
}
