-
Notifications
You must be signed in to change notification settings - Fork 952
feat: make dynamic parameters opt-in by default for new templates #19006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jaaydenh
wants to merge
4
commits into
main
Choose a base branch
from
jaaydenh/dynamic-params-default-optin
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...es/ClassicParameterFlowDeprecationWarning/ClassicParameterFlowDeprecationWarning.test.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { render, screen } from "@testing-library/react"; | ||
import { ClassicParameterFlowDeprecationWarning } from "./ClassicParameterFlowDeprecationWarning"; | ||
|
||
jest.mock("modules/navigation", () => ({ | ||
useLinks: () => () => "/mock-link", | ||
linkToTemplate: () => "/mock-template-link", | ||
})); | ||
|
||
describe("ClassicParameterFlowDeprecationWarning", () => { | ||
const defaultProps = { | ||
enabled: true, | ||
organizationName: "test-org", | ||
templateName: "test-template", | ||
canUpdateTemplate: true, | ||
}; | ||
Comment on lines
+10
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fix prop naming inconsistency in test setup. The default props define const defaultProps = {
- enabled: true,
organizationName: "test-org",
templateName: "test-template",
- canUpdateTemplate: true,
+ isEnabled: true,
};
🤖 Prompt for AI Agents
|
||
|
||
it("renders warning when enabled and user has template update permissions", () => { | ||
render( | ||
<ClassicParameterFlowDeprecationWarning | ||
{...defaultProps} | ||
isEnabled={true} | ||
/>, | ||
); | ||
|
||
expect(screen.getByText("deprecated")).toBeInTheDocument(); | ||
expect(screen.getByText("Go to Template Settings")).toBeInTheDocument(); | ||
}); | ||
|
||
it("does not render when enabled is false", () => { | ||
const { container } = render( | ||
<ClassicParameterFlowDeprecationWarning | ||
{...defaultProps} | ||
isEnabled={false} | ||
/>, | ||
); | ||
|
||
expect(container.firstChild).toBeNull(); | ||
}); | ||
}); |
46 changes: 46 additions & 0 deletions
46
...kspaces/ClassicParameterFlowDeprecationWarning/ClassicParameterFlowDeprecationWarning.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { Alert } from "components/Alert/Alert"; | ||
import { Link } from "components/Link/Link"; | ||
import { linkToTemplate, useLinks } from "modules/navigation"; | ||
import type { FC } from "react"; | ||
import { docs } from "utils/docs"; | ||
|
||
interface ClassicParameterFlowDeprecationWarningProps { | ||
organizationName: string; | ||
templateName: string; | ||
isEnabled: boolean; | ||
} | ||
|
||
export const ClassicParameterFlowDeprecationWarning: FC< | ||
ClassicParameterFlowDeprecationWarningProps | ||
> = ({ organizationName, templateName, isEnabled }) => { | ||
const getLink = useLinks(); | ||
|
||
if (!isEnabled) { | ||
return null; | ||
} | ||
|
||
const templateSettingsLink = `${getLink( | ||
linkToTemplate(organizationName, templateName), | ||
)}/settings`; | ||
|
||
return ( | ||
<Alert severity="warning" className="mb-2"> | ||
<div> | ||
This template is using the classic parameter flow, which will be{" "} | ||
<strong>deprecated</strong> and removed in a future release. Please | ||
migrate to{" "} | ||
<a | ||
href={docs("/admin/templates/extending-templates/dynamic-parameters")} | ||
className="text-content-link" | ||
> | ||
dynamic parameters | ||
</a>{" "} | ||
on template settings for improved functionality. | ||
</div> | ||
|
||
<Link className="text-xs" href={templateSettingsLink}> | ||
Go to Template Settings | ||
</Link> | ||
</Alert> | ||
); | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Breaking-default flip – double-check upstream callers
Switching the default from
true
→false
silently changes behaviour for every client that omitsuse_classic_parameter_flow
when calling thePOST /organizations/:org/templates
endpoint.Please verify that:
true
when the classic flow is expected.Quick scan helper:
🏁 Script executed:
Length of output: 532
🏁 Script executed:
Length of output: 542
Explicitly set
UseClassicParameterFlow
on allCreateTemplateRequest
call sitesWe flipped the default from
true
→false
, so any caller that omitsUseClassicParameterFlow
will now use the new dynamic‐parameter flow. The following literals need to be updated to includeUseClassicParameterFlow: ptr.Bool(true)
where the classic flow is expected:• cli/templatecreate.go:152
• cli/templatepush.go:183
• coderd/templates_test.go:99, 116, 132, 150, 183, 219, 242, 262, 312, 362, 393, 419, 435
• coderd/coderdtest/coderdtest.go:969
• codersdk/toolsdk/toolsdk.go:1284
• enterprise/coderd/users_test.go:282
Additionally:
false
) foruse_classic_parameter_flow
.🤖 Prompt for AI Agents