-
Notifications
You must be signed in to change notification settings - Fork 399
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
view_closed support (Block Kit in Modals) #263
Comments
Sorry this is so long-winded but.... Option 1: For incoming requests that we label as type "Event", there is a pretty big upside: we automatically acknowledge the request before we pass it to any listeners or middleware. This makes it so the developer won't have to call However, this is breaking convention because up until now, we've only had the Another (pretty big) downside is if you had several view submissions, there isn't a built-in way to filter on Ex: Option 2: Another option is using the Ex: Option 3ish: Less interested in this option. It'd be less intuitive as to where the developer should handle the view cancellation and it would still require them to acknowledge it. The pro is that we only have a constraints object on the I don't have a really strong opinion. I lean a little bit more towards the |
@shanedewael
No need to call
From the viewpoint of API consistencies, there is no reason to go with
First of all, for convenience, I believe we should keep the behavior when not specifying a payload type as before (= means handling only app.view('YOUR-CALLBACK-ID', ({ view, ack }) => {
// handle only view_submission events here
});
app.view({callback_id: 'YOUR-CALLBACK-ID'}, ({ view, ack }) => {
// handle only view_submission events here
}); Regarding the ways to specify a payload type, I came up with two ways as below. I want to allow both, but going with either is also excellent. // Option A - giving a full name of type
app.view({callback_id: 'YOUR-CALLBACK-ID', type: 'view_closed'}, ({ view, ack }) => { });
app.view({callback_id: 'YOUR-CALLBACK-ID', type: 'view_submission'}, ({ view, ack }) => { });
// Option B - skipping the redundant part - `view_`, and giving only the suffix
app.view({callback_id: 'YOUR-CALLBACK-ID', type: 'closed'}, ({ view, ack }) => { });
app.view({callback_id: 'YOUR-CALLBACK-ID', type: 'submission'}, ({ view, ack }) => { }); The following part may be a bit off-topic, but, with this approach, we may be able to come up with a similar interface for dialogs. Introducing a new name may be able to make the framework simpler. Disclaimer: I haven't verified the feasibility of providing the APIs for both JS and TS yet (particularly, a bit worrying about // Option A - giving a full name of type
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'dialog_submission'}, ({ dialog, ack }) => { });
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'dialog_suggestion'}, ({ dialog, ack }) => { });
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'dialog_cancellation'}, ({ dialog, ack }) => { });
// Option B - skipping the redundant part - `dialog_`, and giving only the suffix
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'submission'}, ({ dialog, ack }) => { });
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'suggestion'}, ({ dialog, ack }) => { });
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'cancellation'}, ({ dialog, ack }) => { }); However, this approach introduces more ways to do the same. If we go with this, we may deprecate existing // submission
app.action({callback_id: 'YOUR-CALLBACK-ID'}, ({ action, ack }) => { });
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'submission'}, ({ dialog, ack }) => { });
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'dialog_submission'}, ({ dialog, ack }) => { });
// suggestion
app.options({callback_id: 'YOUR-CALLBACK-ID'}, ({ options, ack }) => { }},
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'suggestion'}, ({ dialog, ack }) => { });
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'dialog_suggestion'}, ({ dialog, ack }) => { });
// cancellation
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'cancellation'}, ({ dialog, ack }) => { });
app.dialog({callback_id: 'YOUR-CALLBACK-ID', type: 'dialog_cancellation'}, ({ dialog, ack }) => { }); Having multiple ways for a single purpose is not a small downside, but having .... let's get back on track. Regarding `view_closed support, if you go with Option 2 in some way, I don't have any objections for it. |
I'm glad we're all in agreement! I just wanted to add one more advantage to Option 2 that I'm excited about. With this design, you can write listener middleware that deals with general cleanup that occurs whenever a modal is dismissed, whether its because it was submitted or because it was canceled. Example: // This function cleans up some temporary state from a data store and puts it on the context
// Use case: A partially initialized object is put in the database but fully initializing it depends on gathering input from the modal
function cleanUpTemporaryState({ context, next }) { /* ... */ }
// Submission handler
app.view('create_order', cleanUpTemporaryState, ({ view }) => { /* ... */ });
// Cancel handler
app.view(
{ callback_id: 'create_order', type: 'view_closed' },
cleanUpTemporaryState,
({ view }) => { /* ... */ }
); |
how this would work with python bolt? I trued this but does not seems to work..
|
@smoneta Can you post a new question issue in https://github.com/slackapi/bolt-python/issues with a bit more details such as your code? |
Thanks, slackapi/bolt-python#624 |
Description
As of version 1.3.0, Bolt lacks
view_closed
action support.view_closed
events can be sent to slack app servers whennotify_on_close
in views.What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)Bug Report
Reproducible in:
package version: 1.3.0
node version: any
OS version(s): any
Steps to reproduce:
views.open
havingnotify_on_close: true
[WARN] Could not determine the type of an incoming event. No listeners will be called.
Expected result:
app.view('callback-id' , fn)
can handleview_closed
action as well.Actual result:
As above.
Attachments:
Payload example:
The text was updated successfully, but these errors were encountered: