2024-02-09 10:23:15 +00:00
|
|
|
import React, { useRef } from "react";
|
2023-10-18 07:02:02 +00:00
|
|
|
import { observer } from "mobx-react-lite";
|
2024-06-04 05:42:24 +00:00
|
|
|
// types
|
2024-03-19 14:38:35 +00:00
|
|
|
import { TIssue, IIssueDisplayFilterOptions, IIssueDisplayProperties } from "@plane/types";
|
2023-10-18 07:02:02 +00:00
|
|
|
// components
|
2024-05-15 16:39:16 +00:00
|
|
|
import { LogoSpinner } from "@/components/common";
|
2024-06-04 05:42:24 +00:00
|
|
|
import { MultipleSelectGroup } from "@/components/core";
|
|
|
|
import { IssueBulkOperationsRoot, SpreadsheetQuickAddIssueForm } from "@/components/issues";
|
|
|
|
// constants
|
|
|
|
import { SPREADSHEET_PROPERTY_LIST, SPREADSHEET_SELECT_GROUP } from "@/constants/spreadsheet";
|
|
|
|
// hooks
|
2024-03-19 14:38:35 +00:00
|
|
|
import { useProject } from "@/hooks/store";
|
2024-06-04 05:42:24 +00:00
|
|
|
// types
|
2024-04-30 13:29:07 +00:00
|
|
|
import { TRenderQuickActions } from "../list/list-view-types";
|
2024-03-06 13:09:14 +00:00
|
|
|
import { SpreadsheetTable } from "./spreadsheet-table";
|
2023-10-18 07:02:02 +00:00
|
|
|
|
|
|
|
type Props = {
|
|
|
|
displayProperties: IIssueDisplayProperties;
|
|
|
|
displayFilters: IIssueDisplayFilterOptions;
|
|
|
|
handleDisplayFilterUpdate: (data: Partial<IIssueDisplayFilterOptions>) => void;
|
2024-01-18 10:21:17 +00:00
|
|
|
issueIds: string[] | undefined;
|
2024-04-30 13:29:07 +00:00
|
|
|
quickActions: TRenderQuickActions;
|
2024-06-10 14:45:03 +00:00
|
|
|
updateIssue: ((projectId: string | null, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
2023-10-18 07:02:02 +00:00
|
|
|
openIssuesListModal?: (() => void) | null;
|
2024-06-10 14:45:03 +00:00
|
|
|
quickAddCallback?: (projectId: string | null | undefined, data: TIssue) => Promise<TIssue | undefined>;
|
2023-12-07 14:16:57 +00:00
|
|
|
canEditProperties: (projectId: string | undefined) => boolean;
|
2024-06-10 14:45:03 +00:00
|
|
|
canLoadMoreIssues: boolean;
|
|
|
|
loadMoreIssues: () => void;
|
2023-10-27 07:02:24 +00:00
|
|
|
enableQuickCreateIssue?: boolean;
|
2023-12-12 06:19:43 +00:00
|
|
|
disableIssueCreation?: boolean;
|
2024-04-04 10:19:25 +00:00
|
|
|
isWorkspaceLevel?: boolean;
|
2023-10-18 07:02:02 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
export const SpreadsheetView: React.FC<Props> = observer((props) => {
|
|
|
|
const {
|
|
|
|
displayProperties,
|
|
|
|
displayFilters,
|
|
|
|
handleDisplayFilterUpdate,
|
2024-01-18 10:21:17 +00:00
|
|
|
issueIds,
|
2023-11-27 08:45:33 +00:00
|
|
|
quickActions,
|
2024-03-06 15:17:38 +00:00
|
|
|
updateIssue,
|
2023-11-23 09:17:04 +00:00
|
|
|
quickAddCallback,
|
2023-12-07 14:16:57 +00:00
|
|
|
canEditProperties,
|
2023-10-27 07:02:24 +00:00
|
|
|
enableQuickCreateIssue,
|
2023-12-12 06:19:43 +00:00
|
|
|
disableIssueCreation,
|
2024-06-10 14:45:03 +00:00
|
|
|
canLoadMoreIssues,
|
|
|
|
loadMoreIssues,
|
2024-04-04 10:19:25 +00:00
|
|
|
isWorkspaceLevel = false,
|
2023-10-18 07:02:02 +00:00
|
|
|
} = props;
|
2023-11-29 08:55:57 +00:00
|
|
|
// refs
|
2024-01-11 12:49:19 +00:00
|
|
|
const containerRef = useRef<HTMLTableElement | null>(null);
|
|
|
|
const portalRef = useRef<HTMLDivElement | null>(null);
|
|
|
|
|
|
|
|
const { currentProjectDetails } = useProject();
|
|
|
|
|
|
|
|
const isEstimateEnabled: boolean = currentProjectDetails?.estimate !== null;
|
2023-10-18 07:02:02 +00:00
|
|
|
|
2024-04-04 10:19:25 +00:00
|
|
|
const spreadsheetColumnsList = isWorkspaceLevel
|
|
|
|
? SPREADSHEET_PROPERTY_LIST
|
|
|
|
: SPREADSHEET_PROPERTY_LIST.filter((property) => {
|
|
|
|
if (property === "cycle" && !currentProjectDetails?.cycle_view) return false;
|
|
|
|
if (property === "modules" && !currentProjectDetails?.module_view) return false;
|
|
|
|
return true;
|
|
|
|
});
|
|
|
|
|
2024-01-18 10:21:17 +00:00
|
|
|
if (!issueIds || issueIds.length === 0)
|
2023-12-11 16:54:41 +00:00
|
|
|
return (
|
|
|
|
<div className="grid h-full w-full place-items-center">
|
2024-05-15 16:39:16 +00:00
|
|
|
<LogoSpinner />
|
2023-12-11 16:54:41 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
|
2023-10-18 07:02:02 +00:00
|
|
|
return (
|
2024-05-08 17:31:20 +00:00
|
|
|
<div className="relative flex h-full w-full flex-col overflow-x-hidden whitespace-nowrap rounded-lg bg-custom-background-200 text-custom-text-200">
|
2024-01-11 12:49:19 +00:00
|
|
|
<div ref={portalRef} className="spreadsheet-menu-portal" />
|
2024-06-04 05:42:24 +00:00
|
|
|
<MultipleSelectGroup
|
|
|
|
containerRef={containerRef}
|
|
|
|
entities={{
|
|
|
|
[SPREADSHEET_SELECT_GROUP]: issueIds,
|
|
|
|
}}
|
2024-06-07 08:29:57 +00:00
|
|
|
disabled
|
2024-06-04 05:42:24 +00:00
|
|
|
>
|
|
|
|
{(helpers) => (
|
|
|
|
<>
|
|
|
|
<div ref={containerRef} className="vertical-scrollbar horizontal-scrollbar scrollbar-lg h-full w-full">
|
|
|
|
<SpreadsheetTable
|
|
|
|
displayProperties={displayProperties}
|
|
|
|
displayFilters={displayFilters}
|
|
|
|
handleDisplayFilterUpdate={handleDisplayFilterUpdate}
|
|
|
|
issueIds={issueIds}
|
|
|
|
isEstimateEnabled={isEstimateEnabled}
|
|
|
|
portalElement={portalRef}
|
|
|
|
quickActions={quickActions}
|
|
|
|
updateIssue={updateIssue}
|
|
|
|
canEditProperties={canEditProperties}
|
|
|
|
containerRef={containerRef}
|
2024-06-10 14:45:03 +00:00
|
|
|
canLoadMoreIssues={canLoadMoreIssues}
|
|
|
|
loadMoreIssues={loadMoreIssues}
|
2024-06-04 05:42:24 +00:00
|
|
|
spreadsheetColumnsList={spreadsheetColumnsList}
|
|
|
|
selectionHelpers={helpers}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="border-t border-custom-border-100">
|
|
|
|
<div className="z-5 sticky bottom-0 left-0 mb-3">
|
|
|
|
{enableQuickCreateIssue && !disableIssueCreation && (
|
2024-06-10 14:45:03 +00:00
|
|
|
<SpreadsheetQuickAddIssueForm formKey="name" quickAddCallback={quickAddCallback}/>
|
2024-06-04 05:42:24 +00:00
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-06-05 07:18:50 +00:00
|
|
|
<IssueBulkOperationsRoot selectionHelpers={helpers} />
|
2024-06-04 05:42:24 +00:00
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</MultipleSelectGroup>
|
2023-10-18 13:48:01 +00:00
|
|
|
</div>
|
2023-10-18 07:02:02 +00:00
|
|
|
);
|
|
|
|
});
|