@@ -16,6 +16,7 @@ import { getErrorMessage } from '@sim/utils/errors'
1616import type { FileCopySource } from '@/lib/api/contracts/file-copy-input'
1717import { MAX_WORKSPACE_FILE_BULK_REQUEST_IDS } from '@/lib/workspace-files/limits'
1818import type { EditableFileOwner } from '@/lib/workspace-files/ownership'
19+ import { useFeatureFlag } from '@/app/workspace/[workspaceId]/providers/feature-flags-provider'
1920import { useCopyFileItems , useFileCopyDestination } from '@/hooks/queries/file-copy'
2021import { useProjects } from '@/hooks/queries/projects'
2122import { useWorkspacesQuery } from '@/hooks/queries/workspace'
@@ -62,7 +63,10 @@ export function FileCopyModal({ source, onClose }: FileCopyModalProps) {
6263
6364function FileCopyDestinationPicker ( { source, onClose } : FileCopyModalProps ) {
6465 const workspaces = useWorkspacesQuery ( )
65- const projects = useProjects ( )
66+ const projectsEnabled = useFeatureFlag ( 'projects' )
67+ const projectFilesEnabled = useFeatureFlag ( 'project-files' )
68+ const projectDestinationsEnabled = projectsEnabled && projectFilesEnabled
69+ const projects = useProjects ( undefined , { enabled : projectDestinationsEnabled } )
6670 const copy = useCopyFileItems ( )
6771 const [ selection , setSelection ] = useState ( '' )
6872 const destinations = useMemo ( ( ) => {
@@ -72,14 +76,14 @@ function FileCopyDestinationPicker({ source, onClose }: FileCopyModalProps) {
7276 owner : { entityType : 'workspace' , entityId : workspace . id } ,
7377 name : workspace . name ,
7478 } )
75- for ( const page of projects . data ?. pages ?? [ ] )
79+ for ( const page of projectDestinationsEnabled ? ( projects . data ?. pages ?? [ ] ) : [ ] )
7680 for ( const project of page . projects )
7781 result . set ( `project:${ project . id } ` , {
7882 owner : { entityType : 'project' , entityId : project . id } ,
7983 name : project . name ,
8084 } )
8185 return result
82- } , [ workspaces . data , projects . data ] )
86+ } , [ workspaces . data , projects . data , projectDestinationsEnabled ] )
8387 const destination = destinations . get ( selection )
8488 const groups = [ 'project' , 'workspace' ] . map ( ( kind ) => ( {
8589 section : kind === 'project' ? 'Projects' : 'Environments' ,
@@ -92,7 +96,11 @@ function FileCopyDestinationPicker({ source, onClose }: FileCopyModalProps) {
9296 type = 'custom'
9397 title = 'Destination'
9498 hint = 'Copies saved content. The original files stay in their current location.'
95- error = { workspaces . isError && projects . isError ? 'Could not load destinations.' : undefined }
99+ error = {
100+ workspaces . isError && ( ! projectDestinationsEnabled || projects . isError )
101+ ? 'Could not load destinations.'
102+ : undefined
103+ }
96104 >
97105 < ChipSelect
98106 aria-label = 'Copy destination'
@@ -103,12 +111,14 @@ function FileCopyDestinationPicker({ source, onClose }: FileCopyModalProps) {
103111 searchable
104112 fullWidth
105113 placeholder = {
106- workspaces . isPending && projects . isPending
114+ workspaces . isPending && ( ! projectDestinationsEnabled || projects . isPending )
107115 ? 'Loading...'
108- : 'Choose a Project or environment'
116+ : projectDestinationsEnabled
117+ ? 'Choose a Project or environment'
118+ : 'Choose an environment'
109119 }
110120 />
111- { projects . hasNextPage && (
121+ { projectDestinationsEnabled && projects . hasNextPage && (
112122 < Chip disabled = { projects . isFetchingNextPage } onClick = { ( ) => void projects . fetchNextPage ( ) } >
113123 { projects . isFetchingNextPage ? 'Loading...' : 'Load more Projects' }
114124 </ Chip >
0 commit comments