forked from github/plane
Merge branch 'preview' of github.com:makeplane/plane into preview
This commit is contained in:
commit
0ab2a98777
@ -15,18 +15,16 @@ type Props = {
|
|||||||
handleChartView: (view: TGanttViews) => void;
|
handleChartView: (view: TGanttViews) => void;
|
||||||
handleToday: () => void;
|
handleToday: () => void;
|
||||||
loaderTitle: string;
|
loaderTitle: string;
|
||||||
title: string;
|
|
||||||
toggleFullScreenMode: () => void;
|
toggleFullScreenMode: () => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const GanttChartHeader: React.FC<Props> = observer((props) => {
|
export const GanttChartHeader: React.FC<Props> = observer((props) => {
|
||||||
const { blocks, fullScreenMode, handleChartView, handleToday, loaderTitle, title, toggleFullScreenMode } = props;
|
const { blocks, fullScreenMode, handleChartView, handleToday, loaderTitle, toggleFullScreenMode } = props;
|
||||||
// chart hook
|
// chart hook
|
||||||
const { currentView } = useGanttChart();
|
const { currentView } = useGanttChart();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative flex w-full flex-shrink-0 flex-wrap items-center gap-2 whitespace-nowrap px-2.5 py-2">
|
<div className="relative flex w-full flex-shrink-0 flex-wrap items-center gap-2 whitespace-nowrap px-2.5 py-2">
|
||||||
<div className="flex items-center gap-2 text-lg font-medium">{title}</div>
|
|
||||||
<div className="ml-auto">
|
<div className="ml-auto">
|
||||||
<div className="ml-auto text-sm font-medium">{blocks ? `${blocks.length} ${loaderTitle}` : "Loading..."}</div>
|
<div className="ml-auto text-sm font-medium">{blocks ? `${blocks.length} ${loaderTitle}` : "Loading..."}</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -172,7 +172,6 @@ export const ChartViewRoot: FC<ChartViewRootProps> = observer((props) => {
|
|||||||
handleChartView={(key) => updateCurrentViewRenderPayload(null, key)}
|
handleChartView={(key) => updateCurrentViewRenderPayload(null, key)}
|
||||||
handleToday={handleToday}
|
handleToday={handleToday}
|
||||||
loaderTitle={loaderTitle}
|
loaderTitle={loaderTitle}
|
||||||
title={title}
|
|
||||||
/>
|
/>
|
||||||
<GanttChartMainContent
|
<GanttChartMainContent
|
||||||
blocks={blocks}
|
blocks={blocks}
|
||||||
|
@ -6,6 +6,7 @@ import { Plus } from "lucide-react";
|
|||||||
import { Breadcrumbs, Button, DiceIcon } from "@plane/ui";
|
import { Breadcrumbs, Button, DiceIcon } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
import { BreadcrumbLink } from "@/components/common";
|
import { BreadcrumbLink } from "@/components/common";
|
||||||
|
import { ModuleViewHeader } from "@/components/modules";
|
||||||
import { ProjectLogo } from "@/components/project";
|
import { ProjectLogo } from "@/components/project";
|
||||||
// constants
|
// constants
|
||||||
import { EUserProjectRoles } from "@/constants/project";
|
import { EUserProjectRoles } from "@/constants/project";
|
||||||
@ -57,6 +58,7 @@ export const ModulesListHeader: React.FC = observer(() => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-2">
|
<div className="flex items-center gap-2">
|
||||||
|
<ModuleViewHeader />
|
||||||
{canUserCreateModule && (
|
{canUserCreateModule && (
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
|
@ -7,6 +7,7 @@ import { Breadcrumbs, PhotoFilterIcon, Button } from "@plane/ui";
|
|||||||
import { BreadcrumbLink } from "@/components/common";
|
import { BreadcrumbLink } from "@/components/common";
|
||||||
// helpers
|
// helpers
|
||||||
import { ProjectLogo } from "@/components/project";
|
import { ProjectLogo } from "@/components/project";
|
||||||
|
import { ViewListHeader } from "@/components/views";
|
||||||
import { EUserProjectRoles } from "@/constants/project";
|
import { EUserProjectRoles } from "@/constants/project";
|
||||||
// constants
|
// constants
|
||||||
import { useCommandPalette, useProject, useUser } from "@/hooks/store";
|
import { useCommandPalette, useProject, useUser } from "@/hooks/store";
|
||||||
@ -58,6 +59,7 @@ export const ProjectViewsHeader: React.FC = observer(() => {
|
|||||||
</div>
|
</div>
|
||||||
{canUserCreateIssue && (
|
{canUserCreateIssue && (
|
||||||
<div className="flex flex-shrink-0 items-center gap-2">
|
<div className="flex flex-shrink-0 items-center gap-2">
|
||||||
|
<ViewListHeader />
|
||||||
<div>
|
<div>
|
||||||
<Button
|
<Button
|
||||||
variant="primary"
|
variant="primary"
|
||||||
|
@ -2,11 +2,12 @@ import React, { useRef } from "react";
|
|||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { Info } from "lucide-react";
|
import { CalendarCheck2, CalendarClock, Info, MoveRight, User2 } from "lucide-react";
|
||||||
// ui
|
// ui
|
||||||
import { Avatar, AvatarGroup, LayersIcon, Tooltip, setPromiseToast } from "@plane/ui";
|
import { LayersIcon, Tooltip, setPromiseToast } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
import { FavoriteStar } from "@/components/core";
|
import { FavoriteStar } from "@/components/core";
|
||||||
|
import { ButtonAvatars } from "@/components/dropdowns/member/avatar";
|
||||||
import { ModuleQuickActions } from "@/components/modules";
|
import { ModuleQuickActions } from "@/components/modules";
|
||||||
// constants
|
// constants
|
||||||
import { MODULE_FAVORITED, MODULE_UNFAVORITED } from "@/constants/event-tracker";
|
import { MODULE_FAVORITED, MODULE_UNFAVORITED } from "@/constants/event-tracker";
|
||||||
@ -145,6 +146,8 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
|
|||||||
: `${moduleDetails.completed_issues}/${moduleTotalIssues} Issues`
|
: `${moduleDetails.completed_issues}/${moduleTotalIssues} Issues`
|
||||||
: "0 Issue";
|
: "0 Issue";
|
||||||
|
|
||||||
|
const moduleLeadDetails = moduleDetails.lead_id ? getUserDetails(moduleDetails.lead_id) : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
<Link ref={parentRef} href={`/${workspaceSlug}/projects/${moduleDetails.project_id}/modules/${moduleDetails.id}`}>
|
<Link ref={parentRef} href={`/${workspaceSlug}/projects/${moduleDetails.project_id}/modules/${moduleDetails.id}`}>
|
||||||
@ -179,16 +182,15 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
|
|||||||
<LayersIcon className="h-4 w-4 text-custom-text-300" />
|
<LayersIcon className="h-4 w-4 text-custom-text-300" />
|
||||||
<span className="text-xs text-custom-text-300">{issueCount ?? "0 Issue"}</span>
|
<span className="text-xs text-custom-text-300">{issueCount ?? "0 Issue"}</span>
|
||||||
</div>
|
</div>
|
||||||
{moduleDetails.member_ids?.length > 0 && (
|
{moduleLeadDetails ? (
|
||||||
<Tooltip tooltipContent={`${moduleDetails.member_ids.length} Members`} isMobile={isMobile}>
|
<span className="cursor-default">
|
||||||
<div className="flex cursor-default items-center gap-1">
|
<ButtonAvatars showTooltip={false} userIds={moduleLeadDetails?.id} />
|
||||||
<AvatarGroup showTooltip={false}>
|
</span>
|
||||||
{moduleDetails.member_ids.map((member_id) => {
|
) : (
|
||||||
const member = getUserDetails(member_id);
|
<Tooltip tooltipContent="No lead">
|
||||||
return <Avatar key={member?.id} name={member?.display_name} src={member?.avatar} />;
|
<span className="cursor-default flex h-5 w-5 items-end justify-center rounded-full border border-dashed border-custom-text-400 bg-custom-background-80">
|
||||||
})}
|
<User2 className="h-4 w-4 text-custom-text-400" />
|
||||||
</AvatarGroup>
|
</span>
|
||||||
</div>
|
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
@ -217,11 +219,13 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
<div className="flex items-center justify-between py-0.5">
|
<div className="flex items-center justify-between py-0.5">
|
||||||
{isDateValid ? (
|
{isDateValid ? (
|
||||||
<>
|
<div className="h-6 flex items-center gap-1.5 text-custom-text-300 border-[0.5px] border-custom-border-300 rounded text-xs px-2 cursor-default">
|
||||||
<span className="text-xs text-custom-text-300">
|
<CalendarClock className="h-3 w-3 flex-shrink-0" />
|
||||||
{renderFormattedDate(startDate) ?? "_ _"} - {renderFormattedDate(endDate) ?? "_ _"}
|
<span className="flex-grow truncate">{renderFormattedDate(startDate)}</span>
|
||||||
</span>
|
<MoveRight className="h-3 w-3 flex-shrink-0" />
|
||||||
</>
|
<CalendarCheck2 className="h-3 w-3 flex-shrink-0" />
|
||||||
|
<span className="flex-grow truncate">{renderFormattedDate(endDate)}</span>
|
||||||
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<span className="text-xs text-custom-text-400">No due date</span>
|
<span className="text-xs text-custom-text-400">No due date</span>
|
||||||
)}
|
)}
|
||||||
@ -229,7 +233,7 @@ export const ModuleCardItem: React.FC<Props> = observer((props) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</Link>
|
||||||
<div className="absolute right-4 bottom-3.5 flex items-center gap-1.5">
|
<div className="absolute right-4 bottom-[18px] flex items-center gap-1.5">
|
||||||
{isEditingAllowed && (
|
{isEditingAllowed && (
|
||||||
<FavoriteStar
|
<FavoriteStar
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
@ -2,11 +2,11 @@ import React, { FC } from "react";
|
|||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
// icons
|
// icons
|
||||||
import { User2 } from "lucide-react";
|
import { CalendarCheck2, CalendarClock, MoveRight, User2 } from "lucide-react";
|
||||||
// types
|
// types
|
||||||
import { IModule } from "@plane/types";
|
import { IModule } from "@plane/types";
|
||||||
// ui
|
// ui
|
||||||
import { Avatar, AvatarGroup, Tooltip, setPromiseToast } from "@plane/ui";
|
import { Tooltip, setPromiseToast } from "@plane/ui";
|
||||||
// components
|
// components
|
||||||
import { FavoriteStar } from "@/components/core";
|
import { FavoriteStar } from "@/components/core";
|
||||||
import { ModuleQuickActions } from "@/components/modules";
|
import { ModuleQuickActions } from "@/components/modules";
|
||||||
@ -18,7 +18,7 @@ import { EUserProjectRoles } from "@/constants/project";
|
|||||||
import { getDate, renderFormattedDate } from "@/helpers/date-time.helper";
|
import { getDate, renderFormattedDate } from "@/helpers/date-time.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useEventTracker, useMember, useModule, useUser } from "@/hooks/store";
|
import { useEventTracker, useMember, useModule, useUser } from "@/hooks/store";
|
||||||
import { usePlatformOS } from "@/hooks/use-platform-os";
|
import { ButtonAvatars } from "../dropdowns/member/avatar";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
moduleId: string;
|
moduleId: string;
|
||||||
@ -38,7 +38,6 @@ export const ModuleListItemAction: FC<Props> = observer((props) => {
|
|||||||
const { addModuleToFavorites, removeModuleFromFavorites } = useModule();
|
const { addModuleToFavorites, removeModuleFromFavorites } = useModule();
|
||||||
const { getUserDetails } = useMember();
|
const { getUserDetails } = useMember();
|
||||||
const { captureEvent } = useEventTracker();
|
const { captureEvent } = useEventTracker();
|
||||||
const { isMobile } = usePlatformOS();
|
|
||||||
|
|
||||||
// derived values
|
// derived values
|
||||||
const endDate = getDate(moduleDetails.target_date);
|
const endDate = getDate(moduleDetails.target_date);
|
||||||
@ -109,11 +108,23 @@ export const ModuleListItemAction: FC<Props> = observer((props) => {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const moduleLeadDetails = moduleDetails.lead_id ? getUserDetails(moduleDetails.lead_id) : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
|
{renderDate && (
|
||||||
|
<div className="h-6 flex items-center gap-1.5 text-custom-text-300 border-[0.5px] border-custom-border-300 rounded text-xs px-2 cursor-default">
|
||||||
|
<CalendarClock className="h-3 w-3 flex-shrink-0" />
|
||||||
|
<span className="flex-grow truncate">{renderFormattedDate(startDate)}</span>
|
||||||
|
<MoveRight className="h-3 w-3 flex-shrink-0" />
|
||||||
|
<CalendarCheck2 className="h-3 w-3 flex-shrink-0" />
|
||||||
|
<span className="flex-grow truncate">{renderFormattedDate(endDate)}</span>
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
|
||||||
{moduleStatus && (
|
{moduleStatus && (
|
||||||
<span
|
<span
|
||||||
className="flex h-6 w-20 flex-shrink-0 items-center justify-center rounded-sm text-center text-xs"
|
className="flex h-6 w-20 flex-shrink-0 items-center justify-center rounded-sm text-center text-xs cursor-default"
|
||||||
style={{
|
style={{
|
||||||
color: moduleStatus.color,
|
color: moduleStatus.color,
|
||||||
backgroundColor: `${moduleStatus.color}20`,
|
backgroundColor: `${moduleStatus.color}20`,
|
||||||
@ -123,29 +134,18 @@ export const ModuleListItemAction: FC<Props> = observer((props) => {
|
|||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{renderDate && (
|
{moduleLeadDetails ? (
|
||||||
<span className=" text-xs text-custom-text-300">
|
<span className="cursor-default">
|
||||||
{renderFormattedDate(startDate) ?? "_ _"} - {renderFormattedDate(endDate) ?? "_ _"}
|
<ButtonAvatars showTooltip={false} userIds={moduleLeadDetails?.id} />
|
||||||
</span>
|
</span>
|
||||||
|
) : (
|
||||||
|
<Tooltip tooltipContent="No lead">
|
||||||
|
<span className="cursor-default flex h-5 w-5 items-end justify-center rounded-full border border-dashed border-custom-text-400 bg-custom-background-80">
|
||||||
|
<User2 className="h-4 w-4 text-custom-text-400" />
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<Tooltip tooltipContent={`${moduleDetails?.member_ids?.length || 0} Members`} isMobile={isMobile}>
|
|
||||||
<div className="flex w-10 cursor-default items-center justify-center gap-1">
|
|
||||||
{moduleDetails.member_ids.length > 0 ? (
|
|
||||||
<AvatarGroup showTooltip={false}>
|
|
||||||
{moduleDetails.member_ids.map((member_id) => {
|
|
||||||
const member = getUserDetails(member_id);
|
|
||||||
return <Avatar key={member?.id} name={member?.display_name} src={member?.avatar} />;
|
|
||||||
})}
|
|
||||||
</AvatarGroup>
|
|
||||||
) : (
|
|
||||||
<span className="flex h-5 w-5 items-end justify-center rounded-full border border-dashed border-custom-text-400 bg-custom-background-80">
|
|
||||||
<User2 className="h-4 w-4 text-custom-text-400" />
|
|
||||||
</span>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</Tooltip>
|
|
||||||
|
|
||||||
{isEditingAllowed && !moduleDetails.archived_at && (
|
{isEditingAllowed && !moduleDetails.archived_at && (
|
||||||
<FavoriteStar
|
<FavoriteStar
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
@ -77,7 +77,7 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {
|
|||||||
) : progress === 100 ? (
|
) : progress === 100 ? (
|
||||||
<Check className="h-3 w-3 stroke-[2] text-custom-primary-100" />
|
<Check className="h-3 w-3 stroke-[2] text-custom-primary-100" />
|
||||||
) : (
|
) : (
|
||||||
<span className="text-xs text-custom-text-300">{`${progress}%`}</span>
|
<span className="text-[9px] text-custom-text-300">{`${progress}%`}</span>
|
||||||
)}
|
)}
|
||||||
</CircularProgressIndicator>
|
</CircularProgressIndicator>
|
||||||
}
|
}
|
||||||
@ -89,9 +89,7 @@ export const ModuleListItem: React.FC<Props> = observer((props) => {
|
|||||||
<Info className="h-4 w-4 text-custom-text-400" />
|
<Info className="h-4 w-4 text-custom-text-400" />
|
||||||
</button>
|
</button>
|
||||||
}
|
}
|
||||||
actionableItems={
|
actionableItems={<ModuleListItemAction moduleId={moduleId} moduleDetails={moduleDetails} parentRef={parentRef} />}
|
||||||
<ModuleListItemAction moduleId={moduleId} moduleDetails={moduleDetails} parentRef={parentRef} />
|
|
||||||
}
|
|
||||||
isMobile={isMobile}
|
isMobile={isMobile}
|
||||||
parentRef={parentRef}
|
parentRef={parentRef}
|
||||||
/>
|
/>
|
||||||
|
@ -173,7 +173,7 @@ export const NotificationCard: React.FC<NotificationCardProps> = (props) => {
|
|||||||
<div className="w-full space-y-2.5 overflow-hidden">
|
<div className="w-full space-y-2.5 overflow-hidden">
|
||||||
<div className="flex items-start">
|
<div className="flex items-start">
|
||||||
{!notification.message ? (
|
{!notification.message ? (
|
||||||
<div className="w-full break-words text-sm">
|
<div className="w-full break-all text-sm group-hover:pr-24 line-clamp-2">
|
||||||
<span className="font-semibold">
|
<span className="font-semibold">
|
||||||
{notificationTriggeredBy.is_bot
|
{notificationTriggeredBy.is_bot
|
||||||
? notificationTriggeredBy.first_name
|
? notificationTriggeredBy.first_name
|
||||||
|
@ -2,7 +2,7 @@ import React, { useRef, useState } from "react";
|
|||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
import { ArchiveRestoreIcon, Check, ExternalLink, LinkIcon, Lock, Pencil, Trash2, UserPlus } from "lucide-react";
|
import { ArchiveRestoreIcon, Check, ExternalLink, LinkIcon, Lock, Settings, Trash2, UserPlus } from "lucide-react";
|
||||||
// types
|
// types
|
||||||
import type { IProject } from "@plane/types";
|
import type { IProject } from "@plane/types";
|
||||||
// ui
|
// ui
|
||||||
@ -105,10 +105,10 @@ export const ProjectCard: React.FC<Props> = observer((props) => {
|
|||||||
|
|
||||||
const MENU_ITEMS: TContextMenuItem[] = [
|
const MENU_ITEMS: TContextMenuItem[] = [
|
||||||
{
|
{
|
||||||
key: "edit",
|
key: "settings",
|
||||||
action: () => router.push(`/${workspaceSlug}/projects/${project.id}/settings`),
|
action: () => router.push(`/${workspaceSlug}/projects/${project.id}/settings`),
|
||||||
title: "Edit",
|
title: "Settings",
|
||||||
icon: Pencil,
|
icon: Settings,
|
||||||
shouldRender: !isArchived && (isOwner || isMember),
|
shouldRender: !isArchived && (isOwner || isMember),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -322,7 +322,7 @@ export const ProjectCard: React.FC<Props> = observer((props) => {
|
|||||||
}}
|
}}
|
||||||
href={`/${workspaceSlug}/projects/${project.id}/settings`}
|
href={`/${workspaceSlug}/projects/${project.id}/settings`}
|
||||||
>
|
>
|
||||||
<Pencil className="h-3.5 w-3.5" />
|
<Settings className="h-3.5 w-3.5" />
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<span className="flex items-center gap-1 text-custom-text-400 text-sm">
|
<span className="flex items-center gap-1 text-custom-text-400 text-sm">
|
||||||
|
@ -5,3 +5,4 @@ export * from "./quick-actions";
|
|||||||
export * from "./view-list-item";
|
export * from "./view-list-item";
|
||||||
export * from "./views-list";
|
export * from "./views-list";
|
||||||
export * from "./view-list-item-action";
|
export * from "./view-list-item-action";
|
||||||
|
export * from "./view-list-header";
|
||||||
|
84
web/components/views/view-list-header.tsx
Normal file
84
web/components/views/view-list-header.tsx
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
import React, { useRef, useState } from "react";
|
||||||
|
import { observer } from "mobx-react";
|
||||||
|
// icons
|
||||||
|
import { Search, X } from "lucide-react";
|
||||||
|
// helpers
|
||||||
|
import { cn } from "@/helpers/common.helper";
|
||||||
|
// hooks
|
||||||
|
import { useProjectView } from "@/hooks/store";
|
||||||
|
import useOutsideClickDetector from "@/hooks/use-outside-click-detector";
|
||||||
|
|
||||||
|
export const ViewListHeader = observer(() => {
|
||||||
|
// states
|
||||||
|
const [isSearchOpen, setIsSearchOpen] = useState(false);
|
||||||
|
// const [isSearchOpen, setIsSearchOpen] = useState(searchQuery !== "" ? true : false);
|
||||||
|
// refs
|
||||||
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
|
|
||||||
|
const { searchQuery, updateSearchQuery } = useProjectView();
|
||||||
|
|
||||||
|
// handlers
|
||||||
|
const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
||||||
|
if (e.key === "Escape") {
|
||||||
|
if (searchQuery && searchQuery.trim() !== "") updateSearchQuery("");
|
||||||
|
else {
|
||||||
|
setIsSearchOpen(false);
|
||||||
|
inputRef.current?.blur();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// outside click detector hook
|
||||||
|
useOutsideClickDetector(inputRef, () => {
|
||||||
|
if (isSearchOpen && searchQuery.trim() === "") setIsSearchOpen(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="h-full flex items-center gap-2">
|
||||||
|
<div className="flex items-center">
|
||||||
|
{!isSearchOpen && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="-mr-1 p-2 hover:bg-custom-background-80 rounded text-custom-text-400 grid place-items-center"
|
||||||
|
onClick={() => {
|
||||||
|
setIsSearchOpen(true);
|
||||||
|
inputRef.current?.focus();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Search className="h-3.5 w-3.5" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
className={cn(
|
||||||
|
"ml-auto flex items-center justify-start gap-1 rounded-md border border-transparent bg-custom-background-100 text-custom-text-400 w-0 transition-[width] ease-linear overflow-hidden opacity-0",
|
||||||
|
{
|
||||||
|
"w-64 px-2.5 py-1.5 border-custom-border-200 opacity-100": isSearchOpen,
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
>
|
||||||
|
<Search className="h-3.5 w-3.5" />
|
||||||
|
<input
|
||||||
|
ref={inputRef}
|
||||||
|
className="w-full max-w-[234px] border-none bg-transparent text-sm text-custom-text-100 placeholder:text-custom-text-400 focus:outline-none"
|
||||||
|
placeholder="Search"
|
||||||
|
value={searchQuery}
|
||||||
|
onChange={(e) => updateSearchQuery(e.target.value)}
|
||||||
|
onKeyDown={handleInputKeyDown}
|
||||||
|
/>
|
||||||
|
{isSearchOpen && (
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
className="grid place-items-center"
|
||||||
|
onClick={() => {
|
||||||
|
updateSearchQuery("");
|
||||||
|
setIsSearchOpen(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<X className="h-3 w-3" />
|
||||||
|
</button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
});
|
@ -11,7 +11,8 @@ import { EUserProjectRoles } from "@/constants/project";
|
|||||||
// helpers
|
// helpers
|
||||||
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
||||||
// hooks
|
// hooks
|
||||||
import { useProjectView, useUser } from "@/hooks/store";
|
import { useMember, useProjectView, useUser } from "@/hooks/store";
|
||||||
|
import { ButtonAvatars } from "../dropdowns/member/avatar";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
parentRef: React.RefObject<HTMLElement>;
|
parentRef: React.RefObject<HTMLElement>;
|
||||||
@ -31,6 +32,7 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||||||
membership: { currentProjectRole },
|
membership: { currentProjectRole },
|
||||||
} = useUser();
|
} = useUser();
|
||||||
const { addViewToFavorites, removeViewFromFavorites } = useProjectView();
|
const { addViewToFavorites, removeViewFromFavorites } = useProjectView();
|
||||||
|
const { getUserDetails } = useMember();
|
||||||
|
|
||||||
// derived values
|
// derived values
|
||||||
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
const isEditingAllowed = !!currentProjectRole && currentProjectRole >= EUserProjectRoles.MEMBER;
|
||||||
@ -50,6 +52,8 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||||||
removeViewFromFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
removeViewFromFavorites(workspaceSlug.toString(), projectId.toString(), view.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const createdByDetails = view.created_by ? getUserDetails(view.created_by) : undefined;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{workspaceSlug && projectId && view && (
|
{workspaceSlug && projectId && view && (
|
||||||
@ -65,6 +69,10 @@ export const ViewListItemAction: FC<Props> = observer((props) => {
|
|||||||
<p className="hidden rounded bg-custom-background-80 px-2 py-1 text-xs text-custom-text-200 group-hover:block">
|
<p className="hidden rounded bg-custom-background-80 px-2 py-1 text-xs text-custom-text-200 group-hover:block">
|
||||||
{totalFilters} {totalFilters === 1 ? "filter" : "filters"}
|
{totalFilters} {totalFilters === 1 ? "filter" : "filters"}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{/* created by */}
|
||||||
|
{createdByDetails && <ButtonAvatars showTooltip={false} userIds={createdByDetails?.id} />}
|
||||||
|
|
||||||
{isEditingAllowed && (
|
{isEditingAllowed && (
|
||||||
<FavoriteStar
|
<FavoriteStar
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
import { useRef, useState } from "react";
|
|
||||||
import { observer } from "mobx-react-lite";
|
import { observer } from "mobx-react-lite";
|
||||||
// ui
|
|
||||||
import { Search, X } from "lucide-react";
|
|
||||||
// components
|
// components
|
||||||
import { ListLayout } from "@/components/core/list";
|
import { ListLayout } from "@/components/core/list";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/empty-state";
|
||||||
@ -9,28 +6,13 @@ import { ViewListLoader } from "@/components/ui";
|
|||||||
import { ProjectViewListItem } from "@/components/views";
|
import { ProjectViewListItem } from "@/components/views";
|
||||||
// constants
|
// constants
|
||||||
import { EmptyStateType } from "@/constants/empty-state";
|
import { EmptyStateType } from "@/constants/empty-state";
|
||||||
// helper
|
|
||||||
import { cn } from "@/helpers/common.helper";
|
|
||||||
// hooks
|
// hooks
|
||||||
import { useCommandPalette, useProjectView } from "@/hooks/store";
|
import { useCommandPalette, useProjectView } from "@/hooks/store";
|
||||||
import useOutsideClickDetector from "@/hooks/use-outside-click-detector";
|
|
||||||
|
|
||||||
export const ProjectViewsList = observer(() => {
|
export const ProjectViewsList = observer(() => {
|
||||||
// states
|
|
||||||
const [searchQuery, setSearchQuery] = useState("");
|
|
||||||
const [isSearchOpen, setIsSearchOpen] = useState(searchQuery !== "" ? true : false);
|
|
||||||
|
|
||||||
// refs
|
|
||||||
const inputRef = useRef<HTMLInputElement>(null);
|
|
||||||
|
|
||||||
// store hooks
|
// store hooks
|
||||||
const { toggleCreateViewModal } = useCommandPalette();
|
const { toggleCreateViewModal } = useCommandPalette();
|
||||||
const { projectViewIds, getViewById, loader } = useProjectView();
|
const { projectViewIds, getViewById, loader, searchQuery } = useProjectView();
|
||||||
|
|
||||||
// outside click detector hook
|
|
||||||
useOutsideClickDetector(inputRef, () => {
|
|
||||||
if (isSearchOpen && searchQuery.trim() === "") setIsSearchOpen(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (loader || !projectViewIds) return <ViewListLoader />;
|
if (loader || !projectViewIds) return <ViewListLoader />;
|
||||||
|
|
||||||
@ -39,72 +21,10 @@ export const ProjectViewsList = observer(() => {
|
|||||||
|
|
||||||
const filteredViewsList = viewsList.filter((v) => v?.name.toLowerCase().includes(searchQuery.toLowerCase()));
|
const filteredViewsList = viewsList.filter((v) => v?.name.toLowerCase().includes(searchQuery.toLowerCase()));
|
||||||
|
|
||||||
// handlers
|
|
||||||
const handleInputKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
|
|
||||||
if (e.key === "Escape") {
|
|
||||||
if (searchQuery && searchQuery.trim() !== "") setSearchQuery("");
|
|
||||||
else {
|
|
||||||
setIsSearchOpen(false);
|
|
||||||
inputRef.current?.blur();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{viewsList.length > 0 ? (
|
{viewsList.length > 0 ? (
|
||||||
<div className="flex h-full w-full flex-col">
|
<div className="flex h-full w-full flex-col">
|
||||||
<div className="h-[50px] flex-shrink-0 w-full border-b border-custom-border-200 px-6 relative flex items-center gap-4 justify-between">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<span className="block text-sm font-medium">Project Views</span>
|
|
||||||
</div>
|
|
||||||
<div className="h-full flex items-center gap-2">
|
|
||||||
<div className="flex items-center">
|
|
||||||
{!isSearchOpen && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="-mr-1 p-2 hover:bg-custom-background-80 rounded text-custom-text-400 grid place-items-center"
|
|
||||||
onClick={() => {
|
|
||||||
setIsSearchOpen(true);
|
|
||||||
inputRef.current?.focus();
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Search className="h-3.5 w-3.5" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
<div
|
|
||||||
className={cn(
|
|
||||||
"ml-auto flex items-center justify-start gap-1 rounded-md border border-transparent bg-custom-background-100 text-custom-text-400 w-0 transition-[width] ease-linear overflow-hidden opacity-0",
|
|
||||||
{
|
|
||||||
"w-64 px-2.5 py-1.5 border-custom-border-200 opacity-100": isSearchOpen,
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Search className="h-3.5 w-3.5" />
|
|
||||||
<input
|
|
||||||
ref={inputRef}
|
|
||||||
className="w-full max-w-[234px] border-none bg-transparent text-sm text-custom-text-100 placeholder:text-custom-text-400 focus:outline-none"
|
|
||||||
placeholder="Search"
|
|
||||||
value={searchQuery}
|
|
||||||
onChange={(e) => setSearchQuery(e.target.value)}
|
|
||||||
onKeyDown={handleInputKeyDown}
|
|
||||||
/>
|
|
||||||
{isSearchOpen && (
|
|
||||||
<button
|
|
||||||
type="button"
|
|
||||||
className="grid place-items-center"
|
|
||||||
onClick={() => {
|
|
||||||
setSearchQuery("");
|
|
||||||
setIsSearchOpen(false);
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<X className="h-3 w-3" />
|
|
||||||
</button>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<ListLayout>
|
<ListLayout>
|
||||||
{filteredViewsList.length > 0 ? (
|
{filteredViewsList.length > 0 ? (
|
||||||
filteredViewsList.map((view) => <ProjectViewListItem key={view.id} view={view} />)
|
filteredViewsList.map((view) => <ProjectViewListItem key={view.id} view={view} />)
|
||||||
|
@ -1,20 +1,23 @@
|
|||||||
import { ReactElement, useCallback } from "react";
|
import { ReactElement, useCallback } from "react";
|
||||||
import { observer } from "mobx-react";
|
import { observer } from "mobx-react";
|
||||||
import { useRouter } from "next/router";
|
import { useRouter } from "next/router";
|
||||||
|
// types
|
||||||
import { TModuleFilters } from "@plane/types";
|
import { TModuleFilters } from "@plane/types";
|
||||||
// layouts
|
|
||||||
// components
|
// components
|
||||||
import { PageHead } from "@/components/core";
|
import { PageHead } from "@/components/core";
|
||||||
import { EmptyState } from "@/components/empty-state";
|
import { EmptyState } from "@/components/empty-state";
|
||||||
import { ModulesListHeader } from "@/components/headers";
|
import { ModulesListHeader } from "@/components/headers";
|
||||||
import { ModuleViewHeader, ModuleAppliedFiltersList, ModulesListView } from "@/components/modules";
|
import { ModuleAppliedFiltersList, ModulesListView } from "@/components/modules";
|
||||||
// types
|
|
||||||
// hooks
|
|
||||||
import ModulesListMobileHeader from "@/components/modules/moduels-list-mobile-header";
|
import ModulesListMobileHeader from "@/components/modules/moduels-list-mobile-header";
|
||||||
|
// constants
|
||||||
import { EmptyStateType } from "@/constants/empty-state";
|
import { EmptyStateType } from "@/constants/empty-state";
|
||||||
|
// helpers
|
||||||
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
import { calculateTotalFilters } from "@/helpers/filter.helper";
|
||||||
|
// hooks
|
||||||
import { useModuleFilter, useProject } from "@/hooks/store";
|
import { useModuleFilter, useProject } from "@/hooks/store";
|
||||||
|
// layouts
|
||||||
import { AppLayout } from "@/layouts/app-layout";
|
import { AppLayout } from "@/layouts/app-layout";
|
||||||
|
// types
|
||||||
import { NextPageWithLayout } from "@/lib/types";
|
import { NextPageWithLayout } from "@/lib/types";
|
||||||
|
|
||||||
const ProjectModulesPage: NextPageWithLayout = observer(() => {
|
const ProjectModulesPage: NextPageWithLayout = observer(() => {
|
||||||
@ -58,12 +61,6 @@ const ProjectModulesPage: NextPageWithLayout = observer(() => {
|
|||||||
<>
|
<>
|
||||||
<PageHead title={pageTitle} />
|
<PageHead title={pageTitle} />
|
||||||
<div className="h-full w-full flex flex-col">
|
<div className="h-full w-full flex flex-col">
|
||||||
<div className="h-[50px] flex-shrink-0 w-full border-b border-custom-border-200 px-6 relative flex items-center gap-4 justify-between">
|
|
||||||
<div className="flex items-center">
|
|
||||||
<span className="block text-sm font-medium">Module name</span>
|
|
||||||
</div>
|
|
||||||
<ModuleViewHeader />
|
|
||||||
</div>
|
|
||||||
{(calculateTotalFilters(currentProjectFilters ?? {}) !== 0 || currentProjectDisplayFilters?.favorites) && (
|
{(calculateTotalFilters(currentProjectFilters ?? {}) !== 0 || currentProjectDisplayFilters?.favorites) && (
|
||||||
<div className="border-b border-custom-border-200 px-5 py-3">
|
<div className="border-b border-custom-border-200 px-5 py-3">
|
||||||
<ModuleAppliedFiltersList
|
<ModuleAppliedFiltersList
|
||||||
|
@ -12,11 +12,13 @@ export interface IProjectViewStore {
|
|||||||
loader: boolean;
|
loader: boolean;
|
||||||
fetchedMap: Record<string, boolean>;
|
fetchedMap: Record<string, boolean>;
|
||||||
// observables
|
// observables
|
||||||
|
searchQuery: string;
|
||||||
viewMap: Record<string, IProjectView>;
|
viewMap: Record<string, IProjectView>;
|
||||||
// computed
|
// computed
|
||||||
projectViewIds: string[] | null;
|
projectViewIds: string[] | null;
|
||||||
// computed actions
|
// computed actions
|
||||||
getViewById: (viewId: string) => IProjectView;
|
getViewById: (viewId: string) => IProjectView;
|
||||||
|
updateSearchQuery: (query: string) => void;
|
||||||
// fetch actions
|
// fetch actions
|
||||||
fetchViews: (workspaceSlug: string, projectId: string) => Promise<undefined | IProjectView[]>;
|
fetchViews: (workspaceSlug: string, projectId: string) => Promise<undefined | IProjectView[]>;
|
||||||
fetchViewDetails: (workspaceSlug: string, projectId: string, viewId: string) => Promise<IProjectView>;
|
fetchViewDetails: (workspaceSlug: string, projectId: string, viewId: string) => Promise<IProjectView>;
|
||||||
@ -38,6 +40,7 @@ export class ProjectViewStore implements IProjectViewStore {
|
|||||||
// observables
|
// observables
|
||||||
loader: boolean = false;
|
loader: boolean = false;
|
||||||
viewMap: Record<string, IProjectView> = {};
|
viewMap: Record<string, IProjectView> = {};
|
||||||
|
searchQuery: string = "";
|
||||||
//loaders
|
//loaders
|
||||||
fetchedMap: Record<string, boolean> = {};
|
fetchedMap: Record<string, boolean> = {};
|
||||||
// root store
|
// root store
|
||||||
@ -51,6 +54,7 @@ export class ProjectViewStore implements IProjectViewStore {
|
|||||||
loader: observable.ref,
|
loader: observable.ref,
|
||||||
viewMap: observable,
|
viewMap: observable,
|
||||||
fetchedMap: observable,
|
fetchedMap: observable,
|
||||||
|
searchQuery: observable.ref,
|
||||||
// computed
|
// computed
|
||||||
projectViewIds: computed,
|
projectViewIds: computed,
|
||||||
// fetch actions
|
// fetch actions
|
||||||
@ -60,6 +64,8 @@ export class ProjectViewStore implements IProjectViewStore {
|
|||||||
createView: action,
|
createView: action,
|
||||||
updateView: action,
|
updateView: action,
|
||||||
deleteView: action,
|
deleteView: action,
|
||||||
|
// actions
|
||||||
|
updateSearchQuery: action,
|
||||||
// favorites actions
|
// favorites actions
|
||||||
addViewToFavorites: action,
|
addViewToFavorites: action,
|
||||||
removeViewFromFavorites: action,
|
removeViewFromFavorites: action,
|
||||||
@ -85,6 +91,12 @@ export class ProjectViewStore implements IProjectViewStore {
|
|||||||
*/
|
*/
|
||||||
getViewById = computedFn((viewId: string) => this.viewMap?.[viewId] ?? null);
|
getViewById = computedFn((viewId: string) => this.viewMap?.[viewId] ?? null);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description update search query
|
||||||
|
* @param {string} query
|
||||||
|
*/
|
||||||
|
updateSearchQuery = (query: string) => (this.searchQuery = query);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches views for current project
|
* Fetches views for current project
|
||||||
* @param workspaceSlug
|
* @param workspaceSlug
|
||||||
|
Loading…
Reference in New Issue
Block a user