Skip to content

Commit e2eab2b

Browse files
committed
MVP
1 parent 912a604 commit e2eab2b

File tree

6 files changed

+54
-4
lines changed

6 files changed

+54
-4
lines changed

codersdk/templateversions.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
type TemplateVersionWarning string
1515

1616
const (
17-
TemplateVersionWarningDeprecatedParameters = "DEPRECATED_PARAMETERS"
17+
TemplateVersionWarningDeprecatedParameters TemplateVersionWarning = "DEPRECATED_PARAMETERS"
1818
)
1919

2020
// TemplateVersion represents a single version of a template.

site/src/api/typesGenerated.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1592,8 +1592,10 @@ export type TemplateRole = "" | "admin" | "use"
15921592
export const TemplateRoles: TemplateRole[] = ["", "admin", "use"]
15931593

15941594
// From codersdk/templateversions.go
1595-
export type TemplateVersionWarning = never
1596-
export const TemplateVersionWarnings: TemplateVersionWarning[] = []
1595+
export type TemplateVersionWarning = "DEPRECATED_PARAMETERS"
1596+
export const TemplateVersionWarnings: TemplateVersionWarning[] = [
1597+
"DEPRECATED_PARAMETERS",
1598+
]
15971599

15981600
// From codersdk/users.go
15991601
export type UserStatus = "active" | "suspended"

site/src/components/Workspace/Workspace.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ import {
2626
PageHeaderTitle,
2727
PageHeaderSubtitle,
2828
} from "components/PageHeader/FullWidthPageHeader"
29+
import { Maybe } from "components/Conditionals/Maybe"
30+
import { Link } from "@material-ui/core"
2931

3032
export enum WorkspaceErrors {
3133
GET_BUILDS_ERROR = "getBuildsError",
@@ -52,6 +54,7 @@ export interface WorkspaceProps {
5254
workspace: TypesGen.Workspace
5355
resources?: TypesGen.WorkspaceResource[]
5456
builds?: TypesGen.WorkspaceBuild[]
57+
templateWarnings?: TypesGen.TemplateVersionWarning[]
5558
canUpdateWorkspace: boolean
5659
canUpdateTemplate: boolean
5760
canChangeVersions: boolean
@@ -96,6 +99,7 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
9699
quota_budget,
97100
failedBuildLogs,
98101
handleBuildRetry,
102+
templateWarnings,
99103
}) => {
100104
const styles = useStyles()
101105
const navigate = useNavigate()
@@ -186,6 +190,25 @@ export const Workspace: FC<React.PropsWithChildren<WorkspaceProps>> = ({
186190
handleClick={() => navigate(`/templates`)}
187191
/>
188192

193+
{templateWarnings && (
194+
<Maybe
195+
condition={Boolean(
196+
templateWarnings.includes("DEPRECATED_PARAMETERS"),
197+
)}
198+
>
199+
<AlertBanner severity="warning">
200+
<div>
201+
This template uses legacy parameters which will be deprecated
202+
in the next Coder release. Learn how to migrate in{" "}
203+
<Link href="https://coder.com/docs/v2/latest/templates/parameters#migration">
204+
our documentation
205+
</Link>
206+
.
207+
</div>
208+
</AlertBanner>
209+
</Maybe>
210+
)}
211+
189212
{failedBuildLogs && (
190213
<Stack>
191214
<AlertBanner severity="error">

site/src/pages/TemplatePage/TemplateSummaryPage/TemplateSummaryPageView.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ import { FC, useEffect } from "react"
1111
import { DAUChart } from "../../../components/DAUChart/DAUChart"
1212
import { TemplateSummaryData } from "./data"
1313
import { useLocation, useNavigate } from "react-router-dom"
14+
import { Maybe } from "components/Conditionals/Maybe"
15+
import { AlertBanner } from "components/AlertBanner/AlertBanner"
16+
import Link from "@material-ui/core/Link"
1417

1518
export interface TemplateSummaryPageViewProps {
1619
data?: TemplateSummaryData
@@ -48,6 +51,24 @@ export const TemplateSummaryPageView: FC<TemplateSummaryPageViewProps> = ({
4851

4952
return (
5053
<Stack spacing={4}>
54+
{activeVersion.warnings && (
55+
<Maybe
56+
condition={Boolean(
57+
activeVersion.warnings.includes("DEPRECATED_PARAMETERS"),
58+
)}
59+
>
60+
<AlertBanner severity="warning">
61+
<div>
62+
This template uses legacy parameters which will be deprecated in
63+
the next Coder release. Learn how to migrate in{" "}
64+
<Link href="https://coder.com/docs/v2/latest/templates/parameters#migration">
65+
our documentation
66+
</Link>
67+
.
68+
</div>
69+
</AlertBanner>
70+
</Maybe>
71+
)}
5172
<TemplateStats template={template} activeVersion={activeVersion} />
5273
{daus && <DAUChart daus={daus} />}
5374
<TemplateResourcesTable resources={getStartedResources(resources)} />

site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export const WorkspaceReadyPage = ({
5454
const {
5555
workspace,
5656
template,
57+
templateVersion,
5758
builds,
5859
getBuildsError,
5960
buildError,
@@ -157,6 +158,7 @@ export const WorkspaceReadyPage = ({
157158
sshPrefix={sshPrefix}
158159
template={template}
159160
quota_budget={quotaState.context.quota?.budget}
161+
templateWarnings={templateVersion?.warnings}
160162
/>
161163
<DeleteDialog
162164
entity="workspace"

site/src/xServices/workspace/workspaceXService.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,9 @@ export const workspaceMachine = createMachine(
720720
},
721721
getTemplateVersion: async (context) => {
722722
if (context.template) {
723-
return await API.getTemplateVersion(context.template.active_version_id)
723+
return await API.getTemplateVersion(
724+
context.template.active_version_id,
725+
)
724726
} else {
725727
throw Error("Cannot get template version without template")
726728
}

0 commit comments

Comments
 (0)