Skip to content

Commit

Permalink
feat: added titles and dest interpolation
Browse files Browse the repository at this point in the history
  • Loading branch information
arctic-hen7 committed Jan 14, 2022
1 parent 3d43e22 commit 287129f
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/basic.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
workflows:
test:
title: "Test Workflow"
sections:
Start:
- "Hello, and welcome to the first stage of your contribution journey with [Tribble](https://github.com/arctic-hen7/tribble)! `This is some code.`"
Expand Down Expand Up @@ -29,5 +30,5 @@ workflows:
preamble: "Thanks for the request, we'll take a look!"
text: "This report is requesting an enhancement to the ${feature_area}."
dest_text: "Report on GitHub"
dest_url: "#"
dest_url: "#?body=%s"
Documentation: "You can contribute to the docs by doing *foobar*!"
4 changes: 3 additions & 1 deletion packages/tribble-app/src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ impl Config {
#[derive(Serialize, Deserialize, Debug, Clone)]
#[cfg_attr(feature = "schema", derive(JsonSchema))]
pub struct Workflow {
/// The title of the page dedicated to this workflow (appears in tabs).
pub title: String,
/// The sections that the page can make use of.
pub sections: HashMap<String, Section>,
/// The section to start on, which must be a valid key in the `sections` map.
Expand Down Expand Up @@ -231,7 +233,7 @@ pub enum Endpoint {
/// The text of a button for sending teh user to wherever they'll report the issue. This does not support Markdown.
dest_text: String,
/// A URL to send the user to so that they can report the issue. If the platform supports interpolating text to be sent
/// into the URL, you can do so by interpolating `%r` into this field.
/// into the URL, you can do so by interpolating `%s` into this field.
dest_url: String,
},
/// An instructional endpoint, which tells the user to do something. This supports Markdown.
Expand Down
11 changes: 10 additions & 1 deletion packages/tribble-app/src/templates/workflow/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ mod get_build_state;
mod parse_md;
mod view;

use perseus::{Html, Template};
use perseus::{Html, SsrNode, Template};
use sycamore::view::View;

pub fn get_template<G: Html>() -> Template<G> {
Template::new("workflow")
.template(view::workflow)
.head(head)
.build_state_fn(get_build_state::get_build_state)
.build_paths_fn(get_build_paths::get_build_paths)
}

#[perseus::head]
fn head(props: get_build_state::WorkflowProps) -> View<SsrNode> {
sycamore::view! {
title { (props.workflow.title) }
}
}
2 changes: 2 additions & 0 deletions packages/tribble-app/src/templates/workflow/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ fn render_report_endpoint(
encoded_tags
)
);
// Interpolate that into the destination URL if needed
let dest_url = dest_url.replace("%s", &report_text);

let copy_handler = cloned!(report_text => move |_| {
wasm_bindgen_futures::spawn_local(cloned!(report_text => async move {
Expand Down

0 comments on commit 287129f

Please sign in to comment.