run

look

A command someone approves to run.

Drawn

cargo test --workspace --release

crates · the test target only · sha 4f2a9c1

The sample

site/src/kinds.rs:367–430

fn input() -> Vec<Block> {
    let option = |value: &str, label: &str| ChoiceOption {
        value: value.into(),
        label: label.into(),
        ..ChoiceOption::default()
    };
    let choice = Choice::new(
        "when",
        vec![
            option("friday", "Ship on Friday"),
            option("now", "Ship now"),
            option("later", "Hold for 0.5"),
        ],
    )
    .id("when")
    .question("When do the 0.4 notes ship?")
    .recommended("friday")
    .other(Other {
        placeholder: Some("other…".into()),
        r#for: None,
    });
    let form = Form::new(vec![
        field("name", "Name", FieldValue::Text("Ada Lovelace".into())),
        field("email", "Email", FieldValue::Text("ada@example.com".into())),
        picker("plan", "Plan", &["team", "solo", "school"]),
        toggle("updates", "Updates", true),
    ])
    .id("signup")
    .submit(Submit {
        label: "sign up".into(),
        action: "sign-up".into(),
        ..Submit::default()
    });
    let pick = |name: &str, all: &[&str]| ComposerChip {
        name: name.into(),
        cur: all.first().map(|s| (*s).to_string()),
        all: all.iter().map(|s| (*s).to_string()).collect(),
    };
    let composer = Composer::new("say")
        .id("say")
        .label("send")
        .placeholder("message the team")
        .chips(vec![
            pick("model", &["fast", "deep"]),
            pick("effort", &["medium", "high"]),
        ])
        .queued(vec![Queued {
            q: 1,
            text: "rerun the bench on main".into(),
        }]);
    let run = Run::new("approve", "cargo test --workspace --release", "4f2a9c1")
        .id("tests")
        .dir("crates")
        .touches("the test target only");
    vec![
        button("save", "save", ButtonStyle::Primary),
        button("preview", "preview", ButtonStyle::Plain),
        button("delete", "delete", ButtonStyle::Destructive),
        b!(Choice(choice)),
        b!(Form(form)),
        b!(Composer(composer)),
        b!(Run(run)),
    ]
}
{
  "blocks": [
    {
      "action": "approve",
      "command": "cargo test --workspace --release",
      "dir": "crates",
      "fallback": {
        "title": "cargo test --workspace --release"
      },
      "id": "tests",
      "sha": "4f2a9c1",
      "touches": "the test target only",
      "type": "run"
    }
  ],
  "fallback": {
    "title": "screen"
  },
  "id": "run",
  "type": "screen"
}

Its fallback

What a renderer without run draws: a row from the fallback the block carries.
cargo test --workspace --release

Style hooks

.b-runthe block
[data-block=run]every block of the kind
[data-id=tests]this one block
Every page here is a blocks Screen, written by site::page: no hand-written HTML. Source: https://github.com/jirathip-dev/blocks