feat: improve UI display depending on user persmissions
This commit is contained in:

committed by
Ali BARIN

parent
017a881494
commit
5d2e9ccc67
@@ -8,6 +8,7 @@ import * as URLS from 'config/urls';
|
||||
import useFormatMessage from 'hooks/useFormatMessage';
|
||||
import { ConnectionPropType } from 'propTypes/propTypes';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import Can from 'components/Can';
|
||||
|
||||
function ContextMenu(props) {
|
||||
const {
|
||||
@@ -44,34 +45,57 @@ function ContextMenu(props) {
|
||||
hideBackdrop={false}
|
||||
anchorEl={anchorEl}
|
||||
>
|
||||
<MenuItem
|
||||
component={Link}
|
||||
to={URLS.APP_FLOWS_FOR_CONNECTION(appKey, connection.id)}
|
||||
onClick={createActionHandler({ type: 'viewFlows' })}
|
||||
>
|
||||
{formatMessage('connection.viewFlows')}
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem onClick={createActionHandler({ type: 'test' })}>
|
||||
{formatMessage('connection.testConnection')}
|
||||
</MenuItem>
|
||||
|
||||
<MenuItem
|
||||
component={Link}
|
||||
disabled={disableReconnection}
|
||||
to={URLS.APP_RECONNECT_CONNECTION(
|
||||
appKey,
|
||||
connection.id,
|
||||
connection.appAuthClientId,
|
||||
<Can I="read" a="Flow" passThrough>
|
||||
{(allowed) => (
|
||||
<MenuItem
|
||||
component={Link}
|
||||
to={URLS.APP_FLOWS_FOR_CONNECTION(appKey, connection.id)}
|
||||
onClick={createActionHandler({ type: 'viewFlows' })}
|
||||
disabled={!allowed}
|
||||
>
|
||||
{formatMessage('connection.viewFlows')}
|
||||
</MenuItem>
|
||||
)}
|
||||
onClick={createActionHandler({ type: 'reconnect' })}
|
||||
>
|
||||
{formatMessage('connection.reconnect')}
|
||||
</MenuItem>
|
||||
</Can>
|
||||
|
||||
<MenuItem onClick={createActionHandler({ type: 'delete' })}>
|
||||
{formatMessage('connection.delete')}
|
||||
</MenuItem>
|
||||
<Can I="update" a="Connection" passThrough>
|
||||
{(allowed) => (
|
||||
<MenuItem
|
||||
onClick={createActionHandler({ type: 'test' })}
|
||||
disabled={!allowed}
|
||||
>
|
||||
{formatMessage('connection.testConnection')}
|
||||
</MenuItem>
|
||||
)}
|
||||
</Can>
|
||||
|
||||
<Can I="create" a="Connection" passThrough>
|
||||
{(allowed) => (
|
||||
<MenuItem
|
||||
component={Link}
|
||||
disabled={!allowed || disableReconnection}
|
||||
to={URLS.APP_RECONNECT_CONNECTION(
|
||||
appKey,
|
||||
connection.id,
|
||||
connection.appAuthClientId,
|
||||
)}
|
||||
onClick={createActionHandler({ type: 'reconnect' })}
|
||||
>
|
||||
{formatMessage('connection.reconnect')}
|
||||
</MenuItem>
|
||||
)}
|
||||
</Can>
|
||||
|
||||
<Can I="delete" a="Connection" passThrough>
|
||||
{(allowed) => (
|
||||
<MenuItem
|
||||
onClick={createActionHandler({ type: 'delete' })}
|
||||
disabled={!allowed}
|
||||
>
|
||||
{formatMessage('connection.delete')}
|
||||
</MenuItem>
|
||||
)}
|
||||
</Can>
|
||||
</Menu>
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user