mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Team LBAC: Add epilogue to permissions (#82523)
* add epilogue to permissions
* gs
linting fix
* update docs
* Revert "update docs"
This reverts commit 0902ce2d8a
.
This commit is contained in:
parent
d48bf34227
commit
620cc6dced
@ -1,3 +1,4 @@
|
|||||||
import { hideAppNotification, notifyApp } from '../reducers/appNotification';
|
import { hideAppNotification, notifyApp } from '../reducers/appNotification';
|
||||||
import { updateNavIndex, updateConfigurationSubtitle } from '../reducers/navModel';
|
import { updateNavIndex, updateConfigurationSubtitle } from '../reducers/navModel';
|
||||||
|
|
||||||
export { updateNavIndex, updateConfigurationSubtitle, notifyApp, hideAppNotification };
|
export { updateNavIndex, updateConfigurationSubtitle, notifyApp, hideAppNotification };
|
||||||
|
@ -37,6 +37,7 @@ export type Props = {
|
|||||||
resourceId: ResourceId;
|
resourceId: ResourceId;
|
||||||
canSetPermissions: boolean;
|
canSetPermissions: boolean;
|
||||||
getWarnings?: (items: ResourcePermission[]) => ResourcePermission[];
|
getWarnings?: (items: ResourcePermission[]) => ResourcePermission[];
|
||||||
|
epilogue?: (items: ResourcePermission[]) => React.ReactNode;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const Permissions = ({
|
export const Permissions = ({
|
||||||
@ -48,6 +49,7 @@ export const Permissions = ({
|
|||||||
canSetPermissions,
|
canSetPermissions,
|
||||||
addPermissionTitle,
|
addPermissionTitle,
|
||||||
getWarnings,
|
getWarnings,
|
||||||
|
epilogue,
|
||||||
}: Props) => {
|
}: Props) => {
|
||||||
const styles = useStyles2(getStyles);
|
const styles = useStyles2(getStyles);
|
||||||
const [isAdding, setIsAdding] = useState(false);
|
const [isAdding, setIsAdding] = useState(false);
|
||||||
@ -157,87 +159,90 @@ export const Permissions = ({
|
|||||||
const titleTeam = t('access-control.permissions.team', 'Team');
|
const titleTeam = t('access-control.permissions.team', 'Team');
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
{canSetPermissions && resource === 'folders' && (
|
<div>
|
||||||
<>
|
{canSetPermissions && resource === 'folders' && (
|
||||||
<Trans i18nKey="access-control.permissions.permissions-change-warning">
|
<>
|
||||||
This will change permissions for this folder and all its descendants. In total, this will affect:
|
<Trans i18nKey="access-control.permissions.permissions-change-warning">
|
||||||
</Trans>
|
This will change permissions for this folder and all its descendants. In total, this will affect:
|
||||||
<DescendantCount
|
</Trans>
|
||||||
selectedItems={{
|
<DescendantCount
|
||||||
folder: { [resourceId]: true },
|
selectedItems={{
|
||||||
dashboard: {},
|
folder: { [resourceId]: true },
|
||||||
panel: {},
|
dashboard: {},
|
||||||
$all: false,
|
panel: {},
|
||||||
}}
|
$all: false,
|
||||||
/>
|
}}
|
||||||
<Space v={2} />
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
{items.length === 0 && (
|
|
||||||
<Box>
|
|
||||||
<Text>{emptyLabel}</Text>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
<PermissionList
|
|
||||||
title={titleRole}
|
|
||||||
items={builtInRoles}
|
|
||||||
compareKey={'builtInRole'}
|
|
||||||
permissionLevels={desc.permissions}
|
|
||||||
onChange={onChange}
|
|
||||||
onRemove={onRemove}
|
|
||||||
canSet={canSetPermissions}
|
|
||||||
/>
|
|
||||||
<PermissionList
|
|
||||||
title={titleUser}
|
|
||||||
items={users}
|
|
||||||
compareKey={'userLogin'}
|
|
||||||
permissionLevels={desc.permissions}
|
|
||||||
onChange={onChange}
|
|
||||||
onRemove={onRemove}
|
|
||||||
canSet={canSetPermissions}
|
|
||||||
/>
|
|
||||||
<PermissionList
|
|
||||||
title={titleServiceAccount}
|
|
||||||
items={serviceAccounts}
|
|
||||||
compareKey={'userLogin'}
|
|
||||||
permissionLevels={desc.permissions}
|
|
||||||
onChange={onChange}
|
|
||||||
onRemove={onRemove}
|
|
||||||
canSet={canSetPermissions}
|
|
||||||
/>
|
|
||||||
<PermissionList
|
|
||||||
title={titleTeam}
|
|
||||||
items={teams}
|
|
||||||
compareKey={'team'}
|
|
||||||
permissionLevels={desc.permissions}
|
|
||||||
onChange={onChange}
|
|
||||||
onRemove={onRemove}
|
|
||||||
canSet={canSetPermissions}
|
|
||||||
/>
|
|
||||||
{canSetPermissions && (
|
|
||||||
<>
|
|
||||||
<Button
|
|
||||||
className={styles.addPermissionButton}
|
|
||||||
variant={'primary'}
|
|
||||||
key="add-permission"
|
|
||||||
onClick={() => setIsAdding(true)}
|
|
||||||
icon="plus"
|
|
||||||
>
|
|
||||||
{buttonLabel}
|
|
||||||
</Button>
|
|
||||||
<SlideDown in={isAdding}>
|
|
||||||
<AddPermission
|
|
||||||
title={addPermissionTitle}
|
|
||||||
onAdd={onAdd}
|
|
||||||
permissions={desc.permissions}
|
|
||||||
assignments={desc.assignments}
|
|
||||||
onCancel={() => setIsAdding(false)}
|
|
||||||
/>
|
/>
|
||||||
</SlideDown>
|
<Space v={2} />
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
</div>
|
{items.length === 0 && (
|
||||||
|
<Box>
|
||||||
|
<Text>{emptyLabel}</Text>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
<PermissionList
|
||||||
|
title={titleRole}
|
||||||
|
items={builtInRoles}
|
||||||
|
compareKey={'builtInRole'}
|
||||||
|
permissionLevels={desc.permissions}
|
||||||
|
onChange={onChange}
|
||||||
|
onRemove={onRemove}
|
||||||
|
canSet={canSetPermissions}
|
||||||
|
/>
|
||||||
|
<PermissionList
|
||||||
|
title={titleUser}
|
||||||
|
items={users}
|
||||||
|
compareKey={'userLogin'}
|
||||||
|
permissionLevels={desc.permissions}
|
||||||
|
onChange={onChange}
|
||||||
|
onRemove={onRemove}
|
||||||
|
canSet={canSetPermissions}
|
||||||
|
/>
|
||||||
|
<PermissionList
|
||||||
|
title={titleServiceAccount}
|
||||||
|
items={serviceAccounts}
|
||||||
|
compareKey={'userLogin'}
|
||||||
|
permissionLevels={desc.permissions}
|
||||||
|
onChange={onChange}
|
||||||
|
onRemove={onRemove}
|
||||||
|
canSet={canSetPermissions}
|
||||||
|
/>
|
||||||
|
<PermissionList
|
||||||
|
title={titleTeam}
|
||||||
|
items={teams}
|
||||||
|
compareKey={'team'}
|
||||||
|
permissionLevels={desc.permissions}
|
||||||
|
onChange={onChange}
|
||||||
|
onRemove={onRemove}
|
||||||
|
canSet={canSetPermissions}
|
||||||
|
/>
|
||||||
|
{canSetPermissions && (
|
||||||
|
<>
|
||||||
|
<Button
|
||||||
|
className={styles.addPermissionButton}
|
||||||
|
variant={'primary'}
|
||||||
|
key="add-permission"
|
||||||
|
onClick={() => setIsAdding(true)}
|
||||||
|
icon="plus"
|
||||||
|
>
|
||||||
|
{buttonLabel}
|
||||||
|
</Button>
|
||||||
|
<SlideDown in={isAdding}>
|
||||||
|
<AddPermission
|
||||||
|
title={addPermissionTitle}
|
||||||
|
onAdd={onAdd}
|
||||||
|
permissions={desc.permissions}
|
||||||
|
assignments={desc.assignments}
|
||||||
|
onCancel={() => setIsAdding(false)}
|
||||||
|
/>
|
||||||
|
</SlideDown>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
{epilogue && epilogue(items)}
|
||||||
|
</>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user