-
Notifications
You must be signed in to change notification settings - Fork 6
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
Upgrade dropzone to v2.11.0 #225
Conversation
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.
Great job with this @tomnez, thanks for tackling it! I think we can remove a couple of unnecessary new files (empty-wrapper
and create-unique-id-factory
) to clean things up a bit, other than that just a couple of questions really 👍
@@ -20,4 +20,6 @@ export default Component.extend({ | |||
* @default: null | |||
*/ | |||
text: null, | |||
|
|||
'data-test-caption': true, |
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.
What do you think of passing data-test-caption=true
to the instance of this where you need it, instead of adding this to all instances via the class definition?
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.
agree this is not necessary, but nice to have, ex: a component doesn't have this and another one that uses it is being tested...you can't really add to the instance
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.
Not sure I follow your example @vladucu but I don't feel particularly strongly about this either way
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.
I'd prefer to keep it here, the selectors get removed in a non dev/test environment so I think it's fine to have all instances have these attrs. It would save time in test writing knowing that you can always grab [data-test-<whatever>]
rather than have to go see if the template already has the attr or not.
@@ -4,6 +4,7 @@ import { or } from '@ember/object/computed'; | |||
import { classify } from '@ember/string'; | |||
import { throttle, scheduleOnce } from '@ember/runloop'; | |||
import { isNone, isPresent } from '@ember/utils'; | |||
import { createUniqueIDFactory } from '../utils/create-unique-id-factory'; |
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.
We've eschewed this in the past in favour of using Ember's unique IDs via guidFor(this)
, is there any reason not to continue that path here?
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.
We can swap for guideFor
, I was just following the React version.
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.
Yeah I know, just that so far we've avoided doing that and I'd like to keep our addon self-consistent. We can always look at switching all of the guidFor
s across to follow the React implementation at a later stage if we feel it's valuable 👍
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.
yeah, I think this is not really a problem, but more an advantage that we use Ember 😉
* @public | ||
* @property id | ||
*/ | ||
id: null, |
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.
Not 100% sure how Ember handles passing id=<whatever>
into a component, but from a faint memory I think it might use that as the id
of that component's element, which will cause problems if we then try using that same ID on another element. With that in mind, we might be safer renaming this to something like inputId
(as I think we've done for a bunch of other form-related components) and documenting the difference from the React interface in the component's markdown file.
You could also default this to a CP that returns guidFor(this)
, which I think we've also done elsewhere, if that cleans up logic later on.
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.
I think it should be fine setting the id
as long as it's unique (we don't re-use it in this component on multiple components - which I don't think we do)
setting a default seems to be done in getDerivedStateFromProps()
, but agree we have guidFor
instead of createUniqueIDFactory
@@ -477,31 +539,40 @@ export default Component.extend(ContextBoundEventListenersMixin, { | |||
return; | |||
} | |||
|
|||
let dropzoneContainer = this.element.querySelector('.Polaris-DropZone'); |
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.
Since we're using this in a couple of places, how do you feel about making a dropzoneContainer
CP?
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.
I think we're setting this as this.node
(in setupNode()
) before this runs, so we should just use that everywhere else?
export function createUniqueIDFactory(prefix) { | ||
let index = 1; | ||
return () => `${prefix}${index++}`; | ||
} |
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.
Can possibly remove this file because of my other comment about using guidFor
@@ -20,4 +20,6 @@ export default Component.extend({ | |||
* @default: null | |||
*/ | |||
text: null, | |||
|
|||
'data-test-caption': true, |
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.
agree this is not necessary, but nice to have, ex: a component doesn't have this and another one that uses it is being tested...you can't really add to the instance
@@ -477,31 +539,40 @@ export default Component.extend(ContextBoundEventListenersMixin, { | |||
return; | |||
} | |||
|
|||
let dropzoneContainer = this.element.querySelector('.Polaris-DropZone'); |
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.
I think we're setting this as this.node
(in setupNode()
) before this runs, so we should just use that everywhere else?
{{#polaris-visually-hidden}} | ||
<input | ||
data-test-drop-zone-hidden-input | ||
id={{concat elementId "-input"}} |
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.
I think we've missed updating here to use the id
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.
also, in JS, we'll want to tweak fileInputNode
CP?
* @public | ||
* @property id | ||
*/ | ||
id: null, |
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.
I think it should be fine setting the id
as long as it's unique (we don't re-use it in this component on multiple components - which I don't think we do)
setting a default seems to be done in getDerivedStateFromProps()
, but agree we have guidFor
instead of createUniqueIDFactory
label="my label" | ||
labelAction=(hash | ||
text="my label action" | ||
onAction=labelAction |
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.
onAction=(action labelAction)
assert | ||
.dom(dropZoneLabelWrapperSelector) | ||
.exists('A labelled component is wrapped around the dropzone'); | ||
assert.notOk( |
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.
no harm here, though this is unnecessary....this is basically testing polaris-labelled
component not firing the action on render....likely just that it fires on click should be enough
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.
Yeah I was just being super cautious about getting a false positive or anything. I'll remove it, this whole action test is likely not necessary since it should be covered in the labelled tests, but I'll at least keep the second assertion.
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.
sounds good to me!
Updated. Notes from the updates:
|
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.
I think this looks good now @tomnez! 👍
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.
some conflicts, but 🚀
0d7aec3
to
ff9dc05
Compare
Diff here
Finishes #223