Skip to content

Commit 239371f

Browse files
committed
all fields work
1 parent 93b7531 commit 239371f

File tree

9 files changed

+121
-26
lines changed

9 files changed

+121
-26
lines changed

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,16 @@ export function FileSelectorInput({
4949
const [teamIdValueFromStore] = useSubBlockValue(blockId, 'teamId')
5050
const [siteIdValueFromStore] = useSubBlockValue(blockId, 'siteId')
5151
const [collectionIdValueFromStore] = useSubBlockValue(blockId, 'collectionId')
52+
const [apiKeyValueFromStore] = useSubBlockValue(blockId, 'apiKey')
53+
const [boardIdValueFromStore] = useSubBlockValue(blockId, 'board_id')
54+
const [boardIdCamelFromStore] = useSubBlockValue(blockId, 'boardId')
55+
const [boardIdListFromStore] = useSubBlockValue(blockId, 'board_id_list')
56+
const [boardIdUpdateFromStore] = useSubBlockValue(blockId, 'board_id_update')
57+
const [groupIdValueFromStore] = useSubBlockValue(blockId, 'group_id')
58+
const [groupIdCamelFromStore] = useSubBlockValue(blockId, 'groupId')
59+
const [groupIdListFromStore] = useSubBlockValue(blockId, 'group_id_list')
60+
const [columnIdValueFromStore] = useSubBlockValue(blockId, 'column_id')
61+
const [columnIdCamelFromStore] = useSubBlockValue(blockId, 'columnId')
5262

5363
const connectedCredential = previewContextValues?.credential ?? connectedCredentialFromStore
5464
const domainValue = previewContextValues?.domain ?? domainValueFromStore
@@ -57,6 +67,25 @@ export function FileSelectorInput({
5767
const teamIdValue = previewContextValues?.teamId ?? teamIdValueFromStore
5868
const siteIdValue = previewContextValues?.siteId ?? siteIdValueFromStore
5969
const collectionIdValue = previewContextValues?.collectionId ?? collectionIdValueFromStore
70+
const apiKeyValue = previewContextValues?.apiKey ?? apiKeyValueFromStore
71+
const boardIdValue =
72+
previewContextValues?.board_id ??
73+
previewContextValues?.boardId ??
74+
boardIdValueFromStore ??
75+
boardIdCamelFromStore ??
76+
boardIdListFromStore ??
77+
boardIdUpdateFromStore
78+
const groupIdValue =
79+
previewContextValues?.group_id ??
80+
previewContextValues?.groupId ??
81+
groupIdValueFromStore ??
82+
groupIdCamelFromStore ??
83+
groupIdListFromStore
84+
const columnIdValue =
85+
previewContextValues?.column_id ??
86+
previewContextValues?.columnId ??
87+
columnIdValueFromStore ??
88+
columnIdCamelFromStore
6089

6190
const normalizedCredentialId =
6291
typeof connectedCredential === 'string'
@@ -81,6 +110,10 @@ export function FileSelectorInput({
81110
teamId: (teamIdValue as string) || undefined,
82111
siteId: (siteIdValue as string) || undefined,
83112
collectionId: (collectionIdValue as string) || undefined,
113+
apiKey: (apiKeyValue as string) || undefined,
114+
boardId: (boardIdValue as string) || undefined,
115+
groupId: (groupIdValue as string) || undefined,
116+
columnId: (columnIdValue as string) || undefined,
84117
})
85118
}, [
86119
subBlock,
@@ -92,9 +125,15 @@ export function FileSelectorInput({
92125
teamIdValue,
93126
siteIdValue,
94127
collectionIdValue,
128+
apiKeyValue,
129+
boardIdValue,
130+
groupIdValue,
131+
columnIdValue,
95132
])
96133

97-
const missingCredential = !normalizedCredentialId
134+
const isMondaySelector = selectorResolution?.key?.startsWith('monday.')
135+
const missingCredential = !isMondaySelector && !normalizedCredentialId
136+
const missingApiKey = isMondaySelector && !selectorResolution?.context.apiKey
98137
const missingDomain =
99138
selectorResolution?.key &&
100139
(selectorResolution.key === 'confluence.pages' || selectorResolution.key === 'jira.issues') &&
@@ -109,16 +148,27 @@ export function FileSelectorInput({
109148
selectorResolution?.key === 'webflow.collections' && !selectorResolution.context.siteId
110149
const missingCollection =
111150
selectorResolution?.key === 'webflow.items' && !selectorResolution.context.collectionId
151+
const missingBoard =
152+
isMondaySelector &&
153+
(selectorResolution?.key === 'monday.groups' || selectorResolution?.key === 'monday.columns') &&
154+
!selectorResolution?.context.boardId
155+
const missingColumn =
156+
isMondaySelector &&
157+
selectorResolution?.key === 'monday.status-options' &&
158+
!selectorResolution?.context.columnId
112159

113160
const disabledReason =
114161
finalDisabled ||
115162
isForeignCredential ||
116163
missingCredential ||
164+
missingApiKey ||
117165
missingDomain ||
118166
missingProject ||
119167
missingPlan ||
120168
missingSite ||
121169
missingCollection ||
170+
missingBoard ||
171+
missingColumn ||
122172
!selectorResolution?.key
123173

124174
if (!selectorResolution?.key) {

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ export function FileSelectorInput({
5454
const [apiKeyValueFromStore] = useSubBlockValue(blockId, 'apiKey')
5555
const [boardIdValueFromStore] = useSubBlockValue(blockId, 'board_id')
5656
const [boardIdCamelFromStore] = useSubBlockValue(blockId, 'boardId')
57+
const [boardIdListFromStore] = useSubBlockValue(blockId, 'board_id_list')
58+
const [boardIdUpdateFromStore] = useSubBlockValue(blockId, 'board_id_update')
59+
const [groupIdValueFromStore] = useSubBlockValue(blockId, 'group_id')
60+
const [groupIdCamelFromStore] = useSubBlockValue(blockId, 'groupId')
61+
const [groupIdListFromStore] = useSubBlockValue(blockId, 'group_id_list')
5762
const [columnIdValueFromStore] = useSubBlockValue(blockId, 'column_id')
5863
const [columnIdCamelFromStore] = useSubBlockValue(blockId, 'columnId')
5964

@@ -66,7 +71,18 @@ export function FileSelectorInput({
6671
const collectionIdValue = previewContextValues?.collectionId ?? collectionIdValueFromStore
6772
const apiKeyValue = previewContextValues?.apiKey ?? apiKeyValueFromStore
6873
const boardIdValue =
69-
previewContextValues?.board_id ?? previewContextValues?.boardId ?? boardIdValueFromStore ?? boardIdCamelFromStore
74+
previewContextValues?.board_id ??
75+
previewContextValues?.boardId ??
76+
boardIdValueFromStore ??
77+
boardIdCamelFromStore ??
78+
boardIdListFromStore ??
79+
boardIdUpdateFromStore
80+
const groupIdValue =
81+
previewContextValues?.group_id ??
82+
previewContextValues?.groupId ??
83+
groupIdValueFromStore ??
84+
groupIdCamelFromStore ??
85+
groupIdListFromStore
7086
const columnIdValue =
7187
previewContextValues?.column_id ??
7288
previewContextValues?.columnId ??
@@ -98,6 +114,7 @@ export function FileSelectorInput({
98114
collectionId: (collectionIdValue as string) || undefined,
99115
apiKey: (apiKeyValue as string) || undefined,
100116
boardId: (boardIdValue as string) || undefined,
117+
groupId: (groupIdValue as string) || undefined,
101118
columnId: (columnIdValue as string) || undefined,
102119
})
103120
}, [
@@ -112,9 +129,15 @@ export function FileSelectorInput({
112129
collectionIdValue,
113130
apiKeyValue,
114131
boardIdValue,
132+
groupIdValue,
115133
columnIdValue,
116134
boardIdValueFromStore,
117135
boardIdCamelFromStore,
136+
boardIdListFromStore,
137+
boardIdUpdateFromStore,
138+
groupIdValueFromStore,
139+
groupIdCamelFromStore,
140+
groupIdListFromStore,
118141
columnIdValueFromStore,
119142
columnIdCamelFromStore,
120143
])

apps/sim/blocks/blocks/monday.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,12 +85,14 @@ export const MondayBlock: BlockConfig<MondayResponse> = {
8585
},
8686
{
8787
id: 'board_id_update',
88-
title: 'Board ID (Optional)',
89-
type: 'short-input',
88+
title: 'Board',
89+
type: 'file-selector',
90+
serviceId: 'monday',
9091
canonicalParamId: 'board_id',
91-
placeholder: 'Enter board ID (recommended)',
92-
required: false,
92+
placeholder: 'Select a Monday.com board',
93+
required: true,
9394
condition: { field: 'operation', value: 'monday_update_item' },
95+
dependsOn: ['apiKey'],
9496
},
9597
{
9698
id: 'column_values_update',

apps/sim/hooks/selectors/resolution.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,22 @@ function resolveFileSelector(
127127
}
128128
return { key: null, context, allowSearch: true }
129129
case 'monday':
130-
if (subBlock.id === 'board_id' || subBlock.id === 'boardId') {
130+
if (
131+
subBlock.id === 'board_id' ||
132+
subBlock.id === 'boardId' ||
133+
subBlock.id === 'board_id_list' ||
134+
subBlock.id === 'board_id_update'
135+
) {
131136
return { key: 'monday.boards', context, allowSearch: true }
132137
}
133138
if (subBlock.id === 'column_id' || subBlock.id === 'columnId') {
134139
return { key: 'monday.columns', context, allowSearch: true }
135140
}
136-
if (subBlock.id === 'group_id' || subBlock.id === 'groupId') {
141+
if (
142+
subBlock.id === 'group_id' ||
143+
subBlock.id === 'groupId' ||
144+
subBlock.id === 'group_id_list'
145+
) {
137146
return { key: 'monday.groups', context, allowSearch: true }
138147
}
139148
if (subBlock.id === 'status_column' || subBlock.id === 'statusColumn') {

apps/sim/hooks/selectors/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ export interface SelectorContext {
5656
collectionId?: string
5757
apiKey?: string
5858
boardId?: string
59+
groupId?: string
5960
columnId?: string
6061
}
6162

apps/sim/serializer/index.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -449,19 +449,26 @@ export class Serializer {
449449
})
450450

451451
// Finally, consolidate canonical parameters (e.g., selector and manual ID into a single param)
452-
const canonicalGroups: Record<string, { basic?: string; advanced: string[] }> = {}
452+
const canonicalGroups: Record<string, { basic: string[]; advanced: string[] }> = {}
453453
blockConfig.subBlocks.forEach((sb) => {
454454
if (!sb.canonicalParamId) return
455455
const key = sb.canonicalParamId
456-
if (!canonicalGroups[key]) canonicalGroups[key] = { basic: undefined, advanced: [] }
456+
if (!canonicalGroups[key]) canonicalGroups[key] = { basic: [], advanced: [] }
457457
if (sb.mode === 'advanced') canonicalGroups[key].advanced.push(sb.id)
458-
else canonicalGroups[key].basic = sb.id
458+
else canonicalGroups[key].basic.push(sb.id)
459459
})
460460

461461
Object.entries(canonicalGroups).forEach(([canonicalKey, group]) => {
462-
const basicId = group.basic
462+
const basicIds = group.basic
463463
const advancedIds = group.advanced
464-
const basicVal = basicId ? params[basicId] : undefined
464+
465+
// Check all basic field IDs for a value (not just the last one)
466+
const basicVal = basicIds
467+
.map((id) => params[id])
468+
.find(
469+
(v) => v !== undefined && v !== null && (typeof v !== 'string' || v.trim().length > 0)
470+
)
471+
465472
const advancedVal = advancedIds
466473
.map((id) => params[id])
467474
.find(
@@ -486,7 +493,7 @@ export class Serializer {
486493
existingCanonicalValue !== null &&
487494
(typeof existingCanonicalValue !== 'string' || existingCanonicalValue.trim().length > 0)
488495

489-
const sourceIds = [basicId, ...advancedIds].filter(Boolean) as string[]
496+
const sourceIds = [...basicIds, ...advancedIds].filter(Boolean) as string[]
490497
sourceIds.forEach((id) => {
491498
if (id !== canonicalKey) delete params[id]
492499
})

apps/sim/tools/monday/graphql.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export const QUERIES = {
111111
`,
112112

113113
UPDATE_ITEM: `
114-
mutation ($boardId: ID, $itemId: ID!, $columnValues: JSON!) {
114+
mutation ($boardId: ID!, $itemId: ID!, $columnValues: JSON!) {
115115
change_multiple_column_values(
116116
board_id: $boardId
117117
item_id: $itemId
@@ -150,9 +150,9 @@ export const QUERIES = {
150150
`,
151151

152152
LIST_ITEMS: `
153-
query ($boardId: [ID!]!, $limit: Int, $groupId: String) {
153+
query ($boardId: [ID!]!, $limit: Int) {
154154
boards(ids: $boardId) {
155-
items_page(limit: $limit, query_params: {rules: [{column_id: "group", compare_value: [$groupId]}]}) {
155+
items_page(limit: $limit) {
156156
items {
157157
id
158158
name

apps/sim/tools/monday/list_items.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,17 @@ export const listItemsTool: ToolConfig<ListItemsParams, ListItemsResponse> = {
4747
'API-Version': '2024-01',
4848
}),
4949
body: (params) => {
50-
const query = params.group_id ? QUERIES.LIST_ITEMS : QUERIES.LIST_ITEMS_NO_FILTER
5150
return {
52-
query,
51+
query: QUERIES.LIST_ITEMS,
5352
variables: {
5453
boardId: [parseInt(params.board_id, 10)],
5554
limit: params.limit || 25,
56-
groupId: params.group_id,
5755
},
5856
}
5957
},
6058
},
6159

62-
transformResponse: async (response: Response): Promise<ListItemsResponse> => {
60+
transformResponse: async (response: Response, params): Promise<ListItemsResponse> => {
6361
if (!response.ok) {
6462
const errorText = await response.text()
6563
logger.error('Monday list items failed', {
@@ -84,9 +82,14 @@ export const listItemsTool: ToolConfig<ListItemsParams, ListItemsResponse> = {
8482
}
8583
}
8684

87-
const items = result.data?.boards?.[0]?.items_page?.items || []
85+
let items = result.data?.boards?.[0]?.items_page?.items || []
8886

89-
logger.info('Monday items listed successfully', { count: items.length })
87+
// Filter by group if group_id is provided
88+
if (params.group_id) {
89+
items = items.filter((item: any) => item.group?.id === params.group_id)
90+
}
91+
92+
logger.info('Monday items listed successfully', { count: items.length, filtered: !!params.group_id })
9093

9194
return {
9295
success: true,

apps/sim/tools/monday/update_item.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ export const updateItemTool: ToolConfig<UpdateItemParams, UpdateItemResponse> =
2626
},
2727
board_id: {
2828
type: 'string',
29-
required: false,
29+
required: true,
3030
visibility: 'user-or-llm',
31-
description: 'The board ID (optional but recommended)',
31+
description: 'The board ID containing the item',
3232
},
3333
column_values: {
3434
type: 'json',
@@ -49,7 +49,7 @@ export const updateItemTool: ToolConfig<UpdateItemParams, UpdateItemResponse> =
4949
body: (params) => ({
5050
query: QUERIES.UPDATE_ITEM,
5151
variables: {
52-
boardId: params.board_id ? parseInt(params.board_id, 10) : undefined,
52+
boardId: parseInt(params.board_id, 10),
5353
itemId: parseInt(params.item_id, 10),
5454
columnValues: JSON.stringify(params.column_values),
5555
},

0 commit comments

Comments
 (0)