11import React , { FC , useContext , useState , useEffect } from 'react' ;
2- import { IconBrandGoogleDrive , IconAlertTriangle , IconFolder , IconFolders } from '@tabler/icons-react' ;
2+ import { IconAlertTriangle , IconFolder , IconFolders } from '@tabler/icons-react' ;
33import HomeContext from '@/pages/api/home/home.context' ;
44import { capitalize } from '@/utils/app/data' ;
55import DataSourcesTableScrollingIntegrations from '@/components/DataSources/DataSourcesTableScrollingIntegrations' ;
@@ -15,6 +15,7 @@ import { getScheduledTask } from '@/services/scheduledTasksService';
1515import { cronToDriveRescanSchedule } from '@/utils/app/scheduledTasks' ;
1616import { AssistantDefinition } from '@/types/assistant' ;
1717import { getDriveFileIntegrationTypes } from '@/utils/app/integrations' ;
18+ import { translateIntegrationIcon } from '@/components/Integrations/IntegrationsDialog' ;
1819
1920
2021 // Add helper function to check if there are any files selected
@@ -78,6 +79,7 @@ export const AssistantDriveDataSources: FC<Props> = ({
7879 const [ supportedDriveIntegrations , setSupportedDriveIntegrations ] = useState < string [ ] | null > ( null ) ;
7980
8081 const [ selectedIntegration , setSelectedIntegration ] = useState < string > ( '' ) ;
82+ const [ selectedMicrosoftService , setSelectedMicrosoftService ] = useState < 'microsoft_drive' | 'microsoft_sharepoint' > ( 'microsoft_drive' ) ;
8183 const [ connectedDriveIntegrations , setConnectedDriveIntegrations ] = useState < string [ ] | null > ( null ) ;
8284 const [ currentFolderPath , setCurrentFolderPath ] = useState < string [ ] > ( [ ] ) ;
8385 const [ currentFolderHistory , setCurrentFolderHistory ] = useState < Array < { id : string | null , name : string } > > ( [ ] ) ;
@@ -433,8 +435,13 @@ export const AssistantDriveDataSources: FC<Props> = ({
433435 }
434436
435437 const handleOnTabChange = ( integrationProvider : string ) => {
436- const integration = integrationProvider . toLowerCase ( ) + "_drive" ;
437- setSelectedIntegration ( integration ) ;
438+ if ( integrationProvider . toLowerCase ( ) === 'microsoft' ) {
439+ // For Microsoft, use the selected service (OneDrive or SharePoint)
440+ setSelectedIntegration ( selectedMicrosoftService ) ;
441+ } else {
442+ const integration = integrationProvider . toLowerCase ( ) + "_drive" ;
443+ setSelectedIntegration ( integration ) ;
444+ }
438445 }
439446
440447 // Initialize drive rescan schedule from existing scheduled tasks
@@ -496,13 +503,60 @@ export const AssistantDriveDataSources: FC<Props> = ({
496503 { renderRescanScheduler ( ) }
497504 </ div > }
498505
499- < IntegrationTabs open = { true }
506+ < IntegrationTabs open = { true }
500507 onConnectedIntegrations = { handleOnConnectedIntegrations }
501508 onSupportedIntegrations = { handleOnSupportedIntegrations }
502509 onTabChange = { handleOnTabChange }
503- allowedIntegrations = { Object . values ( integrationProviders ) . map ( provider => provider + "_drive" ) }
510+ allowedIntegrations = { [
511+ ...Object . values ( integrationProviders ) . map ( provider => provider + "_drive" ) ,
512+ 'microsoft_sharepoint' // Add SharePoint explicitly
513+ ] }
504514 />
505-
515+
516+ { /* Microsoft Service Selector - shown when Microsoft tab is active */ }
517+ { selectedIntegration && ( selectedIntegration . startsWith ( 'microsoft_' ) ) && (
518+ < div className = "mb-4 px-4" >
519+ < label className = "block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2 flex items-center gap-2" >
520+ < span className = "flex items-center gap-2" >
521+ Select Service
522+ </ span >
523+ { /* Connection status indicator */ }
524+ { connectedDriveIntegrations ?. includes ( selectedMicrosoftService ) ? (
525+ < span className = "ml-auto text-xs text-green-600 dark:text-green-400 flex items-center gap-1" >
526+ < span className = "w-2 h-2 bg-green-500 rounded-full" > </ span >
527+ Connected
528+ </ span >
529+ ) : (
530+ < span className = "ml-auto text-xs text-red-600 dark:text-red-400 flex items-center gap-1" >
531+ < span className = "w-2 h-2 bg-red-500 rounded-full" > </ span >
532+ Disconnected
533+ </ span >
534+ ) }
535+ </ label >
536+ < div className = "relative" >
537+ < select
538+ value = { selectedMicrosoftService }
539+ onChange = { ( e ) => {
540+ const newService = e . target . value as 'microsoft_drive' | 'microsoft_sharepoint' ;
541+ setSelectedMicrosoftService ( newService ) ;
542+ setSelectedIntegration ( newService ) ;
543+ } }
544+ className = "w-full p-2 pl-10 border border-gray-300 dark:border-[#454652] rounded-md bg-white dark:bg-[#40414F] text-gray-900 dark:text-white text-sm cursor-pointer"
545+ >
546+ < option value = "microsoft_drive" >
547+ OneDrive
548+ </ option >
549+ < option value = "microsoft_sharepoint" >
550+ SharePoint
551+ </ option >
552+ </ select >
553+ < div className = "absolute left-3 top-1/2 -translate-y-1/2 pointer-events-none" >
554+ { translateIntegrationIcon ( selectedMicrosoftService ) }
555+ </ div >
556+ </ div >
557+ </ div >
558+ ) }
559+
506560 { /* File Display */ }
507561 { selectedIntegration && (
508562 < >
0 commit comments