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

add datetimepicker component #1145

Merged
merged 2 commits into from Dec 24, 2022
Merged

add datetimepicker component #1145

merged 2 commits into from Dec 24, 2022

Conversation

hussachai
Copy link
Contributor

@hussachai hussachai commented Dec 19, 2022

This is a new component that Slack supports Datetimepicker where date and time components are in the same row.
This new component takes number which I think it should be int64 for golang because Go's epoch API returns int64 data type.
Since datetimepicker takes two columns, it's not supported in Accessory. So, I don't include it as part of Section serialization/deserialization.

PS. Sorry I deleted and restored a couple times. First didn't realize that I pushed the upstream, then I changed my mind because I tested it and it's working as expected.

Pull Request Guidelines

These are recommendations for pull requests.
They are strictly guidelines to help manage expectations.

PR preparation

Run make pr-prep from the root of the repository to run formatting, linting and tests.

Should this be an issue instead
  • is it a convenience method? (no new functionality, streamlines some use case)
  • exposes a previously private type, const, method, etc.
  • is it application specific (caching, retry logic, rate limiting, etc)
  • is it performance related.
API changes

Since API changes have to be maintained they undergo a more detailed review and are more likely to require changes.

  • no tests, if you're adding to the API include at least a single test of the happy case.
  • If you can accomplish your goal without changing the API, then do so.
  • dependency changes. updates are okay. adding/removing need justification.
Examples of API changes that do not meet guidelines:
  • in library cache for users. caches are use case specific.
  • Convenience methods for Sending Messages, update, post, ephemeral, etc. consider opening an issue instead.

@hussachai hussachai closed this Dec 19, 2022
@hussachai hussachai deleted the datetime branch December 19, 2022 19:38
@hussachai hussachai restored the datetime branch December 19, 2022 19:39
@hussachai hussachai deleted the datetime branch December 19, 2022 19:39
@hussachai hussachai restored the datetime branch December 19, 2022 19:39
@hussachai hussachai reopened this Dec 19, 2022
@kanata2 kanata2 self-requested a review December 20, 2022 14:15
block_element.go Outdated Show resolved Hide resolved
@kanata2 kanata2 added the feedback given When a review has been conducted and awaiting the response from the comitter(s) label Dec 21, 2022
@Houndie
Copy link

Houndie commented Dec 22, 2022

Thank you for doing this! Saved me some time for doing it myself <3

@kanata2 kanata2 self-requested a review December 22, 2022 04:34
@@ -233,6 +237,7 @@ func (a *Accessory) MarshalJSON() ([]byte, error) {

// UnmarshalJSON implements the Unmarshaller interface for Accessory, so that any JSON
// unmarshalling is delegated and proper type determination can be made before unmarshal
// Note: datetimepicker is not supported in Accessory
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question] Is it correct to say that this is because datetimepicker does not work with Section?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe so, and the builder complains about this https://app.slack.com/block-kit-builder/T3E1TGDM3#%7B%22blocks%22:%5B%7B%22type%22:%22section%22,%22text%22:%7B%22type%22:%22mrkdwn%22,%22text%22:%22Pick%20a%20date%20for%20the%20deadline.%22%7D,%22accessory%22:%7B%22type%22:%22datetimepicker%22,%22action_id%22:%22datepicker-action%22%7D%7D%5D%7D

I assume that the space is not permitted for the layout. I hope Slack supports grid layout like Teams in future. Currently, everything seems to be limited to 2 columns at most.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong on this. Let me check one more time. Looks like it is supported
slackapi/java-slack-sdk@4176b91#diff-212bb028a409f158a94e9af3431b61e080b8bec0e72711ba99dc294e02fd5084L2866

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Working on it. Should be done soon. Thanks for asking this. The assumption needs to be tested.

Copy link
Contributor Author

@hussachai hussachai Dec 22, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I tested it out, and my assumption is right.

0 = {string} "[ERROR] failed to match all allowed schemas [json-pointer:/view]"
1 = {string} "[ERROR] unsupported type: datetimepicker [json-pointer:/view/blocks/8/accessory/type]"

datetimepicker won't work in Section. That kinda makes sense to me because I don't see any room to put text on it. It will go overflow.

@kanata2 kanata2 removed the feedback given When a review has been conducted and awaiting the response from the comitter(s) label Dec 24, 2022
Copy link
Member

@kanata2 kanata2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@kanata2 kanata2 merged commit a735199 into slack-go:master Dec 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants