Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8d1821a

Browse files
committed
oh boy
1 parent 1f3ed28 commit 8d1821a

File tree

2 files changed

+16
-31
lines changed

2 files changed

+16
-31
lines changed

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

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ import {
4747
} from "lucide-react";
4848
import { type FC, useEffect, useId, useRef, useState } from "react";
4949
import type { AutofillBuildParameter } from "utils/richParameters";
50-
import { maskText } from "utils/text";
5150
import * as Yup from "yup";
5251

5352
interface DynamicParameterProps {
@@ -82,7 +81,7 @@ export const DynamicParameter: FC<DynamicParameterProps> = ({
8281
/>
8382
<div className="max-w-lg">
8483
{parameter.form_type === "input" ||
85-
parameter.form_type === "textarea" ? (
84+
parameter.form_type === "textarea" ? (
8685
<DebouncedParameterField
8786
id={id}
8887
parameter={parameter}
@@ -313,16 +312,13 @@ const DebouncedParameterField: FC<DebouncedParameterFieldProps> = ({
313312

314313
switch (parameter.form_type) {
315314
case "textarea": {
316-
const shouldMask = parameter.styling?.mask_input && !showMaskedInput;
317-
const displayValue = shouldMask ? maskText(localValue) : localValue;
318-
319315
return (
320316
<div className="relative">
321317
<Textarea
322318
ref={textareaRef}
323319
id={id}
324320
className="overflow-y-auto max-h-[500px]"
325-
value={displayValue}
321+
value={localValue}
326322
onChange={(e) => {
327323
const target = e.currentTarget;
328324
target.style.height = "auto";
@@ -355,7 +351,12 @@ const DebouncedParameterField: FC<DebouncedParameterFieldProps> = ({
355351
}
356352

357353
case "input": {
358-
const inputType = parameter.type === "number" ? "number" : "text";
354+
const inputType =
355+
parameter.type === "number"
356+
? "number"
357+
: parameter.styling?.mask_input && !showMaskedInput
358+
? "password"
359+
: "text";
359360
const inputProps: Record<string, unknown> = {};
360361

361362
if (parameter.type === "number") {
@@ -371,18 +372,12 @@ const DebouncedParameterField: FC<DebouncedParameterFieldProps> = ({
371372
}
372373
}
373374

374-
const shouldMask =
375-
parameter.styling?.mask_input &&
376-
!showMaskedInput &&
377-
parameter.type !== "number";
378-
const displayValue = shouldMask ? maskText(localValue) : localValue;
379-
380375
return (
381376
<div className="relative">
382377
<Input
383378
id={id}
384379
type={inputType}
385-
value={displayValue}
380+
value={localValue}
386381
onChange={(e) => {
387382
setLocalValue(e.target.value);
388383
}}
@@ -686,11 +681,10 @@ const ParameterDiagnostics: FC<ParameterDiagnosticsProps> = ({
686681
return (
687682
<div
688683
key={`parameter-diagnostic-${diagnostic.summary}-${index}`}
689-
className={`text-xs px-1 ${
690-
diagnostic.severity === "error"
684+
className={`text-xs px-1 ${diagnostic.severity === "error"
691685
? "text-content-destructive"
692686
: "text-content-warning"
693-
}`}
687+
}`}
694688
>
695689
<p className="font-medium">{diagnostic.summary}</p>
696690
{diagnostic.detail && <p className="m-0">{diagnostic.detail}</p>}
@@ -745,7 +739,7 @@ const isValidParameterOption = (
745739
if (Array.isArray(parsed)) {
746740
values = parsed;
747741
}
748-
} catch (e) {
742+
} catch {
749743
return false;
750744
}
751745

@@ -947,11 +941,10 @@ export const Diagnostics: FC<DiagnosticsProps> = ({ diagnostics }) => {
947941
<div
948942
key={`diagnostic-${diagnostic.summary}-${index}`}
949943
className={`text-xs font-semibold flex flex-col rounded-md border px-3.5 py-3.5 border-solid
950-
${
951-
diagnostic.severity === "error"
952-
? "text-content-primary border-border-destructive bg-content-destructive/15"
953-
: "text-content-primary border-border-warning bg-content-warning/15"
954-
}`}
944+
${diagnostic.severity === "error"
945+
? "text-content-primary border-border-destructive bg-content-destructive/15"
946+
: "text-content-primary border-border-warning bg-content-warning/15"
947+
}`}
955948
>
956949
<div className="flex flex-row items-start">
957950
{diagnostic.severity === "error" && (

site/src/utils/text.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,3 @@ export const ellipsizeText = (
1212
? text
1313
: `${text.substr(0, maxLength - 3)}...`;
1414
};
15-
16-
/**
17-
* Returns a string of the same length, using the unicode "bullet" character as
18-
* a replacement for each character, like a password input would.
19-
*/
20-
export function maskText(val: string): string {
21-
return "\u2022".repeat(val.length);
22-
}

0 commit comments

Comments
 (0)