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

Agenda quick filters pills #609

Merged
merged 7 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export interface IProps {

saveMyTopic?: (params: ISearchParams) => void;
deselectMyTopic?: (topicId: ITopic['_id']) => void;
clearQuickFilter: (filter: string) => void;

}

export function SearchResultTagsList({
Expand All @@ -58,6 +60,7 @@ export function SearchResultTagsList({
deselectMyTopic,
resetFilter,
refresh,
clearQuickFilter,
}: IProps) {
return (
<ul
Expand Down Expand Up @@ -93,6 +96,7 @@ export function SearchResultTagsList({
readonly={readonly}
/>
<SearchResultsFiltersRow
clearQuickFilter={clearQuickFilter}
searchParams={searchParams}
filterGroups={filterGroups}
toggleFilter={toggleFilter}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {Tag} from 'components/Tag';

import {IProps as IParentProps} from './SearchResultTagsList';
import {setItemTypeFilter} from 'agenda/actions';
import {clearQuickFilter} from 'search/actions';
import {searchFilterSelector} from 'search/selectors';
import {connect} from 'react-redux';
import {agendaCoverageStatusFilter, getActiveFilterLabel} from 'agenda/components/AgendaCoverageExistsFilter';
Expand All @@ -20,7 +19,7 @@ type IProps = Pick<IParentProps,
'toggleFilter' |
'setCreatedFilter' |
'resetFilter'
>;
> & {clearQuickFilter: (filter: string) => void;};

type IActiveFilter = {
calendar?: any;
Expand All @@ -38,9 +37,7 @@ interface IReduxStateProps {
}

interface IReduxDispatchProps {
clearQuickFilter: (filter: string) => void;
clearItemTypeFilter: () => void;
clearAllQuickFilters: () => void;
}

type IPropsAgendaExtended = IReduxDispatchProps & IReduxStateProps & IProps;
Expand All @@ -55,9 +52,17 @@ function SearchResultsFiltersRow({
itemTypeFilter,
clearItemTypeFilter,
activeFilter,
clearQuickFilter,
}: IPropsAgendaExtended) {
const tags = [];

/**
* FIXME: This is a bad implementation, but the proper fix would be too time consuming at this moment.
* Ideally we would want to unify the searchParameters so they are stored in the same variable both from
* agenda and wire. Another solution would be to not reuse the same component in wire and agenda filters
* so that wire has its own filter component and agenda has a separate one. The first solution is the better
* one since from a UI stand point the filters component is identical and should be reused ideally.
*/
if (IS_AGENDA) {
if (itemTypeFilter != null) {
tags.push(
Expand Down Expand Up @@ -203,6 +208,7 @@ function SearchResultsFiltersRow({
onClick={(event) => {
event.preventDefault();
resetFilter();
clearItemTypeFilter?.();
}}
>
{gettext('Clear filters')}
Expand All @@ -225,12 +231,7 @@ const mapStateToProps = (state: any) => ({
});

const mapDispatchToProps = (dispatch: any) => ({
clearQuickFilter: (filter: string) => dispatch(clearQuickFilter(filter)),
clearItemTypeFilter: () => dispatch(setItemTypeFilter(null)),
Copy link
Member

Choose a reason for hiding this comment

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

move this one too

clearAllQuickFilters: () => {
dispatch(setItemTypeFilter(null));
dispatch(clearQuickFilter());
}
});

let component: React.ComponentType<IProps> = SearchResultsFiltersRow as React.ComponentType<IProps>;
Expand Down
3 changes: 3 additions & 0 deletions assets/search/components/SearchResultsBar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
clearAdvancedSearchParams,
resetFilter,
deselectMyTopic,
clearQuickFilter,
} from '../../actions';

import {Dropdown} from './../../../components/Dropdown';
Expand Down Expand Up @@ -196,6 +197,7 @@ class SearchResultsBarComponent extends React.Component<any, any> {
)}
{!isTagSectionShown ? null : (
<SearchResultTagsList
clearQuickFilter={this.props.clearQuickFilter}
refresh={this.props.refresh}
user={this.props.user}
showSaveTopic={this.props.showSaveTopic}
Expand Down Expand Up @@ -299,6 +301,7 @@ const mapDispatchToProps = {
clearAdvancedSearchParams,
deselectMyTopic,
resetFilter,
clearQuickFilter,
};

export const SearchResultsBar: React.ComponentType<any> = connect(mapStateToProps, mapDispatchToProps)(SearchResultsBarComponent);
Loading