+27









sean-brydon
Udit Takkar
Hariom Balhara
Leo Giovanetti
Alex van Andel
CarinaWolli
zomars
Peer Richelsen
Joe Au-Yeung
Udit Takkar
Keith Williams
Peer Richelsen
Syed Ali Shahbaz
gitstart-calcom
Shivam Kalra
cherish2003
rkreddy99
varun thummar
Crowdin Bot
Pradumn Kumar
Richard Poelderl
mohammed hussam
Carina Wollendorfer
Anik Dhabal Babu
nicktrn
sydwardrae
Janakiram Yellapu
GitStart-Cal.com
sajanlamsal
Cherish
Danila
Neel Patel
Rama Krishna Reddy
Varun Thummar
Bhargav
Pratik Kumar
Ritesh Patil
10ffd9bacd
Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Hariom Balhara <[email protected]> Co-authored-by: Leo Giovanetti <[email protected]> Co-authored-by: Alex van Andel <[email protected]> Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: zomars <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Udit Takkar <[email protected]> Co-authored-by: Keith Williams <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Syed Ali Shahbaz <[email protected]> Co-authored-by: gitstart-calcom <[email protected]> Co-authored-by: Shivam Kalra <[email protected]> Co-authored-by: cherish2003 <[email protected]> Co-authored-by: sean-brydon <[email protected]> Co-authored-by: rkreddy99 <[email protected]> Co-authored-by: varun thummar <Varun> Co-authored-by: Crowdin Bot <[email protected]> Co-authored-by: Pradumn Kumar <[email protected]> Co-authored-by: Richard Poelderl <[email protected]> Co-authored-by: mohammed hussam <[email protected]> Co-authored-by: Carina Wollendorfer <[email protected]> Co-authored-by: Anik Dhabal Babu <[email protected]> Co-authored-by: nicktrn <[email protected]> Co-authored-by: sydwardrae <[email protected]> Co-authored-by: Janakiram Yellapu <[email protected]> Co-authored-by: GitStart-Cal.com <[email protected]> Co-authored-by: sajanlamsal <[email protected]> Co-authored-by: Cherish <[email protected]> Co-authored-by: Danila <[email protected]> Co-authored-by: Neel Patel <[email protected]> Co-authored-by: Rama Krishna Reddy <[email protected]> Co-authored-by: Varun Thummar <[email protected]> Co-authored-by: Bhargav <[email protected]> Co-authored-by: Pratik Kumar <[email protected]> Co-authored-by: Ritesh Patil <[email protected]>
181 lines
5.4 KiB
TypeScript
181 lines
5.4 KiB
TypeScript
import { ExternalLink, MoreHorizontal, Edit2, UserX, Lock } from "lucide-react";
|
|
|
|
import { classNames } from "@calcom/lib";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import {
|
|
ButtonGroup,
|
|
Tooltip,
|
|
Button,
|
|
Dropdown,
|
|
DropdownMenuTrigger,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownItem,
|
|
DropdownMenuSeparator,
|
|
} from "@calcom/ui";
|
|
|
|
import type { Action } from "./UserListTable";
|
|
import type { User } from "./UserListTable";
|
|
|
|
export function TableActions({
|
|
user,
|
|
permissionsForUser,
|
|
dispatch,
|
|
domain,
|
|
}: {
|
|
user: User;
|
|
dispatch: React.Dispatch<Action>;
|
|
domain: string;
|
|
permissionsForUser: {
|
|
canEdit: boolean;
|
|
canRemove: boolean;
|
|
canImpersonate: boolean;
|
|
};
|
|
}) {
|
|
const { t } = useLocale();
|
|
|
|
const usersProfileUrl = domain + "/" + user.username;
|
|
|
|
return (
|
|
<>
|
|
<ButtonGroup combined containerProps={{ className: "border-default hidden md:flex" }}>
|
|
<Tooltip content={t("view_public_page")}>
|
|
<Button
|
|
target="_blank"
|
|
href={usersProfileUrl}
|
|
color="secondary"
|
|
className={classNames(!permissionsForUser.canEdit ? "rounded-r-md" : "")}
|
|
variant="icon"
|
|
StartIcon={ExternalLink}
|
|
/>
|
|
</Tooltip>
|
|
{(permissionsForUser.canEdit || permissionsForUser.canRemove) && (
|
|
<Dropdown>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
className="radix-state-open:rounded-r-md"
|
|
color="secondary"
|
|
variant="icon"
|
|
StartIcon={MoreHorizontal}
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent>
|
|
{permissionsForUser.canEdit && (
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
onClick={() =>
|
|
dispatch({
|
|
type: "EDIT_USER_SHEET",
|
|
payload: {
|
|
user,
|
|
showModal: true,
|
|
},
|
|
})
|
|
}
|
|
StartIcon={Edit2}>
|
|
{t("edit")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
)}
|
|
{permissionsForUser.canImpersonate && (
|
|
<>
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
onClick={() =>
|
|
dispatch({
|
|
type: "SET_IMPERSONATE_ID",
|
|
payload: {
|
|
user,
|
|
showModal: true,
|
|
},
|
|
})
|
|
}
|
|
StartIcon={Lock}>
|
|
{t("impersonate")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
<DropdownMenuSeparator />
|
|
</>
|
|
)}
|
|
{permissionsForUser.canRemove && (
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
onClick={() =>
|
|
dispatch({
|
|
type: "SET_DELETE_ID",
|
|
payload: {
|
|
user,
|
|
showModal: true,
|
|
},
|
|
})
|
|
}
|
|
color="destructive"
|
|
StartIcon={UserX}>
|
|
{t("remove")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
)}
|
|
</DropdownMenuContent>
|
|
</Dropdown>
|
|
)}
|
|
</ButtonGroup>
|
|
<div className="flex md:hidden">
|
|
<Dropdown>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button type="button" variant="icon" color="minimal" StartIcon={MoreHorizontal} />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent>
|
|
<DropdownMenuItem className="outline-none">
|
|
<DropdownItem type="button" StartIcon={ExternalLink}>
|
|
{t("view_public_page")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
{permissionsForUser.canEdit && (
|
|
<>
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
onClick={() =>
|
|
dispatch({
|
|
type: "EDIT_USER_SHEET",
|
|
payload: {
|
|
user,
|
|
showModal: true,
|
|
},
|
|
})
|
|
}
|
|
StartIcon={Edit2}>
|
|
{t("edit")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
</>
|
|
)}
|
|
{permissionsForUser.canRemove && (
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
color="destructive"
|
|
onClick={() =>
|
|
dispatch({
|
|
type: "SET_DELETE_ID",
|
|
payload: {
|
|
user,
|
|
showModal: true,
|
|
},
|
|
})
|
|
}
|
|
StartIcon={UserX}>
|
|
{t("remove")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
)}
|
|
</DropdownMenuContent>
|
|
</Dropdown>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|