Skip to content

feat: add required field validation to EnvVarEditor and FileVarEditor#477

Merged
kaviththiranga merged 1 commit intoopenchoreo:mainfrom
kaviththiranga:fix-empty-endpoint
Mar 21, 2026
Merged

feat: add required field validation to EnvVarEditor and FileVarEditor#477
kaviththiranga merged 1 commit intoopenchoreo:mainfrom
kaviththiranga:fix-empty-endpoint

Conversation

@kaviththiranga
Copy link
Contributor

@kaviththiranga kaviththiranga commented Mar 21, 2026

Disable the Apply button until all required fields are filled,
preventing invalid entries with empty values from being saved.
Follows the existing isBufferValid pattern from useEndpointEditBuffer.

EnvVar: key and value required (plain), key + secret name/key (secret)
FileVar: key + mountPath + content required (plain), key + mountPath +
secret name/key (secret)

Screenshot 2026-03-21 at 16 52 46

Summary by CodeRabbit

  • New Features
    • Enhanced validation for environment and file variable editors. The Apply action now intelligently disables when edits contain invalid data—including missing required fields or improperly formatted values—preventing incomplete or malformed configurations from being saved.

  Disable the Apply button until all required fields are filled,
  preventing invalid entries with empty values from being saved.
  Follows the existing isBufferValid pattern from useEndpointEditBuffer.

  EnvVar: key and value required (plain), key + secret name/key (secret)
  FileVar: key + mountPath + content required (plain), key + mountPath +
  secret name/key (secret)

Signed-off-by: Kavith Lokuhewage <kaviththiranga@gmail.com>
@coderabbitai
Copy link

coderabbitai bot commented Mar 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bdd54654-e051-4795-8b5d-ccad36fc0998

📥 Commits

Reviewing files that changed from the base of the PR and between 41015b3 and fd17c3a.

📒 Files selected for processing (8)
  • plugins/openchoreo-react/src/components/EnvVarEditor/EnvVarEditor.tsx
  • plugins/openchoreo-react/src/components/FileVarEditor/FileVarEditor.tsx
  • plugins/openchoreo-react/src/components/OverrideEnvVarList/OverrideEnvVarList.tsx
  • plugins/openchoreo-react/src/components/OverrideFileVarList/OverrideFileVarList.tsx
  • plugins/openchoreo-react/src/components/StandardEnvVarList/StandardEnvVarList.tsx
  • plugins/openchoreo-react/src/components/StandardFileVarList/StandardFileVarList.tsx
  • plugins/openchoreo-react/src/hooks/useEnvVarEditBuffer.ts
  • plugins/openchoreo-react/src/hooks/useFileVarEditBuffer.ts

📝 Walkthrough

Walkthrough

This PR introduces buffer validation to environment and file variable editor components. New isBufferValid flags are computed by edit buffer hooks based on field requirements. Editor components receive a new optional applyDisabled prop, and list components pass it based on buffer validity to prevent applying invalid edits.

Changes

Cohort / File(s) Summary
Editor Components
plugins/openchoreo-react/src/components/EnvVarEditor/EnvVarEditor.tsx, plugins/openchoreo-react/src/components/FileVarEditor/FileVarEditor.tsx
Added optional applyDisabled prop (defaults to false) and updated Apply button disabled state to disabled || applyDisabled, enabling external validation control.
List Components
plugins/openchoreo-react/src/components/OverrideEnvVarList/OverrideEnvVarList.tsx, plugins/openchoreo-react/src/components/OverrideFileVarList/OverrideFileVarList.tsx, plugins/openchoreo-react/src/components/StandardEnvVarList/StandardEnvVarList.tsx, plugins/openchoreo-react/src/components/StandardFileVarList/StandardFileVarList.tsx
Updated to pass applyDisabled prop to editors based on isCurrentlyEditing && !editBuffer.isBufferValid.
Edit Buffer Hooks
plugins/openchoreo-react/src/hooks/useEnvVarEditBuffer.ts, plugins/openchoreo-react/src/hooks/useFileVarEditBuffer.ts
Added isBufferValid: boolean result field with validation logic ensuring required fields (key, trimmed values, secretKeyRef details) are non-empty before allowing apply.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A button to apply with care,
But first, my validation must declare
The buffer is ready, fields all true—
No empty keys, no trickery through.
Now safely we hop with changes to spare! 🐇✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is incomplete according to the repository's template. It provides a brief explanation and screenshot but lacks most required sections like Purpose, Goals, Approach (beyond the brief), User Stories, Release Notes, Documentation, Training, Certification, Marketing, Automation Tests, Security Checks, Samples, Related PRs, Migrations, Test Environment, and Learning sections. Complete the PR description by filling in the required template sections, particularly Purpose (with linked issues), Goals, Automation Tests, Security Checks, and Test Environment details.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding required field validation to disable the Apply button in EnvVarEditor and FileVarEditor components.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@kaviththiranga kaviththiranga merged commit 86f7987 into openchoreo:main Mar 21, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants