mirror of
https://github.com/makeplane/plane.git
synced 2026-07-12 21:40:18 +02:00
* dev: private bucket implementation (#1339) * chore: migrations and backmigration to move attachments to file asset * chore: move attachments to file assets * chore: update migration file to include created by and updated by and size * chore: remove uninmport errors * chore: make size as float field * fix: file asset uploads * chore: asset uploads migration changes * chore: v2 assets endpoint * chore: remove unused imports * chore: issue attachments * chore: issue attachments * chore: workspace logo endpoints * chore: private bucket changes * chore: user asset endpoint * chore: add logo_url validation * chore: cover image urlk * chore: change asset max length * chore: pages endpoint * chore: store the storage_metadata only when none * chore: attachment asset apis * chore: update create private bucket * chore: make bucket private * chore: fix response of user uploads * fix: response of user uploads * fix: job to fix file asset uploads * fix: user asset endpoints * chore: avatar for user profile * chore: external apis user url endpoint * chore: upload workspace and user asset actions updated * chore: analytics endpoint * fix: analytics export * chore: avatar urls * chore: update user avatar instances * chore: avatar urls for assignees and creators * chore: bucket permission script * fix: all user avatr instances in the web app * chore: update project cover image logic * fix: issue attachment endpoint * chore: patch endpoint for issue attachment * chore: attachments * chore: change attachment storage class * chore: update issue attachment endpoints * fix: issue attachment * chore: update issue attachment implementation * chore: page asset endpoints * fix: web build errors * chore: attachments * chore: page asset urls * chore: comment and issue asset endpoints * chore: asset endpoints * chore: attachment endpoints * chore: bulk asset endpoint * chore: restore endpoint * chore: project assets endpoints * chore: asset url * chore: add delete asset endpoints * chore: fix asset upload endpoint * chore: update patch endpoints * chore: update patch endpoint * chore: update editor image handling * chore: asset restore endpoints * chore: avatar url for space assets * chore: space app assets migration * fix: space app urls * chore: space endpoints * fix: old editor images rendering logic * fix: issue archive and attachment activity * chore: asset deletes * chore: update images * chore: attachment delete * fix: issue attachment * fix: issue attachment get * chore: cover image url for projects * chore: remove duplicate py file * fix: url check function * chore: chore project cover asset delete * fix: migrations * chore: delete migration files --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> * fix: private bucket build errors (#1347) * fix: private bucket build errors * fix: build errors * revert: issue type select changes. (#1355) * chore: private bucket implementation for workspace level pages (#1371) * chore: update project modal * chore: update rich-text read-only editor * chore: update workspace pages' components * chore: remove entity identifier in favour of multiple columns of entities (#1405) * fix: issue attachments (#1411) * fix: issue attachments (#1422) * chore: file size limit for pro workspaces (#1437) * chore: file size limit for pro * chore: update maximum file size logic * chore: update editor max file size logic * chore: update max file size limit logic * chore: add comments * fix: close modal after removing workspace logo * chore: update uploaded asstes' status post issue creation * chore: memoize max file size var * chore: check for pro file size limits * chore: added file size limit to the space app --------- Co-authored-by: Aaryan Khandelwal <aaryankhandu123@gmail.com> * chore: add max file size limit to workspace pages (#1440) * fix: remove old workspace logo and user avatar (#1445) * fix: intake exception error (#5810) * chore: filtered active cycles for guest (#1468) * fix: build error --------- Co-authored-by: pablohashescobar <nikhilschacko@gmail.com> Co-authored-by: Nikhil <118773738+pablohashescobar@users.noreply.github.com> Co-authored-by: Prateek Shourya <prateekshourya29@gmail.com> Co-authored-by: sriram veeraghanta <veeraghanta.sriram@gmail.com> Co-authored-by: Anmol Singh Bhatia <121005188+anmolsinghbhatia@users.noreply.github.com> Co-authored-by: Bavisetti Narayan <72156168+NarayanBavisetti@users.noreply.github.com>
289 lines
12 KiB
TypeScript
289 lines
12 KiB
TypeScript
import { FC, Fragment } from "react";
|
|
import { observer } from "mobx-react";
|
|
import Link from "next/link";
|
|
import useSWR from "swr";
|
|
// icons
|
|
import { CalendarCheck } from "lucide-react";
|
|
// headless ui
|
|
import { Tab } from "@headlessui/react";
|
|
// types
|
|
import { IActiveCycle } from "@plane/types";
|
|
// ui
|
|
import { Tooltip, Loader, PriorityIcon, Avatar } from "@plane/ui";
|
|
// components
|
|
import { SingleProgressStats } from "@/components/core";
|
|
import { StateDropdown } from "@/components/dropdowns";
|
|
// constants
|
|
import { EmptyState } from "@/components/empty-state";
|
|
import { EmptyStateType } from "@/constants/empty-state";
|
|
import { CYCLE_ISSUES_WITH_PARAMS } from "@/constants/fetch-keys";
|
|
import { EIssuesStoreType } from "@/constants/issue";
|
|
// helpers
|
|
import { cn } from "@/helpers/common.helper";
|
|
import { renderFormattedDate, renderFormattedDateWithoutYear } from "@/helpers/date-time.helper";
|
|
import { getFileURL } from "@/helpers/file.helper";
|
|
// hooks
|
|
import { useIssues, useProjectState } from "@/hooks/store";
|
|
import useLocalStorage from "@/hooks/use-local-storage";
|
|
|
|
export type ActiveCycleStatsProps = {
|
|
workspaceSlug: string;
|
|
projectId: string;
|
|
cycle: IActiveCycle;
|
|
};
|
|
|
|
export const ActiveCycleStats: FC<ActiveCycleStatsProps> = observer((props) => {
|
|
const { workspaceSlug, projectId, cycle } = props;
|
|
|
|
const { storedValue: tab, setValue: setTab } = useLocalStorage("activeCycleTab", "Assignees");
|
|
|
|
const currentValue = (tab: string | null) => {
|
|
switch (tab) {
|
|
case "Priority-Issues":
|
|
return 0;
|
|
case "Assignees":
|
|
return 1;
|
|
case "Labels":
|
|
return 2;
|
|
default:
|
|
return 0;
|
|
}
|
|
};
|
|
const {
|
|
issues: { fetchActiveCycleIssues },
|
|
} = useIssues(EIssuesStoreType.CYCLE);
|
|
const { fetchWorkspaceStates } = useProjectState();
|
|
|
|
const { data: activeCycleIssues } = useSWR(
|
|
workspaceSlug && projectId && cycle.id ? CYCLE_ISSUES_WITH_PARAMS(cycle.id, { priority: "urgent,high" }) : null,
|
|
workspaceSlug && projectId && cycle.id ? () => fetchActiveCycleIssues(workspaceSlug, projectId, 10, cycle.id) : null
|
|
);
|
|
|
|
useSWR(
|
|
workspaceSlug ? `WORKSPACE_STATES_${workspaceSlug}` : null,
|
|
workspaceSlug ? () => fetchWorkspaceStates(workspaceSlug.toString()) : null
|
|
);
|
|
|
|
const cycleIssues = activeCycleIssues;
|
|
|
|
return (
|
|
<div className="flex flex-col gap-4 p-4 min-h-[17rem] overflow-hidden col-span-1 lg:col-span-2 xl:col-span-1 border border-custom-border-200 rounded-lg">
|
|
<Tab.Group
|
|
as={Fragment}
|
|
defaultIndex={currentValue(tab)}
|
|
onChange={(i) => {
|
|
switch (i) {
|
|
case 0:
|
|
return setTab("Priority-Issues");
|
|
case 1:
|
|
return setTab("Assignees");
|
|
case 2:
|
|
return setTab("Labels");
|
|
|
|
default:
|
|
return setTab("Priority-Issues");
|
|
}
|
|
}}
|
|
>
|
|
<Tab.List
|
|
as="div"
|
|
className="relative border-[0.5px] border-custom-border-200 rounded bg-custom-background-80 p-[1px] grid"
|
|
style={{
|
|
gridTemplateColumns: `repeat(3, 1fr)`,
|
|
}}
|
|
>
|
|
<Tab
|
|
className={({ selected }) =>
|
|
cn(
|
|
"relative z-[1] font-semibold text-xs rounded-[3px] py-1.5 text-custom-text-400 focus:outline-none transition duration-500",
|
|
{
|
|
"text-custom-text-300 bg-custom-background-100": selected,
|
|
"hover:text-custom-text-300": !selected,
|
|
}
|
|
)
|
|
}
|
|
>
|
|
Priority Issues
|
|
</Tab>
|
|
<Tab
|
|
className={({ selected }) =>
|
|
cn(
|
|
"relative z-[1] font-semibold text-xs rounded-[3px] py-1.5 text-custom-text-400 focus:outline-none transition duration-500",
|
|
{
|
|
"text-custom-text-300 bg-custom-background-100": selected,
|
|
"hover:text-custom-text-300": !selected,
|
|
}
|
|
)
|
|
}
|
|
>
|
|
Assignees
|
|
</Tab>
|
|
<Tab
|
|
className={({ selected }) =>
|
|
cn(
|
|
"relative z-[1] font-semibold text-xs rounded-[3px] py-1.5 text-custom-text-400 focus:outline-none transition duration-500",
|
|
{
|
|
"text-custom-text-300 bg-custom-background-100": selected,
|
|
"hover:text-custom-text-300": !selected,
|
|
}
|
|
)
|
|
}
|
|
>
|
|
Labels
|
|
</Tab>
|
|
</Tab.List>
|
|
|
|
<Tab.Panels as={Fragment}>
|
|
<Tab.Panel
|
|
as="div"
|
|
className="flex h-52 w-full flex-col gap-1 overflow-y-auto text-custom-text-200 vertical-scrollbar scrollbar-sm"
|
|
>
|
|
<div className="flex flex-col gap-1 h-full w-full overflow-y-auto vertical-scrollbar scrollbar-sm">
|
|
{cycleIssues ? (
|
|
cycleIssues?.count > 0 && Array.isArray(cycleIssues.results) ? (
|
|
cycleIssues.results.map((issue: any) => (
|
|
<Link
|
|
key={issue.id}
|
|
href={`/${workspaceSlug}/projects/${projectId}/issues/${issue.id}`}
|
|
className="group flex cursor-pointer items-center justify-between gap-2 rounded-md hover:bg-custom-background-90 p-1"
|
|
>
|
|
<div className="flex items-center gap-1.5 flex-grow w-full min-w-24 truncate">
|
|
<PriorityIcon priority={issue.priority} withContainer size={12} />
|
|
|
|
<Tooltip
|
|
tooltipHeading="Issue ID"
|
|
tooltipContent={`${cycle.project_detail?.identifier}-${issue.sequence_id}`}
|
|
>
|
|
<span className="flex-shrink-0 text-xs text-custom-text-200">
|
|
{cycle.project_detail?.identifier}-{issue.sequence_id}
|
|
</span>
|
|
</Tooltip>
|
|
<Tooltip position="top-left" tooltipHeading="Title" tooltipContent={issue.name}>
|
|
<span className="text-[0.825rem] text-custom-text-100 truncate">{issue.name}</span>
|
|
</Tooltip>
|
|
</div>
|
|
<div className="flex items-center gap-1.5 flex-shrink-0">
|
|
<StateDropdown
|
|
value={issue.state_id ?? undefined}
|
|
onChange={() => {}}
|
|
projectId={projectId?.toString() ?? ""}
|
|
disabled
|
|
buttonVariant="background-with-text"
|
|
buttonContainerClassName="cursor-pointer max-w-24"
|
|
showTooltip
|
|
/>
|
|
{issue.target_date && (
|
|
<Tooltip tooltipHeading="Target Date" tooltipContent={renderFormattedDate(issue.target_date)}>
|
|
<div className="h-full flex truncate items-center gap-1.5 rounded text-xs px-2 py-0.5 bg-custom-background-80 group-hover:bg-custom-background-100 cursor-pointer">
|
|
<CalendarCheck className="h-3 w-3 flex-shrink-0" />
|
|
<span className="text-xs truncate">
|
|
{renderFormattedDateWithoutYear(issue.target_date)}
|
|
</span>
|
|
</div>
|
|
</Tooltip>
|
|
)}
|
|
</div>
|
|
</Link>
|
|
))
|
|
) : (
|
|
<div className="flex items-center justify-center h-full w-full">
|
|
<EmptyState
|
|
type={EmptyStateType.ACTIVE_CYCLE_PRIORITY_ISSUE_EMPTY_STATE}
|
|
layout="screen-simple"
|
|
size="sm"
|
|
/>
|
|
</div>
|
|
)
|
|
) : (
|
|
<Loader className="space-y-3">
|
|
<Loader.Item height="50px" />
|
|
<Loader.Item height="50px" />
|
|
<Loader.Item height="50px" />
|
|
</Loader>
|
|
)}
|
|
</div>
|
|
</Tab.Panel>
|
|
|
|
<Tab.Panel
|
|
as="div"
|
|
className="flex h-52 w-full flex-col gap-1 overflow-y-auto text-custom-text-200 vertical-scrollbar scrollbar-sm"
|
|
>
|
|
{cycle?.distribution?.assignees && cycle.distribution.assignees.length > 0 ? (
|
|
cycle.distribution.assignees.map((assignee, index) => {
|
|
if (assignee.assignee_id)
|
|
return (
|
|
<SingleProgressStats
|
|
key={assignee.assignee_id}
|
|
title={
|
|
<div className="flex items-center gap-2">
|
|
<Avatar
|
|
name={assignee?.display_name ?? undefined}
|
|
src={getFileURL(assignee?.avatar_url ?? "")}
|
|
/>
|
|
|
|
<span>{assignee.display_name}</span>
|
|
</div>
|
|
}
|
|
completed={assignee.completed_issues}
|
|
total={assignee.total_issues}
|
|
/>
|
|
);
|
|
else
|
|
return (
|
|
<SingleProgressStats
|
|
key={`unassigned-${index}`}
|
|
title={
|
|
<div className="flex items-center gap-2">
|
|
<div className="h-5 w-5 rounded-full border-2 border-custom-border-200 bg-custom-background-80">
|
|
<img src="/user.png" height="100%" width="100%" className="rounded-full" alt="User" />
|
|
</div>
|
|
<span>No assignee</span>
|
|
</div>
|
|
}
|
|
completed={assignee.completed_issues}
|
|
total={assignee.total_issues}
|
|
/>
|
|
);
|
|
})
|
|
) : (
|
|
<div className="flex items-center justify-center h-full w-full">
|
|
<EmptyState type={EmptyStateType.ACTIVE_CYCLE_ASSIGNEE_EMPTY_STATE} layout="screen-simple" size="sm" />
|
|
</div>
|
|
)}
|
|
</Tab.Panel>
|
|
|
|
<Tab.Panel
|
|
as="div"
|
|
className="flex h-52 w-full flex-col gap-1 overflow-y-auto text-custom-text-200 vertical-scrollbar scrollbar-sm"
|
|
>
|
|
{cycle?.distribution?.labels && cycle.distribution.labels.length > 0 ? (
|
|
cycle.distribution.labels.map((label, index) => (
|
|
<SingleProgressStats
|
|
key={label.label_id ?? `no-label-${index}`}
|
|
title={
|
|
<div className="flex items-center gap-2">
|
|
<span
|
|
className="block h-3 w-3 rounded-full"
|
|
style={{
|
|
backgroundColor: label.color ?? "#000000",
|
|
}}
|
|
/>
|
|
<span className="text-xs">{label.label_name ?? "No labels"}</span>
|
|
</div>
|
|
}
|
|
completed={label.completed_issues}
|
|
total={label.total_issues}
|
|
/>
|
|
))
|
|
) : (
|
|
<div className="flex items-center justify-center h-full w-full">
|
|
<EmptyState type={EmptyStateType.ACTIVE_CYCLE_LABEL_EMPTY_STATE} layout="screen-simple" size="sm" />
|
|
</div>
|
|
)}
|
|
</Tab.Panel>
|
|
</Tab.Panels>
|
|
</Tab.Group>
|
|
</div>
|
|
);
|
|
});
|