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.

SearchableFilterFooter.tsx 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * SonarQube
  3. * Copyright (C) 2009-2019 SonarSource SA
  4. * mailto:info AT sonarsource DOT com
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 3 of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public License
  17. * along with this program; if not, write to the Free Software Foundation,
  18. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  19. */
  20. import * as React from 'react';
  21. import { translate } from 'sonar-ui-common/helpers/l10n';
  22. import Select from 'sonar-ui-common/components/controls/Select';
  23. interface Props {
  24. isFavorite?: boolean;
  25. isLoading?: boolean;
  26. onInputChange?: (query: string) => void;
  27. onOpen?: () => void;
  28. onQueryChange: (change: T.RawQuery) => void;
  29. options: Array<{ label: string; value: string }>;
  30. organization?: { key: string };
  31. property: string;
  32. query: T.Dict<any>;
  33. }
  34. export default class SearchableFilterFooter extends React.PureComponent<Props> {
  35. handleOptionChange = ({ value }: { value: string }) => {
  36. const urlOptions = (this.props.query[this.props.property] || []).concat(value).join(',');
  37. this.props.onQueryChange({ [this.props.property]: urlOptions });
  38. };
  39. render() {
  40. return (
  41. <div className="search-navigator-facet-footer projects-facet-footer">
  42. <Select
  43. className="input-super-large"
  44. clearable={false}
  45. isLoading={this.props.isLoading}
  46. onChange={this.handleOptionChange}
  47. onInputChange={this.props.onInputChange}
  48. onOpen={this.props.onOpen}
  49. options={this.props.options}
  50. placeholder={translate('search_verb')}
  51. searchable={true}
  52. />
  53. </div>
  54. );
  55. }
  56. }