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

WindowTopMenu.js

Blame
  • user avatar
    Jack Reed authored and GitHub committed
    67b1d04c
    History
    WindowTopMenu.js 2.25 KiB
    import React, { Component } from 'react';
    import Menu from '@material-ui/core//Menu';
    import ListSubheader from '@material-ui/core/ListSubheader';
    import PropTypes from 'prop-types';
    import WindowThumbnailSettings from '../containers/WindowThumbnailSettings';
    import WindowViewSettings from '../containers/WindowViewSettings';
    import { PluginHook } from './PluginHook';
    import ns from '../config/css-ns';
    
    /** Renders plugins */
    function PluginHookWithHeader(props) {
      const { PluginComponents, t } = props; // eslint-disable-line react/prop-types
      return PluginComponents ? (
        <>
          <ListSubheader role="presentation" disableSticky tabIndex="-1">{t('windowPluginButtons')}</ListSubheader>
          <PluginHook {...props} />
        </>
      ) : null;
    }
    
    /**
     */
    export class WindowTopMenu extends Component {
      /**
       * render
       * @return
       */
      render() {
        const {
          containerId, handleClose, anchorEl, showThumbnailNavigationSettings,
          toggleDraggingEnabled, windowId,
        } = this.props;
    
        return (
          <Menu
            id={`window-menu_${windowId}`}
            container={document.querySelector(`#${containerId} .${ns('viewer')}`)}
            anchorEl={anchorEl}
            anchorOrigin={{
              horizontal: 'right',
              vertical: 'bottom',
            }}
            transformOrigin={{
              horizontal: 'right',
              vertical: 'top',
            }}
            getContentAnchorEl={null}
            open={Boolean(anchorEl)}
            onClose={handleClose}
            onEntering={toggleDraggingEnabled}
            onExit={toggleDraggingEnabled}
            orientation="horizontal"
          >
            <WindowViewSettings windowId={windowId} handleClose={handleClose} />
            {showThumbnailNavigationSettings
              && <WindowThumbnailSettings windowId={windowId} handleClose={handleClose} />}
            <PluginHookWithHeader {...this.props} />
          </Menu>
        );
      }
    }
    
    WindowTopMenu.propTypes = {
      anchorEl: PropTypes.object, // eslint-disable-line react/forbid-prop-types
      containerId: PropTypes.string.isRequired,
      handleClose: PropTypes.func.isRequired,
      showThumbnailNavigationSettings: PropTypes.bool,
      toggleDraggingEnabled: PropTypes.func.isRequired,
      windowId: PropTypes.string.isRequired,
    };
    
    WindowTopMenu.defaultProps = {
      anchorEl: null,
      showThumbnailNavigationSettings: true,
    };