diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx index d022633222..138601660b 100644 --- a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx +++ b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx @@ -596,11 +596,18 @@ export const CreateWorkspacePageViewExperimental: FC< const currentParameterValueIndex = form.values.rich_parameter_values?.findIndex( (p) => p.name === parameter.name, - ) ?? -1; + ); const parameterFieldIndex = - currentParameterValueIndex !== -1 + currentParameterValueIndex !== undefined ? currentParameterValueIndex : index; + // Get the form value by parameter name to ensure correct value mapping + const formValue = + currentParameterValueIndex !== undefined + ? form.values?.rich_parameter_values?.[ + currentParameterValueIndex + ]?.value || "" + : ""; const parameterField = `rich_parameter_values.${parameterFieldIndex}`; const isPresetParameter = presetParameterNames.includes( parameter.name, @@ -622,14 +629,6 @@ export const CreateWorkspacePageViewExperimental: FC< return null; } - // Get the form value by parameter name to ensure correct value mapping - const formValue = - currentParameterValueIndex !== -1 - ? form.values?.rich_parameter_values?.[ - currentParameterValueIndex - ]?.value || "" - : ""; - return ( { + if (!parameter.mutable && parameter.diagnostics.length > 0) { + return true; + } + return false; + }); + return ( <> {disabled && ( @@ -132,6 +139,38 @@ export const WorkspaceParametersPageViewExperimental: FC< )} + {hasIncompatibleParameters && ( + +

+ Workspace update blocked +

+

+ The new template version includes parameter changes that are + incompatible with this workspace's existing parameter values. This + may be caused by: +

+ +

+ Please contact the template administrator to review + the changes and ensure compatibility for existing workspaces. +

+

+ Consider supplying defaults for new parameters or validating + conditional logic against prior workspace states. +

+
+ )} + {diagnostics && diagnostics.length > 0 && (
{diagnostics.map((diagnostic, index) => ( @@ -182,7 +221,23 @@ export const WorkspaceParametersPageViewExperimental: FC<

{standardParameters.map((parameter, index) => { - const parameterField = `rich_parameter_values.${index}`; + const currentParameterValueIndex = + form.values.rich_parameter_values?.findIndex( + (p) => p.name === parameter.name, + ); + const parameterFieldIndex = + currentParameterValueIndex !== undefined + ? currentParameterValueIndex + : index; + // Get the form value by parameter name to ensure correct value mapping + const formValue = + currentParameterValueIndex !== undefined + ? form.values?.rich_parameter_values?.[ + currentParameterValueIndex + ]?.value || "" + : ""; + + const parameterField = `rich_parameter_values.${parameterFieldIndex}`; const isDisabled = disabled || parameter.styling?.disabled || @@ -198,9 +253,7 @@ export const WorkspaceParametersPageViewExperimental: FC< } autofill={false} disabled={isDisabled} - value={ - form.values?.rich_parameter_values?.[index]?.value || "" - } + value={formValue} /> ); })}