Created
September 24, 2025 16:02
-
-
Save fjudith/05dfac67443032adfe9fa3fee7a58118 to your computer and use it in GitHub Desktop.
Backstage: restrict view only to entity owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Alert from '@material-ui/lab/Alert'; | |
import { RbacIcon } from '@backstage-community/plugin-rbac'; | |
import { useEntity, useEntityOwnership } from '@backstage/plugin-catalog-react'; | |
import { EntityKubernetesContent } from '@beneva/backstage-plugin-kubernetes'; | |
// Composant qui vérifie la propriété de l'entité avant d'afficher le contenu Kubernetes | |
export const KubernetesContent = () => { | |
const { entity } = useEntity(); | |
const { isOwnedEntity } = useEntityOwnership(); | |
// Vérification si l'utilisateur est propriétaire de l'entité | |
if (!isOwnedEntity(entity)) { | |
return ( | |
<Alert icon={<RbacIcon fontSize="inherit" />} severity="info"> | |
Access restricted to entity owners. | |
</Alert> | |
); | |
} | |
// L'utilisateur est propriétaire et Kubernetes est disponible | |
return <EntityKubernetesContent />; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment