Skip to content

added search and filter components#52

Open
DeRaowl wants to merge 8 commits intodevelopfrom
feat/searchBar
Open

added search and filter components#52
DeRaowl wants to merge 8 commits intodevelopfrom
feat/searchBar

Conversation

@DeRaowl
Copy link

@DeRaowl DeRaowl commented Jul 16, 2022

Description

image

Fixes #32

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Manual testing
  • Test B // TODO

Test Configuration:

  • Firmware version:
  • Hardware:
  • Toolchain:
  • SDK:

Checklist:

  • My code follows the style guidelines of this project
  • [X ] I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Copy link
Contributor

@Neha Neha left a comment

Choose a reason for hiding this comment

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

WIP review...

ui/src/App.js Outdated
import Dashboard from './Components/Dashboard/Dashboard';
import Filters from './Components/Filters/Filters';
import Search from './Components/Search/Search';
import { useFilterContext } from './Context/filter_context';
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming convention of the filter_context is not as per the pattern of the project. Please use the Pascal case

Copy link
Author

@DeRaowl DeRaowl Jul 18, 2022

Choose a reason for hiding this comment

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

Renamed filter_context to FilterContext

@@ -0,0 +1,60 @@
import { createContext, useContext, useEffect, useReducer } from 'react';
import { FEATURE_FLAGS, FEATURE_FLAGS_HEADERS } from '../Mock/featureFlags';
import { filterReducer } from '../reducers/filter_reducer';
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming convention of the filter_reducers and reducers is not as per the pattern of the project. Please use the Pascal case

Copy link
Author

Choose a reason for hiding this comment

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

Converted file name to Pascal case

CLEAR_FILTER,
LOADING,
FILTER_LIST,
} from '../actions/actions';
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming convention of the action folder is not as per the pattern of the project. Please use the Pascal case

Copy link
Author

Choose a reason for hiding this comment

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

Converted filename to pascal case

name='userInput'
value={userInput}
onChange={handleInputChange}
placeholder='Search issues by Name, Createdby, Repository...'
Copy link
Contributor

Choose a reason for hiding this comment

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

This should come from the constant file

Copy link
Author

Choose a reason for hiding this comment

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

Added CONST file for placeholder

@@ -0,0 +1,47 @@
import { useState, useCallback } from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

We are not using useState, and useCallback in the component. Please remove it

Copy link
Author

Choose a reason for hiding this comment

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

Removed unused imports


