mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 00:25:46 -06:00
Disable only built-in role selector for external users (#42197)
This commit is contained in:
parent
0f6ae272e9
commit
177a0d69d1
@ -12,6 +12,7 @@ export interface Props {
|
|||||||
onRolesChange: (newRoles: string[]) => void;
|
onRolesChange: (newRoles: string[]) => void;
|
||||||
onBuiltinRoleChange: (newRole: OrgRole) => void;
|
onBuiltinRoleChange: (newRole: OrgRole) => void;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
builtinRolesDisabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const RolePicker = ({
|
export const RolePicker = ({
|
||||||
@ -22,6 +23,7 @@ export const RolePicker = ({
|
|||||||
onRolesChange,
|
onRolesChange,
|
||||||
onBuiltinRoleChange,
|
onBuiltinRoleChange,
|
||||||
disabled,
|
disabled,
|
||||||
|
builtinRolesDisabled,
|
||||||
}: Props): JSX.Element | null => {
|
}: Props): JSX.Element | null => {
|
||||||
const [isOpen, setOpen] = useState(false);
|
const [isOpen, setOpen] = useState(false);
|
||||||
const [roleOptions, setRoleOptions] = useState<Role[]>([]);
|
const [roleOptions, setRoleOptions] = useState<Role[]>([]);
|
||||||
@ -133,6 +135,7 @@ export const RolePicker = ({
|
|||||||
onSelect={onSelect}
|
onSelect={onSelect}
|
||||||
onUpdate={onUpdate}
|
onUpdate={onUpdate}
|
||||||
showGroups={query.length === 0 || query.trim() === ''}
|
showGroups={query.length === 0 || query.trim() === ''}
|
||||||
|
builtinRolesDisabled={builtinRolesDisabled}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</ClickOutsideWrapper>
|
</ClickOutsideWrapper>
|
||||||
|
@ -35,6 +35,7 @@ interface RolePickerMenuProps {
|
|||||||
options: Role[];
|
options: Role[];
|
||||||
appliedRoles: Role[];
|
appliedRoles: Role[];
|
||||||
showGroups?: boolean;
|
showGroups?: boolean;
|
||||||
|
builtinRolesDisabled?: boolean;
|
||||||
onSelect: (roles: Role[]) => void;
|
onSelect: (roles: Role[]) => void;
|
||||||
onBuiltInRoleSelect?: (role: OrgRole) => void;
|
onBuiltInRoleSelect?: (role: OrgRole) => void;
|
||||||
onUpdate: (newBuiltInRole: OrgRole, newRoles: string[]) => void;
|
onUpdate: (newBuiltInRole: OrgRole, newRoles: string[]) => void;
|
||||||
@ -47,6 +48,7 @@ export const RolePickerMenu = ({
|
|||||||
options,
|
options,
|
||||||
appliedRoles,
|
appliedRoles,
|
||||||
showGroups,
|
showGroups,
|
||||||
|
builtinRolesDisabled,
|
||||||
onSelect,
|
onSelect,
|
||||||
onBuiltInRoleSelect,
|
onBuiltInRoleSelect,
|
||||||
onUpdate,
|
onUpdate,
|
||||||
@ -181,6 +183,7 @@ export const RolePickerMenu = ({
|
|||||||
value={selectedBuiltInRole}
|
value={selectedBuiltInRole}
|
||||||
onChange={onSelectedBuiltinRoleChange}
|
onChange={onSelectedBuiltinRoleChange}
|
||||||
fullWidth={true}
|
fullWidth={true}
|
||||||
|
disabled={builtinRolesDisabled}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{!!fixedRoles.length &&
|
{!!fixedRoles.length &&
|
||||||
|
@ -11,6 +11,7 @@ export interface Props {
|
|||||||
getRoleOptions?: () => Promise<Role[]>;
|
getRoleOptions?: () => Promise<Role[]>;
|
||||||
getBuiltinRoles?: () => Promise<{ [key: string]: Role[] }>;
|
getBuiltinRoles?: () => Promise<{ [key: string]: Role[] }>;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
|
builtinRolesDisabled?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const UserRolePicker: FC<Props> = ({
|
export const UserRolePicker: FC<Props> = ({
|
||||||
@ -21,6 +22,7 @@ export const UserRolePicker: FC<Props> = ({
|
|||||||
getRoleOptions,
|
getRoleOptions,
|
||||||
getBuiltinRoles,
|
getBuiltinRoles,
|
||||||
disabled,
|
disabled,
|
||||||
|
builtinRolesDisabled,
|
||||||
}) => {
|
}) => {
|
||||||
return (
|
return (
|
||||||
<RolePicker
|
<RolePicker
|
||||||
@ -31,6 +33,7 @@ export const UserRolePicker: FC<Props> = ({
|
|||||||
getRoles={() => fetchUserRoles(userId, orgId)}
|
getRoles={() => fetchUserRoles(userId, orgId)}
|
||||||
getBuiltinRoles={() => (getBuiltinRoles ? getBuiltinRoles() : fetchBuiltinRoles(orgId))}
|
getBuiltinRoles={() => (getBuiltinRoles ? getBuiltinRoles() : fetchBuiltinRoles(orgId))}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
|
builtinRolesDisabled={builtinRolesDisabled}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
@ -185,7 +185,7 @@ class UnThemedOrgRow extends PureComponent<OrgRowProps> {
|
|||||||
orgId={org.orgId}
|
orgId={org.orgId}
|
||||||
builtInRole={org.role}
|
builtInRole={org.role}
|
||||||
onBuiltinRoleChange={this.onBuiltinRoleChange}
|
onBuiltinRoleChange={this.onBuiltinRoleChange}
|
||||||
disabled={rolePickerDisabled}
|
builtinRolesDisabled={rolePickerDisabled}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{isExternalUser && <ExternalUserTooltip />}
|
{isExternalUser && <ExternalUserTooltip />}
|
||||||
@ -391,7 +391,8 @@ const ExternalUserTooltip: React.FC = () => {
|
|||||||
placement="right-end"
|
placement="right-end"
|
||||||
content={
|
content={
|
||||||
<div>
|
<div>
|
||||||
This user's role is not editable because it is synchronized from your auth provider. Refer to the
|
This user's built-in role is not editable because it is synchronized from your auth provider. Refer to
|
||||||
|
the
|
||||||
<a
|
<a
|
||||||
className={styles.tooltipItemLink}
|
className={styles.tooltipItemLink}
|
||||||
href={'https://grafana.com/docs/grafana/latest/auth'}
|
href={'https://grafana.com/docs/grafana/latest/auth'}
|
||||||
|
Loading…
Reference in New Issue
Block a user