Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
lint
  • Loading branch information
aslilac committed Feb 28, 2024
commit a4d7f27ac9931c955f189b9eed792502096da052
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ import {
} from "components/Form/Form";
import { UserAutocomplete } from "components/UserAutocomplete/UserAutocomplete";
import {
AutofillBuildParameter,
AutofillSource,
type AutofillBuildParameter,
getInitialRichParameterValues,
useValidationSchemaForRichParameters,
} from "utils/richParameters";
Expand All @@ -39,11 +38,11 @@ import {
import { Pill } from "components/Pill/Pill";
import { RichParameterInput } from "components/RichParameterInput/RichParameterInput";
import { generateWorkspaceName } from "modules/workspaces/generateWorkspaceName";
import {
import type {
CreateWorkspaceMode,
ExternalAuthPollingState,
} from "./CreateWorkspacePage";
import { CreateWSPermissions } from "./permissions";
import type { CreateWSPermissions } from "./permissions";

export const Language = {
duplicationWarning:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,11 +159,7 @@ interface FormProps {
onSubmit: (buildParameters: WorkspaceBuildParameter[]) => void;
}

const Form: FC<FormProps> = ({
ephemeralParameters,
buildParameters,
onSubmit,
}) => {
const Form: FC<FormProps> = ({ ephemeralParameters, onSubmit }) => {
const form = useFormik({
initialValues: {
rich_parameter_values: getInitialRichParameterValues(ephemeralParameters),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from "components/Form/Form";
import { RichParameterInput } from "components/RichParameterInput/RichParameterInput";
import {
AutofillBuildParameter,
getInitialRichParameterValues,
useValidationSchemaForRichParameters,
} from "utils/richParameters";
Expand All @@ -28,7 +27,6 @@ export type WorkspaceParametersFormValues = {
interface WorkspaceParameterFormProps {
workspace: Workspace;
templateVersionRichParameters: TemplateVersionParameter[];
autofillParams: AutofillBuildParameter[];
isSubmitting: boolean;
canChangeVersions: boolean;
error: unknown;
Expand All @@ -41,7 +39,6 @@ export const WorkspaceParametersForm: FC<WorkspaceParameterFormProps> = ({
onCancel,
onSubmit,
templateVersionRichParameters,
autofillParams,
error,
canChangeVersions,
isSubmitting,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,29 @@
import { getWorkspaceParameters, postWorkspaceBuild } from "api/api";
import Button from "@mui/material/Button";
import OpenInNewOutlined from "@mui/icons-material/OpenInNewOutlined";
import { type FC } from "react";
import { Helmet } from "react-helmet-async";
import { useMutation, useQuery } from "react-query";
import { useNavigate } from "react-router-dom";
import { getWorkspaceParameters, postWorkspaceBuild } from "api/api";
import type { Workspace, WorkspaceBuildParameter } from "api/typesGenerated";
import { pageTitle } from "utils/page";
import {
WorkspacePermissions,
workspaceChecks,
} from "../../WorkspacePage/permissions";
import { checkAuthorization } from "api/queries/authCheck";
import { useWorkspaceSettings } from "../WorkspaceSettingsLayout";
import { templateByName } from "api/queries/templates";
import { useMutation, useQuery } from "react-query";
import { useWorkspaceSettings } from "../WorkspaceSettingsLayout";
import { Loader } from "components/Loader/Loader";
import {
WorkspaceParametersFormValues,
type WorkspaceParametersFormValues,
WorkspaceParametersForm,
} from "./WorkspaceParametersForm";
import { useNavigate } from "react-router-dom";
import { PageHeader, PageHeaderTitle } from "components/PageHeader/PageHeader";
import { type FC } from "react";
import { isApiValidationError } from "api/errors";
import { ErrorAlert } from "components/Alert/ErrorAlert";
import { Workspace, WorkspaceBuildParameter } from "api/typesGenerated";
import { EmptyState } from "components/EmptyState/EmptyState";
import Button from "@mui/material/Button";
import OpenInNewOutlined from "@mui/icons-material/OpenInNewOutlined";
import { docs } from "utils/docs";
import { AutofillBuildParameter } from "utils/richParameters";

const WorkspaceParametersPage: FC = () => {
const workspace = useWorkspaceSettings();
Expand Down Expand Up @@ -127,12 +126,6 @@ export const WorkspaceParametersPageView: FC<
<WorkspaceParametersForm
workspace={workspace}
canChangeVersions={canChangeVersions}
autofillParams={data.buildParameters.map(
(p): AutofillBuildParameter => ({
...p,
source: "active_build",
}),
)}
templateVersionRichParameters={data.templateVersionRichParameters}
error={submitError}
isSubmitting={isSubmitting}
Expand Down
12 changes: 0 additions & 12 deletions site/src/utils/richParameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,6 @@ export const getInitialRichParameterValues = (
}));
};

const isValidValue = (
templateParam: TemplateVersionParameter,
buildParam: WorkspaceBuildParameter,
) => {
if (templateParam.options.length > 0) {
const validValues = templateParam.options.map((option) => option.value);
return validValues.includes(buildParam.value);
}

return true;
};

export const useValidationSchemaForRichParameters = (
templateParameters?: TemplateVersionParameter[],
lastBuildParameters?: WorkspaceBuildParameter[],
Expand Down