forked from ProjectMirador/mirador
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWindowTopMenu.js
More file actions
66 lines (62 loc) · 2.08 KB
/
WindowTopMenu.js
File metadata and controls
66 lines (62 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import { useContext } from 'react';
import ListSubheader from '@mui/material/ListSubheader';
import Popover from '@mui/material/Popover';
import PropTypes from 'prop-types';
import WindowThumbnailSettings from '../containers/WindowThumbnailSettings';
import WindowViewSettings from '../containers/WindowViewSettings';
import { PluginHook } from './PluginHook';
import WorkspaceContext from '../contexts/WorkspaceContext';
/** 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 function WindowTopMenu({
handleClose, showThumbnailNavigationSettings = true,
toggleDraggingEnabled, windowId, anchorEl = null, open = false,
}) {
const container = useContext(WorkspaceContext);
const pluginProps = arguments[0]; // eslint-disable-line prefer-rest-params
return (
<Popover
container={container?.current}
anchorOrigin={{
horizontal: 'right',
vertical: 'bottom',
}}
transformOrigin={{
horizontal: 'right',
vertical: 'top',
}}
onClose={handleClose}
TransitionProps={{
onEntering: toggleDraggingEnabled,
onExit: toggleDraggingEnabled,
}}
orientation="horizontal"
anchorEl={anchorEl}
open={open}
role="menu"
>
<WindowViewSettings windowId={windowId} handleClose={handleClose} />
{showThumbnailNavigationSettings
&& <WindowThumbnailSettings windowId={windowId} handleClose={handleClose} />}
<PluginHookWithHeader {...pluginProps} />
</Popover>
);
}
WindowTopMenu.propTypes = {
anchorEl: PropTypes.object, // eslint-disable-line react/forbid-prop-types
handleClose: PropTypes.func.isRequired,
open: PropTypes.bool,
showThumbnailNavigationSettings: PropTypes.bool,
toggleDraggingEnabled: PropTypes.func.isRequired,
windowId: PropTypes.string.isRequired,
};