Skip to content
Snippets Groups Projects
Select Git revision
  • fe65c33f6b6783226297ac225e440c81721e6e0f
  • main default
  • 35-cgu
  • 34-peertube-support
  • 27-add-autoplay-to-iframe
  • 33-bug-on-youtube-embed-urls
  • RC-Rekall-v1.1-fix_lpo
  • tuleap-140-go-back-to-my-capsules-page-when-i-m-on-capsule-preview-page
  • RC-Rekall-v1.2-fix10
  • RC-Rekall-v1.2-fix9
  • RC-Rekall-v1.2-fix8
  • RC-Rekall-v1.2-fix7
  • RC-Rekall-v1.2-fix6
  • RC-Rekall-v1.2-fix5
  • RC-Rekall-v1.2-fix4
  • RC-Rekall-v1.2-fix3
  • RC-Rekall-v1.2-fix2
  • RC-Rekall-v1.2-fix1
  • RC-Rekall-v1.1-fix-3
  • RC-Rekall-v1.1-fix-2
  • RC-Rekall-v1.1-fix-1
  • RC-Rekall-v1.1-delivered
  • preprod20220209-1535
23 results

CapsuleEditorController.php

Blame
  • SearchResults.js 1.73 KiB
    import React, { Component } from 'react';
    import PropTypes from 'prop-types';
    import Button from '@material-ui/core/Button';
    import List from '@material-ui/core/List';
    import BackIcon from '@material-ui/icons/ArrowBackSharp';
    import SearchHit from '../containers/SearchHit';
    
    /** */
    export class SearchResults extends Component {
      /** */
      constructor(props) {
        super(props);
    
        this.state = { focused: false };
    
        this.toggleFocus = this.toggleFocus.bind(this);
      }
    
      /** */
      toggleFocus() {
        const {
          focused,
        } = this.state;
    
        this.setState({ focused: !focused });
      }
    
      /** */
      render() {
        const {
          classes,
          searchHits,
          startIndex,
          t,
          windowId,
        } = this.props;
    
        const {
          focused,
        } = this.state;
    
        return (
          <>
            { focused && (
              <Button onClick={this.toggleFocus} className={classes.navigation} size="small">
                <BackIcon />
                {t('backToResults')}
              </Button>
            )}
            <List>
              {
                searchHits.map((hit, index) => (
                  <SearchHit
                    key={hit.annotations[0]}
                    focused={focused}
                    hit={hit}
                    index={startIndex + index}
                    windowId={windowId}
                    showDetails={this.toggleFocus}
                  />
                ))
              }
            </List>
          </>
        );
      }
    }
    
    SearchResults.propTypes = {
      classes: PropTypes.objectOf(PropTypes.string),
      searchHits: PropTypes.arrayOf(PropTypes.object).isRequired,
      startIndex: PropTypes.number,
      t: PropTypes.func,
      windowId: PropTypes.string.isRequired, // eslint-disable-line react/no-unused-prop-types
    };
    
    SearchResults.defaultProps = {
      classes: {},
      startIndex: 0,
      t: k => k,
    };