2024-02-08 06:19:00 +00:00
|
|
|
import { useRef } from "react";
|
2024-03-06 13:09:14 +00:00
|
|
|
import { observer } from "mobx-react";
|
2024-02-08 06:19:00 +00:00
|
|
|
import { useRouter } from "next/router";
|
|
|
|
// types
|
2024-03-06 13:09:14 +00:00
|
|
|
import { SPREADSHEET_PROPERTY_DETAILS } from "constants/spreadsheet";
|
|
|
|
import { useEventTracker } from "hooks/store";
|
2024-02-08 06:19:00 +00:00
|
|
|
import { IIssueDisplayProperties, TIssue } from "@plane/types";
|
2024-03-06 13:09:14 +00:00
|
|
|
import { WithDisplayPropertiesHOC } from "../properties/with-display-properties-HOC";
|
2024-02-08 06:19:00 +00:00
|
|
|
// constants
|
|
|
|
// components
|
|
|
|
|
|
|
|
type Props = {
|
|
|
|
displayProperties: IIssueDisplayProperties;
|
|
|
|
issueDetail: TIssue;
|
|
|
|
disableUserActions: boolean;
|
|
|
|
property: keyof IIssueDisplayProperties;
|
2024-03-06 15:17:38 +00:00
|
|
|
updateIssue: ((projectId: string, issueId: string, data: Partial<TIssue>) => Promise<void>) | undefined;
|
2024-02-08 06:19:00 +00:00
|
|
|
isEstimateEnabled: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const IssueColumn = observer((props: Props) => {
|
2024-03-06 15:17:38 +00:00
|
|
|
const { displayProperties, issueDetail, disableUserActions, property, updateIssue, isEstimateEnabled } = props;
|
2024-02-08 06:19:00 +00:00
|
|
|
// router
|
|
|
|
const router = useRouter();
|
|
|
|
const tableCellRef = useRef<HTMLTableCellElement | null>(null);
|
|
|
|
const { captureIssueEvent } = useEventTracker();
|
|
|
|
|
|
|
|
const shouldRenderProperty = property === "estimate" ? isEstimateEnabled : true;
|
|
|
|
|
|
|
|
const { Column } = SPREADSHEET_PROPERTY_DETAILS[property];
|
|
|
|
|
|
|
|
return (
|
|
|
|
<WithDisplayPropertiesHOC
|
|
|
|
displayProperties={displayProperties}
|
|
|
|
displayPropertyKey={property}
|
2024-02-21 14:25:18 +00:00
|
|
|
shouldRenderProperty={() => shouldRenderProperty}
|
2024-02-08 06:19:00 +00:00
|
|
|
>
|
|
|
|
<td
|
|
|
|
tabIndex={0}
|
2024-02-16 12:50:44 +00:00
|
|
|
className="h-11 w-full min-w-[8rem] bg-custom-background-100 text-sm after:absolute after:w-full after:bottom-[-1px] after:border after:border-custom-border-100 border-r-[1px] border-custom-border-100"
|
2024-02-08 06:19:00 +00:00
|
|
|
ref={tableCellRef}
|
|
|
|
>
|
|
|
|
<Column
|
|
|
|
issue={issueDetail}
|
|
|
|
onChange={(issue: TIssue, data: Partial<TIssue>, updates: any) =>
|
2024-03-06 15:17:38 +00:00
|
|
|
updateIssue &&
|
|
|
|
updateIssue(issue.project_id, issue.id, data).then(() => {
|
2024-02-08 06:19:00 +00:00
|
|
|
captureIssueEvent({
|
|
|
|
eventName: "Issue updated",
|
|
|
|
payload: {
|
|
|
|
...issue,
|
|
|
|
...data,
|
|
|
|
element: "Spreadsheet layout",
|
|
|
|
},
|
|
|
|
updates: updates,
|
|
|
|
path: router.asPath,
|
|
|
|
});
|
|
|
|
})
|
|
|
|
}
|
|
|
|
disabled={disableUserActions}
|
|
|
|
onClose={() => {
|
|
|
|
tableCellRef?.current?.focus();
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
</td>
|
|
|
|
</WithDisplayPropertiesHOC>
|
|
|
|
);
|
|
|
|
});
|