Skip to content

Commit f39a305

Browse files
committed
address comments
1 parent 33cf0de commit f39a305

File tree

3 files changed

+26
-21
lines changed
  • apps/sim
    • app/workspace/[workspaceId]/w/[workflowId]/components/panel/components/editor/components/sub-block/components/dropdown
    • components/emcn/components/combobox
    • triggers/grain

3 files changed

+26
-21
lines changed

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

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -210,31 +210,23 @@ export const Dropdown = memo(function Dropdown({
210210
return opts
211211
}, [fetchOptions, normalizedFetchedOptions, evaluatedOptions, hydratedOption])
212212

213-
const selectableOptions = useMemo(() => {
214-
return allOptions.filter((opt) => typeof opt === 'string' || !opt.hidden)
215-
}, [allOptions])
216-
217213
const comboboxOptions = useMemo((): ComboboxOption[] => {
218-
return selectableOptions.map((opt) => {
214+
return allOptions.map((opt) => {
219215
if (typeof opt === 'string') {
220216
return { label: opt.toLowerCase(), value: opt }
221217
}
222218
return {
223219
label: opt.label.toLowerCase(),
224220
value: opt.id,
225221
icon: 'icon' in opt ? opt.icon : undefined,
222+
hidden: opt.hidden,
226223
}
227224
})
228-
}, [selectableOptions])
225+
}, [allOptions])
229226

230227
const optionMap = useMemo(() => {
231-
return new Map(
232-
allOptions.map((opt) => {
233-
if (typeof opt === 'string') return [opt, opt.toLowerCase()]
234-
return [opt.id, opt.label.toLowerCase()]
235-
})
236-
)
237-
}, [allOptions])
228+
return new Map(comboboxOptions.map((opt) => [opt.value, opt.label]))
229+
}, [comboboxOptions])
238230

239231
const defaultOptionValue = useMemo(() => {
240232
if (multiSelect) return undefined

apps/sim/components/emcn/components/combobox/combobox.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ const comboboxVariants = cva(
4545
export type ComboboxOption = {
4646
label: string
4747
value: string
48+
/** When true, hidden from the picker list but still resolves for display */
49+
hidden?: boolean
4850
/** Icon component to render */
4951
icon?: React.ComponentType<{ className?: string }>
5052
/** Pre-rendered icon element (alternative to icon component) */
@@ -207,12 +209,11 @@ const Combobox = memo(
207209
* Filter options based on current value or search query
208210
*/
209211
const filteredOptions = useMemo(() => {
210-
let result = allOptions
212+
let result = allOptions.filter((opt) => !opt.hidden)
211213

212-
// Filter by editable input value
213214
if (filterOptions && value && open) {
214215
const currentValue = value.toString().toLowerCase()
215-
const exactMatch = allOptions.find(
216+
const exactMatch = result.find(
216217
(opt) => opt.value === value || opt.label.toLowerCase() === currentValue
217218
)
218219
if (!exactMatch) {
@@ -224,7 +225,6 @@ const Combobox = memo(
224225
}
225226
}
226227

227-
// Filter by search query (for searchable mode)
228228
if (searchable && searchQuery) {
229229
const query = searchQuery.toLowerCase()
230230
result = result.filter((option) => {
@@ -242,10 +242,18 @@ const Combobox = memo(
242242
*/
243243
const filteredGroups = useMemo(() => {
244244
if (!groups) return null
245-
if (!searchable || !searchQuery) return groups
245+
246+
const baseGroups = groups
247+
.map((group) => ({
248+
...group,
249+
items: group.items.filter((opt) => !opt.hidden),
250+
}))
251+
.filter((group) => group.items.length > 0)
252+
253+
if (!searchable || !searchQuery) return baseGroups
246254

247255
const query = searchQuery.toLowerCase()
248-
return groups
256+
return baseGroups
249257
.map((group) => ({
250258
...group,
251259
items: group.items.filter((option) => {

apps/sim/triggers/grain/utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,15 @@ export function grainSetupInstructions(eventType: string): string {
3939
/**
4040
* Setup instructions for the v2 triggers that correctly explain view-based scoping.
4141
*/
42-
export function grainV2SetupInstructions(action: string): string {
42+
export function grainV2SetupInstructions(action: 'item added' | 'item updated' | 'all'): string {
43+
const viewSentence =
44+
action === 'all'
45+
? 'Enter a Grain <strong>view ID</strong>. Each view has a type &mdash; <em>recordings</em>, <em>highlights</em>, or <em>stories</em> &mdash; and this trigger will fire on every event (added, updated, or removed) for items in that view.'
46+
: `Enter a Grain <strong>view ID</strong>. Each view has a type &mdash; <em>recordings</em>, <em>highlights</em>, or <em>stories</em> &mdash; and only items matching that type will fire the <strong>${action}</strong> event.`
47+
4348
const instructions = [
4449
'Enter your Grain API Key (Personal Access Token). You can find or create one in Grain at <strong>Workspace Settings &gt; API</strong> under Integrations on <a href="https://grain.com/app/settings/integrations?tab=api" target="_blank" rel="noopener noreferrer">grain.com</a>.',
45-
`Enter a Grain <strong>view ID</strong>. Each view has a type &mdash; <em>recordings</em>, <em>highlights</em>, or <em>stories</em> &mdash; and only items matching that type will fire the <strong>${action}</strong> event.`,
50+
viewSentence,
4651
'To find your view IDs, use the <strong>List Views</strong> operation on this block or call <code>GET /_/public-api/views</code> directly.',
4752
'The webhook is created automatically when you save and will be deleted when you remove this trigger.',
4853
]

0 commit comments

Comments
 (0)