fix: Team URL and booker URLs (#13050)
Co-authored-by: Bailey Pumfleet <bailey@pumfleet.co.uk> Co-authored-by: Peer Richelsen <peeroke@gmail.com>
This commit is contained in:
parent
e2ef9dd710
commit
4aa0b4cc65
|
@ -3,12 +3,14 @@ import prismock from "../../../tests/libs/__mocks__/prisma";
|
||||||
import { describe, expect, it } from "vitest";
|
import { describe, expect, it } from "vitest";
|
||||||
import type { z } from "zod";
|
import type { z } from "zod";
|
||||||
|
|
||||||
|
import { WEBSITE_URL } from "@calcom/lib/constants";
|
||||||
import type { MembershipRole, Prisma } from "@calcom/prisma/client";
|
import type { MembershipRole, Prisma } from "@calcom/prisma/client";
|
||||||
import { RedirectType } from "@calcom/prisma/enums";
|
import { RedirectType } from "@calcom/prisma/enums";
|
||||||
import type { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
import type { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||||
|
|
||||||
import { moveTeamToOrg, moveUserToOrg, removeTeamFromOrg, removeUserFromOrg } from "./orgMigration";
|
import { moveTeamToOrg, moveUserToOrg, removeTeamFromOrg, removeUserFromOrg } from "./orgMigration";
|
||||||
|
|
||||||
|
const WEBSITE_PROTOCOL = new URL(WEBSITE_URL).protocol;
|
||||||
describe("orgMigration", () => {
|
describe("orgMigration", () => {
|
||||||
describe("moveUserToOrg", () => {
|
describe("moveUserToOrg", () => {
|
||||||
describe("when user email does not match orgAutoAcceptEmail", () => {
|
describe("when user email does not match orgAutoAcceptEmail", () => {
|
||||||
|
@ -1366,7 +1368,7 @@ async function expectRedirectToBeEnabled({
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(redirect).not.toBeNull();
|
expect(redirect).not.toBeNull();
|
||||||
expect(redirect?.toUrl).toBe(`http://${orgSlug}.cal.local:3000/${to}`);
|
expect(redirect?.toUrl).toBe(`${WEBSITE_PROTOCOL}//${orgSlug}.cal.local:3000/${to}`);
|
||||||
if (!redirect) {
|
if (!redirect) {
|
||||||
throw new Error(`Redirect doesn't exist for ${JSON.stringify(tempOrgRedirectWhere)}`);
|
throw new Error(`Redirect doesn't exist for ${JSON.stringify(tempOrgRedirectWhere)}`);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
import type { TestFunction } from "vitest";
|
import type { TestFunction } from "vitest";
|
||||||
|
|
||||||
|
import { WEBSITE_URL } from "@calcom/lib/constants";
|
||||||
import { test } from "@calcom/web/test/fixtures/fixtures";
|
import { test } from "@calcom/web/test/fixtures/fixtures";
|
||||||
import type { Fixtures } from "@calcom/web/test/fixtures/fixtures";
|
import type { Fixtures } from "@calcom/web/test/fixtures/fixtures";
|
||||||
import { createOrganization } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
|
import { createOrganization } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
|
||||||
|
|
||||||
|
const WEBSITE_PROTOCOL = new URL(WEBSITE_URL).protocol;
|
||||||
const _testWithAndWithoutOrg = (
|
const _testWithAndWithoutOrg = (
|
||||||
description: Parameters<typeof testWithAndWithoutOrg>[0],
|
description: Parameters<typeof testWithAndWithoutOrg>[0],
|
||||||
fn: Parameters<typeof testWithAndWithoutOrg>[1],
|
fn: Parameters<typeof testWithAndWithoutOrg>[1],
|
||||||
|
@ -28,7 +30,7 @@ const _testWithAndWithoutOrg = (
|
||||||
skip,
|
skip,
|
||||||
org: {
|
org: {
|
||||||
organization: org,
|
organization: org,
|
||||||
urlOrigin: `http://${org.slug}.cal.local:3000`,
|
urlOrigin: `${WEBSITE_PROTOCOL}//${org.slug}.cal.local:3000`,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import type { Prisma } from "@prisma/client";
|
import type { Prisma } from "@prisma/client";
|
||||||
import type { IncomingMessage } from "http";
|
import type { IncomingMessage } from "http";
|
||||||
|
|
||||||
import { IS_PRODUCTION } from "@calcom/lib/constants";
|
import { IS_PRODUCTION, WEBSITE_URL } from "@calcom/lib/constants";
|
||||||
import { ALLOWED_HOSTNAMES, RESERVED_SUBDOMAINS, WEBAPP_URL } from "@calcom/lib/constants";
|
import { ALLOWED_HOSTNAMES, RESERVED_SUBDOMAINS, WEBAPP_URL } from "@calcom/lib/constants";
|
||||||
import logger from "@calcom/lib/logger";
|
import logger from "@calcom/lib/logger";
|
||||||
import slugify from "@calcom/lib/slugify";
|
import slugify from "@calcom/lib/slugify";
|
||||||
|
@ -100,9 +100,10 @@ export function subdomainSuffix() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getOrgFullOrigin(slug: string, options: { protocol: boolean } = { protocol: true }) {
|
export function getOrgFullOrigin(slug: string, options: { protocol: boolean } = { protocol: true }) {
|
||||||
if (!slug) return options.protocol ? WEBAPP_URL : WEBAPP_URL.replace("https://", "").replace("http://", "");
|
if (!slug)
|
||||||
|
return options.protocol ? WEBSITE_URL : WEBSITE_URL.replace("https://", "").replace("http://", "");
|
||||||
const orgFullOrigin = `${
|
const orgFullOrigin = `${
|
||||||
options.protocol ? `${new URL(WEBAPP_URL).protocol}//` : ""
|
options.protocol ? `${new URL(WEBSITE_URL).protocol}//` : ""
|
||||||
}${slug}.${subdomainSuffix()}`;
|
}${slug}.${subdomainSuffix()}`;
|
||||||
return orgFullOrigin;
|
return orgFullOrigin;
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,9 +107,7 @@ export default function TeamListItem(props: Props) {
|
||||||
<span className="text-default text-sm font-bold">{team.name}</span>
|
<span className="text-default text-sm font-bold">{team.name}</span>
|
||||||
<span className="text-muted block text-xs">
|
<span className="text-muted block text-xs">
|
||||||
{team.slug ? (
|
{team.slug ? (
|
||||||
`${getTeamUrlSync({ orgSlug: team.parent ? team.parent.slug : null, teamSlug: team.slug })}/${
|
`${getTeamUrlSync({ orgSlug: team.parent ? team.parent.slug : null, teamSlug: team.slug })}`
|
||||||
team.slug
|
|
||||||
}`
|
|
||||||
) : (
|
) : (
|
||||||
<Badge>{t("upgrade")}</Badge>
|
<Badge>{t("upgrade")}</Badge>
|
||||||
)}
|
)}
|
||||||
|
@ -245,11 +243,10 @@ export default function TeamListItem(props: Props) {
|
||||||
color="secondary"
|
color="secondary"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
navigator.clipboard.writeText(
|
navigator.clipboard.writeText(
|
||||||
`${
|
`${getTeamUrlSync({
|
||||||
orgBranding
|
orgSlug: team.parent ? team.parent.slug : null,
|
||||||
? `${orgBranding.fullDomain}`
|
teamSlug: team.slug,
|
||||||
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team`
|
})}`
|
||||||
}/${team.slug}`
|
|
||||||
);
|
);
|
||||||
showToast(t("link_copied"), "success");
|
showToast(t("link_copied"), "success");
|
||||||
}}
|
}}
|
||||||
|
@ -285,11 +282,10 @@ export default function TeamListItem(props: Props) {
|
||||||
<DropdownItem
|
<DropdownItem
|
||||||
type="button"
|
type="button"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href={`${
|
href={`${getTeamUrlSync({
|
||||||
orgBranding
|
orgSlug: team.parent ? team.parent.slug : null,
|
||||||
? `${orgBranding.fullDomain}`
|
teamSlug: team.slug,
|
||||||
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team`
|
})}`}
|
||||||
}/${team.slug}`}
|
|
||||||
StartIcon={ExternalLink}>
|
StartIcon={ExternalLink}>
|
||||||
{t("preview_team") as string}
|
{t("preview_team") as string}
|
||||||
</DropdownItem>
|
</DropdownItem>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user