mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Auth: Fix visibility of the Invite button on /admin/users page (#68991)
* Fix for invite button visibility * Align test
This commit is contained in:
@@ -65,9 +65,9 @@ describe('Render', () => {
|
||||
expect(screen.getByRole('link', { name: 'someUrl' })).toHaveAttribute('href', 'some/url');
|
||||
});
|
||||
|
||||
it('should not show invite button when disableLoginForm is set', () => {
|
||||
const originalDisableLoginForm = config.disableLoginForm;
|
||||
config.disableLoginForm = true;
|
||||
it('should not show invite button when externalUserMngInfo is set', () => {
|
||||
const originalExternalUserMngInfo = config.externalUserMngInfo;
|
||||
config.externalUserMngInfo = 'truthy';
|
||||
|
||||
setup({
|
||||
canInvite: true,
|
||||
@@ -75,6 +75,6 @@ describe('Render', () => {
|
||||
|
||||
expect(screen.queryByRole('link', { name: 'Invite' })).not.toBeInTheDocument();
|
||||
// Reset the disableLoginForm mock to its original value
|
||||
config.disableLoginForm = originalDisableLoginForm;
|
||||
config.externalUserMngInfo = originalExternalUserMngInfo;
|
||||
});
|
||||
});
|
||||
|
||||
@@ -49,8 +49,8 @@ export const UsersActionBarUnconnected = ({
|
||||
{ label: `Pending Invites (${pendingInvitesCount})`, value: 'invites' },
|
||||
];
|
||||
const canAddToOrg: boolean = contextSrv.hasAccess(AccessControlAction.OrgUsersAdd, canInvite);
|
||||
// backend rejects invitations if the login form is disabled
|
||||
const showInviteButton: boolean = canAddToOrg && !config.disableLoginForm;
|
||||
// Hide Invite button in case users are managed externally
|
||||
const showInviteButton: boolean = canAddToOrg && !config.externalUserMngInfo;
|
||||
|
||||
return (
|
||||
<div className="page-action-bar" data-testid="users-action-bar">
|
||||
|
||||
Reference in New Issue
Block a user