import React from 'react'; import { useIntl } from 'react-intl'; import { Typography, Flex, GridItem } from '@strapi/design-system'; import get from 'lodash/get'; import isEmpty from 'lodash/isEmpty'; import without from 'lodash/without'; 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 pathResolved = path.slice(1).join('.'); const displayedRoutes = isEmpty(controllerRoutes) ? [] : controllerRoutes.filter((o) => o.handler.endsWith(pathResolved)); 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;