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

Feature/772 search #802

Merged
merged 37 commits into from
Apr 22, 2020
Merged

Feature/772 search #802

merged 37 commits into from
Apr 22, 2020

Conversation

kelvin-muchiri
Copy link
Contributor

@kelvin-muchiri kelvin-muchiri commented Apr 15, 2020

Closes #772

Added a reusable search form that is used for search. The search is done by calling Array.filter on the list received from props and is accompanied by a delayed search (debounce) of 1s to make sure the filtering is not done too frequently. The search filter is currently by name/title only

Implement search by plan title by filtering case triggered plans and routine plans that match
the search parameter
Delay search to make sure the filter is not applied to frequently
@coveralls
Copy link

coveralls commented Apr 15, 2020

Coverage Status

Coverage increased (+0.4%) to 77.161% when pulling 5bc3d78 on feature/772_search into 3b9f08d on master.

@moshthepitt
Copy link
Contributor

Question: why not do this using a reselect selector at the store level? It should be possible to make that re-useable as well, right?

I'm leaning towards that because:

  1. What you are doing here (i.e. computing/deriving data from state) is traditionally what selectors are used for in Redux-land
  2. Using reselect may have performance benefits

Let me know what you think.

@kelvin-muchiri
Copy link
Contributor Author

@moshthepitt Let me look into the libabry never worked with it before. It may be of help

src/containers/pages/FocusInvestigation/active/index.tsx Outdated Show resolved Hide resolved
src/containers/pages/FocusInvestigation/active/index.tsx Outdated Show resolved Hide resolved
src/containers/pages/FocusInvestigation/active/index.tsx Outdated Show resolved Hide resolved
src/containers/pages/FocusInvestigation/active/index.tsx Outdated Show resolved Hide resolved
src/helpers/hooks.tsx Outdated Show resolved Hide resolved
src/containers/pages/FocusInvestigation/active/index.tsx Outdated Show resolved Hide resolved
@kelvin-muchiri
Copy link
Contributor Author

@moshthepitt I was able to use reselect for src/containers/pages/FocusInvestigation/active/index.tsx. For the other components, the enhancement to use reselect might not meet this PR.

@kelvin-muchiri
Copy link
Contributor Author

kelvin-muchiri commented Apr 17, 2020

@moshthepitt Shouldn't this part use selectors?

@moshthepitt
Copy link
Contributor

@moshthepitt Shouldn't this part use selectors?

@kelvin-muchiri that's correct. The context is that reselect is being added slowly. Whatever needs https://github.com/onaio/reveal-frontend/blob/master/src/store/ducks/plans.ts#L294 can probably be refactored to use https://github.com/onaio/reveal-frontend/blob/master/src/store/ducks/plans.ts#L523.

Copy link
Contributor

@moshthepitt moshthepitt left a comment

Choose a reason for hiding this comment

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

Nice work so far @kelvin-muchiri

export interface SearchFormProps {
history: History;
location: Location;
placeholder?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this not optional? It seems we already have a desired default, which can be supplied to this component via defaultProps. Parse, don't validate.

Copy link
Contributor

Choose a reason for hiding this comment

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

@kelvin-muchiri can we make this not optional? i.e. remove the ?

src/components/forms/Search/index.tsx Outdated Show resolved Hide resolved
src/containers/pages/FocusInvestigation/active/index.tsx Outdated Show resolved Hide resolved
src/containers/pages/FocusInvestigation/active/index.tsx Outdated Show resolved Hide resolved
src/containers/pages/FocusInvestigation/active/index.tsx Outdated Show resolved Hide resolved
src/containers/pages/IRS/plans/index.tsx Show resolved Hide resolved
src/containers/pages/IRS/plans/index.tsx Outdated Show resolved Hide resolved
Copy link
Contributor

@cKellyDesign cKellyDesign left a comment

Choose a reason for hiding this comment

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

@kelvin-muchiri great work man, this looks good to me once the last few comments from @p-netm and @moshthepitt are addressed (and tickets are generated!)

@kelvin-muchiri
Copy link
Contributor Author

kelvin-muchiri commented Apr 22, 2020

can we please create an issue to address this? ^^

@moshthepitt What issue is this?

@moshthepitt
Copy link
Contributor

@moshthepitt What issue is this?

@kelvin-muchiri the fact that when we get an empty list of plans we will continue showing a Loading indicator


/**
* Get query params from URL
* @param {Location} location location object from props
Copy link
Contributor

Choose a reason for hiding this comment

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

Seems this is repeated location location

Copy link
Contributor

Choose a reason for hiding this comment

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

}

/** plansArrayBaseSelector select an array of all plans
* @param state - the redux store
*/
export const plansArrayBaseSelector = (planKey?: string) => (state: Registry): Plan[] =>
export const plansArrayBaseSelector = (planKey?: string) => (state: Partial<Store>): Plan[] =>
Copy link
Contributor

Choose a reason for hiding this comment

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

@kelvin-muchiri what led to use changing from Registry to Partial<Store> in this file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@moshthepitt state from mapStateToProps is not of type Registry and will raise lint warning if passed as an argument. Or which is the best way to solve this?

Copy link
Collaborator

@peterMuriuki peterMuriuki left a comment

Choose a reason for hiding this comment

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

@kelvin-muchiri kelvin-muchiri merged commit 89e8ef3 into master Apr 22, 2020
@kelvin-muchiri kelvin-muchiri deleted the feature/772_search branch April 22, 2020 13:45
@Naima-Bashir Naima-Bashir added the QA+ Passed QA label Apr 23, 2020
@Naima-Bashir
Copy link

This has passed QA. Please note that only the following search functionalities have been tested:

  • home> monitor >
  • home > manage plans

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
QA+ Passed QA
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RVL-760 Enable WebUI Search for Plans in Plan and Monitor screens
6 participants