-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
V2 settings teams (Profil, Members, Appearance View) (#4350)
* add team profile * first version for team members page * finish up design of member list item * fix dialog buttons * add missing seats and upgrading information * add v2 dialog for changing role * finish basic version of member's schedule * remove modalContainer * design fixes team profile page * show only team info to non admins * allow all member to check availabilities * make time available heading sticky * add dropdown for mobile view * create team appearance view * finish appearance page * use settings layout and add danger zone for member * add fallback logo * Add teams to sidebar and fix UI * add team invitations * Clean up * code clean up * add impersontation and disable autofocus on calendar * improve team info * refactor teaminvitelist code and fix leaving a team * add team pages to settings shell * add link to create new team * small fixes * clean up comments * V2 Multi-select (Team Select) (#4324) * --init * design improved * further fine tuning * more fixes * removed extra JSX tag * added story * NIT * revert to use of CheckedTeamSelect * Removes comments Co-authored-by: Peer Richelsen <peeroke@gmail.com> * fix: toggle alligment (#4361) * fix: add checked tranform for switch (#4357) * fixed input size on mobile, fixed settings (#4360) * fix image uploader button in safari * code clean up * fixing type errors * Moved v2 team components to features Adds deprecation notices * Update SettingsLayout.tsx * Migrated to features and build fixes Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Joe Au-Yeung <j.auyeung419@gmail.com> Co-authored-by: Syed Ali Shahbaz <52925846+alishaz-polymath@users.noreply.github.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com> Co-authored-by: Joe Au-Yeung <65426560+joeauyeung@users.noreply.github.com> Co-authored-by: zomars <zomars@me.com>
- Loading branch information
1 parent
50f63ef
commit 7e917cd
Showing
36 changed files
with
1,917 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "@calcom/features/ee/teams/pages/team-appearance-view"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "@calcom/features/ee/teams/pages/team-members-view"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default } from "@calcom/features/ee/teams/pages/team-profile-view"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
packages/features/ee/teams/components/DisableTeamImpersonation.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { classNames } from "@calcom/lib"; | ||
import { useLocale } from "@calcom/lib/hooks/useLocale"; | ||
import { trpc } from "@calcom/trpc/react"; | ||
import { showToast, Switch } from "@calcom/ui/v2/core"; | ||
|
||
const DisableTeamImpersonation = ({ | ||
teamId, | ||
memberId, | ||
disabled, | ||
}: { | ||
teamId: number; | ||
memberId: number; | ||
disabled: boolean; | ||
}) => { | ||
const { t } = useLocale(); | ||
|
||
const utils = trpc.useContext(); | ||
|
||
const query = trpc.useQuery(["viewer.teams.getMembershipbyUser", { teamId, memberId }]); | ||
|
||
const mutation = trpc.useMutation("viewer.teams.updateMembership", { | ||
onSuccess: async () => { | ||
showToast(t("your_user_profile_updated_successfully"), "success"); | ||
await utils.invalidateQueries(["viewer.teams.getMembershipbyUser"]); | ||
}, | ||
async onSettled() { | ||
await utils.invalidateQueries(["viewer.public.i18n"]); | ||
}, | ||
}); | ||
if (query.isLoading) return <></>; | ||
|
||
return ( | ||
<> | ||
<div className="flex flex-col justify-between sm:flex-row"> | ||
<div> | ||
<div className="flex flex-row items-center"> | ||
<h2 | ||
className={classNames( | ||
"font-cal mb-0.5 text-sm font-semibold leading-6", | ||
disabled ? "text-gray-400 " : "text-gray-900 " | ||
)}> | ||
{t("user_impersonation_heading")} | ||
</h2> | ||
</div> | ||
<p className={classNames("text-sm leading-5 ", disabled ? "text-gray-300" : "text-gray-600")}> | ||
{t("team_impersonation_description")} | ||
</p> | ||
</div> | ||
<div className="mt-5 sm:mt-0 sm:self-center"> | ||
<Switch | ||
disabled={disabled} | ||
defaultChecked={query.data?.disableImpersonation} | ||
onCheckedChange={(isChecked) => { | ||
mutation.mutate({ teamId, memberId, disableImpersonation: isChecked }); | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default DisableTeamImpersonation; |
113 changes: 113 additions & 0 deletions
113
packages/features/ee/teams/components/MemberChangeRoleModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
import { MembershipRole } from "@prisma/client"; | ||
import { SyntheticEvent, useMemo, useState } from "react"; | ||
|
||
import { useLocale } from "@calcom/lib/hooks/useLocale"; | ||
import { trpc } from "@calcom/trpc/react"; | ||
import { Button, Dialog, DialogContent, Select } from "@calcom/ui/v2"; | ||
|
||
type MembershipRoleOption = { | ||
label: string; | ||
value: MembershipRole; | ||
}; | ||
|
||
export default function MemberChangeRoleModal(props: { | ||
isOpen: boolean; | ||
currentMember: MembershipRole; | ||
memberId: number; | ||
teamId: number; | ||
initialRole: MembershipRole; | ||
onExit: () => void; | ||
}) { | ||
const { t } = useLocale(); | ||
|
||
const options = useMemo(() => { | ||
return [ | ||
{ | ||
label: t("member"), | ||
value: MembershipRole.MEMBER, | ||
}, | ||
{ | ||
label: t("admin"), | ||
value: MembershipRole.ADMIN, | ||
}, | ||
{ | ||
label: t("owner"), | ||
value: MembershipRole.OWNER, | ||
}, | ||
].filter(({ value }) => value !== MembershipRole.OWNER || props.currentMember === MembershipRole.OWNER); | ||
}, [t, props.currentMember]); | ||
|
||
const [role, setRole] = useState<MembershipRoleOption>( | ||
options.find((option) => option.value === props.initialRole) || { | ||
label: t("member"), | ||
value: MembershipRole.MEMBER, | ||
} | ||
); | ||
const [errorMessage, setErrorMessage] = useState(""); | ||
const utils = trpc.useContext(); | ||
|
||
const changeRoleMutation = trpc.useMutation("viewer.teams.changeMemberRole", { | ||
async onSuccess() { | ||
await utils.invalidateQueries(["viewer.teams.get"]); | ||
props.onExit(); | ||
}, | ||
async onError(err) { | ||
setErrorMessage(err.message); | ||
}, | ||
}); | ||
|
||
function changeRole(e: SyntheticEvent) { | ||
e.preventDefault(); | ||
|
||
changeRoleMutation.mutate({ | ||
teamId: props.teamId, | ||
memberId: props.memberId, | ||
role: role.value, | ||
}); | ||
} | ||
return ( | ||
<Dialog open={props.isOpen} onOpenChange={props.onExit}> | ||
<DialogContent type="creation" useOwnActionButtons size="md"> | ||
<> | ||
<div className="mb-4 sm:flex sm:items-start"> | ||
<div className="text-center sm:text-left"> | ||
<h3 className="text-lg font-medium leading-6 text-gray-900" id="modal-title"> | ||
{t("change_member_role")} | ||
</h3> | ||
</div> | ||
</div> | ||
<form onSubmit={changeRole}> | ||
<div className="mb-4"> | ||
<label className="mb-2 block text-sm font-medium tracking-wide text-gray-700" htmlFor="role"> | ||
{t("role")} | ||
</label> | ||
{/*<option value="OWNER">{t("owner")}</option> - needs dialog to confirm change of ownership */} | ||
<Select | ||
isSearchable={false} | ||
options={options} | ||
value={role} | ||
onChange={(option) => option && setRole(option)} | ||
id="role" | ||
className="mt-1 block w-full rounded-md border-gray-300 text-sm" | ||
/> | ||
</div> | ||
{errorMessage && ( | ||
<p className="text-sm text-red-700"> | ||
<span className="font-bold">Error: </span> | ||
{errorMessage} | ||
</p> | ||
)} | ||
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse"> | ||
<Button type="submit" color="primary" className="ltr:ml-2 rtl:mr-2"> | ||
{t("save")} | ||
</Button> | ||
<Button type="button" color="secondary" onClick={props.onExit}> | ||
{t("cancel")} | ||
</Button> | ||
</div> | ||
</form> | ||
</> | ||
</DialogContent> | ||
</Dialog> | ||
); | ||
} |
Oops, something went wrong.