export default function Filters() {
const {
filterByEnabled,
Copy link
Contributor

Choose a reason for hiding this comment

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

filterByEnabled is not getting used in this component please remove it.

Copy link
Author

Choose a reason for hiding this comment

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

Removed unused code

name='status'
onChange={handleValueChange}
>
<option value='all'>Both</option>
Copy link
Contributor

Choose a reason for hiding this comment

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

Should move to the constant

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason it is not looking like dropdown
image

Copy link
Author

Choose a reason for hiding this comment

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

image

Added dropdown

Copy link
Contributor

Choose a reason for hiding this comment

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

@DeRaowl Ik the search feature is already implemented, What do you think about having these filters right below the headers? Like the one react-table offers. Just a thought, Let me know what you think?

CC: @Neha

import Filters from './Components/Filters/Filters';
import Search from './Components/Search/Search';
import { useFilterContext } from './Context/filter_context';
import { FEATURE_FLAGS, FEATURE_FLAGS_HEADERS } from './Mock/featureFlags';
Copy link
Contributor

Choose a reason for hiding this comment

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

Not getting used in the component. Please remove

ui/src/App.js Outdated

if (isLoading) {
// We can add spinner here - TODO
return <div>Loading...</div>;
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not accessible content. We should :

  1. Use text tag eg: heading, P, span
  2. We might need to put the focus of the tab on loading text later (it will be decided how our screen is coming). For now, just do point 1

Copy link
Author

Choose a reason for hiding this comment

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

Used span tag instead of div

@@ -0,0 +1,5 @@
export const UPDATE_FILTERS = 'UPDATE_FILTERS';
Copy link
Contributor

Choose a reason for hiding this comment

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

The naming convention of this file should be filters.action.js

Copy link
Author

Choose a reason for hiding this comment

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

renamed file as per suggestion

name='status'
onChange={handleValueChange}
>
<option value='all'>Both</option>
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason it is not looking like dropdown
image

/>
<main className='flex flex-col items-center'>
<section className='flex justify-center items-center '>
<Search />
Copy link
Contributor

Choose a reason for hiding this comment

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

The UI is a bit off. Please add the spacing around the search and filter.

Button should be in the same row as of search and filters

image

Copy link
Author

Choose a reason for hiding this comment

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

image

dispatch({ type: UPDATE_FILTERS, payload: { name, value } });
}

function clearFilter() {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are we removing only 1 filter at a time? If no, then the name should be clearFilters

Copy link
Author

Choose a reason for hiding this comment

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

renamed as per suggestion

}
if (status !== 'all') {
tempList = tempList.filter((value) => String(value.enabled) === status);
console.log(tempList, 'status', status);
Copy link
Contributor

Choose a reason for hiding this comment

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

Avoid having console.log

Copy link
Author

Choose a reason for hiding this comment

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

removed

placeholder-opacity-25
'
name='userInput'
value={userInput}
Copy link
Contributor

Choose a reason for hiding this comment

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

please rename it to a self-explanatory name such as: searchValue or userSearchInput

Copy link
Author

Choose a reason for hiding this comment

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

renamed as per suggestion

updateFilters,
} = useFilterContext();

const handleValueChange = (event) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

the name should be consistent with the rest of the event handlers. Instead of handleValueChange use onValueChange or something more align to the event happening.

Copy link
Author

Choose a reason for hiding this comment

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

renamed as per suggestion

ease-in-out
m-0
focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none'
aria-label='.form-select-sm example'
Copy link
Contributor

Choose a reason for hiding this comment

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

aria-label is not correct here. Aria-label should be the label content

Copy link
Author

Choose a reason for hiding this comment

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

aria-label been removed as we are not using label.

m-0
focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none'
aria-label='.form-select-sm example'
value={status}
Copy link
Contributor

Choose a reason for hiding this comment

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

The status is not implying the use/information about what information it would be holding. Please rename it

focus:text-gray-700 focus:bg-white focus:border-blue-600 focus:outline-none'
aria-label='.form-select-sm example'
value={status}
name='status'
Copy link
Contributor

Choose a reason for hiding this comment

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

The status is not implying the use/information about what information it would be holding. Please rename it

Copy link
Author

Choose a reason for hiding this comment

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

renamed to featureStatus as per suggestion

ui/src/App.js Outdated
<Search />
<Filters />
</section>
<button
Copy link
Contributor

Choose a reason for hiding this comment

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

button should be wrapped within the section of Filters and Search

Copy link
Author

Choose a reason for hiding this comment

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

button moved inside section

};

return (
<div className='mb-2 xl:w-96'>
Copy link
Contributor

Choose a reason for hiding this comment

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

use section tag instead of div for:

  1. consistency
  2. we use section for the section partition

Copy link
Author

Choose a reason for hiding this comment

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

renamed as per suggestion

ui/src/App.js Outdated
import { FEATURE_FLAGS, FEATURE_FLAGS_HEADERS } from './Mock/featureFlags';

function App() {
const { filteredList, isLoading, featureFlagHeader, clearFilter } =
Copy link
Contributor

Choose a reason for hiding this comment

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

Should isLoading be a part of FilterContext?

Copy link
Author

Choose a reason for hiding this comment

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

It should be part of context where we are calling API

@Neha Neha mentioned this pull request Jul 18, 2022
Copy link
Author

@DeRaowl DeRaowl left a comment

Choose a reason for hiding this comment

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

Addressed all the review comments

/>
<main className='flex flex-col items-center'>
<section className='flex justify-center items-center '>
<Search />
Copy link
Author

Choose a reason for hiding this comment

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

image

name='status'
onChange={handleValueChange}
>
<option value='all'>Both</option>
Copy link
Author

Choose a reason for hiding this comment

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

image

Added dropdown

Comment on lines +36 to +44
value.createdBy
.toLowerCase()
.includes(userSearchInput.toLowerCase()) ||
value.featureFlag
.toLowerCase()
.includes(userSearchInput.toLowerCase()) ||
value.repository
.toLowerCase()
.includes(userSearchInput.toLowerCase())

Choose a reason for hiding this comment

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

Is it good to create a function for the same?

Choose a reason for hiding this comment

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

Is it better to be present in util file? A function which could be used for search

.includes(userSearchInput.toLowerCase())
);
}
if (featureStatus !== 'all') {

Choose a reason for hiding this comment

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

Should 'all' be added to constants?

@harshith-venkatesh
Copy link

Good PR @DeRaowl , well written context, reducer

name='featureStatus'
onChange={onValueChange}
>
{FEATURE_STATUS.map((status, idx) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

What is idx here?

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.

[UI] Search & filter

5 participants