import React from 'react'; import { useIntl } from 'react-intl'; import { GridItem, H3, Text, Stack } from '@strapi/parts'; import { get, isEmpty, takeRight, toLower, without } from 'lodash'; import { useUsersPermissions } from '../../contexts/UsersPermissionsContext'; import BoundRoute from '../BoundRoute'; const Policies = () => { const { formatMessage } = useIntl(); const { selectedAction, routes } = useUsersPermissions(); const path = without(selectedAction.split('.'), 'controllers'); const controllerRoutes = get(routes, path[0]); const displayedRoutes = isEmpty(controllerRoutes) ? [] : controllerRoutes.filter(o => toLower(o.handler) === toLower(takeRight(path, 2).join('.'))); return ( {selectedAction ? ( {displayedRoutes.map((route, key) => ( // eslint-disable-next-line react/no-array-index-key ))} ) : (

{formatMessage({ id: 'users-permissions.Policies.header.title', defaultMessage: 'Advanced settings', })}

{formatMessage({ id: 'users-permissions.Policies.header.hint', defaultMessage: "Select the application's actions or the plugin's actions and click on the cog icon to display the bound route", })}
)}
); }; export default Policies;