Skip to content

Commit

Permalink
[Logs UI] Check for privileges with user management links (elastic#91134
Browse files Browse the repository at this point in the history
)

* Wrap users management link with privileges check
  • Loading branch information
Kerry350 committed Feb 16, 2021
1 parent 01e8287 commit 846e5b5
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 ?? false;

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 846e5b5

Please sign in to comment.