2021-12-09 23:51:30 +00:00
|
|
|
import { UserRemoveIcon, PencilIcon } from "@heroicons/react/outline";
|
|
|
|
import { ClockIcon, ExternalLinkIcon, DotsHorizontalIcon } from "@heroicons/react/solid";
|
|
|
|
import Link from "next/link";
|
|
|
|
import React, { useState } from "react";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
import TeamAvailabilityModal from "@ee/components/team/availability/TeamAvailabilityModal";
|
|
|
|
|
|
|
|
import { getPlaceholderAvatar } from "@lib/getPlaceholderAvatar";
|
2021-10-08 11:43:48 +00:00
|
|
|
import { useLocale } from "@lib/hooks/useLocale";
|
2021-12-09 23:51:30 +00:00
|
|
|
import showToast from "@lib/notification";
|
|
|
|
import { trpc, inferQueryOutput } from "@lib/trpc";
|
2021-09-22 19:52:38 +00:00
|
|
|
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
import { Dialog, DialogTrigger } from "@components/Dialog";
|
2021-12-09 23:51:30 +00:00
|
|
|
import { Tooltip } from "@components/Tooltip";
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent";
|
2021-09-14 08:45:28 +00:00
|
|
|
import Avatar from "@components/ui/Avatar";
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
import Button from "@components/ui/Button";
|
2021-12-09 23:51:30 +00:00
|
|
|
import ModalContainer from "@components/ui/ModalContainer";
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
|
2021-09-22 19:52:38 +00:00
|
|
|
import Dropdown, { DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "../ui/Dropdown";
|
2021-12-09 23:51:30 +00:00
|
|
|
import MemberChangeRoleModal from "./MemberChangeRoleModal";
|
|
|
|
import TeamRole from "./TeamRole";
|
|
|
|
import { MembershipRole } from ".prisma/client";
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
team: inferQueryOutput<"viewer.teams.get">;
|
|
|
|
member: inferQueryOutput<"viewer.teams.get">["members"][number];
|
|
|
|
}
|
2021-09-22 19:52:38 +00:00
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
export default function MemberListItem(props: Props) {
|
2021-10-12 13:11:33 +00:00
|
|
|
const { t } = useLocale();
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
|
2021-12-09 23:51:30 +00:00
|
|
|
const utils = trpc.useContext();
|
|
|
|
const [showChangeMemberRoleModal, setShowChangeMemberRoleModal] = useState(false);
|
|
|
|
const [showTeamAvailabilityModal, setShowTeamAvailabilityModal] = useState(false);
|
|
|
|
|
|
|
|
const removeMemberMutation = trpc.useMutation("viewer.teams.removeMember", {
|
|
|
|
async onSuccess() {
|
|
|
|
await utils.invalidateQueries(["viewer.teams.get"]);
|
|
|
|
showToast(t("success"), "success");
|
|
|
|
},
|
|
|
|
async onError(err) {
|
|
|
|
showToast(err.message, "error");
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
const name =
|
|
|
|
props.member.name ||
|
|
|
|
(() => {
|
|
|
|
const emailName = props.member.email.split("@")[0];
|
|
|
|
return emailName.charAt(0).toUpperCase() + emailName.slice(1);
|
|
|
|
})();
|
|
|
|
|
|
|
|
const removeMember = () =>
|
|
|
|
removeMemberMutation.mutate({ teamId: props.team?.id, memberId: props.member.id });
|
|
|
|
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
return (
|
2021-12-09 23:51:30 +00:00
|
|
|
<li className="divide-y">
|
|
|
|
<div className="flex justify-between my-4">
|
|
|
|
<div className="flex flex-col justify-between w-full sm:flex-row">
|
|
|
|
<div className="flex">
|
|
|
|
<Avatar
|
|
|
|
imageSrc={getPlaceholderAvatar(props.member?.avatar, name)}
|
|
|
|
alt={name || ""}
|
|
|
|
className="rounded-full w-9 h-9"
|
|
|
|
/>
|
|
|
|
<div className="inline-block ml-3">
|
|
|
|
<span className="text-sm font-bold text-neutral-700">{name}</span>
|
|
|
|
<span className="block -mt-1 text-xs text-gray-400">{props.member.email}</span>
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
</div>
|
2021-12-09 23:51:30 +00:00
|
|
|
</div>
|
|
|
|
<div className="flex justify-center mr-2">
|
|
|
|
{!props.member.accepted && <TeamRole invitePending />}
|
|
|
|
<TeamRole role={props.member.role} />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="flex">
|
|
|
|
<Tooltip content={t("View user availability")}>
|
|
|
|
<Button
|
|
|
|
onClick={() => setShowTeamAvailabilityModal(true)}
|
|
|
|
color="minimal"
|
|
|
|
className="w-10 h-10 p-0 border border-transparent group text-neutral-400 hover:border-gray-200 hover:bg-white">
|
|
|
|
<ClockIcon className="w-5 h-5 group-hover:text-gray-800" />
|
|
|
|
</Button>
|
|
|
|
</Tooltip>
|
|
|
|
<Dropdown>
|
|
|
|
<DropdownMenuTrigger className="w-10 h-10 p-0 border border-transparent group text-neutral-400 hover:border-gray-200 hover:bg-white">
|
|
|
|
<DotsHorizontalIcon className="w-5 h-5 group-hover:text-gray-800" />
|
|
|
|
</DropdownMenuTrigger>
|
|
|
|
<DropdownMenuContent>
|
|
|
|
<DropdownMenuItem>
|
|
|
|
<Link href={"/" + props.member.username}>
|
|
|
|
<a target="_blank">
|
|
|
|
<Button color="minimal" StartIcon={ExternalLinkIcon} className="w-full">
|
|
|
|
{t("view_public_page")}
|
|
|
|
</Button>
|
|
|
|
</a>
|
|
|
|
</Link>
|
|
|
|
</DropdownMenuItem>
|
|
|
|
|
|
|
|
{(props.team.membership.role === MembershipRole.OWNER ||
|
|
|
|
props.team.membership.role === MembershipRole.ADMIN) && (
|
2021-10-29 12:59:23 +00:00
|
|
|
<>
|
2021-12-09 23:51:30 +00:00
|
|
|
<DropdownMenuItem>
|
|
|
|
<Button
|
|
|
|
onClick={() => setShowChangeMemberRoleModal(true)}
|
|
|
|
color="minimal"
|
|
|
|
StartIcon={PencilIcon}
|
|
|
|
className="flex-shrink-0 w-full">
|
|
|
|
{t("edit_role")}
|
|
|
|
</Button>
|
|
|
|
</DropdownMenuItem>
|
|
|
|
<DropdownMenuItem>
|
|
|
|
<Dialog>
|
|
|
|
<DialogTrigger asChild>
|
|
|
|
<Button
|
|
|
|
onClick={(e) => {
|
|
|
|
e.stopPropagation();
|
|
|
|
}}
|
|
|
|
color="warn"
|
|
|
|
StartIcon={UserRemoveIcon}
|
|
|
|
className="w-full">
|
|
|
|
{t("remove_member")}
|
|
|
|
</Button>
|
|
|
|
</DialogTrigger>
|
|
|
|
<ConfirmationDialogContent
|
|
|
|
variety="danger"
|
|
|
|
title={t("remove_member")}
|
|
|
|
confirmBtnText={t("confirm_remove_member")}
|
|
|
|
onConfirm={removeMember}>
|
|
|
|
{t("remove_member_confirmation_message")}
|
|
|
|
</ConfirmationDialogContent>
|
|
|
|
</Dialog>
|
|
|
|
</DropdownMenuItem>
|
2021-10-29 12:59:23 +00:00
|
|
|
</>
|
|
|
|
)}
|
2021-12-09 23:51:30 +00:00
|
|
|
</DropdownMenuContent>
|
|
|
|
</Dropdown>
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
</div>
|
2021-12-09 23:51:30 +00:00
|
|
|
</div>
|
|
|
|
{showChangeMemberRoleModal && (
|
|
|
|
<MemberChangeRoleModal
|
|
|
|
teamId={props.team?.id}
|
|
|
|
memberId={props.member.id}
|
|
|
|
initialRole={props.member.role as MembershipRole}
|
|
|
|
onExit={() => setShowChangeMemberRoleModal(false)}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
{showTeamAvailabilityModal && (
|
|
|
|
<ModalContainer wide noPadding>
|
|
|
|
<TeamAvailabilityModal team={props.team} member={props.member} />
|
|
|
|
<div className="p-5 space-x-2 border-t">
|
|
|
|
<Button onClick={() => setShowTeamAvailabilityModal(false)}>{t("done")}</Button>
|
|
|
|
<Link href={`/settings/teams/${props.team.id}/availability`}>
|
|
|
|
<Button color="secondary">{t("Open Team Availability")}</Button>
|
|
|
|
</Link>
|
|
|
|
</div>
|
|
|
|
</ModalContainer>
|
|
|
|
)}
|
|
|
|
</li>
|
Cal 262 refactor edit teams according to the design reference (#516)
* refactored settings/team landing page
* changed team edit flow, WIP
* merge conflict fix for teams.tsx
* minor fixes to edit team, WIP
* invite-member and disband team APIs attached inside edit-team page
* added remove-member API in edit-team page, minor fixes
* minor code fix, WIP
* WIP
* add logo, bio, branding to team schema
* bio, logo, branding, slug patch API and minor code fix-- WIP
* fn to Disband team directly from the dropdown menu in settings/teams page, removed debug remnants --WIP
* Pull latest data after an action in settings/teams-edit page
* added slug conflict check at Patch time
* code clean-up
* initial change request fixes --WIP
* prop type fix and add warn button color theme --WIP
* added warn Button to Dialog
* remaining change request fixes
* added noop from react-query
* updated invited team-list design
* prettier fix for api/teams/profile
* removed noop import and added custom noop
* minor Button fix
* requested changes addressed
2021-09-06 13:22:22 +00:00
|
|
|
);
|
|
|
|
}
|