Skip to content
Snippets Groups Projects
Select Git revision
  • f544fddbb5f724ecc5dd0c96c5ea52cf9e94e25f
  • mui5-annotation-on-video-stable default
  • get_setter_canvasSizeInformations
  • fix-error-div-into-p
  • annotation-on-video-v2
  • detached
  • annotation-on-video-r17
  • mui5
  • mui5-react-18
  • jacob-test
  • annotation-on-video protected
  • master
  • test-antoinev1
  • 20-fetch-thumbnail-on-annotation
  • add-research-field
  • Save
  • add-plugin
  • 14-wip-no-seek-to
  • 14-bug-on-video-time-control
  • 9_wip_videotests
  • _upgrade_material_ui
  • latest-tetras-16
  • v3.3.0
  • v3.2.0
  • v3.1.1
  • v3.1.0
  • v3.0.0
  • v3.0.0-rc.7
  • v3.0.0-rc.6
  • v3.0.0-rc.5
  • v3.0.0-rc.4
  • v3.0.0-rc.3
  • v3.0.0-rc.2
  • v3.0.0-rc.1
  • v3.0.0-beta.10
  • v3.0.0-beta.9
  • v3.0.0-beta.8
  • v3.0.0-beta.7
  • v3.0.0-beta.6
  • v3.0.0-beta.5
  • v3.0.0-beta.3
41 results

WindowSideBar.js

Blame
  • WindowList.js 1.99 KiB
    import React, { Component } from 'react';
    import Button from '@material-ui/core/Button';
    import Menu from '@material-ui/core/Menu';
    import MenuItem from '@material-ui/core/MenuItem';
    import ListSubheader from '@material-ui/core/ListSubheader';
    import PropTypes from 'prop-types';
    
    /**
     */
    class WindowList extends Component {
      /**
       * Get the title for a window from its manifest title
       * @private
       */
      titleContent(window) {
        const { manifests, t } = this.props;
    
        if (window.manifestId
            && manifests[window.manifestId]
            && manifests[window.manifestId].manifestation) {
          return manifests[window.manifestId].manifestation.getLabel().map(label => label.value)[0];
        }
        return t('untitled');
      }
    
      /**
       * render
       * @return
       */
      render() {
        const {
          handleClose, anchorEl, windows, focusWindow, t,
        } = this.props;
        return (
          <Menu id="window-list-menu" anchorEl={anchorEl} open={Boolean(anchorEl)} onClose={handleClose}>
            <ListSubheader>
              <Button color="inherit" aria-label={t('closeMenu')} onClick={handleClose} align="right" style={{ float: 'right' }}>&times;</Button>
              {t('openWindows')}
            </ListSubheader>
            {
              Object.values(windows).map(window => (
                <MenuItem
                  key={window.id}
                  onClick={(e) => { focusWindow(window.id); handleClose(e); }}
                >
                  {
                    this.titleContent(window)
                  }
                </MenuItem>
              ))
            }
          </Menu>
        );
      }
    }
    
    WindowList.propTypes = {
      focusWindow: PropTypes.func.isRequired,
      handleClose: PropTypes.func.isRequired,
      anchorEl: PropTypes.object, // eslint-disable-line react/forbid-prop-types
      windows: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
      manifests: PropTypes.object.isRequired, // eslint-disable-line react/forbid-prop-types
      t: PropTypes.func,
    };
    
    WindowList.defaultProps = {
      anchorEl: null,
      t: key => key,
    };
    
    export default WindowList;