-
Notifications
You must be signed in to change notification settings - Fork 144
Calendar: Use isInvalidDate to disallow date selections #1685
Conversation
720bfeb
to
f95fb9f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use master branch of Gutenberg or 7.1.0 of the
components
package.
This is testing well for me with Gutenberg master. However, we don't currently require the Gutenberg plugin itself anymore for using wc-admin
-- so should this hold off until 7.1.0 is released, so we can bump the version in package.json
? Otherwise this change won't work for most.
I also have one optional comment about the date checks, and I do think the 2.0.0
version needs bumped.
packages/components/CHANGELOG.md
Outdated
@@ -1,3 +1,7 @@ | |||
# 1.7.0 (Unreleased) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a breaking change, but we are still on the first version so I think its ok not to bump to
2.0.0
. I'm open to bumping though.
I think we actually do want to release a 2.0.0
. The npm modules are using semver and we've previously published the other versions. We have also already done a 2.0.0
on the navigation package: https://github.com/woocommerce/wc-admin/blob/master/packages/navigation/CHANGELOG.md.
@@ -91,7 +92,7 @@ class DatePickerContent extends Component { | |||
after={ after } | |||
before={ before } | |||
onUpdate={ onUpdate } | |||
invalidDays="future" | |||
isInvalidDate={ dateString => moment().isBefore( moment( dateString ), 'day' ) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional: What would you think about abstracting these one liners out to functions, so the name can make them a bit clearer (i.e. this one would be futureDaysInvalid or something)? I liked that 'future' previously implied that any future days were invalid. Now it takes a second to parse what's going on. This one is also used twice.
Thanks for the review @justinshreve ! Good call on Great suggestion too. I renamed a method |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates. Looks good!
I can add the
blocked
label and we can wait until 7.1.0 of Gutenberg components is released.
Sounds good to me. I think this is ready to go pending the release. One thing to note is I think we have some changes for a 1.7.0
of @woocommerce/components
in an open PR, so you might have some rebasing to do later.
df62bc9
to
c89f85f
Compare
Noting here that this change (WordPress/gutenberg#12962) is in Gutenberg 5.1, https://make.wordpress.org/core/2019/02/20/whats-new-in-gutenberg-20th-february/ |
The version in package.json is only used for tests, in the built file this is transpiled to In any case, I wanted to release |
c89f85f
to
cea449a
Compare
Thanks for looking into this one @ryelle. I think it should make it in because while the prop this PR makes use of, |
Since the repo was renamed, PRs created before the rename fail like this one is. Since they were passing before I rebased, I'm going to go ahead and merge this one. |
Introduce
isInvalidDate
toDatePicker
andDateRange
now that Gutenberg allows invalid days on the single date picker.In an effort to make the two APIs identical, I removed the
{ invalidDays="future" }
helper prop/function because it just masks functionality by adding complexity. I'd much rather expose the underlying ability to suit everyone's needs.This is a breaking change, but we are still on the first version so I think its ok not to bump to
2.0.0
. I'm open to bumping though.Screenshots
Detailed test instructions:
components
package.