Skip to content

Commit

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

* Wrap users management link with privileges check

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
  • Loading branch information
Kerry350 and kibanamachine authored Feb 16, 2021
1 parent 1bfdc14 commit 0c44f5f
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 0c44f5f

Please sign in to comment.