forked from giranm/pd-live-react
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add an indicator with a clear button when there are column filters; i…
…ndicate when no incidents match filters; stop polling when too many incidents
- Loading branch information
1 parent
36e4ed2
commit c35128c
Showing
9 changed files
with
159 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
src/components/QuerySettings/subcomponents/ColumnFilterIndicatorComponent.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { | ||
useMemo, | ||
} from 'react'; | ||
|
||
import { | ||
useSelector, | ||
useDispatch, | ||
} from 'react-redux'; | ||
|
||
import { | ||
useTranslation, | ||
} from 'react-i18next'; | ||
|
||
import { | ||
Flex, | ||
Button, | ||
Tag, | ||
} from '@chakra-ui/react'; | ||
|
||
import { | ||
clearIncidentTableFilters as clearIncidentTableFiltersConnected, | ||
} from 'src/redux/incident_table/actions'; | ||
|
||
const ColumnFilterIndicatorComponent = () => { | ||
const { | ||
t, | ||
} = useTranslation(); | ||
const { | ||
filters, | ||
} = useSelector((state) => state.incidentTable.incidentTableState); | ||
|
||
const dispatch = useDispatch(); | ||
const clearIncidentTableFilters = () => { | ||
dispatch(clearIncidentTableFiltersConnected()); | ||
}; | ||
|
||
const filterCount = useMemo(() => { | ||
if (filters instanceof Array) { | ||
return filters.length; | ||
} | ||
return 0; | ||
}, [filters]); | ||
|
||
return ( | ||
<Flex> | ||
<Tag colorScheme="blue"> | ||
{filterCount} | ||
</Tag> | ||
<Button | ||
size="xs" | ||
ml={1} | ||
colorScheme="red" | ||
aria-label="clear" | ||
onClick={clearIncidentTableFilters} | ||
> | ||
{t('Clear')} | ||
</Button> | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default ColumnFilterIndicatorComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters