Skip to content

Commit

Permalink
Wrap users management link with privileges check
Browse files Browse the repository at this point in the history
  • Loading branch information
Kerry350 committed Feb 11, 2021
1 parent 9f38e3a commit 82c6e61
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ import { EuiButton, EuiButtonProps } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n/react';
import React from 'react';
import { useLinkProps } from '../../../hooks/use_link_props';
import { useKibanaContextForPlugin } from '../../../hooks/use_kibana';

export const UserManagementLink: React.FunctionComponent<EuiButtonProps> = (props) => {
const {
services: {
application: { capabilities },
},
} = useKibanaContextForPlugin();
const canAccessUserManagement = capabilities?.management?.security?.users;

const linkProps = useLinkProps({
app: 'management',
pathname: '/security/users',
});

if (!canAccessUserManagement) return null;

return (
<EuiButton color="primary" fill {...linkProps} {...props}>
<FormattedMessage
Expand Down

0 comments on commit 82c6e61

Please sign in to comment.