Improve onboarding and team settings on dashboard branch#109
Conversation
Initialize dashboard branch commit log for PR preparation. Made-with: Cursor
Add explicit execution note to dashboard commit log. Made-with: Cursor
Document incremental commit sequencing in the log. Made-with: Cursor
Record branch progress marker in dashboard log. Made-with: Cursor
Capture cadence checkpoint for dashboard branch commits. Made-with: Cursor
Add workflow continuity marker in commit log. Made-with: Cursor
Add an owner-only team rename API and wire Settings > Team with inline rename UX, including input autofocus and saved-state feedback. Made-with: Cursor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
Adds owner-only team renaming support in the Team settings UI and backend, plus a dashboard-branch commit log document.
Changes:
- Add a Team Name edit control (owner-only) and client-side rename flow in Settings > Team.
- Add a protected backend endpoint to rename a team with basic validation/authorization.
- Add
dashboard-commit-log.mddocumenting dashboard branch commit sequencing.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/components/views/SettingsView.tsx | Adds owner-only team rename UI, state, and API call logic |
| backend/routes/teamRoutes.js | Adds PATCH /:teamId/name endpoint with owner authorization + validation |
| dashboard-commit-log.md | Adds documentation for dashboard branch commit sequencing |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| useEffect(() => { | ||
| if (!selectedTeam || selectedTeam.ownerId !== currentUser?.uid) { | ||
| return; | ||
| } | ||
|
|
||
| const focusTimer = window.setTimeout(() => { | ||
| teamNameInputRef.current?.focus(); | ||
| teamNameInputRef.current?.select(); | ||
| }, 0); | ||
|
|
||
| return () => window.clearTimeout(focusTimer); | ||
| }, [selectedTeamId, selectedTeam, currentUser?.uid]); |
There was a problem hiding this comment.
The autofocus effect depends on the entire selectedTeam object, so any update to team details (e.g. removing a member, transferring ownership, renaming) will re-run the effect and can steal focus back to the team name input unexpectedly. Consider tightening dependencies so focus only happens when the selected team changes (e.g., selectedTeamId and an isOwner boolean / selectedTeam?.ownerId), rather than on every selectedTeam reference change.
| router.patch('/:teamId/name', verifyToken, async (req, res) => { | ||
| const { teamId } = req.params; | ||
| const uid = req.user.uid; | ||
| const nextName = typeof req.body?.name === 'string' ? req.body.name.trim() : ''; | ||
|
|
||
| if (!nextName) { | ||
| return res.status(400).json({ message: 'Team name is required' }); | ||
| } | ||
|
|
||
| if (nextName.length > 80) { | ||
| return res.status(400).json({ message: 'Team name must be 80 characters or fewer' }); | ||
| } | ||
|
|
||
| try { | ||
| const team = await Team.findById(teamId).lean(); | ||
| if (!team) return res.status(404).json({ message: 'Team not found' }); | ||
|
|
There was a problem hiding this comment.
This endpoint treats an invalid teamId (non-ObjectId) as a server error because Team.findById(teamId) will throw a CastError and the catch returns 500. Since this is client input, consider validating teamId up front and returning 400 (e.g., via mongoose.Types.ObjectId.isValid(teamId)) to avoid misclassifying bad requests as server failures.
| { $set: { name: nextName } }, | ||
| { returnDocument: 'after', lean: true } | ||
| ); | ||
|
|
There was a problem hiding this comment.
findByIdAndUpdate can return null (e.g., if the team is deleted between the initial findById and the update). Right now the route responds 200 with null in that case. Add a guard for !updated and return a 404 (or re-fetch) to avoid returning a successful response with an empty body.
| if (!updated) { | |
| return res.status(404).json({ message: 'Team not found' }); | |
| } |
| router.patch('/:teamId/name', verifyToken, async (req, res) => { | ||
| const { teamId } = req.params; | ||
| const uid = req.user.uid; | ||
| const nextName = typeof req.body?.name === 'string' ? req.body.name.trim() : ''; | ||
|
|
||
| if (!nextName) { | ||
| return res.status(400).json({ message: 'Team name is required' }); | ||
| } | ||
|
|
||
| if (nextName.length > 80) { | ||
| return res.status(400).json({ message: 'Team name must be 80 characters or fewer' }); | ||
| } | ||
|
|
||
| try { | ||
| const team = await Team.findById(teamId).lean(); | ||
| if (!team) return res.status(404).json({ message: 'Team not found' }); | ||
|
|
||
| if (team.ownerId !== uid) { | ||
| return res.status(403).json({ message: 'Only the team owner can rename the team' }); | ||
| } | ||
|
|
||
| const updated = await Team.findByIdAndUpdate( | ||
| teamId, | ||
| { $set: { name: nextName } }, | ||
| { returnDocument: 'after', lean: true } | ||
| ); | ||
|
|
||
| res.status(200).json(normalizeDoc(updated)); | ||
| } catch (error) { | ||
| console.error('Error renaming team:', error); | ||
| res.status(500).json({ message: 'Server error' }); | ||
| } | ||
| }); |
There was a problem hiding this comment.
New behavior is introduced here (owner-only team renaming with validation), but there are currently no automated tests covering team routes in backend/tests/. Since the repo already uses Jest + Supertest for route/security coverage (e.g. backend/tests/project_security.test.js), please add tests for this endpoint (owner can rename, non-owner gets 403, empty/too-long name gets 400).
| # Dashboard Branch Commit Log | ||
|
|
||
| This file tracks requested commit sequencing for the `dashboard` branch. | ||
|
|
There was a problem hiding this comment.
The PR description mentions changes to post-login onboarding routing (/welcome vs /dashboard), but the diff shown here only includes team rename UI/API and this commit-log doc. If onboarding routing changes are intended in this PR, they appear to be missing from the actual changes; otherwise, please update the PR description to match the scope.
Summary
main(team settings/workspace refinements and related cleanup currently on this branch)Test plan
/welcome/dashboardSettings > Teamas team owner, rename the team, and confirm success state appearsnpm run typecheck(note: there is an existing unrelated type error insrc/pages/ProjectDetails.tsx)