88 selectCurrentNamespace ,
99 selectNamespaces
1010} from '~/app/namespaces/namespacesSlice' ;
11+ import { selectLoadSegmentFlagReferences } from '~/app/preferences/preferencesSlice' ;
1112import {
1213 useCopySegmentMutation ,
1314 useDeleteConstraintMutation ,
@@ -92,6 +93,9 @@ export default function Segment() {
9293 const namespaces = useSelector ( selectNamespaces ) ;
9394 const namespace = useSelector ( selectCurrentNamespace ) ;
9495 const readOnly = useSelector ( selectReadonly ) ;
96+ const loadSegmentFlagReferences = useSelector (
97+ selectLoadSegmentFlagReferences
98+ ) ;
9599
96100 const {
97101 data : segment ,
@@ -109,7 +113,7 @@ export default function Segment() {
109113 segmentKey : segmentKey || ''
110114 } ,
111115 {
112- skip : ! segmentKey ,
116+ skip : ! segmentKey || ! loadSegmentFlagReferences ,
113117 refetchOnMountOrArgChange : true
114118 }
115119 ) ;
@@ -269,43 +273,45 @@ export default function Segment() {
269273 < SegmentForm segment = { segment } />
270274 </ div >
271275
272- < div className = "mb-8" >
273- < h3 className = "text-secondary-foreground leading-6 font-medium" >
274- Used in flags
275- </ h3 >
276- < p className = "text-muted-foreground mt-1 mb-3 text-sm" >
277- Flags that reference this segment (in rules or rollouts). Changing
278- constraints may affect how these flags evaluate.
279- </ p >
280- { ! flagsForSegment ? (
281- < Loading size = "sm" variant = "start" />
282- ) : flagsForSegment . flags . length === 0 ? (
283- < p className = "text-secondary-foreground/80 text-sm" >
284- This segment is not used by any flags.
276+ { loadSegmentFlagReferences && (
277+ < div className = "mb-8" >
278+ < h3 className = "text-secondary-foreground leading-6 font-medium" >
279+ Used in flags
280+ </ h3 >
281+ < p className = "text-muted-foreground mt-1 mb-3 text-sm" >
282+ Flags that reference this segment (in rules or rollouts). Changing
283+ constraints may affect how these flags evaluate.
285284 </ p >
286- ) : (
287- < ul className = "flex flex-wrap gap-2" >
288- { flagsForSegment . flags . map ( ( ref ) => (
289- < li key = { ref . key } >
290- < Link
291- tabIndex = { 0 }
292- to = { `/namespaces/${ namespace . key } /flags/${ ref . key } ` }
293- className = "focus:ring-offset-brand focus:ring-brand block shrink-0 cursor-pointer rounded-md text-xs focus:ring-1 focus:ring-offset-1"
294- >
295- < Badge
296- variant = "secondary"
297- title = { ref . name + ' | ' + ref . key }
298- className = "shrink-0 gap-1.5 border-0 px-3 py-1.5 text-xs"
285+ { ! flagsForSegment ? (
286+ < Loading size = "sm" variant = "start" />
287+ ) : flagsForSegment . flags . length === 0 ? (
288+ < p className = "text-secondary-foreground/80 text-sm" >
289+ This segment is not used by any flags.
290+ </ p >
291+ ) : (
292+ < ul className = "flex flex-wrap gap-2" >
293+ { flagsForSegment . flags . map ( ( ref ) => (
294+ < li key = { ref . key } >
295+ < Link
296+ tabIndex = { 0 }
297+ to = { `/namespaces/${ namespace . key } /flags/${ ref . key } ` }
298+ className = "focus:ring-offset-brand focus:ring-brand block shrink-0 cursor-pointer rounded-md text-xs focus:ring-1 focus:ring-offset-1"
299299 >
300- < FlagIcon className = "h-4 w-4" /> { ' ' }
301- < span className = "max-w-24 truncate" > { ref . name } </ span >
302- </ Badge >
303- </ Link >
304- </ li >
305- ) ) }
306- </ ul >
307- ) }
308- </ div >
300+ < Badge
301+ variant = "secondary"
302+ title = { ref . name + ' | ' + ref . key }
303+ className = "shrink-0 gap-1.5 border-0 px-3 py-1.5 text-xs"
304+ >
305+ < FlagIcon className = "h-4 w-4" /> { ' ' }
306+ < span className = "max-w-24 truncate" > { ref . name } </ span >
307+ </ Badge >
308+ </ Link >
309+ </ li >
310+ ) ) }
311+ </ ul >
312+ ) }
313+ </ div >
314+ ) }
309315
310316 < div >
311317 < div className = "sm:flex sm:items-center" >
0 commit comments