Skip to content

Commit 3b8d5a5

Browse files
committed
chore: remove unused typesParameter.ts
1 parent dd5147d commit 3b8d5a5

File tree

4 files changed

+76
-201
lines changed

4 files changed

+76
-201
lines changed

site/src/api/typesParameter.ts

Lines changed: 0 additions & 124 deletions
This file was deleted.

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

Lines changed: 65 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -173,29 +173,26 @@ const ParameterField: FC<ParameterFieldProps> = ({
173173
<SelectValue placeholder="Select option" />
174174
</SelectTrigger>
175175
<SelectContent>
176-
{parameter.options
177-
.map((option) => (
178-
<SelectItem key={option.value.value} value={option.value.value}>
179-
<OptionDisplay option={option} />
180-
</SelectItem>
181-
))}
176+
{parameter.options.map((option) => (
177+
<SelectItem key={option.value.value} value={option.value.value}>
178+
<OptionDisplay option={option} />
179+
</SelectItem>
180+
))}
182181
</SelectContent>
183182
</Select>
184183
);
185184

186185
case "multi-select": {
187186
// Map parameter options to MultiSelectCombobox options format
188-
const comboboxOptions: Option[] = parameter.options
189-
.map((opt) => ({
190-
value: opt.value.value,
191-
label: opt.name,
192-
disable: false,
193-
}));
187+
const comboboxOptions: Option[] = parameter.options.map((opt) => ({
188+
value: opt.value.value,
189+
label: opt.name,
190+
disable: false,
191+
}));
194192

195193
const defaultOptions: Option[] = JSON.parse(defaultValue).map(
196194
(val: string) => {
197-
const option = parameter.options
198-
.find((o) => o.value.value === val);
195+
const option = parameter.options.find((o) => o.value.value === val);
199196
return {
200197
value: val,
201198
label: option?.name || val,
@@ -245,21 +242,20 @@ const ParameterField: FC<ParameterFieldProps> = ({
245242
disabled={disabled}
246243
defaultValue={defaultValue}
247244
>
248-
{parameter.options
249-
.map((option) => (
250-
<div
251-
key={option.value.value}
252-
className="flex items-center space-x-2"
253-
>
254-
<RadioGroupItem
255-
id={option.value.value}
256-
value={option.value.value}
257-
/>
258-
<Label htmlFor={option.value.value} className="cursor-pointer">
259-
<OptionDisplay option={option} />
260-
</Label>
261-
</div>
262-
))}
245+
{parameter.options.map((option) => (
246+
<div
247+
key={option.value.value}
248+
className="flex items-center space-x-2"
249+
>
250+
<RadioGroupItem
251+
id={option.value.value}
252+
value={option.value.value}
253+
/>
254+
<Label htmlFor={option.value.value} className="cursor-pointer">
255+
<OptionDisplay option={option} />
256+
</Label>
257+
</div>
258+
))}
263259
</RadioGroup>
264260
);
265261

@@ -353,20 +349,19 @@ const ParameterDiagnostics: FC<ParameterDiagnosticsProps> = ({
353349
}) => {
354350
return (
355351
<div className="flex flex-col gap-2">
356-
{diagnostics
357-
.map((diagnostic, index) => (
358-
<div
359-
key={`diagnostic-${diagnostic.summary}-${index}`}
360-
className={`text-xs px-1 ${
361-
diagnostic.severity === "error"
362-
? "text-content-destructive"
363-
: "text-content-warning"
364-
}`}
365-
>
366-
<div className="font-medium">{diagnostic.summary}</div>
367-
{diagnostic.detail && <div>{diagnostic.detail}</div>}
368-
</div>
369-
))}
352+
{diagnostics.map((diagnostic, index) => (
353+
<div
354+
key={`diagnostic-${diagnostic.summary}-${index}`}
355+
className={`text-xs px-1 ${
356+
diagnostic.severity === "error"
357+
? "text-content-destructive"
358+
: "text-content-warning"
359+
}`}
360+
>
361+
<div className="font-medium">{diagnostic.summary}</div>
362+
{diagnostic.detail && <div>{diagnostic.detail}</div>}
363+
</div>
364+
))}
370365
</div>
371366
);
372367
};
@@ -408,8 +403,9 @@ const isValidValue = (
408403
buildParam: WorkspaceBuildParameter,
409404
) => {
410405
if (previewParam.options.length > 0) {
411-
const validValues = previewParam.options
412-
.map((option) => option.value.value);
406+
const validValues = previewParam.options.map(
407+
(option) => option.value.value,
408+
);
413409
return validValues.includes(buildParam.value);
414410
}
415411

@@ -437,10 +433,12 @@ export const useValidationSchemaForDynamicParameters = (
437433
if (parameter) {
438434
switch (parameter.type) {
439435
case "number": {
440-
const minValidation = parameter.validations
441-
.find((v) => v.validation_min !== null);
442-
const maxValidation = parameter.validations
443-
.find((v) => v.validation_max !== null);
436+
const minValidation = parameter.validations.find(
437+
(v) => v.validation_min !== null,
438+
);
439+
const maxValidation = parameter.validations.find(
440+
(v) => v.validation_max !== null,
441+
);
444442

445443
if (
446444
minValidation &&
@@ -486,12 +484,11 @@ export const useValidationSchemaForDynamicParameters = (
486484
});
487485
}
488486

489-
const monotonic = parameter.validations
490-
.find(
491-
(v) =>
492-
v.validation_monotonic !== null &&
493-
v.validation_monotonic !== "",
494-
);
487+
const monotonic = parameter.validations.find(
488+
(v) =>
489+
v.validation_monotonic !== null &&
490+
v.validation_monotonic !== "",
491+
);
495492

496493
if (monotonic && lastBuildParameters) {
497494
const lastBuildParameter = lastBuildParameters.find(
@@ -521,12 +518,10 @@ export const useValidationSchemaForDynamicParameters = (
521518
break;
522519
}
523520
case "string": {
524-
const regex = parameter.validations
525-
.find(
526-
(v) =>
527-
v.validation_regex !== null &&
528-
v.validation_regex !== "",
529-
);
521+
const regex = parameter.validations.find(
522+
(v) =>
523+
v.validation_regex !== null && v.validation_regex !== "",
524+
);
530525
if (!regex || !regex.validation_regex) {
531526
return true;
532527
}
@@ -552,12 +547,15 @@ const parameterError = (
552547
parameter: PreviewParameter,
553548
value?: string,
554549
): string | undefined => {
555-
const validation_error = parameter.validations
556-
.find((v) => v.validation_error !== null);
557-
const minValidation = parameter.validations
558-
.find((v) => v.validation_min !== null);
559-
const maxValidation = parameter.validations
560-
.find((v) => v.validation_max !== null);
550+
const validation_error = parameter.validations.find(
551+
(v) => v.validation_error !== null,
552+
);
553+
const minValidation = parameter.validations.find(
554+
(v) => v.validation_min !== null,
555+
);
556+
const maxValidation = parameter.validations.find(
557+
(v) => v.validation_max !== null,
558+
);
561559

562560
if (!validation_error || !value) {
563561
return;

site/src/pages/CreateWorkspacePage/CreateWorkspacePageExperimental.tsx

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ import {
66
templateVersionPresets,
77
} from "api/queries/templates";
88
import { autoCreateWorkspace, createWorkspace } from "api/queries/workspaces";
9-
import type { Template, Workspace } from "api/typesGenerated";
9+
import type {
10+
DynamicParametersResponse,
11+
Template,
12+
Workspace,
13+
} from "api/typesGenerated";
1014
import { Loader } from "components/Loader/Loader";
1115
import { useAuthenticated } from "contexts/auth/RequireAuth";
1216
import { useEffectEvent } from "hooks/hookPolyfills";
@@ -27,7 +31,6 @@ import type { AutofillBuildParameter } from "utils/richParameters";
2731
import { CreateWorkspacePageViewExperimental } from "./CreateWorkspacePageViewExperimental";
2832
export const createWorkspaceModes = ["form", "auto", "duplicate"] as const;
2933
export type CreateWorkspaceMode = (typeof createWorkspaceModes)[number];
30-
import type { Response } from "api/typesParameter";
3134
import { useWebSocket } from "hooks/useWebsocket";
3235
import {
3336
type CreateWorkspacePermissions,
@@ -46,14 +49,11 @@ const CreateWorkspacePageExperimental: FC = () => {
4649
const navigate = useNavigate();
4750
const [searchParams] = useSearchParams();
4851

49-
const [currentResponse, setCurrentResponse] = useState<Response | null>(null);
52+
const [currentResponse, setCurrentResponse] =
53+
useState<DynamicParametersResponse | null>(null);
5054
const [wsResponseId, setWSResponseId] = useState<number>(0);
51-
const { message: webSocketResponse, sendMessage } = useWebSocket<Response>(
52-
wsUrl,
53-
urlTestdata,
54-
"",
55-
"",
56-
);
55+
const { message: webSocketResponse, sendMessage } =
56+
useWebSocket<DynamicParametersResponse>(wsUrl, urlTestdata, "", "");
5757

5858
useEffect(() => {
5959
if (webSocketResponse && webSocketResponse.id >= wsResponseId) {

site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,8 @@ export const CreateWorkspacePageViewExperimental: FC<
320320
dismissible
321321
data-testid="duplication-warning"
322322
>
323-
Duplicating a workspace only copies its parameters. No state from the old workspace is copied over.
323+
Duplicating a workspace only copies its parameters. No state from
324+
the old workspace is copied over.
324325
</Alert>
325326
)}
326327

0 commit comments

Comments
 (0)