Skip to content

Commit

Permalink
fix(topology): remove check for catalog entity permission (#1800)
Browse files Browse the repository at this point in the history
  • Loading branch information
PatAKnight authored Jun 7, 2024
1 parent 173a24a commit fd6ae41
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 19 deletions.
1 change: 0 additions & 1 deletion plugins/topology/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"@backstage/catalog-model": "^1.4.5",
"@backstage/core-components": "^0.14.6",
"@backstage/core-plugin-api": "^1.9.2",
"@backstage/plugin-catalog-common": "^1.0.23",
"@backstage/plugin-catalog-react": "^1.11.3",
"@backstage/plugin-kubernetes": "^0.11.9",
"@backstage/plugin-kubernetes-common": "^0.7.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import TopologyToolbar from './TopologyToolbar';

import './TopologyToolbar.css';

import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha';
import { usePermission } from '@backstage/plugin-permission-react';

import { topologyViewPermission } from '@janus-idp/backstage-plugin-topology-common';
Expand Down Expand Up @@ -58,11 +57,6 @@ const TopologyViewWorkloadComponent = ({
permission: topologyViewPermission,
});

const catalogEntityPermissionResult = usePermission({
permission: catalogEntityReadPermission,
resourceRef: catalogEntityReadPermission.resourceType,
});

const allErrors: ClusterErrors = [
...(responseError ? [{ message: responseError }] : []),
...(selectedClusterErrors ?? []),
Expand Down Expand Up @@ -117,6 +111,21 @@ const TopologyViewWorkloadComponent = ({

const isDataModelEmpty = loaded && dataModel?.nodes?.length === 0;

const getTopologyState = () => {
if (isDataModelEmpty) {
return <TopologyEmptyState />;
}
if (!topologyViewPermissionResult.allowed) {
return (
<TopologyEmptyState
title="Permission required"
description="To view Topology, contact your administrator to give you the topology.view.read permission"
/>
);
}
return <VisualizationSurface state={{ selectedIds: [selectedId] }} />;
};

return (
<>
{allErrors && allErrors.length > 0 && (
Expand All @@ -140,18 +149,7 @@ const TopologyViewWorkloadComponent = ({
sideBarOpen={sideBarOpen}
minSideBarSize="400px"
>
{isDataModelEmpty ||
!(
topologyViewPermissionResult.allowed &&
catalogEntityPermissionResult.allowed
) ? (
<TopologyEmptyState
title="Permission required"
description="To view Topology, contact your administrator to give you the topology.view.read and catalog.entity.read permissions"
/>
) : (
<VisualizationSurface state={{ selectedIds: [selectedId] }} />
)}
{getTopologyState()}
</TopologyView>
)}
</InfoCard>
Expand Down

0 comments on commit fd6ae41

Please sign in to comment.