All Downloads are FREE. Search and download functionalities are using the official Maven repository.

web.lib.components.extensions-picker.search-results-info.tsx Maven / Gradle / Ivy

There is a newer version: 37
Show newest version
import React, { SetStateAction } from 'react';
import { clearFilterOrigin, FilterResult } from './extensions-utils';
import classNames from 'classnames';
import { FaCheck } from 'react-icons/fa';
import { Alert, Button } from 'react-bootstrap';
import './search-results-info.scss';
import { DEFAULT_FILTER } from '../api/quarkus-project-utils';
import { useAnalytics } from '../../core/analytics';
import { Plural } from '../../core/components';
import { PlatformIcon } from "./extensions-origin";

export function SearchResultsInfo(props: { filter: string; setFilter: React.Dispatch>, result: FilterResult }) {
  const analytics = useAnalytics();
  const context = { element: 'search-result-info-panel' };
  function clickPlatform() {
    if (props.result.origin !== 'platform') {
      analytics.event('Switch origin', { origin: 'platform', ...context });
      props.setFilter(`origin:platform ${clearFilterOrigin(props.filter)}`);
    } else {
      analytics.event('Switch origin', { origin: '', ...context });
      props.setFilter(`${clearFilterOrigin(props.filter)}`);
    }
  }
  function clickOther() {
    if (props.result.origin !== 'other' ) {
      analytics.event('Switch origin', { origin: 'other', ...context });
      props.setFilter(`origin:other ${clearFilterOrigin(props.filter)}`);
    } else {
      analytics.event('Switch origin', { origin: '', ...context });
      props.setFilter(`${clearFilterOrigin(props.filter)}`);
    }
  }

  const origin = props.result?.origin;
  const originOther =  origin === 'other' ;
  const originPlatform =  origin === 'platform';
  return (
    <>
      {props.result?.filtered && (
        <>
          
{props.result.all.length === 0 && No extensions found } {props.result.all.length > 0 && ( Extensions found by origin: {originPlatform && }{props.result.platform.length} in platform {originOther && }{props.result.other.length} in other )}
{props.result.selected.length === 0 && props.result.other.length > 0 && ( No extensions found in platform. . )} {props.result.selected.length === 0 && props.result.platform.length > 0 && ( No extensions found in other origin. . )} )} ) }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy