-
Notifications
You must be signed in to change notification settings - Fork 18
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
Category UI state #316
Category UI state #316
Conversation
This pull request has been linked to Shortcut Story #172043: Category UI State. |
@@ -239,4 +261,115 @@ describe('filterResults()', () => { | |||
expect(filtered).toEqual(getLicenseResults('valid')); | |||
}); | |||
}); | |||
|
|||
describe('filter by workflow step', () => { | |||
const results = getCategoryResults( |
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.
Very nice test case!
* @param index The plugin index. | ||
*/ | ||
export function initCategoryFilters(index: PluginIndexData[]): void { | ||
for (const plugin of 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.
Would the triple for loop become a performance bottleneck? I am not sure if there is a way to get around it, but just wanted to get some clarity on this!
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 feedback! 🤩
It could be if the amount of categories and category keys increase a lot. That would be basically O(NMK)
🤣 I can't think of a better way at the moment since:
- We need to iterate the entire list of
N
plugins. - We need to iterate up to
M
categories. - We need to iterate over all
K
keys so we can populate the form state.
There's no way around this because we need to figure out the entire set of keys possible, and the only way to do that is by looking at every key for every category for every plugin.
I'm not too worried also because our existing category datasets are small, and we are eventually planning to move the search to the backend so that user's don't have to compute this on their devices
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.
Nicely done!
Sets up the UI state necessary for storing category and category hierarchy data from the backend, and reading that data for filtering and rendering.
The TypeScript interfaces for the category data were taken from the
napari-demo
plugin:https://api.staging.napari-hub.org/plugins/napari-demo