Conversation
There was a problem hiding this comment.
Pull request overview
Adds validation to prevent creating/renaming files with an empty base name (e.g., .py), wiring in a new localized error message and covering the behavior with modal tests.
Changes:
- Updated filename validation to reject dot-prefixed “no name” inputs and dispatch a dedicated
emptyFileNameerror. - Added unit tests for New File and Rename File modals to assert the new error behavior.
- Added an English translation string for the new validation error.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/utils/componentNameValidation.js | Introduces base-name extraction and dispatches a new empty-name error when appropriate. |
| src/components/Modals/RenameFileModal.test.js | Adds a test ensuring renaming to .py triggers the empty-name error. |
| src/components/Modals/NewFileModal.test.js | Adds a test ensuring creating .py triggers the empty-name error. |
| public/translations/en.json | Adds the filePanel.errors.emptyFileName translation entry. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| }), | ||
| ), | ||
| ); | ||
| } else if (baseName.length === 0) { | ||
| dispatch(setNameError(t("filePanel.errors.emptyFileName"))); |
There was a problem hiding this comment.
The emptyFileName branch runs after the unsupported-extension branch. For truly blank inputs like "" or ".", extension is "" so this function will currently dispatch unsupportedExtension rather than the new emptyFileName message. Consider checking fileName.trim().length === 0 / baseName.length === 0 before extension validation (or explicitly handling extension === "") so empty inputs consistently show the empty-name error.
Add validation to prevent a file being created/updated without a name such as .txt for example.