fix(documents): strip extension from document name on upload and rename - #1361
fix(documents): strip extension from document name on upload and rename#1361Pallavikumarimdb wants to merge 1 commit into
Conversation
📝 WalkthroughWalkthroughDocument names are now stored and edited without file extensions, while ChangesDocument naming
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx (1)
50-59: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winUse
props.documentNameas the form value.getDocumentNameWithoutExtensionwill strip any user-entered trailing segment, so names likeQ3.Reportreopen asQ3. Apply this in bothinitialValuesand thecreateEffectreset.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx` around lines 50 - 59, Update the rename form initialization and reset in the component’s form setup and createEffect to use props.documentName directly as the name value. Remove getDocumentNameWithoutExtension from both initialValues and the reactive reset so names containing trailing segments such as “Q3.Report” are preserved.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx`:
- Line 12: Remove the unused getDocumentNameWithoutExtension import from
rename-document-button.component.tsx, ensuring form initialization no longer
references it.
---
Outside diff comments:
In
`@apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx`:
- Around line 50-59: Update the rename form initialization and reset in the
component’s form setup and createEffect to use props.documentName directly as
the name value. Remove getDocumentNameWithoutExtension from both initialValues
and the reactive reset so names containing trailing segments such as “Q3.Report”
are preserved.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: ab27e721-1d07-41ad-ac42-a45917d94da4
📒 Files selected for processing (6)
apps/papra-client/src/modules/documents/components/rename-document-button.component.tsxapps/papra-server/src/modules/documents/documents.repository.tsapps/papra-server/src/modules/documents/documents.usecases.test.tsapps/papra-server/src/modules/documents/documents.usecases.tsapps/papra-server/src/modules/documents/e2e/upload-documents.e2e.test.tsapps/papra-server/src/modules/shared/files/file-names.ts
| import { createToast } from '@/modules/ui/components/sonner'; | ||
| import { TextField, TextFieldLabel, TextFieldRoot } from '@/modules/ui/components/textfield'; | ||
| import { getDocumentNameExtension, getDocumentNameWithoutExtension } from '../document.models'; | ||
| import { getDocumentNameWithoutExtension } from '../document.models'; |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
Remove the unused import.
Since getDocumentNameWithoutExtension should no longer be used for form initialization (to avoid truncating user-provided names containing dots), this import can be completely removed.
♻️ Proposed fix
-import { getDocumentNameWithoutExtension } from '../document.models';📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| import { getDocumentNameWithoutExtension } from '../document.models'; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In
`@apps/papra-client/src/modules/documents/components/rename-document-button.component.tsx`
at line 12, Remove the unused getDocumentNameWithoutExtension import from
rename-document-button.component.tsx, ensuring form initialization no longer
references it.
Contributor License Agreement✅ Everyone who contributed to this pull request has signed the CLA for it. |
Description
This PR resolves the issue where documents uploaded via the web UI permanently keep their file extensions in their display names and cannot have them removed.
Changes
getFileNameWithoutExtensioninfile-names.tsto return the extension-stripped filename string directly rather than a wrapped object.createDocumentandrestoreDocumentinsidedocuments.usecases.tsto usegetFileNameWithoutExtensionto save default document names without extensions.restoreDocumentindocuments.repository.tsto handleoriginalNameandnameseparately so that the original extension remains preserved in the storage metadata.onSubmithandler inrename-document-button.component.tsx, allowing users to rename their documents without forcing the original file extension.documents.usecases.test.tsand integration/e2e tests inupload-documents.e2e.test.ts.Closes: #1169