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 type { z } from "zod";
|
||||
|
||||
import { WEBSITE_URL } from "@calcom/lib/constants";
|
||||
import type { MembershipRole, Prisma } from "@calcom/prisma/client";
|
||||
import { RedirectType } from "@calcom/prisma/enums";
|
||||
import type { teamMetadataSchema } from "@calcom/prisma/zod-utils";
|
||||
|
||||
import { moveTeamToOrg, moveUserToOrg, removeTeamFromOrg, removeUserFromOrg } from "./orgMigration";
|
||||
|
||||
const WEBSITE_PROTOCOL = new URL(WEBSITE_URL).protocol;
|
||||
describe("orgMigration", () => {
|
||||
describe("moveUserToOrg", () => {
|
||||
describe("when user email does not match orgAutoAcceptEmail", () => {
|
||||
|
@ -1366,7 +1368,7 @@ async function expectRedirectToBeEnabled({
|
|||
}
|
||||
|
||||
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) {
|
||||
throw new Error(`Redirect doesn't exist for ${JSON.stringify(tempOrgRedirectWhere)}`);
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import type { TestFunction } from "vitest";
|
||||
|
||||
import { WEBSITE_URL } from "@calcom/lib/constants";
|
||||
import { test } from "@calcom/web/test/fixtures/fixtures";
|
||||
import type { Fixtures } from "@calcom/web/test/fixtures/fixtures";
|
||||
import { createOrganization } from "@calcom/web/test/utils/bookingScenario/bookingScenario";
|
||||
|
||||
const WEBSITE_PROTOCOL = new URL(WEBSITE_URL).protocol;
|
||||
const _testWithAndWithoutOrg = (
|
||||
description: Parameters<typeof testWithAndWithoutOrg>[0],
|
||||
fn: Parameters<typeof testWithAndWithoutOrg>[1],
|
||||
|
@ -28,7 +30,7 @@ const _testWithAndWithoutOrg = (
|
|||
skip,
|
||||
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 { 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 logger from "@calcom/lib/logger";
|
||||
import slugify from "@calcom/lib/slugify";
|
||||
|
@ -100,9 +100,10 @@ export function subdomainSuffix() {
|
|||
}
|
||||
|
||||
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 = `${
|
||||
options.protocol ? `${new URL(WEBAPP_URL).protocol}//` : ""
|
||||
options.protocol ? `${new URL(WEBSITE_URL).protocol}//` : ""
|
||||
}${slug}.${subdomainSuffix()}`;
|
||||
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-muted block text-xs">
|
||||
{team.slug ? (
|
||||
`${getTeamUrlSync({ orgSlug: team.parent ? team.parent.slug : null, teamSlug: team.slug })}/${
|
||||
team.slug
|
||||
}`
|
||||
`${getTeamUrlSync({ orgSlug: team.parent ? team.parent.slug : null, teamSlug: team.slug })}`
|
||||
) : (
|
||||
<Badge>{t("upgrade")}</Badge>
|
||||
)}
|
||||
|
@ -245,11 +243,10 @@ export default function TeamListItem(props: Props) {
|
|||
color="secondary"
|
||||
onClick={() => {
|
||||
navigator.clipboard.writeText(
|
||||
`${
|
||||
orgBranding
|
||||
? `${orgBranding.fullDomain}`
|
||||
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team`
|
||||
}/${team.slug}`
|
||||
`${getTeamUrlSync({
|
||||
orgSlug: team.parent ? team.parent.slug : null,
|
||||
teamSlug: team.slug,
|
||||
})}`
|
||||
);
|
||||
showToast(t("link_copied"), "success");
|
||||
}}
|
||||
|
@ -285,11 +282,10 @@ export default function TeamListItem(props: Props) {
|
|||
<DropdownItem
|
||||
type="button"
|
||||
target="_blank"
|
||||
href={`${
|
||||
orgBranding
|
||||
? `${orgBranding.fullDomain}`
|
||||
: `${process.env.NEXT_PUBLIC_WEBSITE_URL}/team`
|
||||
}/${team.slug}`}
|
||||
href={`${getTeamUrlSync({
|
||||
orgSlug: team.parent ? team.parent.slug : null,
|
||||
teamSlug: team.slug,
|
||||
})}`}
|
||||
StartIcon={ExternalLink}>
|
||||
{t("preview_team") as string}
|
||||
</DropdownItem>
|
||||
|
|
Loading…
Reference in New Issue
Block a user