* chore: removed viewer role * chore: indentation * chore: remove viewer role * chore: handled user permissions in store * chore: updated the migration file * chore: updated user permissions store * chore: removed the owner key * chore: code refactor * chore: code refactor * chore: code refactor * chore: code refactor * chore: code refactor * fix: build error * chore: updated user permissions store and handled the permissions fetch in workspace and project wrappers * chore: package user enum updated * chore: user permission updated * chore: user permission updated * chore: resolved build errors * chore: resolved build error * chore: resolved build errors * chore: computedFn deep map issue resolved * chore: added back migration * chore: added new field in project table * chore: removed member store in users * chore: private project for admins * chore: workspace notification access validation updated * fix: workspace member edit option * fix: project intake permission validation updated * chore: workspace export settings permission updated * chore: guest_view_all_issues added * chore: guest_view_all_issues added * chore: key changed for guest access * chore: added validation for individual issues * chore: changed the dashboard issues count * chore: added new yarn file * chore: modified yarn file * chore: project page permission updated * chore: project page permission updated * chore: member setting ux updated * chore: build error * fix: yarn lock * fix: build error --------- Co-authored-by: gurusainath <gurusainath007@gmail.com> Co-authored-by: Anmol Singh Bhatia <anmolsinghbhatia@plane.so>
111 lines
4 KiB
TypeScript
111 lines
4 KiB
TypeScript
"use client";
|
|
|
|
// ui
|
|
import { FC } from "react";
|
|
import { observer } from "mobx-react";
|
|
import Link from "next/link";
|
|
import { useParams } from "next/navigation";
|
|
import { ChevronDown, PanelRight } from "lucide-react";
|
|
import { IUserProfileProjectSegregation } from "@plane/types";
|
|
import { Breadcrumbs, Header, CustomMenu, UserActivityIcon } from "@plane/ui";
|
|
import { BreadcrumbLink } from "@/components/common";
|
|
// components
|
|
import { ProfileIssuesFilter } from "@/components/profile";
|
|
import { PROFILE_ADMINS_TAB, PROFILE_VIEWER_TAB } from "@/constants/profile";
|
|
import { cn } from "@/helpers/common.helper";
|
|
import { useAppTheme, useUser, useUserPermissions } from "@/hooks/store";
|
|
import { EUserPermissions, EUserPermissionsLevel } from "@/plane-web/constants/user-permissions";
|
|
|
|
type TUserProfileHeader = {
|
|
userProjectsData: IUserProfileProjectSegregation | undefined;
|
|
type?: string | undefined;
|
|
showProfileIssuesFilter?: boolean;
|
|
};
|
|
|
|
export const UserProfileHeader: FC<TUserProfileHeader> = observer((props) => {
|
|
const { userProjectsData, type = undefined, showProfileIssuesFilter } = props;
|
|
// router
|
|
const { workspaceSlug, userId } = useParams();
|
|
// store hooks
|
|
const { toggleProfileSidebar, profileSidebarCollapsed } = useAppTheme();
|
|
const { data: currentUser } = useUser();
|
|
const { workspaceUserInfo, allowPermissions } = useUserPermissions();
|
|
// derived values
|
|
const isAuthorized = allowPermissions(
|
|
[EUserPermissions.ADMIN, EUserPermissions.MEMBER],
|
|
EUserPermissionsLevel.WORKSPACE
|
|
);
|
|
|
|
if (!workspaceUserInfo) return null;
|
|
|
|
const tabsList = isAuthorized ? [...PROFILE_VIEWER_TAB, ...PROFILE_ADMINS_TAB] : PROFILE_VIEWER_TAB;
|
|
|
|
const userName = `${userProjectsData?.user_data?.first_name} ${userProjectsData?.user_data?.last_name}`;
|
|
|
|
const isCurrentUser = currentUser?.id === userId;
|
|
|
|
const breadcrumbLabel = `${isCurrentUser ? "Your" : userName} Work`;
|
|
|
|
return (
|
|
<Header>
|
|
<Header.LeftItem>
|
|
<Breadcrumbs>
|
|
<Breadcrumbs.BreadcrumbItem
|
|
type="text"
|
|
link={
|
|
<BreadcrumbLink
|
|
label={breadcrumbLabel}
|
|
disableTooltip
|
|
icon={<UserActivityIcon className="h-4 w-4 text-custom-text-300" />}
|
|
/>
|
|
}
|
|
/>
|
|
</Breadcrumbs>
|
|
</Header.LeftItem>
|
|
<Header.RightItem>
|
|
<div className="hidden md:flex md:items-center">{showProfileIssuesFilter && <ProfileIssuesFilter />}</div>
|
|
<div className="flex gap-4 md:hidden">
|
|
<CustomMenu
|
|
maxHeight={"md"}
|
|
className="flex flex-grow justify-center text-sm text-custom-text-200"
|
|
placement="bottom-start"
|
|
customButton={
|
|
<div className="flex items-center gap-2 rounded-md border border-custom-border-200 px-2 py-1.5">
|
|
<span className="flex flex-grow justify-center text-sm text-custom-text-200">{type}</span>
|
|
<ChevronDown className="h-4 w-4 text-custom-text-400" />
|
|
</div>
|
|
}
|
|
customButtonClassName="flex flex-grow justify-center text-custom-text-200 text-sm"
|
|
closeOnSelect
|
|
>
|
|
<></>
|
|
{tabsList.map((tab) => (
|
|
<CustomMenu.MenuItem className="flex items-center gap-2" key={tab.route}>
|
|
<Link
|
|
key={tab.route}
|
|
href={`/${workspaceSlug}/profile/${userId}/${tab.route}`}
|
|
className="w-full text-custom-text-300"
|
|
>
|
|
{tab.label}
|
|
</Link>
|
|
</CustomMenu.MenuItem>
|
|
))}
|
|
</CustomMenu>
|
|
<button
|
|
className="block transition-all md:hidden"
|
|
onClick={() => {
|
|
toggleProfileSidebar();
|
|
}}
|
|
>
|
|
<PanelRight
|
|
className={cn(
|
|
"block h-4 w-4 md:hidden",
|
|
!profileSidebarCollapsed ? "text-[#3E63DD]" : "text-custom-text-200"
|
|
)}
|
|
/>
|
|
</button>
|
|
</div>
|
|
</Header.RightItem>
|
|
</Header>
|
|
);
|
|
});
|