Skip to content

Commit 6877142

Browse files
authored
feat: create experimental template embed page for dynamic params (#17999)
resolves coder/preview#58
1 parent 7dd90f3 commit 6877142

File tree

10 files changed

+493
-8
lines changed

10 files changed

+493
-8
lines changed

site/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
"@radix-ui/react-radio-group": "1.2.3",
6565
"@radix-ui/react-scroll-area": "1.2.3",
6666
"@radix-ui/react-select": "2.1.4",
67+
"@radix-ui/react-separator": "1.1.7",
6768
"@radix-ui/react-slider": "1.2.2",
6869
"@radix-ui/react-slot": "1.1.1",
6970
"@radix-ui/react-switch": "1.1.1",

site/pnpm-lock.yaml

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as SeparatorPrimitive from "@radix-ui/react-separator";
2+
/**
3+
* Copied from shadc/ui on 06/20/2025
4+
* @see {@link https://ui.shadcn.com/docs/components/separator}
5+
*/
6+
import type * as React from "react";
7+
8+
import { cn } from "utils/cn";
9+
10+
function Separator({
11+
className,
12+
orientation = "horizontal",
13+
decorative = true,
14+
...props
15+
}: React.ComponentProps<typeof SeparatorPrimitive.Root>) {
16+
return (
17+
<SeparatorPrimitive.Root
18+
data-slot="separator"
19+
decorative={decorative}
20+
orientation={orientation}
21+
className={cn(
22+
"bg-border shrink-0 data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
23+
className,
24+
)}
25+
{...props}
26+
/>
27+
);
28+
}
29+
30+
export { Separator };
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copied from shadc/ui on 06/20/2025
3+
* @see {@link https://ui.shadcn.com/docs/components/skeleton}
4+
*/
5+
import { cn } from "utils/cn";
6+
7+
function Skeleton({ className, ...props }: React.ComponentProps<"div">) {
8+
return (
9+
<div
10+
data-slot="skeleton"
11+
className={cn("bg-surface-tertiary animate-pulse rounded-md", className)}
12+
{...props}
13+
/>
14+
);
15+
}
16+
17+
export { Skeleton };

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ interface DynamicParameterProps {
5252
onChange: (value: string) => void;
5353
disabled?: boolean;
5454
isPreset?: boolean;
55-
autofill: boolean;
55+
autofill?: boolean;
5656
}
5757

5858
export const DynamicParameter: FC<DynamicParameterProps> = ({
@@ -873,7 +873,6 @@ interface DiagnosticsProps {
873873
diagnostics: PreviewParameter["diagnostics"];
874874
}
875875

876-
// Displays a diagnostic with a border, icon and background color
877876
export const Diagnostics: FC<DiagnosticsProps> = ({ diagnostics }) => {
878877
return (
879878
<div className="flex flex-col gap-4">

site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ import { type FormikContextType, useFormik } from "formik";
2929
import type { ExternalAuthPollingState } from "hooks/useExternalAuth";
3030
import { ArrowLeft, CircleHelp } from "lucide-react";
3131
import { useSyncFormParameters } from "modules/hooks/useSyncFormParameters";
32-
import { Diagnostics } from "modules/workspaces/DynamicParameter/DynamicParameter";
3332
import {
33+
Diagnostics,
3434
DynamicParameter,
3535
getInitialParameterValues,
3636
useValidationSchemaForDynamicParameters,
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { templateByName } from "api/queries/templates";
2+
import { ErrorAlert } from "components/Alert/ErrorAlert";
3+
import { Loader } from "components/Loader/Loader";
4+
import type { FC } from "react";
5+
import { useQuery } from "react-query";
6+
import { useParams } from "react-router-dom";
7+
import TemplateEmbedPage from "./TemplateEmbedPage";
8+
import TemplateEmbedPageExperimental from "./TemplateEmbedPageExperimental";
9+
10+
const TemplateEmbedExperimentRouter: FC = () => {
11+
const { organization: organizationName = "default", template: templateName } =
12+
useParams() as { organization?: string; template: string };
13+
const templateQuery = useQuery(
14+
templateByName(organizationName, templateName),
15+
);
16+
17+
if (templateQuery.isError) {
18+
return <ErrorAlert error={templateQuery.error} />;
19+
}
20+
if (!templateQuery.data) {
21+
return <Loader />;
22+
}
23+
24+
return (
25+
<>
26+
{templateQuery.data?.use_classic_parameter_flow ? (
27+
<TemplateEmbedPage />
28+
) : (
29+
<TemplateEmbedPageExperimental />
30+
)}
31+
</>
32+
);
33+
};
34+
35+
export default TemplateEmbedExperimentRouter;

site/src/pages/TemplatePage/TemplateEmbedPage/TemplateEmbedPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ export const TemplateEmbedPageView: FC<TemplateEmbedPageViewProps> = ({
9797
{!buttonValues || !templateParameters ? (
9898
<Loader />
9999
) : (
100-
<div css={{ display: "flex", alignItems: "flex-start", gap: 48 }}>
101-
<div css={{ flex: 1, maxWidth: 400 }}>
100+
<div className="flex items-start gap-12">
101+
<div className="max-w-3xl">
102102
<VerticalForm>
103103
<FormSection
104104
title="Creation mode"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy