-
Notifications
You must be signed in to change notification settings - Fork 286
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
Support tracked and other improvements #1035
Changes from all commits
feaab82
fb8f7a3
178a2b6
e242dc7
ae32f42
0dbedc7
69b8107
08c31ec
5e1ce0c
57ff01f
3f5300a
b533e96
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,55 @@ | ||
import Component from '@ember/component'; | ||
import { sort } from '@ember/object/computed'; | ||
import { sort, map } from '@ember/object/computed'; | ||
import { set, computed } from '@ember/object'; | ||
import { A } from '@ember/array'; | ||
|
||
export default Component.extend({ | ||
tagName: '', | ||
|
||
isArray: computed('properties', function () { | ||
const props = A(this.get('properties') || []); | ||
return props.findBy('name', 'length') && props.findBy('name', 0); | ||
}), | ||
|
||
/** | ||
* Sort the properties by name to make them easier to find in the object inspector. | ||
* Sort the properties by name and group them by property type to make them easier to find in the object inspector. | ||
* | ||
* @property sortedProperties | ||
* @type {Array<Object>} | ||
*/ | ||
sortedProperties: sort('properties', 'sortProperties'), | ||
sortedProperties: sort('props', 'sortProperties'), | ||
|
||
init() { | ||
this._super(...arguments); | ||
props: map('properties', function (p) { | ||
set(p, 'isFunction', p.value.type === 'type-function'); | ||
if (p.name == parseInt(p.name)) { | ||
set(p, 'name', parseInt(p.name)); | ||
} | ||
return p; | ||
}), | ||
|
||
/** | ||
* Used by the `sort` computed macro. | ||
* | ||
* @property sortProperties | ||
* @type {Array<String>} | ||
*/ | ||
this.sortProperties = ['name']; | ||
}, | ||
/** | ||
* Used by the `sort` computed macro. | ||
* | ||
* @property sortProperties | ||
* @type {Array<String>} | ||
*/ | ||
sortProperties: computed('isArray', function () { | ||
const order = [ | ||
'isFunction', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm curious, how did you decide the ordering for sorting? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mmm, a mix between how it looks like (most times) in the code and whats useful:
So, final order is: the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the order should be:
That mimics the recommended ordering from eslint-plugin-ember of the order we should define things in our component JS files. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mmm, i think this is what I had initially too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think maybe we should follow eslint-plugin-emebr, but you make a good point, so perhaps for arrays we could have a special case that changes the order? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think special casing arrays would be fine, this could also be done in a followup though. I agree that properties and tracked fields should likely be grouped together, the eslint rule seems to make the most sense. I'd say let's do that to get this merged, then followup to improve the story for arrays specifically. |
||
'isService:desc', | ||
'isProperty:desc', | ||
'isTracked:desc', | ||
'isComputed:desc', | ||
'isGetter:desc', | ||
'name' | ||
]; | ||
// change order for arrays, if the array doesnt have items, then the order does not need to be changed | ||
if (this.get('isArray')) { | ||
const i = order.indexOf('isProperty:desc'); | ||
order.splice(i, 1); | ||
order.splice(order.length - 1, 0, 'isProperty:desc'); | ||
} | ||
return order; | ||
}) | ||
}); | ||
|
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.
Does this not need to be
model.value.isComputed
?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.
model.isComputed now indicates this is is a
Ember.computed
property. And instead it will usemodel.value.isCalculated
to check if it was calculated.Somehow I feel the value.computed was used for both
is Ember.computed
and isCalculatedhttps://github.com/emberjs/ember-inspector/pull/1035/files/96efd0d7e7e98103fcd44e6a696b238d57d6e3df#diff-7c2c7ea1dfc0ef384d1ec6e685711d15L455