* WIP restored from .git cache * fix exports * sortable row model * feat column visibility component * wip filters with nuqs * pull in unique values from table into filters * correctly assign filters via v/f * inital selection bar refactor * data-table selection bar + optmistic update of delete * dynamic link * migrate member list table to new data-table * total list shows filtered value > db valuie * add filters for attributes * type errors * make content bigger on lg * add mb-6 to teams user datatable to match spacing spec * correctly render multi-badge * fix: masss asignment optimistic UI * fix type errors * remove log * fix toolbar type error * chore: Remove debug artifact * type errors * Update apps/web/public/static/locales/en/common.json * use max-w-fit * chore: Remove unused translation now we don't specify 'mass' in assign * perf: fix: use the onBlur event to prevent focus loss whilst the list is rerendering * Move the data-table exports together in the main barrel, then import * fix exports that were lost in a merge * fix exports that were lost in a merge * fix groupteammapping/availbilityslider * fix overflow problems * add scrollbar-thin class * fix type error * user serverside values for faceted filters * pass filters to serverside * filter serverside * fix team server side filter * add loaded x of y * attributes icon change * correct implementation for text/input attr optimistic * type check fixes * fix platform checks * fix types again * fix types again * fix types again * add use client * add use client * fix-types * fix: Add missing translation in EN * fix e2e tests via testid * fix e2e tests via testid * fix: Member invite popup not popping up * Update copyInviteLink to new-member-button testid * Hopefully fix test ids this time * fix: Use the right buttons on the right pages --------- Co-authored-by: Alex van Andel <me@alexvanandel.com> Co-authored-by: Peer Richelsen <peeroke@gmail.com> Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
213 lines
6.5 KiB
TypeScript
213 lines
6.5 KiB
TypeScript
import { useSession } from "next-auth/react";
|
|
|
|
import { classNames } from "@calcom/lib";
|
|
import { useLocale } from "@calcom/lib/hooks/useLocale";
|
|
import { trpc } from "@calcom/trpc/react";
|
|
import {
|
|
ButtonGroup,
|
|
Tooltip,
|
|
Button,
|
|
Dropdown,
|
|
DropdownMenuTrigger,
|
|
DropdownMenuContent,
|
|
DropdownMenuItem,
|
|
DropdownItem,
|
|
DropdownMenuSeparator,
|
|
showToast,
|
|
} from "@calcom/ui";
|
|
|
|
import type { UserTableUser, UserTableAction } from "./types";
|
|
|
|
export function TableActions({
|
|
user,
|
|
permissionsForUser,
|
|
dispatch,
|
|
domain,
|
|
}: {
|
|
user: UserTableUser;
|
|
dispatch: React.Dispatch<UserTableAction>;
|
|
domain: string;
|
|
permissionsForUser: {
|
|
canEdit: boolean;
|
|
canRemove: boolean;
|
|
canImpersonate: boolean;
|
|
canResendInvitation: boolean;
|
|
};
|
|
}) {
|
|
const { t, i18n } = useLocale();
|
|
const { data: session } = useSession();
|
|
const resendInvitationMutation = trpc.viewer.teams.resendInvitation.useMutation({
|
|
onSuccess: () => {
|
|
showToast(t("invitation_resent"), "success");
|
|
},
|
|
onError: (error) => {
|
|
showToast(error.message, "error");
|
|
},
|
|
});
|
|
|
|
const usersProfileUrl = `${domain}/${user.username}`;
|
|
|
|
if (!session?.user.org?.id) return null;
|
|
|
|
const orgId = session?.user?.org?.id;
|
|
|
|
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="external-link"
|
|
/>
|
|
</Tooltip>
|
|
{(permissionsForUser.canEdit || permissionsForUser.canRemove) && (
|
|
<Dropdown>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button
|
|
className="radix-state-open:rounded-r-md"
|
|
color="secondary"
|
|
variant="icon"
|
|
StartIcon="ellipsis"
|
|
/>
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent>
|
|
{permissionsForUser.canEdit && (
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
onClick={() =>
|
|
dispatch({
|
|
type: "EDIT_USER_SHEET",
|
|
payload: {
|
|
user,
|
|
showModal: true,
|
|
},
|
|
})
|
|
}
|
|
StartIcon="pencil">
|
|
{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="user-x">
|
|
{t("remove")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
)}
|
|
{permissionsForUser.canResendInvitation && (
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
onClick={() => {
|
|
resendInvitationMutation.mutate({
|
|
teamId: orgId,
|
|
language: i18n.language,
|
|
email: user.email,
|
|
isOrg: true,
|
|
});
|
|
}}
|
|
StartIcon="send">
|
|
{t("resend_invitation")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
)}
|
|
</DropdownMenuContent>
|
|
</Dropdown>
|
|
)}
|
|
</ButtonGroup>
|
|
<div className="flex md:hidden">
|
|
<Dropdown>
|
|
<DropdownMenuTrigger asChild>
|
|
<Button type="button" variant="icon" color="minimal" StartIcon="ellipsis" />
|
|
</DropdownMenuTrigger>
|
|
<DropdownMenuContent>
|
|
<DropdownMenuItem className="outline-none">
|
|
<DropdownItem type="button" StartIcon="external-link">
|
|
{t("view_public_page")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
{permissionsForUser.canEdit && (
|
|
<>
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
onClick={() =>
|
|
dispatch({
|
|
type: "EDIT_USER_SHEET",
|
|
payload: {
|
|
user,
|
|
showModal: true,
|
|
},
|
|
})
|
|
}
|
|
StartIcon="pencil">
|
|
{t("edit")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
</>
|
|
)}
|
|
{permissionsForUser.canRemove && (
|
|
<DropdownMenuItem>
|
|
<DropdownItem
|
|
type="button"
|
|
color="destructive"
|
|
onClick={() =>
|
|
dispatch({
|
|
type: "SET_DELETE_ID",
|
|
payload: {
|
|
user,
|
|
showModal: true,
|
|
},
|
|
})
|
|
}
|
|
StartIcon="user-x">
|
|
{t("remove")}
|
|
</DropdownItem>
|
|
</DropdownMenuItem>
|
|
)}
|
|
</DropdownMenuContent>
|
|
</Dropdown>
|
|
</div>
|
|
</>
|
|
);
|
|
}
|