1- import { PermissionsSummary } from "@flanksource-ui/api/types/permissions" ;
1+ import {
2+ PermissionGlobalObject ,
3+ PermissionsSummary
4+ } from "@flanksource-ui/api/types/permissions" ;
25import CanaryLink from "../Canary/CanaryLink" ;
36import ConfigLink from "../Configs/ConfigLink/ConfigLink" ;
47import ConnectionIcon from "../Connections/ConnectionIcon" ;
58import ConnectionLink from "../Connections/ConnectionLink" ;
69import PlaybookSpecIcon from "../Playbooks/Settings/PlaybookSpecIcon" ;
710import { TopologyLink } from "../Topology/TopologyLink" ;
8- import { permissionObjectList } from "./ManagePermissions/Forms/FormikPermissionSelectResourceFields" ;
911import { PermissionErrorDisplay } from "./PermissionErrorDisplay" ;
1012
1113interface ScopeObject {
@@ -87,6 +89,16 @@ type PermissionResourceCellProps = {
8789 permission : PermissionsSummary ;
8890} ;
8991
92+ const OBJECT_LABELS : Record < PermissionGlobalObject , string > = {
93+ catalog : "Catalog" ,
94+ component : "Component" ,
95+ canaries : "Canaries" ,
96+ connection : "Connection" ,
97+ playbook : "Playbook" ,
98+ topology : "Topology" ,
99+ mcp : "MCP"
100+ } ;
101+
90102export default function PermissionResourceCell ( {
91103 permission
92104} : PermissionResourceCellProps ) {
@@ -98,6 +110,9 @@ export default function PermissionResourceCell({
98110 const object = permission . object ;
99111 const objectSelector = permission . object_selector ;
100112 const error = permission . error ;
113+ const hasConcreteObject = Boolean (
114+ config || playbook || component || canary || connection
115+ ) ;
101116
102117 if ( objectSelector ) {
103118 // Format scopes as "Scope: namespace/name, namespace2/name2"
@@ -187,13 +202,69 @@ export default function PermissionResourceCell({
187202 ) ;
188203 }
189204
205+ if ( hasConcreteObject ) {
206+ return (
207+ < div className = "flex flex-row items-center gap-3" >
208+ < div className = "flex flex-row items-center gap-2" >
209+ < div className = "flex flex-col" >
210+ { config && (
211+ < div className = "flex items-center gap-1" >
212+ < span className = "text-sm text-gray-600" > Catalog:</ span >
213+ < ConfigLink config = { config } />
214+ </ div >
215+ ) }
216+
217+ { playbook && (
218+ < div className = "flex items-center gap-1" >
219+ < span className = "text-sm text-gray-600" > Playbook:</ span >
220+ < PlaybookSpecIcon
221+ playbook = { {
222+ ...playbook ,
223+ title : playbook . name ,
224+ spec : { icon : playbook . icon || "" , actions : [ ] }
225+ } }
226+ showLabel
227+ />
228+ </ div >
229+ ) }
230+
231+ { component && (
232+ < div className = "flex items-center gap-1" >
233+ < span className = "text-sm text-gray-600" > Component:</ span >
234+ < TopologyLink
235+ topology = { component }
236+ className = "h-5 w-5 text-gray-600"
237+ linkClassName = "text-gray-600"
238+ size = "md"
239+ />
240+ </ div >
241+ ) }
242+
243+ { canary && (
244+ < div className = "flex items-center gap-1" >
245+ < span className = "text-sm text-gray-600" > Canary:</ span >
246+ < CanaryLink canary = { canary } />
247+ </ div >
248+ ) }
249+
250+ { connection && (
251+ < div className = "flex items-center gap-1" >
252+ < span className = "text-sm text-gray-600" > Connection:</ span >
253+ < ConnectionIcon connection = { connection } showLabel />
254+ </ div >
255+ ) }
256+ </ div >
257+ </ div >
258+ < PermissionErrorDisplay error = { error } />
259+ </ div >
260+ ) ;
261+ }
262+
190263 if ( object ) {
191264 return (
192265 < div className = "flex flex-row items-center gap-3" >
193266 < div className = "flex flex-row items-center gap-2" >
194- < span >
195- { permissionObjectList . find ( ( o ) => o . value === object ) ?. label }
196- </ span >
267+ < span > { OBJECT_LABELS [ object ] ?? object } </ span >
197268 </ div >
198269 < PermissionErrorDisplay error = { error } />
199270 </ div >
@@ -202,56 +273,6 @@ export default function PermissionResourceCell({
202273
203274 return (
204275 < div className = "flex flex-row items-center gap-3" >
205- < div className = "flex flex-row items-center gap-2" >
206- < div className = "flex flex-col" >
207- { config && (
208- < div className = "flex items-center gap-1" >
209- < span className = "text-sm text-gray-600" > Catalog:</ span >
210- < ConfigLink config = { config } />
211- </ div >
212- ) }
213-
214- { playbook && (
215- < div className = "flex items-center gap-1" >
216- < span className = "text-sm text-gray-600" > Playbook:</ span >
217- < PlaybookSpecIcon
218- playbook = { {
219- ...playbook ,
220- title : playbook . name ,
221- spec : { icon : playbook . icon || "" , actions : [ ] }
222- } }
223- showLabel
224- />
225- </ div >
226- ) }
227-
228- { component && (
229- < div className = "flex items-center gap-1" >
230- < span className = "text-sm text-gray-600" > Component:</ span >
231- < TopologyLink
232- topology = { component }
233- className = "h-5 w-5 text-gray-600"
234- linkClassName = "text-gray-600"
235- size = "md"
236- />
237- </ div >
238- ) }
239-
240- { canary && (
241- < div className = "flex items-center gap-1" >
242- < span className = "text-sm text-gray-600" > Canary:</ span >
243- < CanaryLink canary = { canary } />
244- </ div >
245- ) }
246-
247- { connection && (
248- < div className = "flex items-center gap-1" >
249- < span className = "text-sm text-gray-600" > Connection:</ span >
250- < ConnectionIcon connection = { connection } showLabel />
251- </ div >
252- ) }
253- </ div >
254- </ div >
255276 < PermissionErrorDisplay error = { error } />
256277 </ div >
257278 ) ;
0 commit comments