Skip to content

Commit

Permalink
Merge pull request #65 from mantro/feature/dispatch_actions
Browse files Browse the repository at this point in the history
Dispatch actions
  • Loading branch information
soxtoby authored Oct 24, 2020
2 parents 68de054 + 0fb11ae commit fad2669
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
22 changes: 22 additions & 0 deletions SlackNet/Blocks/DispatchActionConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System.Collections.Generic;

namespace SlackNet.Blocks
{
/// <summary>
/// Determines when a<see cref="PlainTextInput"/> element will return a <see cref="BlockAction"/> interaction payload.
/// </summary>
public class DispatchActionConfig
{
/// <summary>
/// An array of <see cref="InteractionType"/> that you would like to receive a <see cref="BlockAction"/> payload for.
/// </summary>
[IgnoreIfEmpty]
public IList<InteractionType> TriggerActionsOn { get; set; } = new List<InteractionType>();
}

public enum InteractionType
{
OnEnterPressed,
OnCharacterEntered
}
}
5 changes: 5 additions & 0 deletions SlackNet/Blocks/InputBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@ public InputBlock() : base("input") { }
/// A boolean that indicates whether the input element may be empty when a user submits the modal.
/// </summary>
public bool Optional { get; set; }

/// <summary>
/// A boolean that indicates whether or not the use of elements in this block should dispatch a <see cref="BlockAction"/> payload. Defaults to false.
/// </summary>
public bool DispatchAction { get; set; }
}
}
11 changes: 11 additions & 0 deletions SlackNet/Blocks/PlainTextInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ public PlainTextInput() : base("plain_text_input") { }
/// The maximum length of input that the user can provide. If the user provides more, they will receive an error.
/// </summary>
public int? MaxLength { get; set; }

/// <summary>
/// A <see cref="DispatchActionConfig"/> that determines when during text input the element returns a <see cref="BlockAction"/> payload.
/// </summary>
public DispatchActionConfig DispatchActionConfig { get; set; }
}

[SlackType("plain_text_input")]
public class PlainTextInputAction : BlockAction
{
public string Value { get; set; }
}

[SlackType("plain_text_input")]
Expand Down

0 comments on commit fad2669

Please sign in to comment.