@@ -25,7 +25,6 @@ import TopologyToolbar from './TopologyToolbar';
25
25
26
26
import './TopologyToolbar.css' ;
27
27
28
- import { catalogEntityReadPermission } from '@backstage/plugin-catalog-common/alpha' ;
29
28
import { usePermission } from '@backstage/plugin-permission-react' ;
30
29
31
30
import { topologyViewPermission } from '@janus-idp/backstage-plugin-topology-common' ;
@@ -58,11 +57,6 @@ const TopologyViewWorkloadComponent = ({
58
57
permission : topologyViewPermission ,
59
58
} ) ;
60
59
61
- const catalogEntityPermissionResult = usePermission ( {
62
- permission : catalogEntityReadPermission ,
63
- resourceRef : catalogEntityReadPermission . resourceType ,
64
- } ) ;
65
-
66
60
const allErrors : ClusterErrors = [
67
61
...( responseError ? [ { message : responseError } ] : [ ] ) ,
68
62
...( selectedClusterErrors ?? [ ] ) ,
@@ -117,6 +111,21 @@ const TopologyViewWorkloadComponent = ({
117
111
118
112
const isDataModelEmpty = loaded && dataModel ?. nodes ?. length === 0 ;
119
113
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
+
120
129
return (
121
130
< >
122
131
{ allErrors && allErrors . length > 0 && (
@@ -140,18 +149,7 @@ const TopologyViewWorkloadComponent = ({
140
149
sideBarOpen = { sideBarOpen }
141
150
minSideBarSize = "400px"
142
151
>
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 ( ) }
155
153
</ TopologyView >
156
154
) }
157
155
</ InfoCard >
0 commit comments