mirror of
https://bitbucket.org/wisemapping/wisemapping-frontend.git
synced 2024-11-25 23:54:55 +01:00
Fix dialog action filtering
This commit is contained in:
parent
5f41821f00
commit
d2a4fa0365
@ -11,17 +11,18 @@ import PrintOutlinedIcon from '@material-ui/icons/PrintOutlined';
|
|||||||
import ShareOutlinedIcon from '@material-ui/icons/ShareOutlined';
|
import ShareOutlinedIcon from '@material-ui/icons/ShareOutlined';
|
||||||
import { FormattedMessage } from 'react-intl';
|
import { FormattedMessage } from 'react-intl';
|
||||||
import { LabelOutlined } from '@material-ui/icons';
|
import { LabelOutlined } from '@material-ui/icons';
|
||||||
|
import { fetchMapById } from '../action-dispatcher';
|
||||||
|
|
||||||
export type ActionType = 'open' | 'share' | 'import' | 'delete' | 'info' | 'create' | 'duplicate' | 'export' | 'label' | 'rename' | 'print' | 'info' | 'publish' | 'history' | undefined;
|
export type ActionType = 'open' | 'share' | 'import' | 'delete' | 'info' | 'create' | 'duplicate' | 'export' | 'label' | 'rename' | 'print' | 'info' | 'publish' | 'history' | undefined;
|
||||||
|
|
||||||
interface ActionProps {
|
interface ActionProps {
|
||||||
onClose: (action: ActionType) => void;
|
onClose: (action: ActionType) => void;
|
||||||
anchor: undefined | HTMLElement;
|
anchor?: HTMLElement;
|
||||||
role: 'owner' | 'editor' | 'viewer'
|
mapId?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
const ActionChooser = (props: ActionProps) => {
|
const ActionChooser = (props: ActionProps) => {
|
||||||
const { anchor, onClose, role } = props;
|
const { anchor, onClose, mapId } = props;
|
||||||
|
|
||||||
const handleOnClose = (action: ActionType): ((event: React.MouseEvent<HTMLLIElement>) => void) => {
|
const handleOnClose = (action: ActionType): ((event: React.MouseEvent<HTMLLIElement>) => void) => {
|
||||||
return (event): void => {
|
return (event): void => {
|
||||||
@ -30,8 +31,8 @@ const ActionChooser = (props: ActionProps) => {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const role = mapId ? fetchMapById(mapId)?.map?.role : undefined;
|
||||||
return (
|
return (
|
||||||
|
|
||||||
<Menu
|
<Menu
|
||||||
anchorEl={anchor}
|
anchorEl={anchor}
|
||||||
keepMounted
|
keepMounted
|
||||||
|
@ -319,6 +319,8 @@ export const MapsList = (props: MapsListProps) => {
|
|||||||
const isSelected = (id: number) => selected.indexOf(id) !== -1;
|
const isSelected = (id: number) => selected.indexOf(id) !== -1;
|
||||||
return (
|
return (
|
||||||
<div className={classes.root}>
|
<div className={classes.root}>
|
||||||
|
<ActionChooser anchor={activeRowAction?.el} onClose={handleActionMenuClose} mapId={activeRowAction?.mapId} />
|
||||||
|
|
||||||
<Paper className={classes.paper} elevation={0}>
|
<Paper className={classes.paper} elevation={0}>
|
||||||
<Toolbar className={classes.toolbar} variant="dense">
|
<Toolbar className={classes.toolbar} variant="dense">
|
||||||
|
|
||||||
@ -467,7 +469,6 @@ export const MapsList = (props: MapsListProps) => {
|
|||||||
<MoreHorizIcon color="action" />
|
<MoreHorizIcon color="action" />
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
<ActionChooser anchor={activeRowAction?.el} onClose={handleActionMenuClose} role={row.role} />
|
|
||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
);
|
);
|
||||||
@ -478,7 +479,6 @@ export const MapsList = (props: MapsListProps) => {
|
|||||||
|
|
||||||
</Paper>
|
</Paper>
|
||||||
|
|
||||||
{/* Action Dialog */}
|
|
||||||
<ActionDispatcher action={activeDialog?.actionType} onClose={() => setActiveDialog(undefined)} mapId={activeDialog ? activeDialog.mapId : -1} />
|
<ActionDispatcher action={activeDialog?.actionType} onClose={() => setActiveDialog(undefined)} mapId={activeDialog ? activeDialog.mapId : -1} />
|
||||||
</div >
|
</div >
|
||||||
);
|
);
|
||||||
|
Loading…
Reference in New Issue
Block a user