mirror of
https://github.com/grafana/grafana.git
synced 2025-01-25 15:56:56 -06:00
Auth: Show invite button if disable login form is set to false (#69946)
* show invite button if disable login form is set to false * fix test * Update public/app/features/users/UsersActionBar.tsx Co-authored-by: Misi <mgyongyosi@users.noreply.github.com> --------- Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
This commit is contained in:
parent
14c4c26215
commit
21f8dd9599
@ -65,9 +65,10 @@ describe('Render', () => {
|
||||
expect(screen.getByRole('link', { name: 'someUrl' })).toHaveAttribute('href', 'some/url');
|
||||
});
|
||||
|
||||
it('should not show invite button when externalUserMngInfo is set', () => {
|
||||
it('should not show invite button when externalUserMngInfo is set and disableLoginForm is true', () => {
|
||||
const originalExternalUserMngInfo = config.externalUserMngInfo;
|
||||
config.externalUserMngInfo = 'truthy';
|
||||
config.disableLoginForm = true;
|
||||
|
||||
setup({
|
||||
canInvite: true,
|
||||
@ -77,4 +78,30 @@ describe('Render', () => {
|
||||
// Reset the disableLoginForm mock to its original value
|
||||
config.externalUserMngInfo = originalExternalUserMngInfo;
|
||||
});
|
||||
|
||||
it('should show invite button when externalUserMngInfo is not set and disableLoginForm is true', () => {
|
||||
config.externalUserMngInfo = '';
|
||||
config.disableLoginForm = true;
|
||||
|
||||
setup({
|
||||
canInvite: true,
|
||||
});
|
||||
|
||||
expect(screen.getByRole('link', { name: 'Invite' })).toHaveAttribute('href', 'org/users/invite');
|
||||
// Reset the disableLoginForm mock to its original value
|
||||
config.disableLoginForm = false;
|
||||
});
|
||||
|
||||
it('should show invite button when externalUserMngInfo is set and disableLoginForm is false', () => {
|
||||
const originalExternalUserMngInfo = config.externalUserMngInfo;
|
||||
config.externalUserMngInfo = 'truthy';
|
||||
|
||||
setup({
|
||||
canInvite: true,
|
||||
});
|
||||
|
||||
expect(screen.getByRole('link', { name: 'Invite' })).toHaveAttribute('href', 'org/users/invite');
|
||||
// Reset the disableLoginForm mock to its original value
|
||||
config.externalUserMngInfo = originalExternalUserMngInfo;
|
||||
});
|
||||
});
|
||||
|
@ -49,8 +49,10 @@ export const UsersActionBarUnconnected = ({
|
||||
{ label: `Pending Invites (${pendingInvitesCount})`, value: 'invites' },
|
||||
];
|
||||
const canAddToOrg: boolean = contextSrv.hasAccess(AccessControlAction.OrgUsersAdd, canInvite);
|
||||
// Hide Invite button in case users are managed externally
|
||||
const showInviteButton: boolean = canAddToOrg && !config.externalUserMngInfo;
|
||||
// Show invite button in the following cases:
|
||||
// 1) the instance is not a hosted Grafana instance (!config.externalUserMngInfo)
|
||||
// 2) new basic auth users can be created for this instance (!config.disableLoginForm).
|
||||
const showInviteButton: boolean = canAddToOrg && !(config.disableLoginForm && config.externalUserMngInfo);
|
||||
|
||||
return (
|
||||
<div className="page-action-bar" data-testid="users-action-bar">
|
||||
|
Loading…
Reference in New Issue
Block a user