-
-
Notifications
You must be signed in to change notification settings - Fork 129
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
fix(api): Only user's default workspace returns isDefault: true #647
fix(api): Only user's default workspace returns isDefault: true #647
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
||
return { | ||
...workspace, | ||
isDefault: workspace.isDefault && workspace.ownerId === user.id |
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.
Suggestion: ✅ Use strict equality comparison [General, importance: 5]
isDefault: workspace.isDefault && workspace.ownerId === user.id | |
isDefault: workspace.isDefault && workspace.ownerId === user.id |
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.
The entire file shows changes. Can you once revert everything and do it again?
5b7c9ee
to
49e7f85
Compare
Changes updated |
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.
I feel the best thing todo here would be to move this default checking to authorityService.checkAuthorityOverWorkspace
. That way, we will ensure that these changes are propagated to any endpoint that fetches single workspaces aswell.
The change in the next section of this file stays as is ofcourse
49e7f85
to
256ff02
Compare
|
To my mind, isolating the internal model from the model returned via the controller (DTO) by introducing the Workspace DTO and extracting mapping logic from the service would solve the issue. At least, mapping logic should be extracted from the service. |
I agree with you. The thing is, we don't have mapping dtos at all. Introducting one might make us introduce others aswell. So i guess, for now we can let this be. |
🎉 This PR is included in version 2.10.0-stage.2 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #647 +/- ##
===========================================
- Coverage 91.71% 86.79% -4.92%
===========================================
Files 111 113 +2
Lines 2510 2969 +459
Branches 469 447 -22
===========================================
+ Hits 2302 2577 +275
- Misses 208 392 +184
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
## [2.10.0](v2.9.1...v2.10.0) (2025-01-28) ### 🚀 Features * **api:** Secret rotation ([#652](#652)) ([ad9a808](ad9a808)) * **platform:** Implement delete project ([#671](#671)) ([d243c89](d243c89)) * **platform:** Improved UI of [secure] listing ([#655](#655)) ([b19de47](b19de47)) * **platform:** Operate on environments ([#670](#670)) ([f45c5fa](f45c5fa)) ### 🐛 Bug Fixes * Added lockfile ([856eb3c](856eb3c)) * **api:** Only user's default workspace returns isDefault: true ([#647](#647)) ([870b4dc](870b4dc)) * **cli:** Workspace membership API client payload fixed ([#614](#614)) ([#648](#648)) ([e23057b](e23057b)) * **platform:** Refactor layout structure to improve Navbar positioning & child component ([#661](#661)) ([31067f3](31067f3)) * **Platfrom:** Replace manual date calculation with dayjs to improve better calculation ([#668](#668)) ([990eb86](990eb86)) ### 🔧 Miscellaneous Chores * **ci:** Add manual trigger ([cfbf4b9](cfbf4b9)) * **ci:** Add missing LATEST_TAG variable ([a2ea2ed](a2ea2ed)) * **ci:** Fixed misplaced sentry sourcemaps commands ([fbd6f3b](fbd6f3b)) * **ci:** Fixed scripts ([374f7ed](374f7ed)) * **ci:** Update API sentry dist folder ([2bc9afb](2bc9afb)) * **CI:** Update pipeline ([fd63b70](fd63b70)) * **ci:** Update sourcemap upload commands ([c7e8e45](c7e8e45)) * **cli:** Bumped CLI version to 2.5.0 ([7b772f8](7b772f8)) * Fix prerelease branch config ([7e84021](7e84021)) * **release:** 2.10.0-stage.1 [skip ci] ([a4f8414](a4f8414)), closes [#652](#652) * **release:** 2.10.0-stage.2 [skip ci] ([00ee123](00ee123)), closes [#647](#647) * **release:** 2.10.0-stage.3 [skip ci] ([941a815](941a815)), closes [#655](#655) * **release:** 2.10.0-stage.4 [skip ci] ([ae7c44f](ae7c44f)), closes [#614](#614) [#648](#648) * **release:** 2.10.0-stage.5 [skip ci] ([d718483](d718483)), closes [#661](#661) * **release:** 2.10.0-stage.6 [skip ci] ([4e63f47](4e63f47)), closes [#668](#668) * **release:** 2.10.0-stage.7 [skip ci] ([4a35fe7](4a35fe7)), closes [#671](#671) * **release:** 2.10.0-stage.8 [skip ci] ([36ef21d](36ef21d)), closes [#670](#670) * **release:** 2.9.2-stage.1 [skip ci] ([443f8d4](443f8d4)) ### 🔨 Code Refactoring * **api:** Update getSelf function ([fe752ce](fe752ce))
🎉 This PR is included in version 2.10.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
User description
Description
workspace.isDefault
property mapping takes into account the owner in order to avoid returning multiple defaults.Fixes #587
Screenshots of relevant screens
Developer's checklist
If changes are made in the code:
Documentation Update
PR Type
Bug fix
Description
Fixes the issue of multiple workspaces being marked as
isDefault
.Ensures only the user's default workspace has
isDefault: true
.Updates logic in
getWorkspaceBySlug
to validate ownership forisDefault
.Adjusts
getAllWorkspaces
to correctly mapisDefault
based on ownership.Changes walkthrough 📝
workspace.service.ts
Fix `isDefault` property logic in workspace service
apps/api/src/workspace/service/workspace.service.ts
getWorkspaceBySlug
to ensureisDefault
is true only for theowner's default workspace.
getAllWorkspaces
to mapisDefault
based on ownership.isDefault
againstownerId
for both methods.