Skip to content

Commit e1e2af8

Browse files
committed
chore: add switching template flow from api
1 parent 459ec29 commit e1e2af8

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

coderd/templates.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,6 +1078,7 @@ func (api *API) convertTemplate(
10781078
Deprecated: templateAccessControl.IsDeprecated(),
10791079
DeprecationMessage: templateAccessControl.Deprecated,
10801080
MaxPortShareLevel: maxPortShareLevel,
1081+
ClassicParameterFlow: template.ClassicParameterFlow,
10811082
}
10821083
}
10831084

coderd/templates_test.go

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,6 +1540,41 @@ func TestPatchTemplateMeta(t *testing.T) {
15401540
require.False(t, template.Deprecated)
15411541
})
15421542
})
1543+
1544+
t.Run("ClassicParameterFlow", func(t *testing.T) {
1545+
t.Parallel()
1546+
1547+
client := coderdtest.New(t, nil)
1548+
user := coderdtest.CreateFirstUser(t, client)
1549+
version := coderdtest.CreateTemplateVersion(t, client, user.OrganizationID, nil)
1550+
template := coderdtest.CreateTemplate(t, client, user.OrganizationID, version.ID)
1551+
require.False(t, template.ClassicParameterFlow, "default is false")
1552+
1553+
bTrue := true
1554+
bFalse := false
1555+
req := codersdk.UpdateTemplateMeta{
1556+
ClassicParameterFlow: &bTrue,
1557+
}
1558+
1559+
ctx := testutil.Context(t, testutil.WaitLong)
1560+
1561+
// set to true
1562+
updated, err := client.UpdateTemplateMeta(ctx, template.ID, req)
1563+
require.NoError(t, err)
1564+
assert.True(t, updated.ClassicParameterFlow, "expected true")
1565+
1566+
// noop
1567+
req.ClassicParameterFlow = nil
1568+
updated, err = client.UpdateTemplateMeta(ctx, template.ID, req)
1569+
require.NoError(t, err)
1570+
assert.True(t, updated.ClassicParameterFlow, "expected true")
1571+
1572+
// back to false
1573+
req.ClassicParameterFlow = &bFalse
1574+
updated, err = client.UpdateTemplateMeta(ctx, template.ID, req)
1575+
require.NoError(t, err)
1576+
assert.False(t, updated.ClassicParameterFlow, "expected false")
1577+
})
15431578
}
15441579

15451580
func TestDeleteTemplate(t *testing.T) {

codersdk/templates.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@ type Template struct {
6161
// template version.
6262
RequireActiveVersion bool `json:"require_active_version"`
6363
MaxPortShareLevel WorkspaceAgentPortShareLevel `json:"max_port_share_level"`
64+
65+
ClassicParameterFlow bool `json:"classic_parameter_flow"`
6466
}
6567

6668
// WeekdaysToBitmap converts a list of weekdays to a bitmap in accordance with

0 commit comments

Comments
 (0)