2024-06-04 05:42:24 +00:00
|
|
|
import { observer } from "mobx-react";
|
|
|
|
import { useRouter } from "next/router";
|
2024-01-11 12:49:19 +00:00
|
|
|
// ui
|
2024-03-19 14:38:35 +00:00
|
|
|
import { IIssueDisplayFilterOptions, IIssueDisplayProperties } from "@plane/types";
|
2024-01-11 12:49:19 +00:00
|
|
|
// components
|
2024-06-04 05:42:24 +00:00
|
|
|
import { MultipleSelectGroupAction } from "@/components/core";
|
2024-05-10 09:54:18 +00:00
|
|
|
import { SpreadsheetHeaderColumn } from "@/components/issues/issue-layouts";
|
2024-06-04 05:42:24 +00:00
|
|
|
// constants
|
|
|
|
import { SPREADSHEET_SELECT_GROUP } from "@/constants/spreadsheet";
|
|
|
|
// helpers
|
|
|
|
import { cn } from "@/helpers/common.helper";
|
|
|
|
// hooks
|
|
|
|
import { TSelectionHelper } from "@/hooks/use-multiple-select";
|
2024-01-11 12:49:19 +00:00
|
|
|
|
|
|
|
interface Props {
|
|
|
|
displayProperties: IIssueDisplayProperties;
|
|
|
|
displayFilters: IIssueDisplayFilterOptions;
|
|
|
|
handleDisplayFilterUpdate: (data: Partial<IIssueDisplayFilterOptions>) => void;
|
2024-06-04 05:42:24 +00:00
|
|
|
canEditProperties: (projectId: string | undefined) => boolean;
|
2024-01-11 12:49:19 +00:00
|
|
|
isEstimateEnabled: boolean;
|
2024-04-04 10:19:25 +00:00
|
|
|
spreadsheetColumnsList: (keyof IIssueDisplayProperties)[];
|
2024-06-04 05:42:24 +00:00
|
|
|
selectionHelpers: TSelectionHelper;
|
2024-01-11 12:49:19 +00:00
|
|
|
}
|
|
|
|
|
2024-06-04 05:42:24 +00:00
|
|
|
export const SpreadsheetHeader = observer((props: Props) => {
|
|
|
|
const {
|
|
|
|
displayProperties,
|
|
|
|
displayFilters,
|
|
|
|
handleDisplayFilterUpdate,
|
|
|
|
canEditProperties,
|
|
|
|
isEstimateEnabled,
|
|
|
|
spreadsheetColumnsList,
|
|
|
|
selectionHelpers,
|
|
|
|
} = props;
|
|
|
|
// router
|
|
|
|
const router = useRouter();
|
|
|
|
const { projectId } = router.query;
|
|
|
|
// derived values
|
|
|
|
const isGroupSelectionEmpty = selectionHelpers.isGroupSelected(SPREADSHEET_SELECT_GROUP) === "empty";
|
|
|
|
// auth
|
2024-06-07 08:29:57 +00:00
|
|
|
const canSelectIssues = canEditProperties(projectId?.toString()) && !selectionHelpers.isSelectionDisabled;
|
2024-01-11 12:49:19 +00:00
|
|
|
|
|
|
|
return (
|
2024-02-28 13:45:03 +00:00
|
|
|
<thead className="sticky top-0 left-0 z-[12] border-b-[0.5px] border-custom-border-100">
|
2024-01-11 12:49:19 +00:00
|
|
|
<tr>
|
2024-02-08 06:19:00 +00:00
|
|
|
<th
|
2024-06-04 05:42:24 +00:00
|
|
|
className="group/list-header sticky left-0 z-[15] h-11 w-[28rem] flex items-center gap-1 bg-custom-background-90 text-sm font-medium before:absolute before:h-full before:right-0 before:border-[0.5px] before:border-custom-border-100 pl-2"
|
2024-02-08 06:19:00 +00:00
|
|
|
tabIndex={-1}
|
|
|
|
>
|
2024-06-04 05:42:24 +00:00
|
|
|
{canSelectIssues && (
|
2024-06-06 05:33:56 +00:00
|
|
|
<div className="flex-shrink-0 flex items-center w-3.5 mr-1">
|
2024-06-04 05:42:24 +00:00
|
|
|
<MultipleSelectGroupAction
|
|
|
|
className={cn(
|
|
|
|
"size-3.5 opacity-0 pointer-events-none group-hover/list-header:opacity-100 group-hover/list-header:pointer-events-auto !outline-none",
|
|
|
|
{
|
|
|
|
"opacity-100 pointer-events-auto": !isGroupSelectionEmpty,
|
|
|
|
}
|
|
|
|
)}
|
|
|
|
groupID={SPREADSHEET_SELECT_GROUP}
|
|
|
|
selectionHelpers={selectionHelpers}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
<span className="flex h-full w-full flex-grow items-center py-2.5">Issues</span>
|
2024-01-11 12:49:19 +00:00
|
|
|
</th>
|
|
|
|
|
2024-04-04 10:19:25 +00:00
|
|
|
{spreadsheetColumnsList.map((property) => (
|
2024-02-08 06:19:00 +00:00
|
|
|
<SpreadsheetHeaderColumn
|
2024-03-06 13:09:14 +00:00
|
|
|
key={property}
|
2024-02-08 06:19:00 +00:00
|
|
|
property={property}
|
|
|
|
displayProperties={displayProperties}
|
|
|
|
displayFilters={displayFilters}
|
|
|
|
handleDisplayFilterUpdate={handleDisplayFilterUpdate}
|
|
|
|
isEstimateEnabled={isEstimateEnabled}
|
|
|
|
/>
|
|
|
|
))}
|
2024-01-11 12:49:19 +00:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
);
|
2024-06-04 05:42:24 +00:00
|
|
|
});
|