Skip to content

Commit fd6ae41

Browse files
authored
fix(topology): remove check for catalog entity permission (#1800)
1 parent 173a24a commit fd6ae41

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

plugins/topology/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"@backstage/catalog-model": "^1.4.5",
3030
"@backstage/core-components": "^0.14.6",
3131
"@backstage/core-plugin-api": "^1.9.2",
32-
"@backstage/plugin-catalog-common": "^1.0.23",
3332
"@backstage/plugin-catalog-react": "^1.11.3",
3433
"@backstage/plugin-kubernetes": "^0.11.9",
3534
"@backstage/plugin-kubernetes-common": "^0.7.5",

plugins/topology/src/components/Topology/TopologyViewWorkloadComponent.tsx

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import TopologyToolbar from './TopologyToolbar';
2525

2626
import './TopologyToolbar.css';
2727

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

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

61-
const catalogEntityPermissionResult = usePermission({
62-
permission: catalogEntityReadPermission,
63-
resourceRef: catalogEntityReadPermission.resourceType,
64-
});
65-
6660
const allErrors: ClusterErrors = [
6761
...(responseError ? [{ message: responseError }] : []),
6862
...(selectedClusterErrors ?? []),
@@ -117,6 +111,21 @@ const TopologyViewWorkloadComponent = ({
117111

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

114+
const getTopologyState = () => {
115+
if (isDataModelEmpty) {
116+
return <TopologyEmptyState />;
117+
}
118+
if (!topologyViewPermissionResult.allowed) {
119+
return (
120+
<TopologyEmptyState
121+
title="Permission required"
122+
description="To view Topology, contact your administrator to give you the topology.view.read permission"
123+
/>
124+
);
125+
}
126+
return <VisualizationSurface state={{ selectedIds: [selectedId] }} />;
127+
};
128+
120129
return (
121130
<>
122131
{allErrors && allErrors.length > 0 && (
@@ -140,18 +149,7 @@ const TopologyViewWorkloadComponent = ({
140149
sideBarOpen={sideBarOpen}
141150
minSideBarSize="400px"
142151
>
143-
{isDataModelEmpty ||
144-
!(
145-
topologyViewPermissionResult.allowed &&
146-
catalogEntityPermissionResult.allowed
147-
) ? (
148-
<TopologyEmptyState
149-
title="Permission required"
150-
description="To view Topology, contact your administrator to give you the topology.view.read and catalog.entity.read permissions"
151-
/>
152-
) : (
153-
<VisualizationSurface state={{ selectedIds: [selectedId] }} />
154-
)}
152+
{getTopologyState()}
155153
</TopologyView>
156154
)}
157155
</InfoCard>

0 commit comments

Comments
 (0)