Skip to content

Commit 7c13eb7

Browse files
committed
fix: remove filters
1 parent d109874 commit 7c13eb7

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

site/src/modules/workspaces/DynamicParameter/DynamicParameter.tsx

+1-22
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,6 @@ const ParameterField: FC<ParameterFieldProps> = ({
174174
</SelectTrigger>
175175
<SelectContent>
176176
{parameter.options
177-
.filter(
178-
(option): option is NonNullable<typeof option> =>
179-
option !== null,
180-
)
181177
.map((option) => (
182178
<SelectItem key={option.value.value} value={option.value.value}>
183179
<OptionDisplay option={option} />
@@ -190,7 +186,6 @@ const ParameterField: FC<ParameterFieldProps> = ({
190186
case "multi-select": {
191187
// Map parameter options to MultiSelectCombobox options format
192188
const comboboxOptions: Option[] = parameter.options
193-
.filter((opt): opt is NonNullable<typeof opt> => opt !== null)
194189
.map((opt) => ({
195190
value: opt.value.value,
196191
label: opt.name,
@@ -200,7 +195,6 @@ const ParameterField: FC<ParameterFieldProps> = ({
200195
const defaultOptions: Option[] = JSON.parse(defaultValue).map(
201196
(val: string) => {
202197
const option = parameter.options
203-
.filter((o): o is NonNullable<typeof o> => o !== null)
204198
.find((o) => o.value.value === val);
205199
return {
206200
value: val,
@@ -252,9 +246,6 @@ const ParameterField: FC<ParameterFieldProps> = ({
252246
defaultValue={defaultValue}
253247
>
254248
{parameter.options
255-
.filter(
256-
(option): option is NonNullable<typeof option> => option !== null,
257-
)
258249
.map((option) => (
259250
<div
260251
key={option.value.value}
@@ -294,10 +285,7 @@ const ParameterField: FC<ParameterFieldProps> = ({
294285
const inputProps: Record<string, unknown> = {};
295286

296287
if (parameter.type === "number") {
297-
const validations =
298-
parameter.validations.filter(
299-
(v): v is NonNullable<typeof v> => v !== null,
300-
)[0] || {};
288+
const validations = parameter.validations[0] || {};
301289
const { validation_min, validation_max } = validations;
302290

303291
if (validation_min !== null) {
@@ -366,10 +354,6 @@ const ParameterDiagnostics: FC<ParameterDiagnosticsProps> = ({
366354
return (
367355
<div className="flex flex-col gap-2">
368356
{diagnostics
369-
.filter(
370-
(diagnostic): diagnostic is NonNullable<typeof diagnostic> =>
371-
diagnostic !== null,
372-
)
373357
.map((diagnostic, index) => (
374358
<div
375359
key={`diagnostic-${diagnostic.summary}-${index}`}
@@ -455,10 +439,8 @@ export const useValidationSchemaForDynamicParameters = (
455439
switch (parameter.type) {
456440
case "number": {
457441
const minValidation = parameter.validations
458-
.filter((v): v is NonNullable<typeof v> => v !== null)
459442
.find((v) => v.validation_min !== null);
460443
const maxValidation = parameter.validations
461-
.filter((v): v is NonNullable<typeof v> => v !== null)
462444
.find((v) => v.validation_max !== null);
463445

464446
if (
@@ -569,13 +551,10 @@ const parameterError = (
569551
value?: string,
570552
): string | undefined => {
571553
const validation_error = parameter.validations
572-
.filter((v): v is NonNullable<typeof v> => v !== null)
573554
.find((v) => v.validation_error !== null);
574555
const minValidation = parameter.validations
575-
.filter((v): v is NonNullable<typeof v> => v !== null)
576556
.find((v) => v.validation_min !== null);
577557
const maxValidation = parameter.validations
578-
.filter((v): v is NonNullable<typeof v> => v !== null)
579558
.find((v) => v.validation_max !== null);
580559

581560
if (!validation_error || !value) {

0 commit comments

Comments
 (0)