Skip to content

Commit f5219d0

Browse files
fix(ms-oauth): oauth edge cases (#1093)
1 parent f0643e0 commit f5219d0

File tree

2 files changed

+14
-13
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/file-selector
    • blocks/blocks

2 files changed

+14
-13
lines changed

apps/sim/app/workspace/[workspaceId]/w/[workflowId]/components/workflow-block/components/sub-block/components/file-selector/file-selector-input.tsx

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import { useParams } from 'next/navigation'
44
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'
55
import { getEnv } from '@/lib/env'
6+
import { getProviderIdFromServiceId } from '@/lib/oauth'
67
import {
78
ConfluenceFileSelector,
89
DiscordChannelSelector,
@@ -73,8 +74,12 @@ export function FileSelectorInput({
7374
const [botTokenValue] = useSubBlockValue(blockId, 'botToken')
7475

7576
// Determine if the persisted credential belongs to the current viewer
77+
// Use service providerId where available (e.g., onedrive/sharepoint) instead of base provider ("microsoft")
78+
const foreignCheckProvider = subBlock.serviceId
79+
? getProviderIdFromServiceId(subBlock.serviceId)
80+
: (subBlock.provider as string) || ''
7681
const { isForeignCredential } = useForeignCredential(
77-
subBlock.provider || subBlock.serviceId || '',
82+
foreignCheckProvider,
7883
(connectedCredential as string) || ''
7984
)
8085

@@ -224,12 +229,6 @@ export function FileSelectorInput({
224229
}
225230
onChange={(issueKey) => {
226231
collaborativeSetSubblockValue(blockId, subBlock.id, issueKey)
227-
// Clear related fields when a new issue is selected
228-
collaborativeSetSubblockValue(blockId, 'summary', '')
229-
collaborativeSetSubblockValue(blockId, 'description', '')
230-
if (!issueKey) {
231-
collaborativeSetSubblockValue(blockId, 'manualIssueKey', '')
232-
}
233232
}}
234233
domain={domain}
235234
provider='jira'
@@ -353,7 +352,7 @@ export function FileSelectorInput({
353352
requiredScopes={subBlock.requiredScopes || []}
354353
serviceId={subBlock.serviceId}
355354
label={subBlock.placeholder || 'Select SharePoint site'}
356-
disabled={disabled || !credential}
355+
disabled={finalDisabled}
357356
showPreview={true}
358357
workflowId={activeWorkflowId || ''}
359358
credentialId={credential}
@@ -389,7 +388,7 @@ export function FileSelectorInput({
389388
requiredScopes={subBlock.requiredScopes || []}
390389
serviceId='microsoft-planner'
391390
label={subBlock.placeholder || 'Select task'}
392-
disabled={disabled || !credential || !planId}
391+
disabled={finalDisabled}
393392
showPreview={true}
394393
planId={planId}
395394
workflowId={activeWorkflowId || ''}
@@ -447,7 +446,7 @@ export function FileSelectorInput({
447446
requiredScopes={subBlock.requiredScopes || []}
448447
serviceId={subBlock.serviceId}
449448
label={subBlock.placeholder || 'Select Teams message location'}
450-
disabled={disabled || !credential}
449+
disabled={finalDisabled}
451450
showPreview={true}
452451
credential={credential}
453452
selectionType={selectionType}
@@ -490,7 +489,7 @@ export function FileSelectorInput({
490489
requiredScopes={subBlock.requiredScopes || []}
491490
serviceId={subBlock.serviceId}
492491
label={subBlock.placeholder || `Select ${itemType}`}
493-
disabled={disabled || !credential}
492+
disabled={finalDisabled}
494493
showPreview={true}
495494
credentialId={credential}
496495
itemType={itemType}
@@ -531,7 +530,7 @@ export function FileSelectorInput({
531530
provider={provider}
532531
requiredScopes={subBlock.requiredScopes || []}
533532
label={subBlock.placeholder || 'Select file'}
534-
disabled={disabled || !credential}
533+
disabled={finalDisabled}
535534
serviceId={subBlock.serviceId}
536535
mimeTypeFilter={subBlock.mimeType}
537536
showPreview={true}

apps/sim/blocks/blocks/jira.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ export const JiraBlock: BlockConfig<JiraResponse> = {
9595
type: 'short-input',
9696
layout: 'full',
9797
placeholder: 'Enter Jira issue key',
98-
dependsOn: ['credential', 'domain', 'projectId'],
98+
dependsOn: ['credential', 'domain', 'projectId', 'issueKey'],
9999
condition: { field: 'operation', value: ['read', 'update'] },
100100
mode: 'advanced',
101101
},
@@ -106,6 +106,7 @@ export const JiraBlock: BlockConfig<JiraResponse> = {
106106
layout: 'full',
107107
required: true,
108108
placeholder: 'Enter new summary for the issue',
109+
dependsOn: ['issueKey'],
109110
condition: { field: 'operation', value: ['update', 'write'] },
110111
},
111112
{
@@ -114,6 +115,7 @@ export const JiraBlock: BlockConfig<JiraResponse> = {
114115
type: 'long-input',
115116
layout: 'full',
116117
placeholder: 'Enter new description for the issue',
118+
dependsOn: ['issueKey'],
117119
condition: { field: 'operation', value: ['update', 'write'] },
118120
},
119121
],

0 commit comments

Comments
 (0)