Skip to content
Snippets Groups Projects
Select Git revision
  • 965ac3c4d2c669b70c8663f809ca14eaa48dfb4b
  • 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

ProjectControllerTest.php

Blame
  • CanvasAnnotations.js 2.17 KiB
    import { compose } from 'redux';
    import { connect } from 'react-redux';
    import { withTranslation } from 'react-i18next';
    import { withStyles } from '@material-ui/core/styles';
    import { withPlugins } from '../extend/withPlugins';
    import * as actions from '../state/actions';
    import {
      getAnnotationResourcesByMotivationForCanvas,
      getCanvasLabel,
      getSelectedAnnotationIds,
      getWindow,
    } from '../state/selectors';
    import { CanvasAnnotations } from '../components/CanvasAnnotations';
    
    /**
     * @param {Array} resources
     * @return {Array} [{ id: 'abc123', content: 'Annotation Content' }, ...]
     */
    function getIdAndContentOfResources(resources) {
      return resources.map((resource, i) => ({
        content: resource.chars,
        id: resource.id,
        targetId: resource.targetId,
      }));
    }
    
    /** For connect */
    const mapStateToProps = (state, { canvasId, windowId }) => ({
      allAnnotationsAreHighlighted: getWindow(state, { windowId }).displayAllAnnotations,
      annotations: getIdAndContentOfResources(
        getAnnotationResourcesByMotivationForCanvas(
          state, { canvasId, motivations: state.config.annotations.filteredMotivations, windowId },
        ),
      ),
      htmlSanitizationRuleSet: state.config.annotations.htmlSanitizationRuleSet,
      label: getCanvasLabel(state, {
        canvasId,
        windowId,
      }),
      selectedAnnotationIds: getSelectedAnnotationIds(state, { windowId }),
    });
    
    /**
     * mapDispatchToProps - to hook up connect
     * @memberof WindowSideBarAnnotationsPanel
     * @private
     */
    const mapDispatchToProps = {
      deselectAnnotation: actions.deselectAnnotation,
      highlightAnnotation: actions.highlightAnnotation,
      selectAnnotation: actions.selectAnnotation,
    };
    
    /** For withStlyes */
    const styles = theme => ({
      annotationListItem: {
        '&:hover': {
          backgroundColor: theme.palette.action.hover,
        },
        borderBottom: `0.5px solid ${theme.palette.divider}`,
        cursor: 'pointer',
      },
      sectionHeading: {
        paddingLeft: theme.spacing(2),
        paddingRight: theme.spacing(1),
        paddingTop: theme.spacing(2),
      },
    });
    
    const enhance = compose(
      withTranslation(),
      withStyles(styles),
      connect(mapStateToProps, mapDispatchToProps),
      withPlugins('CanvasAnnotations'),
    );
    
    export default enhance(CanvasAnnotations);