Skip to content

Commit 971ffea

Browse files
committed
fix(webapp): conform v1 form fixes from review
Address CodeRabbit feedback on the conform 1.x migration: use defaultValue (not value) on hidden inputs so they stay uncontrolled, return the env-var project-lookup failure as a form-level error, join multi-message field errors when rendering, and clone alerts.emails before using it as mutable field-list state.
1 parent 2761a35 commit 971ffea

4 files changed

Lines changed: 10 additions & 6 deletions

File tree

  • apps/webapp/app/routes
    • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.environment-variables.new
    • _app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings.integrations
    • _app.orgs.$organizationSlug.settings.billing-alerts
    • _app.orgs.$organizationSlug_.projects.new

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.environment-variables.new/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ export const action = dashboardAction(
164164
},
165165
});
166166
if (!project) {
167-
return json(submission.reply({ fieldErrors: { key: ["Project not found"] } }));
167+
return json(submission.reply({ formErrors: ["Project not found"] }));
168168
}
169169

170170
const repository = new EnvironmentVariablesRepository(prisma);

apps/webapp/app/routes/_app.orgs.$organizationSlug.projects.$projectParam.env.$envParam.settings.integrations/route.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,9 @@ function BuildSettingsForm({ buildSettings }: { buildSettings: BuildSettings })
499499
Command to install your project dependencies. This will be run from the root directory
500500
of your repo. Auto-detected by default.
501501
</Hint>
502-
<FormError id={fields.installCommand.errorId}>{fields.installCommand.errors}</FormError>
502+
<FormError id={fields.installCommand.errorId}>
503+
{fields.installCommand.errors?.join(", ")}
504+
</FormError>
503505
</InputGroup>
504506
<InputGroup fullWidth>
505507
<Label htmlFor={fields.preBuildCommand.id}>Pre-build command</Label>
@@ -518,7 +520,9 @@ function BuildSettingsForm({ buildSettings }: { buildSettings: BuildSettings })
518520
Any command that needs to run before we build and deploy your project. This will be run
519521
from the root directory of your repo.
520522
</Hint>
521-
<FormError id={fields.preBuildCommand.errorId}>{fields.preBuildCommand.errors}</FormError>
523+
<FormError id={fields.preBuildCommand.errorId}>
524+
{fields.preBuildCommand.errors?.join(", ")}
525+
</FormError>
522526
</InputGroup>
523527
<div className="border-t border-grid-dimmed pt-4">
524528
<InputGroup>

apps/webapp/app/routes/_app.orgs.$organizationSlug.settings.billing-alerts/route.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ function BillingAlerts({ alerts }: { alerts: BillingAlertsData["alerts"] }) {
228228
});
229229
const { emails, amount, alertLevels } = fields;
230230

231-
const fieldValues = useRef<string[]>(alerts.emails);
231+
const fieldValues = useRef<string[]>([...alerts.emails]);
232232
const emailFields = emails.getFieldList();
233233

234234
const checkboxLevels = [0.75, 0.9, 1.0, 2.0, 5.0];

apps/webapp/app/routes/_app.orgs.$organizationSlug_.projects.new/route.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -388,9 +388,9 @@ export default function Page() {
388388
<FormError id={projectName.errorId}>{projectName.errors}</FormError>
389389
</InputGroup>
390390
{canCreateV3Projects ? (
391-
<input {...getInputProps(projectVersion, { type: "hidden" })} value={"v3"} />
391+
<input {...getInputProps(projectVersion, { type: "hidden" })} defaultValue={"v3"} />
392392
) : (
393-
<input {...getInputProps(projectVersion, { type: "hidden" })} value={"v2"} />
393+
<input {...getInputProps(projectVersion, { type: "hidden" })} defaultValue={"v2"} />
394394
)}
395395

396396
<div className="border-t border-charcoal-700" />

0 commit comments

Comments
 (0)