mirror of
https://github.com/coder/coder.git
synced 2025-07-15 22:20:27 +00:00
feat: rich parameters: introduce display_name (#6919)
* model * DB * fix: DisplayName * proto * Proto * Update go dep * fixme * fix format * config * fmt * fix * Fix * fix * chore(UI): redirecting from workspace page if 404 (#6880) * model * CLI: Display parameter * fix * update dep * fix * fix * fix * UI changes * fmt --------- Co-authored-by: Kira Pilot <kira@coder.com>
This commit is contained in:
@ -2944,6 +2944,7 @@ func (q *fakeQuerier) InsertTemplateVersionParameter(_ context.Context, arg data
|
||||
param := database.TemplateVersionParameter{
|
||||
TemplateVersionID: arg.TemplateVersionID,
|
||||
Name: arg.Name,
|
||||
DisplayName: arg.DisplayName,
|
||||
Description: arg.Description,
|
||||
Type: arg.Type,
|
||||
Mutable: arg.Mutable,
|
||||
|
3
coderd/database/dump.sql
generated
3
coderd/database/dump.sql
generated
@ -354,6 +354,7 @@ CREATE TABLE template_version_parameters (
|
||||
validation_monotonic text DEFAULT ''::text NOT NULL,
|
||||
required boolean DEFAULT true NOT NULL,
|
||||
legacy_variable_name text DEFAULT ''::text NOT NULL,
|
||||
display_name text DEFAULT ''::text NOT NULL,
|
||||
CONSTRAINT validation_monotonic_order CHECK ((validation_monotonic = ANY (ARRAY['increasing'::text, 'decreasing'::text, ''::text])))
|
||||
);
|
||||
|
||||
@ -385,6 +386,8 @@ COMMENT ON COLUMN template_version_parameters.required IS 'Is parameter required
|
||||
|
||||
COMMENT ON COLUMN template_version_parameters.legacy_variable_name IS 'Name of the legacy variable for migration purposes';
|
||||
|
||||
COMMENT ON COLUMN template_version_parameters.display_name IS 'Display name of the rich parameter';
|
||||
|
||||
CREATE TABLE template_version_variables (
|
||||
template_version_id uuid NOT NULL,
|
||||
name text NOT NULL,
|
||||
|
@ -0,0 +1 @@
|
||||
ALTER TABLE template_version_parameters DROP COLUMN display_name;
|
@ -0,0 +1,4 @@
|
||||
ALTER TABLE template_version_parameters ADD COLUMN display_name text NOT NULL DEFAULT '';
|
||||
|
||||
COMMENT ON COLUMN template_version_parameters.display_name
|
||||
IS 'Display name of the rich parameter';
|
@ -1472,6 +1472,8 @@ type TemplateVersionParameter struct {
|
||||
Required bool `db:"required" json:"required"`
|
||||
// Name of the legacy variable for migration purposes
|
||||
LegacyVariableName string `db:"legacy_variable_name" json:"legacy_variable_name"`
|
||||
// Display name of the rich parameter
|
||||
DisplayName string `db:"display_name" json:"display_name"`
|
||||
}
|
||||
|
||||
type TemplateVersionVariable struct {
|
||||
|
@ -3677,7 +3677,7 @@ func (q *sqlQuerier) UpdateTemplateScheduleByID(ctx context.Context, arg UpdateT
|
||||
}
|
||||
|
||||
const getTemplateVersionParameters = `-- name: GetTemplateVersionParameters :many
|
||||
SELECT template_version_id, name, description, type, mutable, default_value, icon, options, validation_regex, validation_min, validation_max, validation_error, validation_monotonic, required, legacy_variable_name FROM template_version_parameters WHERE template_version_id = $1
|
||||
SELECT template_version_id, name, description, type, mutable, default_value, icon, options, validation_regex, validation_min, validation_max, validation_error, validation_monotonic, required, legacy_variable_name, display_name FROM template_version_parameters WHERE template_version_id = $1
|
||||
`
|
||||
|
||||
func (q *sqlQuerier) GetTemplateVersionParameters(ctx context.Context, templateVersionID uuid.UUID) ([]TemplateVersionParameter, error) {
|
||||
@ -3705,6 +3705,7 @@ func (q *sqlQuerier) GetTemplateVersionParameters(ctx context.Context, templateV
|
||||
&i.ValidationMonotonic,
|
||||
&i.Required,
|
||||
&i.LegacyVariableName,
|
||||
&i.DisplayName,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@ -3736,7 +3737,8 @@ INSERT INTO
|
||||
validation_error,
|
||||
validation_monotonic,
|
||||
required,
|
||||
legacy_variable_name
|
||||
legacy_variable_name,
|
||||
display_name
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@ -3754,8 +3756,9 @@ VALUES
|
||||
$12,
|
||||
$13,
|
||||
$14,
|
||||
$15
|
||||
) RETURNING template_version_id, name, description, type, mutable, default_value, icon, options, validation_regex, validation_min, validation_max, validation_error, validation_monotonic, required, legacy_variable_name
|
||||
$15,
|
||||
$16
|
||||
) RETURNING template_version_id, name, description, type, mutable, default_value, icon, options, validation_regex, validation_min, validation_max, validation_error, validation_monotonic, required, legacy_variable_name, display_name
|
||||
`
|
||||
|
||||
type InsertTemplateVersionParameterParams struct {
|
||||
@ -3774,6 +3777,7 @@ type InsertTemplateVersionParameterParams struct {
|
||||
ValidationMonotonic string `db:"validation_monotonic" json:"validation_monotonic"`
|
||||
Required bool `db:"required" json:"required"`
|
||||
LegacyVariableName string `db:"legacy_variable_name" json:"legacy_variable_name"`
|
||||
DisplayName string `db:"display_name" json:"display_name"`
|
||||
}
|
||||
|
||||
func (q *sqlQuerier) InsertTemplateVersionParameter(ctx context.Context, arg InsertTemplateVersionParameterParams) (TemplateVersionParameter, error) {
|
||||
@ -3793,6 +3797,7 @@ func (q *sqlQuerier) InsertTemplateVersionParameter(ctx context.Context, arg Ins
|
||||
arg.ValidationMonotonic,
|
||||
arg.Required,
|
||||
arg.LegacyVariableName,
|
||||
arg.DisplayName,
|
||||
)
|
||||
var i TemplateVersionParameter
|
||||
err := row.Scan(
|
||||
@ -3811,6 +3816,7 @@ func (q *sqlQuerier) InsertTemplateVersionParameter(ctx context.Context, arg Ins
|
||||
&i.ValidationMonotonic,
|
||||
&i.Required,
|
||||
&i.LegacyVariableName,
|
||||
&i.DisplayName,
|
||||
)
|
||||
return i, err
|
||||
}
|
||||
|
@ -15,7 +15,8 @@ INSERT INTO
|
||||
validation_error,
|
||||
validation_monotonic,
|
||||
required,
|
||||
legacy_variable_name
|
||||
legacy_variable_name,
|
||||
display_name
|
||||
)
|
||||
VALUES
|
||||
(
|
||||
@ -33,7 +34,8 @@ VALUES
|
||||
$12,
|
||||
$13,
|
||||
$14,
|
||||
$15
|
||||
$15,
|
||||
$16
|
||||
) RETURNING *;
|
||||
|
||||
-- name: GetTemplateVersionParameters :many
|
||||
|
Reference in New Issue
Block a user