The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Rocket.Chat/client/components/FilterByText.tsx

59 lines
1.7 KiB

import { Box, Icon, TextInput, Button } from '@rocket.chat/fuselage';
import React, { FC, ChangeEvent, FormEvent, memo, useCallback, useEffect, useState } from 'react';
import { useTranslation } from '../contexts/TranslationContext';
type FilterByTextProps = {
placeholder?: string;
onChange: (filter: { text: string }) => void;
inputRef?: () => void;
};
type FilterByTextPropsWithButton = FilterByTextProps & {
displayButton: true;
textButton: string;
onButtonClick: () => void;
};
[NEW] App empty states component, category filter and empty states error variation implementations (#23818) * WIP * wip state control * Styled the categories list * Finished proposal * fix width * Fragment key * feat: :sparkles: Finish tags list component I've Created a new hook(useTagList) and a new component(TagList) to implement the chip list based on the selected filter categories list. * WIP * Fix review * Fix Review * TS Conversion * More conversions * Finished TS migration * Prevent rendering loop * Cleaning tree for merging * Eslint * Implement rout changing on button click * Eslint * improved useFilteredApps * typecheck * refactor: :truck: Change the name of the empty search components and add translation functions I've changed the name of the Fallback component to States so that it matches fuselage and have implemented the translation functions in the component texts together with their respective entries in the i18n dictionary. * Fix build * [IMPROVE] Feat Apps Category Filter (#23704) * Solving conflicts * WIP: Implemented initial category filtering logic * eslint * Finished implementing the filtering logic * Implementing final form of filtering logic * Refactor Tag list logic * fix review [2] * fix: :bug: Fixing outsideClick error and eslint Fixed an error where clicking on the category filter anchor button when the filter was open caused it to blink instead of just closing and also solved some eslint errors * Stylelint * Fix review [3] * Installing @next version of fuselage * eslint Co-authored-by: rique223 <henrique.jobs1@gmail.com> * Create refetch function for apps provider * Create and expose refetch function appsProvider * WIP * Fix review * Review * WIP: solve category filter error * Eslint * Update fuselage icons * Category only filtering and chips bug solving * . * fix lint * . fix lint * fix: :bug: Fix marketplace and installed apps requests We solved the bug where both installed and marketplace would show an error even though only the marketplace apps request failed. Also refactored some code so that it works better with our solution. Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> * Consuming categories endpoint instead of fixed obj * Eslint * Refactoring thens * Resolving change requests * Removing commented code Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com> Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com>
4 years ago
const isFilterByTextPropsWithButton = (props: any): props is FilterByTextPropsWithButton =>
'displayButton' in props && props.displayButton === true;
[NEW] App empty states component, category filter and empty states error variation implementations (#23818) * WIP * wip state control * Styled the categories list * Finished proposal * fix width * Fragment key * feat: :sparkles: Finish tags list component I've Created a new hook(useTagList) and a new component(TagList) to implement the chip list based on the selected filter categories list. * WIP * Fix review * Fix Review * TS Conversion * More conversions * Finished TS migration * Prevent rendering loop * Cleaning tree for merging * Eslint * Implement rout changing on button click * Eslint * improved useFilteredApps * typecheck * refactor: :truck: Change the name of the empty search components and add translation functions I've changed the name of the Fallback component to States so that it matches fuselage and have implemented the translation functions in the component texts together with their respective entries in the i18n dictionary. * Fix build * [IMPROVE] Feat Apps Category Filter (#23704) * Solving conflicts * WIP: Implemented initial category filtering logic * eslint * Finished implementing the filtering logic * Implementing final form of filtering logic * Refactor Tag list logic * fix review [2] * fix: :bug: Fixing outsideClick error and eslint Fixed an error where clicking on the category filter anchor button when the filter was open caused it to blink instead of just closing and also solved some eslint errors * Stylelint * Fix review [3] * Installing @next version of fuselage * eslint Co-authored-by: rique223 <henrique.jobs1@gmail.com> * Create refetch function for apps provider * Create and expose refetch function appsProvider * WIP * Fix review * Review * WIP: solve category filter error * Eslint * Update fuselage icons * Category only filtering and chips bug solving * . * fix lint * . fix lint * fix: :bug: Fix marketplace and installed apps requests We solved the bug where both installed and marketplace would show an error even though only the marketplace apps request failed. Also refactored some code so that it works better with our solution. Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> * Consuming categories endpoint instead of fixed obj * Eslint * Refactoring thens * Resolving change requests * Removing commented code Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com> Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com>
4 years ago
const FilterByText: FC<FilterByTextProps> = ({ placeholder, onChange: setFilter, inputRef, children, ...props }) => {
const t = useTranslation();
const [text, setText] = useState('');
const handleInputChange = useCallback((event: ChangeEvent<HTMLInputElement>) => {
setText(event.currentTarget.value);
}, []);
useEffect(() => {
setFilter({ text });
}, [setFilter, text]);
const handleFormSubmit = useCallback((event: FormEvent<HTMLFormElement>) => {
event.preventDefault();
}, []);
return (
<Box mb='x16' is='form' onSubmit={handleFormSubmit} display='flex' flexDirection='row' {...props}>
<TextInput
placeholder={placeholder ?? t('Search')}
ref={inputRef}
addon={<Icon name='magnifier' size='x20' />}
onChange={handleInputChange}
value={text}
/>
[NEW] App empty states component, category filter and empty states error variation implementations (#23818) * WIP * wip state control * Styled the categories list * Finished proposal * fix width * Fragment key * feat: :sparkles: Finish tags list component I've Created a new hook(useTagList) and a new component(TagList) to implement the chip list based on the selected filter categories list. * WIP * Fix review * Fix Review * TS Conversion * More conversions * Finished TS migration * Prevent rendering loop * Cleaning tree for merging * Eslint * Implement rout changing on button click * Eslint * improved useFilteredApps * typecheck * refactor: :truck: Change the name of the empty search components and add translation functions I've changed the name of the Fallback component to States so that it matches fuselage and have implemented the translation functions in the component texts together with their respective entries in the i18n dictionary. * Fix build * [IMPROVE] Feat Apps Category Filter (#23704) * Solving conflicts * WIP: Implemented initial category filtering logic * eslint * Finished implementing the filtering logic * Implementing final form of filtering logic * Refactor Tag list logic * fix review [2] * fix: :bug: Fixing outsideClick error and eslint Fixed an error where clicking on the category filter anchor button when the filter was open caused it to blink instead of just closing and also solved some eslint errors * Stylelint * Fix review [3] * Installing @next version of fuselage * eslint Co-authored-by: rique223 <henrique.jobs1@gmail.com> * Create refetch function for apps provider * Create and expose refetch function appsProvider * WIP * Fix review * Review * WIP: solve category filter error * Eslint * Update fuselage icons * Category only filtering and chips bug solving * . * fix lint * . fix lint * fix: :bug: Fix marketplace and installed apps requests We solved the bug where both installed and marketplace would show an error even though only the marketplace apps request failed. Also refactored some code so that it works better with our solution. Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> * Consuming categories endpoint instead of fixed obj * Eslint * Refactoring thens * Resolving change requests * Removing commented code Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com> Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com>
4 years ago
{isFilterByTextPropsWithButton(props) ? (
<Button onClick={props.onButtonClick} mis='x8' primary>
{props.textButton}
</Button>
[NEW] App empty states component, category filter and empty states error variation implementations (#23818) * WIP * wip state control * Styled the categories list * Finished proposal * fix width * Fragment key * feat: :sparkles: Finish tags list component I've Created a new hook(useTagList) and a new component(TagList) to implement the chip list based on the selected filter categories list. * WIP * Fix review * Fix Review * TS Conversion * More conversions * Finished TS migration * Prevent rendering loop * Cleaning tree for merging * Eslint * Implement rout changing on button click * Eslint * improved useFilteredApps * typecheck * refactor: :truck: Change the name of the empty search components and add translation functions I've changed the name of the Fallback component to States so that it matches fuselage and have implemented the translation functions in the component texts together with their respective entries in the i18n dictionary. * Fix build * [IMPROVE] Feat Apps Category Filter (#23704) * Solving conflicts * WIP: Implemented initial category filtering logic * eslint * Finished implementing the filtering logic * Implementing final form of filtering logic * Refactor Tag list logic * fix review [2] * fix: :bug: Fixing outsideClick error and eslint Fixed an error where clicking on the category filter anchor button when the filter was open caused it to blink instead of just closing and also solved some eslint errors * Stylelint * Fix review [3] * Installing @next version of fuselage * eslint Co-authored-by: rique223 <henrique.jobs1@gmail.com> * Create refetch function for apps provider * Create and expose refetch function appsProvider * WIP * Fix review * Review * WIP: solve category filter error * Eslint * Update fuselage icons * Category only filtering and chips bug solving * . * fix lint * . fix lint * fix: :bug: Fix marketplace and installed apps requests We solved the bug where both installed and marketplace would show an error even though only the marketplace apps request failed. Also refactored some code so that it works better with our solution. Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> * Consuming categories endpoint instead of fixed obj * Eslint * Refactoring thens * Resolving change requests * Removing commented code Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com> Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com>
4 years ago
) : (
children && <Box mis='x8'>{children} </Box>
)}
</Box>
);
};
[NEW] App empty states component, category filter and empty states error variation implementations (#23818) * WIP * wip state control * Styled the categories list * Finished proposal * fix width * Fragment key * feat: :sparkles: Finish tags list component I've Created a new hook(useTagList) and a new component(TagList) to implement the chip list based on the selected filter categories list. * WIP * Fix review * Fix Review * TS Conversion * More conversions * Finished TS migration * Prevent rendering loop * Cleaning tree for merging * Eslint * Implement rout changing on button click * Eslint * improved useFilteredApps * typecheck * refactor: :truck: Change the name of the empty search components and add translation functions I've changed the name of the Fallback component to States so that it matches fuselage and have implemented the translation functions in the component texts together with their respective entries in the i18n dictionary. * Fix build * [IMPROVE] Feat Apps Category Filter (#23704) * Solving conflicts * WIP: Implemented initial category filtering logic * eslint * Finished implementing the filtering logic * Implementing final form of filtering logic * Refactor Tag list logic * fix review [2] * fix: :bug: Fixing outsideClick error and eslint Fixed an error where clicking on the category filter anchor button when the filter was open caused it to blink instead of just closing and also solved some eslint errors * Stylelint * Fix review [3] * Installing @next version of fuselage * eslint Co-authored-by: rique223 <henrique.jobs1@gmail.com> * Create refetch function for apps provider * Create and expose refetch function appsProvider * WIP * Fix review * Review * WIP: solve category filter error * Eslint * Update fuselage icons * Category only filtering and chips bug solving * . * fix lint * . fix lint * fix: :bug: Fix marketplace and installed apps requests We solved the bug where both installed and marketplace would show an error even though only the marketplace apps request failed. Also refactored some code so that it works better with our solution. Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> * Consuming categories endpoint instead of fixed obj * Eslint * Refactoring thens * Resolving change requests * Removing commented code Co-authored-by: Guilherme Gazzo <guilhermegazzo@gmail.com> Co-authored-by: gabriellsh <40830821+gabriellsh@users.noreply.github.com> Co-authored-by: Aaron Ogle <geekgonecrazy@users.noreply.github.com>
4 years ago
export default memo<FC<FilterByTextProps>>(FilterByText);