mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Auth: add a lock message for Grafana Admin role (#72724)
* add a lock message for Grafana admin role sync * Update public/app/features/admin/UserAdminPage.tsx Co-authored-by: Misi <mgyongyosi@users.noreply.github.com> * linting * use theme for spacing --------- Co-authored-by: Misi <mgyongyosi@users.noreply.github.com>
This commit is contained in:
@@ -105,6 +105,8 @@ export class UserAdminPage extends PureComponent<Props> {
|
|||||||
const isLDAPUser = user?.isExternal && user?.authLabels?.includes('LDAP');
|
const isLDAPUser = user?.isExternal && user?.authLabels?.includes('LDAP');
|
||||||
const canReadSessions = contextSrv.hasPermission(AccessControlAction.UsersAuthTokenList);
|
const canReadSessions = contextSrv.hasPermission(AccessControlAction.UsersAuthTokenList);
|
||||||
const canReadLDAPStatus = contextSrv.hasPermission(AccessControlAction.LDAPStatusRead);
|
const canReadLDAPStatus = contextSrv.hasPermission(AccessControlAction.LDAPStatusRead);
|
||||||
|
const authSource = user?.authLabels?.[0];
|
||||||
|
const lockMessage = authSource ? `Synced via ${authSource}` : '';
|
||||||
|
|
||||||
const pageNav: NavModelItem = {
|
const pageNav: NavModelItem = {
|
||||||
text: user?.login ?? '',
|
text: user?.login ?? '',
|
||||||
@@ -135,6 +137,7 @@ export class UserAdminPage extends PureComponent<Props> {
|
|||||||
<UserPermissions
|
<UserPermissions
|
||||||
isGrafanaAdmin={user.isGrafanaAdmin}
|
isGrafanaAdmin={user.isGrafanaAdmin}
|
||||||
isExternalUser={user?.isGrafanaAdminExternallySynced}
|
isExternalUser={user?.isGrafanaAdminExternallySynced}
|
||||||
|
lockMessage={lockMessage}
|
||||||
onGrafanaAdminChange={this.onGrafanaAdminChange}
|
onGrafanaAdminChange={this.onGrafanaAdminChange}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -488,7 +488,7 @@ interface ExternalUserTooltipProps {
|
|||||||
lockMessage?: string;
|
lockMessage?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ExternalUserTooltip = ({ lockMessage }: ExternalUserTooltipProps) => {
|
export const ExternalUserTooltip = ({ lockMessage }: ExternalUserTooltipProps) => {
|
||||||
const styles = useStyles2(getTooltipStyles);
|
const styles = useStyles2(getTooltipStyles);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -1,12 +1,16 @@
|
|||||||
|
import { css } from '@emotion/css';
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
|
|
||||||
import { ConfirmButton, RadioButtonGroup, Icon } from '@grafana/ui';
|
import { GrafanaTheme2 } from '@grafana/data';
|
||||||
|
import { ConfirmButton, RadioButtonGroup, Icon, useStyles2 } from '@grafana/ui';
|
||||||
import { contextSrv } from 'app/core/core';
|
import { contextSrv } from 'app/core/core';
|
||||||
|
import { ExternalUserTooltip } from 'app/features/admin/UserOrgs';
|
||||||
import { AccessControlAction } from 'app/types';
|
import { AccessControlAction } from 'app/types';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
isGrafanaAdmin: boolean;
|
isGrafanaAdmin: boolean;
|
||||||
isExternalUser?: boolean;
|
isExternalUser?: boolean;
|
||||||
|
lockMessage?: string;
|
||||||
|
|
||||||
onGrafanaAdminChange: (isGrafanaAdmin: boolean) => void;
|
onGrafanaAdminChange: (isGrafanaAdmin: boolean) => void;
|
||||||
}
|
}
|
||||||
@@ -16,7 +20,7 @@ const adminOptions = [
|
|||||||
{ label: 'No', value: false },
|
{ label: 'No', value: false },
|
||||||
];
|
];
|
||||||
|
|
||||||
export function UserPermissions({ isGrafanaAdmin, isExternalUser, onGrafanaAdminChange }: Props) {
|
export function UserPermissions({ isGrafanaAdmin, isExternalUser, lockMessage, onGrafanaAdminChange }: Props) {
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
const [isEditing, setIsEditing] = useState(false);
|
||||||
const [currentAdminOption, setCurrentAdminOption] = useState(isGrafanaAdmin);
|
const [currentAdminOption, setCurrentAdminOption] = useState(isGrafanaAdmin);
|
||||||
|
|
||||||
@@ -31,6 +35,8 @@ export function UserPermissions({ isGrafanaAdmin, isExternalUser, onGrafanaAdmin
|
|||||||
|
|
||||||
const canChangePermissions = contextSrv.hasPermission(AccessControlAction.UsersPermissionsUpdate) && !isExternalUser;
|
const canChangePermissions = contextSrv.hasPermission(AccessControlAction.UsersPermissionsUpdate) && !isExternalUser;
|
||||||
|
|
||||||
|
const styles = useStyles2(getTooltipStyles);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<h3 className="page-heading">Permissions</h3>
|
<h3 className="page-heading">Permissions</h3>
|
||||||
@@ -71,6 +77,11 @@ export function UserPermissions({ isGrafanaAdmin, isExternalUser, onGrafanaAdmin
|
|||||||
Change
|
Change
|
||||||
</ConfirmButton>
|
</ConfirmButton>
|
||||||
)}
|
)}
|
||||||
|
{isExternalUser && (
|
||||||
|
<div className={styles.lockMessageClass}>
|
||||||
|
<ExternalUserTooltip lockMessage={lockMessage} />
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@@ -80,3 +91,12 @@ export function UserPermissions({ isGrafanaAdmin, isExternalUser, onGrafanaAdmin
|
|||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getTooltipStyles = (theme: GrafanaTheme2) => ({
|
||||||
|
lockMessageClass: css`
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
font-style: italic;
|
||||||
|
margin-right: ${theme.spacing(0.6)};
|
||||||
|
`,
|
||||||
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user