Skip to content
This repository has been archived by the owner on Jan 23, 2024. It is now read-only.

Commit

Permalink
fix: disable create team button for non admins (calcom#11470)
Browse files Browse the repository at this point in the history
Co-authored-by: CarinaWolli <[email protected]>
  • Loading branch information
Udit-takkar and CarinaWolli authored Sep 21, 2023
1 parent 9447656 commit 86b3a33
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export const CreateANewTeamForm = () => {
<div className="mb-8">
{serverErrorMessage && (
<div className="mb-4">
<Alert severity="error" message={serverErrorMessage} />
<Alert severity="error" message={t(serverErrorMessage)} />
</div>
)}

Expand Down
10 changes: 8 additions & 2 deletions packages/features/ee/teams/components/TeamsListing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export function TeamsListing() {
const teams = useMemo(() => data?.filter((m) => m.accepted) || [], [data]);
const invites = useMemo(() => data?.filter((m) => !m.accepted) || [], [data]);

const isCreateTeamButtonDisabled = user?.organizationId && !user?.organization?.isOrgAdmin;

const features = [
{
icon: <Users className="h-5 w-5 text-red-500" />,
Expand Down Expand Up @@ -95,7 +97,7 @@ export function TeamsListing() {

{invites.length > 0 && (
<div className="bg-subtle mb-6 rounded-md p-5">
<Label className=" text-emphasis pb-2 font-semibold">{t("pending_invites")}</Label>
<Label className="text-emphasis pb-2 font-semibold">{t("pending_invites")}</Label>
<TeamList teams={invites} pending />
</div>
)}
Expand Down Expand Up @@ -131,7 +133,11 @@ export function TeamsListing() {
buttonRaw={
<Button
color="secondary"
href={`${WEBAPP_URL}/settings/teams/new?returnTo=${WEBAPP_URL}/teams`}>
disabled={!!isCreateTeamButtonDisabled}
tooltip={
isCreateTeamButtonDisabled ? t("org_admins_can_create_new_teams") : t("create_new_team")
}
onClick={() => router.push(`${WEBAPP_URL}/settings/teams/new?returnTo=${WEBAPP_URL}/teams`)}>
{t(`create_new_team`)}
</Button>
}
Expand Down

0 comments on commit 86b3a33

Please sign in to comment.