Skip to content

Commit b7550bf

Browse files
chore(site): remove unecessary types and move types to where they are used (#9621)
1 parent 0e28397 commit b7550bf

File tree

21 files changed

+70
-87
lines changed

21 files changed

+70
-87
lines changed

site/src/api/api.ts

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import axios from "axios";
22
import dayjs from "dayjs";
3-
import * as Types from "./types";
4-
import { DeploymentConfig } from "./types";
53
import * as TypesGen from "./typesGenerated";
64
import { delay } from "utils/delay";
75
import userAgentParser from "ua-parser-js";
@@ -365,8 +363,8 @@ export const createTemplate = async (
365363
export const updateActiveTemplateVersion = async (
366364
templateId: string,
367365
data: TypesGen.UpdateActiveTemplateVersion,
368-
): Promise<Types.Message> => {
369-
const response = await axios.patch<Types.Message>(
366+
) => {
367+
const response = await axios.patch<TypesGen.Response>(
370368
`/api/v2/templates/${templateId}/versions`,
371369
data,
372370
);
@@ -547,7 +545,7 @@ export const deleteWorkspace = (
547545

548546
export const cancelWorkspaceBuild = async (
549547
workspaceBuildId: TypesGen.WorkspaceBuild["id"],
550-
): Promise<Types.Message> => {
548+
): Promise<TypesGen.Response> => {
551549
const response = await axios.patch(
552550
`/api/v2/workspacebuilds/${workspaceBuildId}/cancel`,
553551
);
@@ -595,7 +593,7 @@ export const restartWorkspace = async ({
595593

596594
export const cancelTemplateVersionBuild = async (
597595
templateVersionId: TypesGen.TemplateVersion["id"],
598-
): Promise<Types.Message> => {
596+
): Promise<TypesGen.Response> => {
599597
const response = await axios.patch(
600598
`/api/v2/templateversions/${templateVersionId}/cancel`,
601599
);
@@ -985,6 +983,29 @@ export const getDeploymentSSHConfig =
985983
return response.data;
986984
};
987985

986+
// The Deployment types are not generated on from the Go generator yet because
987+
// it does not know how to generate OptionSet
988+
export interface DeploymentGroup {
989+
readonly name: string;
990+
readonly parent?: DeploymentGroup;
991+
readonly description: string;
992+
readonly children: DeploymentGroup[];
993+
}
994+
export interface DeploymentOption {
995+
readonly name: string;
996+
readonly description: string;
997+
readonly flag: string;
998+
readonly flag_shorthand: string;
999+
readonly value: unknown;
1000+
readonly hidden: boolean;
1001+
readonly group?: DeploymentGroup;
1002+
}
1003+
1004+
export type DeploymentConfig = {
1005+
readonly config: TypesGen.DeploymentValues;
1006+
readonly options: DeploymentOption[];
1007+
};
1008+
9881009
export const getDeploymentValues = async (): Promise<DeploymentConfig> => {
9891010
const response = await axios.get(`/api/v2/deployment/config`);
9901011
return response.data;

site/src/api/types.ts

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

site/src/components/DeploySettingsLayout/DeploySettingsLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { deploymentConfigMachine } from "xServices/deploymentConfig/deploymentCo
1010
import { RequirePermission } from "components/RequirePermission/RequirePermission";
1111
import { usePermissions } from "hooks/usePermissions";
1212
import { Outlet } from "react-router-dom";
13-
import { DeploymentConfig } from "api/types";
13+
import { DeploymentConfig } from "api/api";
1414

1515
type DeploySettingsContextValue = {
1616
deploymentValues: DeploymentConfig;

site/src/components/DeploySettingsLayout/OptionsTable.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@ import TableCell from "@mui/material/TableCell";
55
import TableContainer from "@mui/material/TableContainer";
66
import TableHead from "@mui/material/TableHead";
77
import TableRow from "@mui/material/TableRow";
8-
import { DeploymentOption } from "api/types";
98
import {
109
OptionDescription,
1110
OptionName,
1211
OptionValue,
1312
} from "components/DeploySettingsLayout/Option";
1413
import { FC } from "react";
1514
import { optionValue } from "./optionValue";
15+
import { DeploymentOption } from "api/api";
1616

1717
const OptionsTable: FC<{
1818
options: DeploymentOption[];

site/src/components/DeploySettingsLayout/optionValue.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1+
import { DeploymentOption } from "api/api";
12
import { optionValue } from "./optionValue";
2-
import { DeploymentOption } from "api/types";
33

44
const defaultOption: DeploymentOption = {
55
name: "",

site/src/components/DeploySettingsLayout/optionValue.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeploymentOption } from "api/types";
1+
import { DeploymentOption } from "api/api";
22
import { intervalToDuration, formatDuration } from "date-fns";
33

44
// optionValue is a helper function to format the value of a specific deployment options

site/src/pages/DeploySettingsPage/GeneralSettingsPage/GeneralSettingsPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import Box from "@mui/material/Box";
2-
import { DeploymentOption } from "api/types";
32
import { DAUsResponse } from "api/typesGenerated";
43
import { ErrorAlert } from "components/Alert/ErrorAlert";
54
import { DAUChart, DAUTitle } from "components/DAUChart/DAUChart";
@@ -9,6 +8,7 @@ import { Stack } from "components/Stack/Stack";
98
import { ChartSection } from "./ChartSection";
109
import { useDeploymentOptions } from "utils/deployOptions";
1110
import { docs } from "utils/docs";
11+
import { DeploymentOption } from "api/api";
1212

1313
export type GeneralSettingsPageViewProps = {
1414
deploymentOptions: DeploymentOption[];

site/src/pages/DeploySettingsPage/NetworkSettingsPage/NetworkSettingsPageView.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeploymentGroup } from "api/types";
1+
import { DeploymentGroup } from "api/api";
22
import { NetworkSettingsPageView } from "./NetworkSettingsPageView";
33
import type { Meta, StoryObj } from "@storybook/react";
44

site/src/pages/DeploySettingsPage/NetworkSettingsPage/NetworkSettingsPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeploymentOption } from "api/types";
1+
import { DeploymentOption } from "api/api";
22
import {
33
Badges,
44
EnabledBadge,

site/src/pages/DeploySettingsPage/SecuritySettingsPage/SecuritySettingsPageView.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { DeploymentGroup, DeploymentOption } from "api/types";
1+
import { DeploymentGroup, DeploymentOption } from "api/api";
22
import { SecuritySettingsPageView } from "./SecuritySettingsPageView";
33
import type { Meta, StoryObj } from "@storybook/react";
44

0 commit comments

Comments
 (0)