From c9226559253ae194dc4bbc27614403e8dd6df442 Mon Sep 17 00:00:00 2001 From: Simon Oxtoby Date: Fri, 3 Jan 2020 09:59:10 +1000 Subject: [PATCH] Adding multi-select block elements --- SlackNet/Blocks/ActionElement.cs | 24 +++++++++++++ SlackNet/Blocks/Button.cs | 13 +------ SlackNet/Blocks/ChannelMultiSelectAction.cs | 10 ++++++ SlackNet/Blocks/ChannelMultiSelectMenu.cs | 23 ++++++++++++ SlackNet/Blocks/ChannelSelectMenu.cs | 18 +--------- .../Blocks/ConversationMultiSelectAction.cs | 10 ++++++ .../Blocks/ConversationMultiSelectMenu.cs | 23 ++++++++++++ SlackNet/Blocks/ConversationSelectMenu.cs | 18 +--------- SlackNet/Blocks/DatePicker.cs | 13 +------ SlackNet/Blocks/ExternalMultiSelectAction.cs | 10 ++++++ SlackNet/Blocks/ExternalMultiSelectMenu.cs | 26 ++++++++++++++ SlackNet/Blocks/ExternalSelectMenu.cs | 24 +------------ SlackNet/Blocks/ExternalSelectMenuBase.cs | 13 +++++++ SlackNet/Blocks/IActionElement.cs | 8 ----- SlackNet/Blocks/OverflowMenu.cs | 13 +------ SlackNet/Blocks/SelectMenuBase.cs | 12 +++++++ SlackNet/Blocks/StaticMultiSelectAction.cs | 10 ++++++ SlackNet/Blocks/StaticMultiSelectMenu.cs | 25 +++++++++++++ SlackNet/Blocks/StaticSelectMenu.cs | 36 ++----------------- SlackNet/Blocks/StaticSelectMenuBase.cs | 21 +++++++++++ SlackNet/Blocks/UserMultiSelectAction.cs | 10 ++++++ SlackNet/Blocks/UserMultiSelectMenu.cs | 23 ++++++++++++ SlackNet/Blocks/UserSelectMenu.cs | 18 +--------- 23 files changed, 250 insertions(+), 151 deletions(-) create mode 100644 SlackNet/Blocks/ActionElement.cs create mode 100644 SlackNet/Blocks/ChannelMultiSelectAction.cs create mode 100644 SlackNet/Blocks/ChannelMultiSelectMenu.cs create mode 100644 SlackNet/Blocks/ConversationMultiSelectAction.cs create mode 100644 SlackNet/Blocks/ConversationMultiSelectMenu.cs create mode 100644 SlackNet/Blocks/ExternalMultiSelectAction.cs create mode 100644 SlackNet/Blocks/ExternalMultiSelectMenu.cs create mode 100644 SlackNet/Blocks/ExternalSelectMenuBase.cs delete mode 100644 SlackNet/Blocks/IActionElement.cs create mode 100644 SlackNet/Blocks/SelectMenuBase.cs create mode 100644 SlackNet/Blocks/StaticMultiSelectAction.cs create mode 100644 SlackNet/Blocks/StaticMultiSelectMenu.cs create mode 100644 SlackNet/Blocks/StaticSelectMenuBase.cs create mode 100644 SlackNet/Blocks/UserMultiSelectAction.cs create mode 100644 SlackNet/Blocks/UserMultiSelectMenu.cs diff --git a/SlackNet/Blocks/ActionElement.cs b/SlackNet/Blocks/ActionElement.cs new file mode 100644 index 0000000..71789ba --- /dev/null +++ b/SlackNet/Blocks/ActionElement.cs @@ -0,0 +1,24 @@ +namespace SlackNet.Blocks +{ + public interface IActionElement + { + string Type { get; } + string ActionId { get; set; } + } + + public abstract class ActionElement : BlockElement, IActionElement + { + protected ActionElement(string type) : base(type) { } + + /// + /// An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. + /// Should be unique among all other s used elsewhere by your app. + /// + public string ActionId { get; set; } + + /// + /// Defines an optional confirmation dialog that appears after the element is activated. + /// + public ConfirmationDialog Confirm { get; set; } + } +} \ No newline at end of file diff --git a/SlackNet/Blocks/Button.cs b/SlackNet/Blocks/Button.cs index 0482452..d04d3b2 100644 --- a/SlackNet/Blocks/Button.cs +++ b/SlackNet/Blocks/Button.cs @@ -4,7 +4,7 @@ /// An interactive element that inserts a button. The button can be a trigger for anything from opening a simple link to starting a complex workflow. /// [SlackType("button")] - public class Button : BlockElement, IActionElement + public class Button : ActionElement { public Button() : base("button") { } @@ -30,17 +30,6 @@ public Button() : base("button") { } /// [IgnoreIfDefault] public ButtonStyle Style { get; set; } - - /// - /// Defines an optional confirmation dialog after the button is clicked. - /// - public ConfirmationDialog Confirm { get; set; } - - /// - /// An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. - /// Should be unique among all other s used elsewhere by your app. - /// - public string ActionId { get; set; } } public enum ButtonStyle diff --git a/SlackNet/Blocks/ChannelMultiSelectAction.cs b/SlackNet/Blocks/ChannelMultiSelectAction.cs new file mode 100644 index 0000000..1b94fff --- /dev/null +++ b/SlackNet/Blocks/ChannelMultiSelectAction.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace SlackNet.Blocks +{ + [SlackType("multi_channels_select")] + public class ChannelMultiSelectAction + { + public IList SelectedChannels { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/SlackNet/Blocks/ChannelMultiSelectMenu.cs b/SlackNet/Blocks/ChannelMultiSelectMenu.cs new file mode 100644 index 0000000..54b867d --- /dev/null +++ b/SlackNet/Blocks/ChannelMultiSelectMenu.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace SlackNet.Blocks +{ + /// + /// This multi-select menu will populate its options with a list of public channels visible to the current user in the active workspace. + /// + [SlackType("multi_channels_select")] + public class ChannelMultiSelectMenu : SelectMenuBase + { + public ChannelMultiSelectMenu() : base("multi_channels_select") { } + + /// + /// A list of one or more IDs of any valid public channel to be pre-selected when the menu loads. + /// + public IList InitialChannels { get; set; } = new List(); + + /// + /// Specifies the maximum number of items that can be selected in the menu. Minimum number is 1. + /// + public int? MaxSelectedItems { get; set; } + } +} \ No newline at end of file diff --git a/SlackNet/Blocks/ChannelSelectMenu.cs b/SlackNet/Blocks/ChannelSelectMenu.cs index c90cc67..a6fb6ca 100644 --- a/SlackNet/Blocks/ChannelSelectMenu.cs +++ b/SlackNet/Blocks/ChannelSelectMenu.cs @@ -4,29 +4,13 @@ /// This select menu will populate its options with a list of public channels visible to the current user in the active workspace. /// [SlackType("channels_select")] - public class ChannelSelectMenu : BlockElement, IActionElement + public class ChannelSelectMenu : SelectMenuBase { public ChannelSelectMenu() : base("channels_select") { } - /// - /// A plain text object that defines the placeholder text shown on the menu. - /// - public PlainText Placeholder { get; set; } - /// /// The ID of any valid public channel to be pre-selected when the menu loads. /// public string InitialChannel { get; set; } - - /// - /// Defines an optional confirmation dialog that appears after a menu item is selected. - /// - public ConfirmationDialog Confirm { get; set; } - - /// - /// An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. - /// Should be unique among all other s used elsewhere by your app. - /// - public string ActionId { get; set; } } } \ No newline at end of file diff --git a/SlackNet/Blocks/ConversationMultiSelectAction.cs b/SlackNet/Blocks/ConversationMultiSelectAction.cs new file mode 100644 index 0000000..706cef0 --- /dev/null +++ b/SlackNet/Blocks/ConversationMultiSelectAction.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace SlackNet.Blocks +{ + [SlackType("multi_conversations_select")] + public class ConversationMultiSelectAction + { + public IList SelectedConversations { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/SlackNet/Blocks/ConversationMultiSelectMenu.cs b/SlackNet/Blocks/ConversationMultiSelectMenu.cs new file mode 100644 index 0000000..aa1f161 --- /dev/null +++ b/SlackNet/Blocks/ConversationMultiSelectMenu.cs @@ -0,0 +1,23 @@ +using System.Collections.Generic; + +namespace SlackNet.Blocks +{ + /// + /// This multi-select menu will populate its options with a list of public and private channels, DMs, and MPIMs visible to the current user in the active workspace. + /// + [SlackType("multi_conversations_select")] + public class ConversationMultiSelectMenu : SelectMenuBase + { + public ConversationMultiSelectMenu() : base("multi_conversations_select") { } + + /// + /// A list of one or more IDs of any valid conversations to be pre-selected when the menu loads. + /// + public IList InitialConversations { get; set; } = new List(); + + /// + /// Specifies the maximum number of items that can be selected in the menu. Minimum number is 1. + /// + public int? MaxSelectedItems { get; set; } + } +} \ No newline at end of file diff --git a/SlackNet/Blocks/ConversationSelectMenu.cs b/SlackNet/Blocks/ConversationSelectMenu.cs index 1c31f06..23300e1 100644 --- a/SlackNet/Blocks/ConversationSelectMenu.cs +++ b/SlackNet/Blocks/ConversationSelectMenu.cs @@ -4,29 +4,13 @@ /// This select menu will populate its options with a list of public and private channels, DMs, and MPIMs visible to the current user in the active workspace. /// [SlackType("conversations_select")] - public class ConversationSelectMenu : BlockElement, IActionElement + public class ConversationSelectMenu : SelectMenuBase { public ConversationSelectMenu() : base("conversations_select") { } - /// - /// A plain text object that defines the placeholder text shown on the menu. - /// - public PlainText Placeholder { get; set; } - /// /// The ID of any valid conversation to be pre-selected when the menu loads. /// public string InitialConversation { get; set; } - - /// - /// Defines an optional confirmation dialog that appears after a menu item is selected. - /// - public ConfirmationDialog Confirm { get; set; } - - /// - /// An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. - /// Should be unique among all other s used elsewhere by your app. - /// - public string ActionId { get; set; } } } \ No newline at end of file diff --git a/SlackNet/Blocks/DatePicker.cs b/SlackNet/Blocks/DatePicker.cs index 2f50748..5d181bf 100644 --- a/SlackNet/Blocks/DatePicker.cs +++ b/SlackNet/Blocks/DatePicker.cs @@ -7,7 +7,7 @@ namespace SlackNet.Blocks /// Date picker elements can be used inside of section and actions blocks. /// [SlackType("datepicker")] - public class DatePicker : BlockElement, IActionElement + public class DatePicker : ActionElement { public DatePicker() : base("datepicker") { } @@ -20,16 +20,5 @@ public DatePicker() : base("datepicker") { } /// The initial date that is selected when the element is loaded. /// public DateTime? InitialDate { get; set; } - - /// - /// Defines an optional confirmation dialog that appears after a menu item is selected. - /// - public ConfirmationDialog Confirm { get; set; } - - /// - /// An identifier for this action. You can use this when you receive an interaction payload to identify the source of the action. - /// Should be unique among all other s used elsewhere by your app. - /// - public string ActionId { get; set; } } } \ No newline at end of file diff --git a/SlackNet/Blocks/ExternalMultiSelectAction.cs b/SlackNet/Blocks/ExternalMultiSelectAction.cs new file mode 100644 index 0000000..64b0e80 --- /dev/null +++ b/SlackNet/Blocks/ExternalMultiSelectAction.cs @@ -0,0 +1,10 @@ +using System.Collections.Generic; + +namespace SlackNet.Blocks +{ + [SlackType("multi_external_select")] + public class ExternalMultiSelectAction + { + public IList