From 3fe8f7c0d21389092e954a94070e9509f9c16336 Mon Sep 17 00:00:00 2001 From: Jaayden Halko Date: Fri, 13 Jun 2025 17:06:10 +0000 Subject: [PATCH] fix: show error message for incompatible parameters --- .../CreateWorkspacePageViewExperimental.tsx | 19 +++--- ...orkspaceParametersPageViewExperimental.tsx | 61 +++++++++++++++++-- 2 files changed, 66 insertions(+), 14 deletions(-) diff --git a/site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx b/site/src/pages/CreateWorkspacePage/CreateWorkspacePageViewExperimental.tsx index d0226332227f9..138601660b384 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: +

+
    +
  • + New required parameters that cannot be provided + after workspace creation +
  • +
  • + Changes to valid options or validations for + existing parameters +
  • +
  • Logic changes that conflict with previously selected values
  • +
+

+ 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} /> ); })} pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy