Skip to content

Commit e479921

Browse files
committed
fix type errors
1 parent f638e94 commit e479921

4 files changed

Lines changed: 11 additions & 285 deletions

File tree

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/file-selector/components/google-calendar-selector.tsx

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useCallback, useEffect, useState } from 'react'
4-
import { Check, ChevronDown, RefreshCw, X } from 'lucide-react'
4+
import { Check, ChevronDown, RefreshCw } from 'lucide-react'
55
import { GoogleCalendarIcon } from '@/components/icons'
66
import { Button } from '@/components/ui/button'
77
import {
@@ -242,40 +242,6 @@ export function GoogleCalendarSelector({
242242
</Command>
243243
</PopoverContent>
244244
</Popover>
245-
246-
{/* Calendar preview */}
247-
{showPreview && selectedCalendar && (
248-
<div className='relative mt-2 rounded-md border border-muted bg-muted/10 p-2'>
249-
<div className='absolute top-2 right-2'>
250-
<Button
251-
variant='ghost'
252-
size='icon'
253-
className='h-5 w-5 hover:bg-muted'
254-
onClick={handleClearSelection}
255-
>
256-
<X className='h-3 w-3' />
257-
</Button>
258-
</div>
259-
<div className='flex items-center gap-3 pr-4'>
260-
<div className='flex h-6 w-6 flex-shrink-0 items-center justify-center rounded bg-muted/20'>
261-
<div
262-
className='h-3 w-3 rounded-full'
263-
style={{
264-
backgroundColor: selectedCalendar.backgroundColor || '#4285f4',
265-
}}
266-
/>
267-
</div>
268-
<div className='min-w-0 flex-1 overflow-hidden'>
269-
<h4 className='truncate font-medium text-xs'>
270-
{getCalendarDisplayName(selectedCalendar)}
271-
</h4>
272-
<div className='text-muted-foreground text-xs'>
273-
Access: {selectedCalendar.accessRole}
274-
</div>
275-
</div>
276-
</div>
277-
</div>
278-
)}
279245
</div>
280246
)
281247
}

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/file-selector/components/jira-issue-selector.tsx

Lines changed: 1 addition & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'
4-
import { Check, ChevronDown, ExternalLink, RefreshCw, X } from 'lucide-react'
4+
import { Check, ChevronDown, RefreshCw } from 'lucide-react'
55
import { JiraIcon } from '@/components/icons'
66
import { Button } from '@/components/ui/button'
77
import {
@@ -416,18 +416,6 @@ export function JiraIssueSelector({
416416
}
417417

418418
// Fetch selected issue metadata once credentials are ready or changed
419-
useEffect(() => {
420-
if (
421-
value &&
422-
selectedCredentialId &&
423-
domain &&
424-
domain.includes('.') &&
425-
(!selectedIssue || selectedIssue.id !== value)
426-
) {
427-
fetchIssueInfo(value)
428-
}
429-
}, [value, selectedCredentialId, selectedIssue, domain, fetchIssueInfo])
430-
431419
// Keep internal selectedIssueId in sync with the value prop
432420
useEffect(() => {
433421
if (value !== selectedIssueId) {
@@ -610,51 +598,6 @@ export function JiraIssueSelector({
610598
</PopoverContent>
611599
)}
612600
</Popover>
613-
614-
{/* Issue preview */}
615-
{showPreview && selectedIssue && (
616-
<div className='relative mt-2 rounded-md border border-muted bg-muted/10 p-2'>
617-
<div className='absolute top-2 right-2'>
618-
<Button
619-
variant='ghost'
620-
size='icon'
621-
className='h-5 w-5 hover:bg-muted'
622-
onClick={handleClearSelection}
623-
>
624-
<X className='h-3 w-3' />
625-
</Button>
626-
</div>
627-
<div className='flex items-center gap-3 pr-4'>
628-
<div className='flex h-6 w-6 flex-shrink-0 items-center justify-center rounded bg-muted/20'>
629-
<JiraIcon className='h-4 w-4' />
630-
</div>
631-
<div className='min-w-0 flex-1 overflow-hidden'>
632-
<div className='flex items-center gap-2'>
633-
<h4 className='truncate font-medium text-xs'>{selectedIssue.name}</h4>
634-
{selectedIssue.modifiedTime && (
635-
<span className='whitespace-nowrap text-muted-foreground text-xs'>
636-
{new Date(selectedIssue.modifiedTime).toLocaleDateString()}
637-
</span>
638-
)}
639-
</div>
640-
{selectedIssue.webViewLink ? (
641-
<a
642-
href={selectedIssue.webViewLink}
643-
target='_blank'
644-
rel='noopener noreferrer'
645-
className='flex items-center gap-1 text-foreground text-xs hover:underline'
646-
onClick={(e) => e.stopPropagation()}
647-
>
648-
<span>Open in Jira</span>
649-
<ExternalLink className='h-3 w-3' />
650-
</a>
651-
) : (
652-
<></>
653-
)}
654-
</div>
655-
</div>
656-
</div>
657-
)}
658601
</div>
659602

660603
{showOAuthModal && (

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/panel-new/components/editor/components/sub-block/components/file-selector/components/microsoft-file-selector.tsx

Lines changed: 8 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use client'
22

33
import { useCallback, useEffect, useRef, useState } from 'react'
4-
import { Check, ChevronDown, ExternalLink, RefreshCw, X } from 'lucide-react'
4+
import { Check, ChevronDown, ExternalLink, RefreshCw } from 'lucide-react'
55
import { MicrosoftExcelIcon } from '@/components/icons'
66
import { Button } from '@/components/ui/button'
77
import {
@@ -281,7 +281,6 @@ export function MicrosoftFileSelector({
281281
]
282282
: [],
283283
}
284-
setSelectedFile(fileInfo)
285284
onFileInfoChange?.(fileInfo)
286285
return fileInfo
287286
}
@@ -309,7 +308,6 @@ export function MicrosoftFileSelector({
309308
mimeType: 'sharepoint/site',
310309
webViewLink: site.webUrl,
311310
}
312-
setSelectedFile(siteInfo)
313311
onFileInfoChange?.(siteInfo)
314312
return siteInfo
315313
} catch (error) {
@@ -433,7 +431,6 @@ export function MicrosoftFileSelector({
433431
modifiedTime: task.createdDateTime,
434432
}
435433
setSelectedTask(task)
436-
setSelectedFile(taskAsFileInfo)
437434
onFileInfoChange?.(taskAsFileInfo)
438435
return taskAsFileInfo
439436
} catch {
@@ -498,7 +495,6 @@ export function MicrosoftFileSelector({
498495

499496
// Update internal state first to avoid race with list refetch
500497
setSelectedFileId(taskId)
501-
setSelectedFile(taskAsFileInfo)
502498
setSelectedTask(task)
503499
// Then propagate up
504500
onChange(taskId, taskAsFileInfo)
@@ -524,81 +520,26 @@ export function MicrosoftFileSelector({
524520

525521
if (!selectedCredentialId) {
526522
// No credentials - clear everything
527-
if (selectedFile) {
528-
setSelectedFile(null)
529-
setSelectedFileId('')
530-
onChange('')
531-
}
523+
setSelectedFileId('')
524+
onChange('')
532525
// Reset memo when credential is cleared
533526
lastMetaAttemptRef.current = ''
534527
} else if (prevCredentialId && prevCredentialId !== selectedCredentialId) {
535-
// Credentials changed (not initial load) - clear file info to force refetch
536-
if (selectedFile) {
537-
setSelectedFile(null)
538-
}
539528
// Reset memo when switching credentials
540529
lastMetaAttemptRef.current = ''
541530
}
542-
}, [selectedCredentialId, selectedFile, onChange])
531+
}, [selectedCredentialId, onChange])
543532

544-
// Fetch the selected file metadata once credentials are loaded or changed
533+
// Keep internal selectedFileId in sync with the value prop
545534
useEffect(() => {
546-
// Fetch metadata when the external value doesn't match our current selectedFile
547-
if (
548-
value &&
549-
selectedCredentialId &&
550-
credentialsLoaded &&
551-
(!selectedFile || selectedFile.id !== value) &&
552-
!isLoadingSelectedFile
553-
) {
554-
// Avoid tight retry loops by memoizing the last attempt tuple
555-
const attemptKey = `${selectedCredentialId}::${value}`
556-
if (lastMetaAttemptRef.current === attemptKey) {
557-
return
558-
}
559-
lastMetaAttemptRef.current = attemptKey
560-
561-
if (serviceId === 'microsoft-planner') {
562-
void fetchPlannerTaskById(value)
563-
} else {
564-
void fetchFileById(value)
565-
}
566-
}
567-
}, [
568-
value,
569-
selectedCredentialId,
570-
credentialsLoaded,
571-
selectedFile,
572-
isLoadingSelectedFile,
573-
fetchFileById,
574-
fetchPlannerTaskById,
575-
serviceId,
576-
])
577-
578-
// Resolve planner task selection for collaborators
579-
useEffect(() => {
580-
if (
581-
value &&
582-
selectedCredentialId &&
583-
credentialsLoaded &&
584-
!selectedTask &&
585-
serviceId === 'microsoft-planner'
586-
) {
587-
void fetchPlannerTaskById(value)
535+
if (value !== selectedFileId) {
536+
setSelectedFileId(value)
588537
}
589-
}, [
590-
value,
591-
selectedCredentialId,
592-
credentialsLoaded,
593-
selectedTask,
594-
serviceId,
595-
fetchPlannerTaskById,
596-
])
538+
}, [value, selectedFileId])
597539

598540
// Handle selecting a file from the available files
599541
const handleFileSelect = (file: MicrosoftFileInfo) => {
600542
setSelectedFileId(file.id)
601-
setSelectedFile(file)
602543
onChange(file.id, file)
603544
onFileInfoChange?.(file)
604545
setOpen(false)
@@ -616,7 +557,6 @@ export function MicrosoftFileSelector({
616557
// Clear selection
617558
const handleClearSelection = () => {
618559
setSelectedFileId('')
619-
setSelectedFile(null)
620560
onChange('', undefined)
621561
onFileInfoChange?.(null)
622562
}
@@ -781,13 +721,6 @@ export function MicrosoftFileSelector({
781721
})
782722
: availableFiles
783723

784-
const canShowPreview = !!(
785-
showPreview &&
786-
selectedFile &&
787-
selectedFileId &&
788-
selectedFile.id === selectedFileId
789-
)
790-
791724
return (
792725
<>
793726
<div className='space-y-2'>
@@ -979,68 +912,6 @@ export function MicrosoftFileSelector({
979912
</PopoverContent>
980913
)}
981914
</Popover>
982-
983-
{/* File preview */}
984-
{canShowPreview && (
985-
<div className='relative mt-2 rounded-md border border-muted bg-muted/10 p-2'>
986-
<div className='absolute top-2 right-2'>
987-
<Button
988-
variant='ghost'
989-
size='icon'
990-
className='h-5 w-5 hover:bg-muted'
991-
onClick={handleClearSelection}
992-
>
993-
<X className='h-3 w-3' />
994-
</Button>
995-
</div>
996-
<div className='flex items-center gap-3 pr-4'>
997-
<div className='flex h-6 w-6 flex-shrink-0 items-center justify-center rounded bg-muted/20'>
998-
{getFileIcon(selectedFile, 'sm')}
999-
</div>
1000-
<div className='min-w-0 flex-1 overflow-hidden'>
1001-
<div className='flex items-center gap-2'>
1002-
<h4 className='truncate font-medium text-xs'>{selectedFile.name}</h4>
1003-
{selectedFile.modifiedTime && (
1004-
<span className='whitespace-nowrap text-muted-foreground text-xs'>
1005-
{new Date(selectedFile.modifiedTime).toLocaleDateString()}
1006-
</span>
1007-
)}
1008-
</div>
1009-
{selectedFile.webViewLink ? (
1010-
<a
1011-
href={selectedFile.webViewLink}
1012-
target='_blank'
1013-
rel='noopener noreferrer'
1014-
className='flex items-center gap-1 text-foreground text-xs hover:underline'
1015-
onClick={(e) => e.stopPropagation()}
1016-
>
1017-
<span>
1018-
{serviceId === 'microsoft-planner'
1019-
? 'Open in Planner'
1020-
: serviceId === 'sharepoint'
1021-
? 'Open in SharePoint'
1022-
: 'Open in OneDrive'}
1023-
</span>
1024-
<ExternalLink className='h-3 w-3' />
1025-
</a>
1026-
) : (
1027-
<a
1028-
href={`https://graph.microsoft.com/v1.0/me/drive/items/${selectedFile.id}`}
1029-
target='_blank'
1030-
rel='noopener noreferrer'
1031-
className='flex items-center gap-1 text-foreground text-xs hover:underline'
1032-
onClick={(e) => e.stopPropagation()}
1033-
>
1034-
<span>
1035-
{serviceId === 'sharepoint' ? 'Open in SharePoint' : 'Open in OneDrive'}
1036-
</span>
1037-
<ExternalLink className='h-3 w-3' />
1038-
</a>
1039-
)}
1040-
</div>
1041-
</div>
1042-
</div>
1043-
)}
1044915
</div>
1045916

1046917
{showOAuthModal && (

0 commit comments

Comments
 (0)