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

Upgrade dropzone to v2.11.0 #225

Merged
merged 8 commits into from
Oct 25, 2018
Merged

Upgrade dropzone to v2.11.0 #225

merged 8 commits into from
Oct 25, 2018

Conversation

tomnez
Copy link
Contributor

@tomnez tomnez commented Oct 23, 2018

Diff here

Finishes #223

@tomnez tomnez self-assigned this Oct 23, 2018
Copy link
Member

@andrewpye andrewpye left a 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,
Copy link
Member

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?

Copy link
Member

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

Copy link
Member

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

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'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';
Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@andrewpye andrewpye Oct 25, 2018

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 guidFors across to follow the React implementation at a later stage if we feel it's valuable 👍

Copy link
Member

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,
Copy link
Member

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.

Copy link
Member

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');
Copy link
Member

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?

Copy link
Member

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++}`;
}
Copy link
Member

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,
Copy link
Member

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');
Copy link
Member

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"}}
Copy link
Member

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

Copy link
Member

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,
Copy link
Member

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

addon/components/polaris-drop-zone.js Show resolved Hide resolved
label="my label"
labelAction=(hash
text="my label action"
onAction=labelAction
Copy link
Member

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(
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

sounds good to me!

@tomnez
Copy link
Contributor Author

tomnez commented Oct 24, 2018

Updated. Notes from the updates:

  • Left test-selectors as-is
  • Left id as id, but used guidFor instead of the ID util

Copy link
Member

@andrewpye andrewpye left a 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! 👍

Copy link
Member

@vladucu vladucu left a comment

Choose a reason for hiding this comment

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

some conflicts, but 🚀

@tomnez tomnez merged commit 9320d6d into dev Oct 25, 2018
@delete-merged-branch delete-merged-branch bot deleted the upgrade-v2.11.0-dropzone branch October 25, 2018 19:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants