Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Input Block Support for Modals #519

Closed
4 of 9 tasks
ruberVulpes opened this issue Sep 25, 2019 · 5 comments · Fixed by #659
Closed
4 of 9 tasks

Adding Input Block Support for Modals #519

ruberVulpes opened this issue Sep 25, 2019 · 5 comments · Fixed by #659
Assignees
Labels
enhancement M-T: A feature request for new functionality Version: 2x
Milestone

Comments

@ruberVulpes
Copy link
Contributor

Description

Describe your issue here.

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Enhancement

Slack just announced modals today. With these came input blocks. I was hoping to get support for the creation of these blocks in /slack/web/classes/blocks.py or possibly a new /slack/web/classes/modals.py similar to /slack/web/classes/dialogs.py.

@ruberVulpes ruberVulpes changed the title Adding Input Block Support Adding Input Block Support for Modals Sep 25, 2019
@RodneyU215 RodneyU215 added Priority: Medium enhancement M-T: A feature request for new functionality Version: 2x labels Oct 19, 2019
@RodneyU215 RodneyU215 self-assigned this Oct 23, 2019
@shollingsworth
Copy link

I'd love to be able to use this with interactive as well! Thanks for the great library all :)

@stevengill stevengill assigned seratch and unassigned RodneyU215 Jan 30, 2020
@seratch seratch added this to the 2.x milestone Mar 17, 2020
@seratch seratch modified the milestones: 2.x, 2.6.0 Apr 20, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 23, 2020
* Fix slackapi#639 Missing blocks & block elements
  * blocks
    * file blocks (for remote files)
    * rich-text blocks (out-of-scope in this commit)
  * block elements
    * multi-select elements
    * checkboxes
    * radio buttons
    * input block's elements slackapi#519
    * rich text elements (out-of-scope in this commit)
    * filtering options for conversations
* Fix slackapi#519 as mentioned above
* Fix slackapi#632 DatePickerElement - missing placeholder causes TypeError
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 23, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 23, 2020
* Fix slackapi#639 Missing blocks & block elements
  * blocks
    * file blocks (for remote files)
    * rich-text blocks (out-of-scope in this commit)
  * block elements
    * multi-select elements
    * checkboxes
    * radio buttons
    * input block's elements slackapi#519
    * rich text elements (out-of-scope in this commit)
    * filtering options for conversations
* Fix slackapi#519 as mentioned above
* Fix slackapi#632 DatePickerElement - missing placeholder causes TypeError
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 23, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 24, 2020
* Fix slackapi#639 Missing blocks & block elements
  * blocks
    * file blocks (for remote files)
    * rich-text blocks (out-of-scope in this commit)
  * block elements
    * multi-select elements
    * checkboxes
    * radio buttons
    * input block's elements slackapi#519
    * rich text elements (out-of-scope in this commit)
    * filtering options for conversations
* Fix slackapi#519 as mentioned above
* Fix slackapi#632 DatePickerElement - missing placeholder causes TypeError
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 24, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 28, 2020
* Fix slackapi#639 Missing blocks & block elements
  * blocks
    * file blocks (for remote files)
    * rich-text blocks (out-of-scope in this commit)
  * block elements
    * multi-select elements
    * checkboxes
    * radio buttons
    * input block's elements slackapi#519
    * rich text elements (out-of-scope in this commit)
    * filtering options for conversations
* Fix slackapi#519 as mentioned above
* Fix slackapi#632 DatePickerElement - missing placeholder causes TypeError
seratch added a commit to seratch/python-slack-sdk that referenced this issue Apr 28, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* Fix slackapi#639 Missing blocks & block elements
  * blocks
    * file blocks (for remote files)
    * rich-text blocks (out-of-scope in this commit)
  * block elements
    * multi-select elements
    * checkboxes
    * radio buttons
    * input block's elements slackapi#519
    * rich text elements (out-of-scope in this commit)
    * filtering options for conversations
* Fix slackapi#519 as mentioned above
* Fix slackapi#632 DatePickerElement - missing placeholder causes TypeError
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* Fix slackapi#639 Missing blocks & block elements
  * blocks
    * file blocks (for remote files)
    * rich-text blocks (out-of-scope in this commit)
  * block elements
    * multi-select elements
    * checkboxes
    * radio buttons
    * input block's elements slackapi#519
    * rich text elements (out-of-scope in this commit)
    * filtering options for conversations
