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

Category UI state #316

Merged
merged 5 commits into from
Nov 15, 2021
Merged

Category UI state #316

merged 5 commits into from
Nov 15, 2021

Conversation

codemonkey800
Copy link
Collaborator

@codemonkey800 codemonkey800 commented Nov 9, 2021

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

  "category": {
    "Supported data": [
      "2D", 
      "3D"
    ], 
    "Workflow step": [
      "Image Segmentation", 
      "Image annotation"
    ]
  }, 
  "category_hierarchy": {
    "Supported data": [
      [
        "2D"
      ], 
      [
        "3D"
      ]
    ], 
    "Workflow step": [
      [
        "Image Segmentation", 
        "Manual segmentation"
      ], 
      [
        "Image annotation", 
        "Dense image annotation", 
        "Manual segmentation"
      ], 
      [
        "Image Segmentation", 
        "Semi-automatic segmentation"
      ]
    ]
  }, 

@shortcut-integration
Copy link

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

Choose a reason for hiding this comment

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

Very nice test case!

frontend/src/store/search/filters.test.ts Outdated Show resolved Hide resolved
frontend/src/store/search/filters.test.ts Outdated Show resolved Hide resolved
frontend/src/store/search/form.store.ts Outdated Show resolved Hide resolved
frontend/src/types.ts Show resolved Hide resolved
* @param index The plugin index.
*/
export function initCategoryFilters(index: PluginIndexData[]): void {
for (const plugin of index) {
Copy link
Contributor

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!

Copy link
Collaborator Author

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:

  1. We need to iterate the entire list of N plugins.
  2. We need to iterate up to M categories.
  3. 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

@codemonkey800 codemonkey800 requested a review from klai95 November 15, 2021 19:22
Copy link
Contributor

@klai95 klai95 left a comment

Choose a reason for hiding this comment

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

Nicely done!

@codemonkey800 codemonkey800 merged commit f8a4022 into main Nov 15, 2021
@codemonkey800 codemonkey800 deleted the jeremy/sc-172043/category-ui-state branch November 15, 2021 21:49
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.

2 participants