Skip to content
Snippets Groups Projects
Select Git revision
  • 2406eda5663463ed65c6f1398cfb23020e4e11de
  • annotation-on-video default protected
  • demo_ci
  • 3-upstream-01022023
  • master
  • gh3538-captions
  • 16-adapt-for-images-annot
  • 15-api-for-annotations-on-video
  • 15-annotations-on-videos
  • video_for_annotations
  • wip-1-annotations-on-videos
  • 9-videoviewer-tests
  • 9_wip_videotests
  • 6-fix-tests-and-ci
  • _fix_ci
  • wip-webpack-from-git
16 results

AnnotationSettings.js

Blame
  • AnnotationSettings.js 1.32 KiB
    import { compose } from 'redux';
    import { connect } from 'react-redux';
    import { withTranslation } from 'react-i18next';
    import * as actions from '../state/actions';
    import { withPlugins } from '../extend/withPlugins';
    import {
      getAnnotationResourcesByMotivation,
      getWindow,
    } from '../state/selectors';
    import { AnnotationSettings } from '../components/AnnotationSettings';
    
    /**
     * Mapping redux state to component props using connect
     */
    const mapStateToProps = (state, { windowId }) => ({
      autoScroll: getWindow(state, { windowId }).autoScrollAnnotationList,
      autoScrollDisabled: getAnnotationResourcesByMotivation(state, { windowId }).length < 2,
      displayAll: getWindow(state, { windowId }).highlightAllAnnotations,
      displayAllDisabled: getAnnotationResourcesByMotivation(
        state,
        { windowId },
      ).length < 2,
    });
    
    /**
     * Mapping redux action dispatches to component props using connect
     */
    const mapDispatchToProps = (dispatch, { windowId }) => ({
      toggleAnnotationAutoScroll: () => {
        dispatch(actions.toggleAnnotationAutoScroll(windowId));
      },
      toggleAnnotationDisplay: () => {
        dispatch(actions.toggleAnnotationDisplay(windowId));
      },
    });
    
    const enhance = compose(
      withTranslation(),
      connect(mapStateToProps, mapDispatchToProps),
      withPlugins('AnnotationSettings'),
    );
    
    export default enhance(AnnotationSettings);