SearchControl.tsx 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. import DeleteSelectedPageGroup from './DeleteSelectedPageGroup';
  6. import { CheckboxType } from '../../interfaces/search';
  7. type Props = {
  8. searchingKeyword: string,
  9. appContainer: AppContainer,
  10. onSearchInvoked: (data : any[]) => boolean,
  11. onExcludeUsersHome?: () => void,
  12. onExcludeTrash?: () => void,
  13. }
  14. const SearchControl: FC <Props> = (props: Props) => {
  15. // Temporaly workaround for lint error
  16. // later needs to be fixed: SearchControl to typescript componet
  17. const SearchPageFormTypeAny : any = SearchPageForm;
  18. const { t } = useTranslation('');
  19. const onExcludeUsersHome = () => {
  20. if (props.onExcludeUsersHome != null) {
  21. props.onExcludeUsersHome();
  22. }
  23. };
  24. const onExcludeTrash = () => {
  25. if (props.onExcludeTrash != null) {
  26. props.onExcludeTrash();
  27. }
  28. };
  29. const onDeleteSelectedPageHandler = () => {
  30. console.log('onDeleteSelectedPageHandler is called');
  31. // TODO: implement this function to delete selected pages.
  32. // https://estoc.weseek.co.jp/redmine/issues/77525
  33. };
  34. const onCheckAllPagesInvoked = (nextCheckboxState:CheckboxType) => {
  35. console.log(`onCheckAllPagesInvoked is called with arg ${nextCheckboxState}`);
  36. // Todo: set the checkboxState, isChecked, and indeterminate value of checkbox element according to the passed argument
  37. // https://estoc.weseek.co.jp/redmine/issues/77525
  38. // setting checkbox to indeterminate is required to use of useRef to access checkbox element.
  39. // ref: https://getbootstrap.com/docs/4.5/components/forms/#checkboxes
  40. };
  41. return (
  42. <>
  43. <div className="search-page-nav d-flex py-3 align-items-center">
  44. <div className="flex-grow-1 mx-4">
  45. <SearchPageFormTypeAny
  46. keyword={props.searchingKeyword}
  47. appContainer={props.appContainer}
  48. onSearchFormChanged={props.onSearchInvoked}
  49. />
  50. </div>
  51. <div className="mr-4">
  52. {/* TODO: replace the following button */}
  53. <button type="button">related pages</button>
  54. </div>
  55. </div>
  56. {/* TODO: replace the following elements deleteAll button , relevance button and include specificPath button component */}
  57. <div className="d-flex align-items-center py-3 border-bottom border-gray">
  58. <div className="d-flex mr-auto ml-3">
  59. {/* Todo: design will be fixed in #80324. Function will be implemented in #77525 */}
  60. <DeleteSelectedPageGroup
  61. checkboxState={'' || CheckboxType.NONE_CHECKED} // Todo: change the left value to appropriate value
  62. onClickInvoked={onDeleteSelectedPageHandler}
  63. onCheckInvoked={onCheckAllPagesInvoked}
  64. />
  65. </div>
  66. <div className="d-flex align-items-center mr-3">
  67. <div className="border border-gray mr-3">
  68. <label className="px-3 py-2 mb-0 d-flex align-items-center" htmlFor="flexCheckDefault">
  69. <input
  70. className="mr-2"
  71. type="checkbox"
  72. id="flexCheckDefault"
  73. onClick={() => onExcludeUsersHome()}
  74. />
  75. {t('Include Subordinated Target Page', { target: '/user' })}
  76. </label>
  77. </div>
  78. <div className="border border-gray">
  79. <label className="px-3 py-2 mb-0 d-flex align-items-center" htmlFor="flexCheckChecked">
  80. <input
  81. className="mr-2"
  82. type="checkbox"
  83. id="flexCheckChecked"
  84. onClick={() => onExcludeTrash()}
  85. />
  86. {t('Include Subordinated Target Page', { target: '/trash' })}
  87. </label>
  88. </div>
  89. </div>
  90. </div>
  91. </>
  92. );
  93. };
  94. export default SearchControl;