From aaaf764331c215d7558e7797a1db670e03fbfad1 Mon Sep 17 00:00:00 2001 From: Orion Kindel Date: Wed, 19 May 2021 16:21:35 -0700 Subject: [PATCH] feat: plaintext input (#128) --- Makefile.toml | 4 + src/block_elements/mod.rs | 9 +- src/block_elements/radio.rs | 66 +++++- src/block_elements/text_input.rs | 345 +++++++++++++++++++++++++++++++ src/blocks/actions.rs | 9 +- src/blocks/input.rs | 19 +- 6 files changed, 440 insertions(+), 12 deletions(-) create mode 100644 src/block_elements/text_input.rs diff --git a/Makefile.toml b/Makefile.toml index 4664440..52a2461 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -26,6 +26,10 @@ command = "cargo" args = ["fmt"] dependencies = ["install-fmt"] +[tasks.doctest-slow] +command = "cargo" +args = ["--locked", "test", "--jobs", "1", "--doc", "--", "--quiet"] + [tasks.doctest] command = "cargo" args = ["--locked", "test", "--doc", "--", "--quiet"] diff --git a/src/block_elements/mod.rs b/src/block_elements/mod.rs index 2c8ed93..d566a00 100644 --- a/src/block_elements/mod.rs +++ b/src/block_elements/mod.rs @@ -11,6 +11,9 @@ pub use button::Contents as Button; pub mod select; pub use select::Select; +pub mod text_input; +pub use text_input::TextInput; + /// # Block Elements - interactive components /// [slack api docs 🔗](https://api.slack.com/reference/block-kit/block-elements) /// @@ -34,9 +37,11 @@ pub enum BlockElement<'a> { Image, MultiSelect, OverflowMenu, - PlainInput, RadioButtons(Radio<'a>), + #[serde(rename = "plain_text_input")] + TextInput(TextInput<'a>), + #[serde(rename = "channels_select")] SelectPublicChannel(select::PublicChannel<'a>), @@ -62,6 +67,7 @@ impl<'a> BlockElement<'a> { | Self::SelectUser(cts) => cts.validate(), | Self::SelectExternal(cts) => cts.validate(), | Self::SelectStatic(cts) => cts.validate(), + | Self::RadioButtons(cts) => cts.validate(), | rest => todo!("validation not implemented for {:?}", rest), } } @@ -69,6 +75,7 @@ impl<'a> BlockElement<'a> { convert!(impl From