refactor(web): remove typescript
This commit is contained in:
@@ -1,29 +1,10 @@
|
||||
import * as React from 'react';
|
||||
import { Link } from 'react-router-dom';
|
||||
import Menu from '@mui/material/Menu';
|
||||
import type { PopoverProps } from '@mui/material/Popover';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
import type { IConnection } from 'types';
|
||||
|
||||
import * as URLS from 'config/urls';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
|
||||
type Action = {
|
||||
type: 'test' | 'reconnect' | 'delete' | 'viewFlows';
|
||||
};
|
||||
|
||||
type ContextMenuProps = {
|
||||
appKey: string;
|
||||
connection: IConnection;
|
||||
onClose: () => void;
|
||||
onMenuItemClick: (event: React.MouseEvent, action: Action) => void;
|
||||
anchorEl: PopoverProps['anchorEl'];
|
||||
disableReconnection: boolean;
|
||||
};
|
||||
|
||||
export default function ContextMenu(
|
||||
props: ContextMenuProps
|
||||
): React.ReactElement {
|
||||
export default function ContextMenu(props) {
|
||||
const {
|
||||
appKey,
|
||||
connection,
|
||||
@@ -33,18 +14,15 @@ export default function ContextMenu(
|
||||
disableReconnection,
|
||||
} = props;
|
||||
const formatMessage = useFormatMessage();
|
||||
|
||||
const createActionHandler = React.useCallback(
|
||||
(action: Action) => {
|
||||
return function clickHandler(event: React.MouseEvent) {
|
||||
(action) => {
|
||||
return function clickHandler(event) {
|
||||
onMenuItemClick(event, action);
|
||||
|
||||
onClose();
|
||||
};
|
||||
},
|
||||
[onMenuItemClick, onClose]
|
||||
[onMenuItemClick, onClose],
|
||||
);
|
||||
|
||||
return (
|
||||
<Menu
|
||||
open={true}
|
||||
@@ -70,7 +48,7 @@ export default function ContextMenu(
|
||||
to={URLS.APP_RECONNECT_CONNECTION(
|
||||
appKey,
|
||||
connection.id,
|
||||
connection.appAuthClientId
|
||||
connection.appAuthClientId,
|
||||
)}
|
||||
onClick={createActionHandler({ type: 'reconnect' })}
|
||||
>
|
Reference in New Issue
Block a user