-
Notifications
You must be signed in to change notification settings - Fork 11.7k
fix: allow team with same slug for diff cases #24029
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
Merged
Merged
Changes from 7 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
07846ec
fix: aalow team with slug for diff cases
anikdhabal 517541f
Merge branch 'main' into allow-team-with-same-slug
anikdhabal bcda920
addressed review
anikdhabal 3b88f35
fix type error
anikdhabal a90216a
update test
anikdhabal 8457a88
addressed review
anikdhabal a74fe2f
Merge branch 'main' into allow-team-with-same-slug
anikdhabal cc9120e
fix test
anikdhabal a274c1f
Update team.ts
anikdhabal cac44e4
Merge branch 'main' into allow-team-with-same-slug
Udit-takkar 03794ae
Merge branch 'main' into allow-team-with-same-slug
emrysal 1ec282e
mistake
anikdhabal 4427e5f
Merge branch 'main' into allow-team-with-same-slug
Ryukemeister d3d6267
Merge branch 'main' into allow-team-with-same-slug
anikdhabal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -160,6 +160,7 @@ const createTeamAndAddUser = async ( | |
| orgRequestedSlug, | ||
| schedulingType, | ||
| assignAllTeamMembersForSubTeamEvents, | ||
| teamSlug, | ||
| }: { | ||
| user: { id: number; email: string; username: string | null; role?: MembershipRole }; | ||
| isUnpublished?: boolean; | ||
|
|
@@ -172,12 +173,15 @@ const createTeamAndAddUser = async ( | |
| orgRequestedSlug?: string; | ||
| schedulingType?: SchedulingType; | ||
| assignAllTeamMembersForSubTeamEvents?: boolean; | ||
| teamSlug?: string; | ||
| }, | ||
| workerInfo: WorkerInfo | ||
| ) => { | ||
| const slugIndex = index ? `-count-${index}` : ""; | ||
| const slug = | ||
| orgRequestedSlug ?? `${isOrg ? "org" : "team"}-${workerInfo.workerIndex}-${Date.now()}${slugIndex}`; | ||
| teamSlug ?? | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIT: can we abstract this logic into its own function instead of just using the nullish coalescing operator? this could get messy really fast if in future we might need to update the logic and add some stuff in here |
||
| orgRequestedSlug ?? | ||
| `${isOrg ? "org" : "team"}-${workerInfo.workerIndex}-${Date.now()}${slugIndex}`; | ||
| const data: PrismaType.TeamCreateInput = { | ||
| name: `user-id-${user.id}'s ${isOrg ? "Org" : "Team"}`, | ||
| isOrganization: isOrg, | ||
|
|
@@ -283,6 +287,7 @@ export const createUsersFixture = ( | |
| schedulingType?: SchedulingType; | ||
| teamEventTitle?: string; | ||
| teamEventSlug?: string; | ||
| teamSlug?: string; | ||
| teamEventLength?: number; | ||
| isOrg?: boolean; | ||
| isOrgVerified?: boolean; | ||
|
|
@@ -367,6 +372,7 @@ export const createUsersFixture = ( | |
| orgRequestedSlug: scenario.orgRequestedSlug, | ||
| schedulingType: scenario.schedulingType, | ||
| assignAllTeamMembersForSubTeamEvents: scenario.assignAllTeamMembersForSubTeamEvents, | ||
| teamSlug: scenario?.teamSlug, | ||
| }, | ||
| workerInfo | ||
| ); | ||
|
|
@@ -465,7 +471,7 @@ export const createUsersFixture = ( | |
| }, | ||
| data: { | ||
| orgProfiles: _user.profiles.length | ||
| ? { | ||
| ? { | ||
| connect: _user.profiles.map((profile) => ({ id: profile.id })), | ||
| } | ||
| : { | ||
|
|
@@ -711,6 +717,31 @@ const createUserFixture = (user: UserWithIncludes, page: Page) => { | |
| } | ||
| return membership; | ||
| }, | ||
| getAllTeamMembership: async () => { | ||
| const memberships = await prisma.membership.findMany({ | ||
| where: { | ||
| userId: user.id, | ||
| team: { | ||
| isOrganization: false, | ||
| }, | ||
| }, | ||
| include: { team: true, user: true }, | ||
| }); | ||
|
|
||
| const filteredMemberships = memberships.map((membership) => ({ | ||
| ...membership, | ||
| team: { | ||
| ...membership.team, | ||
| metadata: teamMetadataSchema.parse(membership.team.metadata), | ||
| }, | ||
| })); | ||
|
|
||
| if (filteredMemberships.length === 0) { | ||
| throw new Error("No team memberships found for user"); | ||
| } | ||
|
|
||
| return filteredMemberships; | ||
| }, | ||
| getOrgMembership: async () => { | ||
| const membership = await prisma.membership.findFirstOrThrow({ | ||
| where: { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.