Skip to content

Commit 378c1b2

Browse files
committed
fix(ux): dropdown reload
1 parent 7049b5a commit 378c1b2

File tree

3 files changed

+62
-61
lines changed

3 files changed

+62
-61
lines changed

sim/app/w/[id]/components/workflow-block/components/sub-block/components/dropdown.tsx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useMemo } from 'react'
1+
import { useMemo } from 'react'
22
import {
33
Select,
44
SelectContent,
@@ -55,13 +55,6 @@ export function Dropdown({ options, defaultValue, blockId, subBlockId }: Dropdow
5555
return undefined
5656
}, [value, defaultValue, evaluatedOptions])
5757

58-
// Set initial default value if current value is null/undefined
59-
useEffect(() => {
60-
if ((value === null || value === undefined) && effectiveValue !== undefined) {
61-
setValue(effectiveValue)
62-
}
63-
}, [value, effectiveValue, setValue])
64-
6558
// Handle the case where evaluatedOptions changes and the current selection is no longer valid
6659
const isValueInOptions = useMemo(() => {
6760
if (!effectiveValue || evaluatedOptions.length === 0) return false

sim/blocks/blocks/drive.ts

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,17 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
2222
icon: GoogleDriveIcon,
2323
subBlocks: [
2424
// Operation selector
25-
{
26-
id: 'operation',
27-
title: 'Operation',
28-
type: 'dropdown',
29-
layout: 'full',
30-
options: [
31-
// { label: 'Upload File', id: 'upload' },
32-
// { label: 'Download File', id: 'download' },
33-
{ label: 'List Files', id: 'list' },
34-
],
35-
},
25+
// {
26+
// id: 'operation',
27+
// title: 'Operation',
28+
// type: 'dropdown',
29+
// layout: 'full',
30+
// options: [
31+
// // { label: 'Upload File', id: 'upload' },
32+
// // { label: 'Download File', id: 'download' },
33+
// { label: 'List Files', id: 'list' },
34+
// ],
35+
// },
3636
// Google Drive Credentials
3737
{
3838
id: 'credential',
@@ -98,7 +98,7 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
9898
requiredScopes: [],
9999
mimeType: 'application/vnd.google-apps.folder',
100100
placeholder: 'Select a folder',
101-
condition: { field: 'operation', value: 'list' },
101+
// condition: { field: 'operation', value: 'list' },
102102
},
103103
// Manual Folder ID input (shown only when no folder is selected)
104104
{
@@ -108,9 +108,11 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
108108
layout: 'full',
109109
placeholder: 'ID of the folder to list (leave empty for root folder)',
110110
condition: {
111-
field: 'operation',
112-
value: 'list',
113-
and: { field: 'folderId', value: '' },
111+
// field: 'operation',
112+
// value: 'list',
113+
// and: {
114+
field: 'folderId', value: ''
115+
// },
114116
},
115117
},
116118
{
@@ -119,31 +121,34 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
119121
type: 'short-input',
120122
layout: 'full',
121123
placeholder: 'Search for specific files (e.g., name contains "report")',
122-
condition: { field: 'operation', value: 'list' },
124+
// condition: { field: 'operation', value: 'list' },
123125
},
124126
{
125127
id: 'pageSize',
126128
title: 'Results Per Page',
127129
type: 'short-input',
128130
layout: 'full',
129131
placeholder: 'Number of results (default: 100, max: 1000)',
130-
condition: { field: 'operation', value: 'list' },
132+
// condition: { field: 'operation', value: 'list' },
131133
},
132134
],
133135
tools: {
134136
access: ['google_drive_upload', 'google_drive_download', 'google_drive_list'],
135137
config: {
136138
tool: (params) => {
137-
switch (params.operation) {
138-
case 'upload':
139-
return 'google_drive_upload'
140-
case 'download':
141-
return 'google_drive_download'
142-
case 'list':
143-
return 'google_drive_list'
144-
default:
145-
throw new Error(`Invalid Google Drive operation: ${params.operation}`)
146-
}
139+
// Since we only have 'list' now, we can simplify this
140+
return 'google_drive_list';
141+
142+
// switch (params.operation) {
143+
// case 'upload':
144+
// return 'google_drive_upload'
145+
// case 'download':
146+
// return 'google_drive_download'
147+
// case 'list':
148+
// return 'google_drive_list'
149+
// default:
150+
// throw new Error(`Invalid Google Drive operation: ${params.operation}`)
151+
// }
147152
},
148153
params: (params) => {
149154
const { credential, folderId, ...rest } = params
@@ -158,7 +163,7 @@ export const GoogleDriveBlock: BlockConfig<GoogleDriveResponse> = {
158163
},
159164
},
160165
inputs: {
161-
operation: { type: 'string', required: true },
166+
// operation: { type: 'string', required: true },
162167
credential: { type: 'string', required: true },
163168
// Upload operation inputs
164169
fileName: { type: 'string', required: false },

sim/blocks/blocks/gmail.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
1313
icon: GmailIcon,
1414
subBlocks: [
1515
// Operation selector
16-
{
17-
id: 'operation',
18-
title: 'Operation',
19-
type: 'dropdown',
20-
layout: 'full',
21-
options: [
22-
{ label: 'Send Email', id: 'send_gmail' },
23-
// { label: 'Read Email', id: 'read_gmail' },
24-
// { label: 'Search Emails', id: 'search_gmail' },
25-
],
26-
},
16+
// {
17+
// id: 'operation',
18+
// title: 'Operation',
19+
// type: 'dropdown',
20+
// layout: 'full',
21+
// options: [
22+
// { label: 'Send Email', id: 'send_gmail' },
23+
// // { label: 'Read Email', id: 'read_gmail' },
24+
// // { label: 'Search Emails', id: 'search_gmail' },
25+
// ],
26+
// },
2727
// Gmail Credentials
2828
{
2929
id: 'credential',
@@ -46,23 +46,23 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
4646
type: 'short-input',
4747
layout: 'full',
4848
placeholder: 'Recipient email address',
49-
condition: { field: 'operation', value: 'send_gmail' },
49+
// condition: { field: 'operation', value: 'send_gmail' },
5050
},
5151
{
5252
id: 'subject',
5353
title: 'Subject',
5454
type: 'short-input',
5555
layout: 'full',
5656
placeholder: 'Email subject',
57-
condition: { field: 'operation', value: 'send_gmail' },
57+
// condition: { field: 'operation', value: 'send_gmail' },
5858
},
5959
{
6060
id: 'body',
6161
title: 'Body',
6262
type: 'long-input',
6363
layout: 'full',
6464
placeholder: 'Email content',
65-
condition: { field: 'operation', value: 'send_gmail' },
65+
// condition: { field: 'operation', value: 'send_gmail' },
6666
},
6767
// Read Email Fields - Add folder selector
6868
// {
@@ -131,16 +131,19 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
131131
access: ['gmail_send', 'gmail_read', 'gmail_search'],
132132
config: {
133133
tool: (params) => {
134-
switch (params.operation) {
135-
case 'send_gmail':
136-
return 'gmail_send'
137-
case 'read_gmail':
138-
return 'gmail_read'
139-
case 'search_gmail':
140-
return 'gmail_search'
141-
default:
142-
throw new Error(`Invalid Gmail operation: ${params.operation}`)
143-
}
134+
// Since we only have send_gmail now, we can simplify this
135+
return 'gmail_send';
136+
137+
// switch (params.operation) {
138+
// case 'send_gmail':
139+
// return 'gmail_send'
140+
// case 'read_gmail':
141+
// return 'gmail_read'
142+
// case 'search_gmail':
143+
// return 'gmail_search'
144+
// default:
145+
// throw new Error(`Invalid Gmail operation: ${params.operation}`)
146+
// }
144147
},
145148
params: (params) => {
146149
// Pass the credential directly from the credential field
@@ -159,7 +162,7 @@ export const GmailBlock: BlockConfig<GmailToolResponse> = {
159162
},
160163
},
161164
inputs: {
162-
operation: { type: 'string', required: true },
165+
// operation: { type: 'string', required: true },
163166
credential: { type: 'string', required: true },
164167
// Send operation inputs
165168
to: { type: 'string', required: false },

0 commit comments

Comments
 (0)