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

View tree search filter #720

Merged
merged 6 commits into from
Oct 7, 2017

Conversation

kamikaz1k
Copy link
Contributor

When dealing with a complicated view tree, it can be cumbersome scrolling through all the views trying to identify the one that is of interest.

To help make finding it easier I added an input field to filter the list that is visible in the scroll view.
It naively looks for the substring to be present in the name of the view to determine a match.
The filter also works with the components included in the view tree.

Demo:
view-tree-filter

Refs Issue #677

Looking for feedback around contribution guidelines, and if this solution fits the pattern being used in the application. Otherwise also accepting suggestions for improving the implementation.

Copy link
Contributor

@teddyzeenny teddyzeenny left a comment

Choose a reason for hiding this comment

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

Thanks a lot for working on this! Looks great, just left a few comments. Very useful feature! 🕺

@@ -12,6 +12,19 @@ export default Controller.extend({
components: false
},

searchText: "",
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use single quotes.
We're also trying to document any new code so that we slowly migrate to a more documented code base.

  /**
   * Bound to the search field to filter the component list.
   * 
   * @property searchText
   * @type {String}
   * @default ''
   */

@@ -12,6 +12,19 @@ export default Controller.extend({
components: false
},

searchText: "",

filteredList: computed('model', 'searchText', function() {
Copy link
Contributor

Choose a reason for hiding this comment

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

computed('model.[]', 'searchText'

  /**
   * The filtered view list.
   * 
   * @property filteredList
   * @type {Array<Object>}
   */

return this.get('model');
}

let filtered = this.get('model').filter(v => v.value.name.includes(searchText));
Copy link
Contributor

Choose a reason for hiding this comment

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

Please use search-match just so we're consistent in our query matching. If we later improve our matching it would improve everywhere. You can also just return it directly.

let treeNodes = findAll('.js-view-tree-item');
assert.equal(treeNodes.length, 3, 'expected some tree nodes');

fillIn('.js-filter-views input', 'post');
Copy link
Contributor

Choose a reason for hiding this comment

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

await

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 didn't realize we had to use await for async helpers because I thought the test framework automatically took care of making it all synchronous. I read the docs again, and is it that the awareness comes from preceding async tasks, rather than ensuring downstream logic is synchronous? (I hope I said that clearly...)

In other words:

asyncFunction();
// Async helper is aware of the above async behaviour and will wait
fillIn();
// But it doesn't make sure the stuff below gets executed in a synchronous way
some = synchronousLogic(); 

So to fix it, I would have to use either await or andThen?

await fillIn();
// or
andThen(() => { some = synchronousLogic() });

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes precisely, you got it. await is used to avoid using andThen down the line.

let viewClassNames = [];
let durations = [];

function textFor(selector, context) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you move this function outside the tests callbacks so we can reuse the same one to avoid duplication?

@kamikaz1k
Copy link
Contributor Author

Thanks for being so quick to provide feedback :)
I made the changes requested to address them.

@teddyzeenny teddyzeenny merged commit 46f2606 into emberjs:master Oct 7, 2017
cyril-sf pushed a commit to cyril-sf/ember-inspector that referenced this pull request Mar 30, 2022
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

2 participants