fix: Team and User Links (#15342)
* fix: Team and User Links * Add tests
This commit is contained in:
1 parent
4153e5b2d5
commit
def87ea84a
7 files changed
+55
-17
No files matched your search
@@ -33,6 +33,7 @@ export const mapMemberToChildrenOption = (
|
|||||||
membership: member.membership,
|
membership: member.membership,
|
||||||
eventTypeSlugs: member.eventTypes ?? [],
|
eventTypeSlugs: member.eventTypes ?? [],
|
||||||
avatar: member.avatar,
|
avatar: member.avatar,
|
||||||
|
profile: member.profile,
|
||||||
},
|
},
|
||||||
value: `${member.id ?? ""}`,
|
value: `${member.id ?? ""}`,
|
||||||
label: `${member.name || member.email || ""}${!member.username ? ` (${pendingString})` : ""}`,
|
label: `${member.name || member.email || ""}${!member.username ? ` (${pendingString})` : ""}`,
|
||||||
|
|||||||
File renamed without changes.
@@ -115,7 +115,12 @@ const ProfileView = () => {
|
|||||||
const isAdmin =
|
const isAdmin =
|
||||||
team && (team.membership.role === MembershipRole.OWNER || team.membership.role === MembershipRole.ADMIN);
|
team && (team.membership.role === MembershipRole.OWNER || team.membership.role === MembershipRole.ADMIN);
|
||||||
|
|
||||||
const permalink = `${WEBAPP_URL}/team/${team?.slug}`;
|
const permalink = team
|
||||||
|
? `${getTeamUrlSync({
|
||||||
|
orgSlug: team.parent ? team.parent.slug : null,
|
||||||
|
teamSlug: team.slug,
|
||||||
|
})}`
|
||||||
|
: "";
|
||||||
|
|
||||||
const isBioEmpty = !team || !team.bio || !team.bio.replace("<p><br></p>", "").length;
|
const isBioEmpty = !team || !team.bio || !team.bio.replace("<p><br></p>", "").length;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
import { useAutoAnimate } from "@formkit/auto-animate/react";
|
||||||
import type { Props } from "react-select";
|
import type { Props } from "react-select";
|
||||||
|
|
||||||
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
|
|
||||||
import { classNames } from "@calcom/lib";
|
import { classNames } from "@calcom/lib";
|
||||||
import { WEBSITE_URL } from "@calcom/lib/constants";
|
import { getBookerBaseUrlSync } from "@calcom/lib/getBookerUrl/client";
|
||||||
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
||||||
import { MembershipRole } from "@calcom/prisma/enums";
|
import { MembershipRole } from "@calcom/prisma/enums";
|
||||||
|
import type { UserProfile } from "@calcom/types/UserProfile";
|
||||||
import { Avatar, Badge, Button, ButtonGroup, Select, Switch, Tooltip } from "@calcom/ui";
|
import { Avatar, Badge, Button, ButtonGroup, Select, Switch, Tooltip } from "@calcom/ui";
|
||||||
|
|
||||||
export type ChildrenEventType = {
|
export type ChildrenEventType = {
|
||||||
@@ -20,6 +20,7 @@ export type ChildrenEventType = {
|
|||||||
username: string;
|
username: string;
|
||||||
membership: MembershipRole;
|
membership: MembershipRole;
|
||||||
eventTypeSlugs: string[];
|
eventTypeSlugs: string[];
|
||||||
|
profile: UserProfile;
|
||||||
};
|
};
|
||||||
slug: string;
|
slug: string;
|
||||||
hidden: boolean;
|
hidden: boolean;
|
||||||
@@ -35,10 +36,7 @@ export const ChildrenEventTypeSelect = ({
|
|||||||
onChange: (value: readonly ChildrenEventType[]) => void;
|
onChange: (value: readonly ChildrenEventType[]) => void;
|
||||||
}) => {
|
}) => {
|
||||||
const { t } = useLocale();
|
const { t } = useLocale();
|
||||||
const orgBranding = useOrgBranding();
|
|
||||||
|
|
||||||
const [animationRef] = useAutoAnimate<HTMLUListElement>();
|
const [animationRef] = useAutoAnimate<HTMLUListElement>();
|
||||||
const domain = orgBranding?.fullDomain ?? WEBSITE_URL;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -109,7 +107,9 @@ export const ChildrenEventTypeSelect = ({
|
|||||||
color="secondary"
|
color="secondary"
|
||||||
target="_blank"
|
target="_blank"
|
||||||
variant="icon"
|
variant="icon"
|
||||||
href={`${domain}/${children.owner?.username}/${children.slug}`}
|
href={`${getBookerBaseUrlSync(
|
||||||
|
children.owner.profile?.organization?.slug ?? null
|
||||||
|
)}/${children.owner?.username}/${children.slug}`}
|
||||||
StartIcon="external-link"
|
StartIcon="external-link"
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
import { describe, it, vi, expect } from "vitest";
|
||||||
|
|
||||||
|
import { getTeamUrlSync } from "./client";
|
||||||
|
import * as getBookerBaseUrlSyncExport from "./getBookerBaseUrlSync";
|
||||||
|
|
||||||
|
vi.mock("./getBookerBaseUrlSync", async () => {
|
||||||
|
return {
|
||||||
|
getBookerBaseUrlSync: vi.fn(),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("getBookerUrl:client", () => {
|
||||||
|
describe("getTeamUrlSync", () => {
|
||||||
|
it("if orgSlug is null, it should return a URL with /team in it", () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
getBookerBaseUrlSyncExport.getBookerBaseUrlSync.mockReturnValueOnce("https://abc.com");
|
||||||
|
const url = getTeamUrlSync({ orgSlug: null, teamSlug: "myTeam" });
|
||||||
|
expect(url).toBe("https://abc.com/team/myTeam");
|
||||||
|
});
|
||||||
|
|
||||||
|
it("if orgSlug is set, it should return a URL without /team in it", () => {
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
|
// @ts-ignore
|
||||||
|
getBookerBaseUrlSyncExport.getBookerBaseUrlSync.mockReturnValueOnce("https://acme.com");
|
||||||
|
const url = getTeamUrlSync({ orgSlug: "acme", teamSlug: "myTeam" });
|
||||||
|
expect(url).toBe("https://acme.com/myTeam");
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,14 +1,6 @@
|
|||||||
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
|
import { getBookerBaseUrlSync } from "./getBookerBaseUrlSync";
|
||||||
|
|
||||||
export const getBookerBaseUrlSync = (
|
|
||||||
orgSlug: string | null,
|
|
||||||
options?: {
|
|
||||||
protocol: boolean;
|
|
||||||
}
|
|
||||||
) => {
|
|
||||||
return getOrgFullOrigin(orgSlug ?? "", options);
|
|
||||||
};
|
|
||||||
|
|
||||||
|
export { getBookerBaseUrlSync } from "./getBookerBaseUrlSync";
|
||||||
export const getTeamUrlSync = (
|
export const getTeamUrlSync = (
|
||||||
{
|
{
|
||||||
orgSlug,
|
orgSlug,
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
import { getOrgFullOrigin } from "@calcom/ee/organizations/lib/orgDomains";
|
||||||
|
|
||||||
|
export const getBookerBaseUrlSync = (
|
||||||
|
orgSlug: string | null,
|
||||||
|
options?: {
|
||||||
|
protocol: boolean;
|
||||||
|
}
|
||||||
|
) => {
|
||||||
|
return getOrgFullOrigin(orgSlug ?? "", options);
|
||||||
|
};
|
||||||
Reference in new issue
Block a user