-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to modify document titles #342
Add ability to modify document titles #342
Conversation
WalkthroughThe pull request introduces functionality for updating document titles in a NestJS application. It includes the creation of a Data Transfer Object (DTO) for title updates, a new PUT endpoint in the controller, and a corresponding service method. Frontend components are enhanced to manage document titles interactively. Additionally, a new mutation hook is added to facilitate the title update process. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Frontend
participant Backend
participant Database
User->>Frontend: Update Document Title
Frontend->>Backend: PUT /workspace/:workspaceId/document/:documentId/title
Backend->>Database: Find Document
Database-->>Backend: Document Found
Backend->>Database: Update Document Title
Database-->>Backend: Title Updated
Backend-->>Frontend: Success Response
Frontend-->>User: Title Updated Successfully
Assessment against linked issues
Recent review detailsConfiguration used: CodeRabbit UI Files ignored due to path filters (1)
Files selected for processing (3)
Files skipped from review as they are similar to previous changes (2)
Additional comments not posted (6)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please resolve the merge conflict. A conflict occurred because another PR was merged. Feel free to ask if you're unsure how to proceed.
backend/src/workspace-documents/workspace-documents.controller.ts
Outdated
Show resolved
Hide resolved
backend/src/workspace-documents/workspace-documents.controller.ts
Outdated
Show resolved
Hide resolved
Thanks a lot for the feedback. Il look into it as soon as possible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (6)
- backend/.env.development (1 hunks)
- backend/docker/docker-compose-full.yml (0 hunks)
- backend/src/workspace-documents/workspace-documents.controller.ts (3 hunks)
- backend/src/workspace-documents/workspace-documents.service.ts (1 hunks)
- frontend/src/components/headers/DocumentHeader.tsx (4 hunks)
- frontend/src/hooks/api/workspaceDocument.ts (2 hunks)
Files not reviewed due to no reviewable changes (1)
- backend/docker/docker-compose-full.yml
Files skipped from review as they are similar to previous changes (2)
- backend/src/workspace-documents/workspace-documents.service.ts
- frontend/src/hooks/api/workspaceDocument.ts
Additional context used
Gitleaks
backend/.env.development
8-9: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.
(generic-api-key)
Additional comments not posted (7)
backend/src/workspace-documents/workspace-documents.controller.ts (1)
41-70
: LGTM!The new
PUT
endpoint for updating document titles is well-implemented and follows best practices. The code segment includes:
- Appropriate endpoint route and method name
- Clear and concise API documentation decorators
- Correctly typed and named method parameters
- Invocation of the service function with the appropriate parameters
- Consistent response handling with the
@ApiOkResponse
decoratorThe implementation enhances the functionality of the
WorkspaceDocumentsController
without introducing any apparent issues or inconsistencies.frontend/src/components/headers/DocumentHeader.tsx (6)
14-16
: LGTM!The imports for
Button
,FormControl
, andTypography
components from@mui/material
are necessary for the newly added UI components in the file.
18-18
: LGTM!The imports for
useEffect
anduseState
hooks fromreact
are necessary for the newly added state management and side effects in the component.
29-32
: LGTM!The imports for
FormContainer
andTextFieldElement
components fromreact-hook-form-mui
,selectDocument
andsetDocumentData
from../../store/documentSlice
,useUpdateDocumentTitleMutation
from../../hooks/api/workspaceDocument
, andUpdateDocumentRequest
from../../hooks/api/types/document
are necessary for the newly added form handling, state management, and API calls in the component.
39-51
: LGTM!The changes introduce necessary state management for the document store and the focus state of the title input field. The
useUpdateDocumentTitleMutation
hook is used to get the function for updating the document title, and theisEditingDisabled
variable is used to disable editing when the user has a read-only share role. ThehandleFocus
function is used to update the focus state when the title input field is focused. The code changes look good.
68-97
: LGTM!The
handleDocumentTitleChange
function updates the document title in the Redux store when the input field value changes, and thehandleUpdateDocumentTitle
function calls theupdateDocumentTitle
mutation to update the document title on the server and resets the focus state. ThevalidationRules
object defines the necessary validation rules for the document title input field. The code changes look good.
137-176
: LGTM!The changes introduce a new UI for displaying and updating the document title. If editing is disabled, a
Typography
component is rendered with the document title. If editing is enabled, a form is rendered with aTextFieldElement
for the document title input field and a submit button. The form is implemented using thereact-hook-form-mui
library for form handling and validation, and theTextFieldElement
component is configured with various props for validation, event handling, and UI customization. The submit button is conditionally rendered based on the focus state of the input field. The code changes look good.
I've addressed the comments you provided and look forward to your feedback. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated changes from review
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution.
What this PR does / why we need it:
Created the logic to update the document title after its created since it would create a better user experience. A title could be misspelled or the content and the needs of that document could change over time.
Which issue(s) this PR fixes:
Fixes #143
Special notes for your reviewer:
I am currently studying web development at YRGO in Gothenburg, Sweden, and this contribution is part of an open-source assignment for my coursework. Working on this issue has been an enjoyable and educational experience, and I appreciate the opportunity to contribute to this project.
I welcome any feedback you may have.
Additionally, I want to mention that although I was not initially assigned to this issue, I communicated with the original assignees in the comments, and they confirmed it was fine for me to proceed with the work.
Does this PR introduce a user-facing change?:
Additional documentation:
Checklist:
Summary by CodeRabbit
Summary by CodeRabbit
New Features
Bug Fixes
Documentation
Chores