* Fix slackapi#519 as mentioned above
* Fix slackapi#632 DatePickerElement - missing placeholder causes TypeError

* Add view support for modals and Home tabs ref slackapi#519
* Move parser methods to class methods, add more tests for view.state
* Rename validation methods and fix backward incompatibilities
* Add a test case for slackapi#623 and revise subtype getter
* Fix slackapi#628 text length validation in SectionBlock
* Add a sample using native Block Kit builders ref slackapi#500
seratch added a commit to seratch/python-slack-sdk that referenced this issue May 11, 2020
* Fix slackapi#639 Missing blocks & block elements
  * blocks
    * file blocks (for remote files)
    * rich-text blocks (out-of-scope in this commit)
  * block elements
    * multi-select elements
    * checkboxes
    * radio buttons
    * input block's elements slackapi#519
    * rich text elements (out-of-scope in this commit)
    * filtering options for conversations
* Fix slackapi#519 as mentioned above
* Fix slackapi#632 DatePickerElement - missing placeholder causes TypeError

* Add view support for modals and Home tabs ref slackapi#519
* Move parser methods to class methods, add more tests for view.state
* Rename validation methods and fix backward incompatibilities
* Add a test case for slackapi#623 and revise subtype getter
* Fix slackapi#628 text length validation in SectionBlock
* Add a sample using native Block Kit builders ref slackapi#500
seratch added a commit that referenced this issue May 14, 2020
Complete sets of Block Kit components & views support #639 #632 #519
@seratch
Copy link
Member

seratch commented May 15, 2020

👋 slackclient 2.6.0rc1 is out. The pre-release version contains fixes for your issue described here.
https://pypi.org/project/slackclient/2.6.0rc1/

One week later from now, we'll be releasing version 2.6.0 to PyPI.

If you have a chance, could you try the release candidate version out and let us know your feedback? Thank you very much for being patient with this issue.

@ruberVulpes
Copy link
Contributor Author

Sounds good, I'll try to give it a go this weekend. I looked over the source and it looked good to me. Thanks so much.

@ruberVulpes
Copy link
Contributor Author

I was able to get it working, I'll drop the code snippet I used to test it below.

def open_modal(command: SlashCommandInteractiveEvent):
    title = PlainTextObject(text="Color Survey")
    color_input_blocks = [InputBlock(label=PlainTextObject(text="What is your favorite color?"),
                                     element=PlainTextInputElement(placeholder="Green")),
                          InputBlock(label=PlainTextObject(text="Why is that your favorite color?"),
                                     element=PlainTextInputElement(placeholder="It reminds me of my childhood home"),
                                     optional=True)]
    modal = views.View(type="modal", title=title, blocks=color_input_blocks, submit="Submit")
    slack_client.views_open(trigger_id=command.trigger_id, view=modal.to_dict())

If this looks like good usage I wouldn't mind adding it to the documentation for the usage of the message and dialog builders.

I did have some problems getting started at first. The only suggestion I have is to make the type argument in the init of View to be required, I was getting this error The server responded with: {'ok': False, 'error': 'invalid_arguments', 'response_metadata': {'messages': ['[ERROR] failed to match all allowed schemas [json-pointer:/view]', '[ERROR] missing required field: type [json-pointer:/view]']}} at first and was unsure what was causing it. I took a peek at the tests in test_views.py and I wasn't sure if it was needed because the testes seemed to be validating the to_dict() mainly. I eventually figured it out from the "modal", "home" comment .

I'm also unsure about when I would use View vs ViewState or ViewStateValue, but this may just be my unfamiliarity with Views.

Overall I'm very happy with the additions and I'm excited to use it to implement App Homes or Modals.

@seratch
Copy link
Member

seratch commented May 17, 2020

@ruberVulpes Thanks! I've revisited the View class:

If you have more feedback, access my pull request #689 and feel free to leave comments there. I will be merging the PR within a few days.

If this looks like good usage I wouldn't mind adding it to the documentation for the usage of the message and dialog builders.

I'm not going to maintain the README file. We'll be removing those files and will update the documents much more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement M-T: A feature request for new functionality Version: 2x
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants