Skip to content

Commit

Permalink
Tidy up object inspector (emberjs#1024)
Browse files Browse the repository at this point in the history
* Create DependentKeys component

* Call object-inspector with angle brackets

* ObjectInspector:Errors

* Cleanup some mixin-details property names

* Move grouped props and flat list into separate components

- also move errors in ObjectInspector

* Create ObjectInspector::Accordion

* ObjectInspector::SortedProperties

* Untangle ObjectInspector child components

- namespace children under ObjectInspector
- do not pass parent component down to child
- separate accordion logic
- separate property sorting
- fix calculate for “all” flat properties?

* Attempt to make Code Climate happy

#valueClicked function has a Cognitive Complexity dialed up to 11

* Remove unneeded component classes
  • Loading branch information
nummi authored and patricklx committed Sep 19, 2022
1 parent f212a16 commit b3b0074
Show file tree
Hide file tree
Showing 24 changed files with 382 additions and 364 deletions.
83 changes: 0 additions & 83 deletions app/components/mixin-detail.js

This file was deleted.

41 changes: 0 additions & 41 deletions app/components/mixin-details.js

This file was deleted.

19 changes: 9 additions & 10 deletions app/components/object-inspector.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
import Component from '@ember/component';
import { action, computed, get } from '@ember/object';

export default Component.extend({
tagName: '',

/**
* Application Controller passed
* through the template
*
* @property application
* @type {Controller}
*/
application: null,

propDisplayType: 'grouped',

trail: computed('model.[]', function () {
Expand All @@ -37,7 +29,14 @@ export default Component.extend({

popStack: action(function () {
if (this.isNested) {
this.application.popMixinDetails();
this.popMixinDetails();
}
}),

traceErrors: action(function(objectId) {
this.port.send('objectInspector:traceErrors', {
objectId
});
})
});

15 changes: 15 additions & 0 deletions app/components/object-inspector/accordion.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { action, computed } from '@ember/object';
import Component from '@ember/component';

export default Component.extend({
tagName: '',

isExpanded: computed('mixin.expand', 'mixin.properties.length', function () {
return this.get('mixin.expand') && this.get('mixin.properties.length') > 0;
}),

toggle: action(function () {
this.toggleProperty('mixin.expand');
}),
});

31 changes: 31 additions & 0 deletions app/components/object-inspector/properties-all.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { action, computed } from '@ember/object';
import PropertiesBase from 'ember-inspector/components/object-inspector/properties-base';

const findMixin = function(mixins, property) {
return mixins.find((m) => {
return m.properties.includes(property);
});
};

export default PropertiesBase.extend({
calculate: action(function(property) {
const mixin = findMixin(this.get('model.mixins'), property);

this.port.send('objectInspector:calculate', {
objectId: this.model.objectId,
mixinIndex: this.get('model.mixins').indexOf(mixin),
property: property.name
});
}),

flatPropertyList: computed('model', function () {
const props = this.get('model.mixins').map(function (mixin) {
return mixin.properties.filter(function (p) {
return !p.hasOwnProperty('overridden');
});
});

return props.flat();
}),
});

30 changes: 30 additions & 0 deletions app/components/object-inspector/properties-base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Component from '@ember/component';
import { action } from '@ember/object';

export default Component.extend({
tagName: '',

sendToConsole: action(function ({ name }) {
this.port.send('objectInspector:sendToConsole', {
objectId: this.model.objectId,
property: name
});
}),

digDeeper: action(function({ name }) {
this.port.send('objectInspector:digDeeper', {
objectId: this.model.objectId,
property: name
});
}),

saveProperty: action(function(property, value, dataType) {
this.port.send('objectInspector:saveProperty', {
objectId: this.model.objectId,
property,
value,
dataType
});
}),
});

13 changes: 13 additions & 0 deletions app/components/object-inspector/properties-grouped.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { action } from '@ember/object';
import PropertiesBase from 'ember-inspector/components/object-inspector/properties-base';

export default PropertiesBase.extend({
calculate: action(function({ name }, mixin) {
this.port.send('objectInspector:calculate', {
objectId: this.model.objectId,
mixinIndex: this.get('model.mixins').indexOf(mixin),
property: name
});
}),
});

9 changes: 9 additions & 0 deletions app/components/object-inspector/property-field.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import TextField from '@ember/component/text-field';

export default TextField.extend({
didInsertElement() {
this.element.select();
return this._super(...arguments);
}
});

Loading

0 comments on commit b3b0074

Please sign in to comment.