SearchControl.tsx 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import React, { FC } from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import SearchPageForm from './SearchPageForm';
  4. import AppContainer from '../../client/services/AppContainer';
  5. type Props = {
  6. searchingKeyword: string,
  7. appContainer: AppContainer,
  8. onSearchInvoked: (data : any[]) => boolean,
  9. onExcludeUsersHome?: () => void,
  10. onExcludeTrash?: () => void,
  11. }
  12. const SearchControl: FC <Props> = (props: Props) => {
  13. // Temporaly workaround for lint error
  14. // later needs to be fixed: SearchControl to typescript componet
  15. const SearchPageFormTypeAny : any = SearchPageForm;
  16. const { t } = useTranslation('');
  17. const onExcludeUsersHome = () => {
  18. if (props.onExcludeUsersHome != null) {
  19. props.onExcludeUsersHome();
  20. }
  21. };
  22. const onExcludeTrash = () => {
  23. if (props.onExcludeTrash != null) {
  24. props.onExcludeTrash();
  25. }
  26. };
  27. return (
  28. <div className="">
  29. <div className="search-page-input sps sps--abv">
  30. <SearchPageFormTypeAny
  31. keyword={props.searchingKeyword}
  32. appContainer={props.appContainer}
  33. onSearchFormChanged={props.onSearchInvoked}
  34. />
  35. </div>
  36. {/* TODO: replace the following elements deleteAll button , relevance button and include specificPath button component */}
  37. <div className="d-flex my-4">
  38. <div className="d-flex align-items-center border rounded border-gray px-2 py-1 mr-2 ml-auto">
  39. <label className="my-0 mr-2" htmlFor="flexCheckDefault">
  40. {t('Include Subordinated Target Page', { target: '/user' })}
  41. </label>
  42. <input
  43. type="checkbox"
  44. id="flexCheckDefault"
  45. onClick={() => onExcludeUsersHome()}
  46. />
  47. </div>
  48. <div className="d-flex align-items-center border rounded border-gray px-2 mr-3">
  49. <label className="my-0 mr-2" htmlFor="flexCheckChecked">
  50. {t('Include Subordinated Target Page', { target: '/trash' })}
  51. </label>
  52. <input
  53. type="checkbox"
  54. id="flexCheckChecked"
  55. onClick={() => onExcludeTrash()}
  56. />
  57. </div>
  58. </div>
  59. </div>
  60. );
  61. };
  62. export default SearchControl;