Skip to content

fix: Allow org creation with conflicting slug and renaming team slug during migration#13065

Merged
hariombalhara merged 1 commit intomainfrom
feat-rename-team-slug-and-allow-org-creation-with-conflicting-slug-with-team
Jan 7, 2024
Merged

fix: Allow org creation with conflicting slug and renaming team slug during migration#13065
hariombalhara merged 1 commit intomainfrom
feat-rename-team-slug-and-allow-org-creation-with-conflicting-slug-with-team

Conversation

@hariombalhara
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara commented Jan 6, 2024

What does this PR do?

  • Now an organization can be created with the requestedSlug same as a team's slug. It allows then moving that team to the organization itself. It is a common scenario when a team upgrades to be come an organization
  • Org Migration - Allow renaming team slug which is a common scenario when team's migrate to an organization e.g. calcom-engineering -> engineering inside calcom org.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Mandatory Tasks

  • Make sure you have self-reviewed the code. A decent size PR without self-review might be rejected.

Checklist

  • I haven't added tests that prove my fix is effective or that my feature works

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 6, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2024 8:43am
api ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2024 8:43am
dev ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 6, 2024 8:43am
qa 🔄 Building (Inspect) Visit Preview 💬 Add feedback Jan 6, 2024 8:43am
3 Ignored Deployments
Name Status Preview Comments Updated (UTC)
cal ⬜️ Ignored (Inspect) Visit Preview Jan 6, 2024 8:43am
cal-demo ⬜️ Ignored (Inspect) Jan 6, 2024 8:43am
ui ⬜️ Ignored (Inspect) Visit Preview Jan 6, 2024 8:43am

@hariombalhara
Copy link
Copy Markdown
Member Author

Current dependencies on/for this PR:

This stack of pull requests is managed by Graphite.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 6, 2024

Thank you for following the naming conventions! 🙏 Feel free to join our discord and post your PR link.

@keithwillcode keithwillcode added the core area: core, team members only label Jan 6, 2024
@hariombalhara hariombalhara changed the title feat: Allow org creation with conflicting slug and renaming team slug during migration fix: Allow org creation with conflicting slug and renaming team slug during migration Jan 6, 2024
Comment on lines -695 to -700
if (team.parentId !== targetOrgId) {
log.warn(`Team ${teamId} is not part of org ${targetOrgId}. Not updating`);
return {
slug: team.slug,
};
}
Copy link
Copy Markdown
Member Author

@hariombalhara hariombalhara Jan 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to unnecessarily stop the revert as it can possibly allow fixing things by running revert again. Goal is to keep the functions idempotent

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jan 6, 2024

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌

async function expectTeamToBeAPartOfOrg({
teamId,
orgId,
teamSlugInOrg,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify the new teamSlug is there

await addTeamRedirect(movedTeam.slug, targetOrganization.slug || orgMetadata.requestedSlug || null);
await setOrgSlugIfNotSet({ slug: targetOrganization.slug }, orgMetadata, targetOrgId);
await addTeamRedirect({
oldTeamSlug,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify that the redirect is from oldTeamSlug to new URL

Comment on lines +279 to +282
migratedToOrgFrom: {
teamSlug: team.slug,
lastMigrationTime: new Date().toISOString(),
},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just saw this - how should we store this info in the new organization settings PR?

@hariombalhara hariombalhara merged commit 2f1e545 into main Jan 7, 2024
@hariombalhara hariombalhara deleted the feat-rename-team-slug-and-allow-org-creation-with-conflicting-slug-with-team branch January 7, 2024 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants