Skip to content

Commit dd5147d

Browse files
committed
fix: remove filters
1 parent 5784127 commit dd5147d

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

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

Lines changed: 1 addition & 25 deletions
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}`}
@@ -425,7 +409,6 @@ const isValidValue = (
425409
) => {
426410
if (previewParam.options.length > 0) {
427411
const validValues = previewParam.options
428-
.filter((option): option is NonNullable<typeof option> => option !== null)
429412
.map((option) => option.value.value);
430413
return validValues.includes(buildParam.value);
431414
}
@@ -455,10 +438,8 @@ export const useValidationSchemaForDynamicParameters = (
455438
switch (parameter.type) {
456439
case "number": {
457440
const minValidation = parameter.validations
458-
.filter((v): v is NonNullable<typeof v> => v !== null)
459441
.find((v) => v.validation_min !== null);
460442
const maxValidation = parameter.validations
461-
.filter((v): v is NonNullable<typeof v> => v !== null)
462443
.find((v) => v.validation_max !== null);
463444

464445
if (
@@ -506,7 +487,6 @@ export const useValidationSchemaForDynamicParameters = (
506487
}
507488

508489
const monotonic = parameter.validations
509-
.filter((v): v is NonNullable<typeof v> => v !== null)
510490
.find(
511491
(v) =>
512492
v.validation_monotonic !== null &&
@@ -542,7 +522,6 @@ export const useValidationSchemaForDynamicParameters = (
542522
}
543523
case "string": {
544524
const regex = parameter.validations
545-
.filter((v): v is NonNullable<typeof v> => v !== null)
546525
.find(
547526
(v) =>
548527
v.validation_regex !== null &&
@@ -574,13 +553,10 @@ const parameterError = (
574553
value?: string,
575554
): string | undefined => {
576555
const validation_error = parameter.validations
577-
.filter((v): v is NonNullable<typeof v> => v !== null)
578556
.find((v) => v.validation_error !== null);
579557
const minValidation = parameter.validations
580-
.filter((v): v is NonNullable<typeof v> => v !== null)
581558
.find((v) => v.validation_min !== null);
582559
const maxValidation = parameter.validations
583-
.filter((v): v is NonNullable<typeof v> => v !== null)
584560
.find((v) => v.validation_max !== null);
585561

586562
if (!validation_error || !value) {

0 commit comments

Comments
 (0)